[Openvas-commits] r13370 - in trunk/openvas-manager: . src

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 25 17:14:44 CEST 2012


Author: mattm
Date: 2012-04-25 17:14:44 +0200 (Wed, 25 Apr 2012)
New Revision: 13370

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage.h
   trunk/openvas-manager/src/manage_sql.c
   trunk/openvas-manager/src/omp.c
Log:
	Setup an OMP GET response style where the common part of the response
	to a GET command is done by support code instead of being done in each
	command.  Convert GET_TARGETS and GET_AGENTS to this style.

	* src/manage_sql.c (GET_ITERATOR_FILTER_COLUMNS)
	(GET_ITERATOR_COLUMNS): New defines.  Increment agent iterator
	access functions to match.
	(TARGET_ITERATOR_COLUMNS, TARGET_ITERATOR_TRASH_COLUMNS)
	(TARGET_ITERATOR_FILTER_COLUMNS, AGENT_ITERATOR_FILTER_COLUMNS)
	(AGENT_ITERATOR_COLUMNS): Use GET column definitions.
	(target_iterator_hosts, target_iterator_comment): Match to positions in
	GET columns.
	(get_iterator_resource, get_iterator_uuid, get_iterator_name)
	(get_iterator_comment): New functions.

	* src/manage.h: Add headers accordingly.

	* src/omp.c (send_get_start, send_get_common, send_get_end): New
	functions.
	(SEND_GET_START, SEND_GET_COMMON, SEND_GET_END): New macros.
	(omp_xml_handle_end_element): In GET_AGENTS and GET_TARGETS send the
	common part of the response with the new send_get functions.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2012-04-25 12:57:39 UTC (rev 13369)
+++ trunk/openvas-manager/ChangeLog	2012-04-25 15:14:44 UTC (rev 13370)
@@ -1,5 +1,30 @@
 2012-04-25  Matthew Mundell <matthew.mundell at greenbone.net>
 
+	Setup an OMP GET response style where the common part of the response
+	to a GET command is done by support code instead of being done in each
+	command.  Convert GET_TARGETS and GET_AGENTS to this style.
+
+	* src/manage_sql.c (GET_ITERATOR_FILTER_COLUMNS)
+	(GET_ITERATOR_COLUMNS): New defines.  Increment agent iterator
+	access functions to match.
+	(TARGET_ITERATOR_COLUMNS, TARGET_ITERATOR_TRASH_COLUMNS)
+	(TARGET_ITERATOR_FILTER_COLUMNS, AGENT_ITERATOR_FILTER_COLUMNS)
+	(AGENT_ITERATOR_COLUMNS): Use GET column definitions.
+	(target_iterator_hosts, target_iterator_comment): Match to positions in
+	GET columns.
+	(get_iterator_resource, get_iterator_uuid, get_iterator_name)
+	(get_iterator_comment): New functions.
+
+	* src/manage.h: Add headers accordingly.
+
+	* src/omp.c (send_get_start, send_get_common, send_get_end): New
+	functions.
+	(SEND_GET_START, SEND_GET_COMMON, SEND_GET_END): New macros.
+	(omp_xml_handle_end_element): In GET_AGENTS and GET_TARGETS send the
+	common part of the response with the new send_get functions.
+
+2012-04-25  Matthew Mundell <matthew.mundell at greenbone.net>
+
 	* src/openvasmd.c (serve_and_schedule): Check that the second socket is in
 	use before trying to call FD_ISSET on it.
 

Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h	2012-04-25 12:57:39 UTC (rev 13369)
+++ trunk/openvas-manager/src/manage.h	2012-04-25 15:14:44 UTC (rev 13370)
@@ -635,7 +635,7 @@
 } action_t;
 
 

-/* OMP command oriented types. */
+/* OMP GET. */
 
 /**
  * @brief Command data for a get command.
@@ -652,6 +652,15 @@
   int trash;           ///< Boolean.  Whether to return from trashcan.
 } get_data_t;
 
+const char*
+get_iterator_uuid (iterator_t*);
+
+const char*
+get_iterator_name (iterator_t*);
+
+const char*
+get_iterator_comment (iterator_t*);
+
 

 /* Results. */
 

Modified: trunk/openvas-manager/src/manage_sql.c
===================================================================
--- trunk/openvas-manager/src/manage_sql.c	2012-04-25 12:57:39 UTC (rev 13369)
+++ trunk/openvas-manager/src/manage_sql.c	2012-04-25 15:14:44 UTC (rev 13370)
@@ -23405,10 +23405,20 @@
 }
 
 /**
+ * @brief Filter columns for GET iterator.
+ */
+#define GET_ITERATOR_FILTER_COLUMNS "uuid", "name", "comment"
+
+/**
+ * @brief Columns for GET iterator.
+ */
+#define GET_ITERATOR_COLUMNS "ROWID, uuid, name, comment"
+
+/**
  * @brief Filter columns for target iterator.
  */
 #define TARGET_ITERATOR_FILTER_COLUMNS                                         \
- { "uuid", "name", "comment", "hosts", "ips", "port_list", "ssh_credential",   \
+ { GET_ITERATOR_FILTER_COLUMNS, "hosts", "ips", "port_list", "ssh_credential", \
    "smb_credential", NULL }
 
 /**
@@ -23767,7 +23777,7 @@
  * @brief Target iterator columns.
  */
 #define TARGET_ITERATOR_COLUMNS                             \
-  "ROWID, uuid, name, hosts, comment, lsc_credential,"      \
+  GET_ITERATOR_COLUMNS ", hosts, lsc_credential,"           \
   " ssh_port, smb_lsc_credential, port_range, 0, 0,"        \
   " (SELECT uuid FROM port_lists"                           \
   "  WHERE port_lists.ROWID = port_range),"                 \
@@ -23788,7 +23798,7 @@
  * @brief Target iterator columns for trash case.
  */
 #define TARGET_ITERATOR_TRASH_COLUMNS                         \
-  "ROWID, uuid, name, hosts, comment, lsc_credential,"        \
+  GET_ITERATOR_COLUMNS ", hosts, lsc_credential,"             \
   " ssh_port, smb_lsc_credential, port_range, ssh_location,"  \
   " smb_location,"                                            \
   " (CASE"                                                    \
@@ -23891,15 +23901,6 @@
 DEF_ACCESS (target_iterator_name, 2);
 
 /**
- * @brief Get the hosts of the target from a target iterator.
- *
- * @param[in]  iterator  Iterator.
- *
- * @return Hosts of the target or NULL if iteration is complete.
- */
-DEF_ACCESS (target_iterator_hosts, 3);
-
-/**
  * @brief Get the comment from a target iterator.
  *
  * @param[in]  iterator  Iterator.
@@ -23911,11 +23912,20 @@
 {
   const char *ret;
   if (iterator->done) return "";
-  ret = (const char*) sqlite3_column_text (iterator->stmt, 4);
+  ret = (const char*) sqlite3_column_text (iterator->stmt, 3);
   return ret ? ret : "";
 }
 
 /**
+ * @brief Get the hosts of the target from a target iterator.
+ *
+ * @param[in]  iterator  Iterator.
+ *
+ * @return Hosts of the target or NULL if iteration is complete.
+ */
+DEF_ACCESS (target_iterator_hosts, 4);
+
+/**
  * @brief Get the SSH LSC credential from a target iterator.
  *
  * @param[in]  iterator  Iterator.
@@ -30609,18 +30619,66 @@
  * @brief Filter columns for agent iterator.
  */
 #define AGENT_ITERATOR_FILTER_COLUMNS          \
- { "uuid", "name", "comment", /* FIX "trust", */ NULL }
+ { GET_ITERATOR_FILTER_COLUMNS, /* FIX "trust", */ NULL }
 
 /**
  * @brief Agent iterator columns.
  */
 #define AGENT_ITERATOR_COLUMNS                              \
-  "uuid, name, comment, installer, installer_64,"           \
+  GET_ITERATOR_COLUMNS ", installer, installer_64,"         \
   " installer_filename, installer_signature_64,"            \
   " installer_trust, installer_trust_time, howto_install,"  \
   " howto_use"
 
 /**
+ * @brief Get the resource from a GET iterator.
+ *
+ * @param[in]  iterator  Iterator.
+ *
+ * @return Resource.
+ */
+resource_t
+get_iterator_resource (iterator_t* iterator)
+{
+  if (iterator->done) return 0;
+  return sqlite3_column_int64 (iterator->stmt, 0);
+}
+
+/**
+ * @brief Get the UUID of the resource from a GET iterator.
+ *
+ * @param[in]  iterator  Iterator.
+ *
+ * @return UUID of the resource or NULL if iteration is complete.
+ */
+DEF_ACCESS (get_iterator_uuid, 1);
+
+/**
+ * @brief Get the name of the resource from a GET iterator.
+ *
+ * @param[in]  iterator  Iterator.
+ *
+ * @return Name of the resource or NULL if iteration is complete.
+ */
+DEF_ACCESS (get_iterator_name, 2);
+
+/**
+ * @brief Get the comment from a GET iterator.
+ *
+ * @param[in]  iterator  Iterator.
+ *
+ * @return Comment.
+ */
+const char*
+get_iterator_comment (iterator_t* iterator)
+{
+  const char *ret;
+  if (iterator->done) return "";
+  ret = (const char*) sqlite3_column_text (iterator->stmt, 3);
+  return ret ? ret : "";
+}
+
+/**
  * @brief Agent iterator columns for trash case.
  */
 #define AGENT_ITERATOR_TRASH_COLUMNS NULL
@@ -30656,7 +30714,7 @@
  * @return UUID, or NULL if iteration is complete.  Freed by
  *         cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_uuid, 0);
+DEF_ACCESS (agent_iterator_uuid, 1);
 
 /**
  * @brief Get the name from an agent iterator.
@@ -30666,7 +30724,7 @@
  * @return Name, or NULL if iteration is complete.  Freed by
  *         cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_name, 1);
+DEF_ACCESS (agent_iterator_name, 2);
 
 /**
  * @brief Get the comment from an agent iterator.
@@ -30680,7 +30738,7 @@
 {
   const char *ret;
   if (iterator->done) return "";
-  ret = (const char*) sqlite3_column_text (iterator->stmt, 2);
+  ret = (const char*) sqlite3_column_text (iterator->stmt, 3);
   return ret ? ret : "";
 }
 
@@ -30692,7 +30750,7 @@
  * @return Installer, or NULL if iteration is complete.  Freed
  *         by cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_installer, 3);
+DEF_ACCESS (agent_iterator_installer, 4);
 
 /**
  * @brief Get the installer_64 from an agent iterator.
@@ -30702,7 +30760,7 @@
  * @return Base 64 encoded installer, or NULL if iteration is complete.  Freed
  *         by cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_installer_64, 4);
+DEF_ACCESS (agent_iterator_installer_64, 5);
 
 /**
  * @brief Get the installer size from an agent iterator.
@@ -30738,7 +30796,7 @@
  * @return Installer filename, or NULL if iteration is complete.  Freed by
  *         cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_installer_filename, 5);
+DEF_ACCESS (agent_iterator_installer_filename, 6);
 
 /**
  * @brief Get the installer_signature_64 from an agent iterator.
@@ -30748,7 +30806,7 @@
  * @return Installer signature in base64, or NULL if iteration is complete.
  *         Freed by cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_installer_signature_64, 6);
+DEF_ACCESS (agent_iterator_installer_signature_64, 7);
 
 /**
  * @brief Get the trust value from an agent iterator.
@@ -30761,7 +30819,7 @@
 agent_iterator_trust (iterator_t* iterator)
 {
   if (iterator->done) return NULL;
-  switch (sqlite3_column_int (iterator->stmt, 7))
+  switch (sqlite3_column_int (iterator->stmt, 8))
     {
       case 1:  return "yes";
       case 2:  return "no";
@@ -30782,7 +30840,7 @@
 {
   int ret;
   if (iterator->done) return -1;
-  ret = (time_t) sqlite3_column_int (iterator->stmt, 8);
+  ret = (time_t) sqlite3_column_int (iterator->stmt, 9);
   return ret;
 }
 
@@ -30794,7 +30852,7 @@
  * @return Install HOWTO, or NULL if iteration is complete.  Freed by
  *         cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_howto_install, 9);
+DEF_ACCESS (agent_iterator_howto_install, 10);
 
 /**
  * @brief Get the usage HOWTO from an agent iterator.
@@ -30804,7 +30862,7 @@
  * @return Usage HOWTO, or NULL if iteration is complete.  Freed by
  *         cleanup_iterator.
  */
-DEF_ACCESS (agent_iterator_howto_use, 10);
+DEF_ACCESS (agent_iterator_howto_use, 11);
 
 /**
  * @brief Get the name of an agent.

Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c	2012-04-25 12:57:39 UTC (rev 13369)
+++ trunk/openvas-manager/src/omp.c	2012-04-25 15:14:44 UTC (rev 13370)
@@ -4094,6 +4094,169 @@
 /** @cond STATIC */
 
 /**
+ * @brief Send start of GET response.
+ *
+ * @param[in]  type                  Type.
+ * @param[in]  get                   GET data.
+ * @param[in]  write_to_client       Function that sends to clients.
+ * @param[in]  write_to_client_data  Data for write_to_client.
+ */
+int
+send_get_start (const char *type, get_data_t *get,
+                int (*write_to_client) (void*), void* write_to_client_data)
+{
+  gchar* msg;
+
+  if (get->max == -2)
+    setting_value_int ("5f5a8712-8017-11e1-8556-406186ea4fc5",
+                       &get->max);
+
+  msg = g_markup_printf_escaped ("<get_%ss_response"
+                                 " status=\"" STATUS_OK "\""
+                                 " status_text=\"" STATUS_OK_TEXT "\">"
+                                 "<filters>"
+                                 "<term>%s</term>"
+                                 "</filters>"
+                                 "<%ss start=\"%i\" max=\"%i\"/>",
+                                 type,
+                                 get->filter ? get->filter : "",
+                                 type,
+                                 /* Add 1 for 1 indexing. */
+                                 get->first + 1,
+                                 get->max);
+
+  if (send_to_client (msg, write_to_client, write_to_client_data))
+    {
+      g_free (msg);
+      return 1;
+    }
+  g_free (msg);
+  return 0;
+}
+
+/**
+ * @brief Send common part of GET response for a single resource.
+ *
+ * @param[in]  type                  Type.
+ * @param[in]  get                   GET data.
+ * @param[in]  iterator              Iterator.
+ * @param[in]  write_to_client       Function that sends to clients.
+ * @param[in]  write_to_client_data  Data for write_to_client.
+ */
+int
+send_get_common (const char *type, get_data_t *get, iterator_t *iterator,
+                 int (*write_to_client) (void*), void* write_to_client_data)
+{
+  gchar* msg;
+
+  msg = g_markup_printf_escaped ("<%s id=\"%s\">"
+                                 "<name>%s</name>"
+                                 "<comment>%s</comment>",
+                                 type,
+                                 get_iterator_uuid (iterator),
+                                 get_iterator_name (iterator),
+                                 get_iterator_comment (iterator));
+
+  if (send_to_client (msg, write_to_client, write_to_client_data))
+    {
+      g_free (msg);
+      return 1;
+    }
+  g_free (msg);
+  return 0;
+}
+
+/**
+ * @brief Send end of GET response.
+ *
+ * @param[in]  type                  Type.
+ * @param[in]  get                   GET data.
+ * @param[in]  count                 Count.
+ * @param[in]  filtered              Filtered count.
+ * @param[in]  write_to_client       Function that sends to clients.
+ * @param[in]  write_to_client_data  Data for write_to_client.
+ */
+int
+send_get_end (const char *type, get_data_t *get, int count, int filtered,
+              int (*write_to_client) (void*), void* write_to_client_data)
+{
+  gchar* msg;
+
+  msg = g_markup_printf_escaped ("<%s_count>"
+                                 "<filtered>%i</filtered>"
+                                 "<page>%i</page>"
+                                 "</%s_count>"
+                                 "</get_%ss_response>",
+                                 type,
+                                 filtered,
+                                 count,
+                                 type,
+                                 type);
+
+  if (send_to_client (msg, write_to_client, write_to_client_data))
+    {
+      g_free (msg);
+      return 1;
+    }
+  g_free (msg);
+  return 0;
+}
+
+/**
+ * @brief Send start of GET response to client, returning on fail.
+ *
+ * @param[in]  type  Type of resource.
+ * @param[in]  get   GET data.
+ */
+#define SEND_GET_START(type, get)                                            \
+  do                                                                         \
+    {                                                                        \
+      if (send_get_start (type, get, write_to_client, write_to_client_data)) \
+        {                                                                    \
+          error_send_to_client (error);                                      \
+          return;                                                            \
+        }                                                                    \
+    }                                                                        \
+  while (0)
+
+/**
+ * @brief Send common part of GET response to client, returning on fail.
+ *
+ * @param[in]  type      Type of resource.
+ * @param[in]  get       GET data.
+ * @param[in]  iterator  Iterator.
+ */
+#define SEND_GET_COMMON(type, get, iterator)                                   \
+  do                                                                           \
+    {                                                                          \
+      if (send_get_common (type, get, iterator,                                \
+                           write_to_client, write_to_client_data))             \
+        {                                                                      \
+          error_send_to_client (error);                                        \
+          return;                                                              \
+        }                                                                      \
+    }                                                                          \
+  while (0)
+
+/**
+ * @brief Send end of GET response to client, returning on fail.
+ *
+ * @param[in]  type  Type of resource.
+ * @param[in]  get   GET data.
+ */
+#define SEND_GET_END(type, get, count, filtered)                             \
+  do                                                                         \
+    {                                                                        \
+      if (send_get_end (type, get, count, filtered, write_to_client,         \
+                        write_to_client_data))                               \
+        {                                                                    \
+          error_send_to_client (error);                                      \
+          return;                                                            \
+        }                                                                    \
+    }                                                                        \
+  while (0)
+
+/**
  * @brief Send response message to client, returning on fail.
  *
  * Queue a message in \ref to_client with \ref send_to_client.  On failure
@@ -14356,7 +14519,7 @@
           else
             {
               iterator_t agents;
-              int ret;
+              int ret, count, filtered;
 
               ret = init_agent_iterator (&agents,
                                          &get_agents_data->get);
@@ -14385,55 +14548,42 @@
                   break;
                 }
 
-              SEND_TO_CLIENT_OR_FAIL ("<get_agents_response"
-                                      " status=\"" STATUS_OK "\""
-                                      " status_text=\"" STATUS_OK_TEXT "\">");
+              count = 0;
+              SEND_GET_START ("agent", &get_agents_data->get);
 
               while (next (&agents))
                 {
                   switch (format)
                     {
                       case 1: /* installer */
+                        SEND_GET_COMMON ("agent", &get_agents_data->get,
+                                         &agents);
                         SENDF_TO_CLIENT_OR_FAIL
-                         ("<agent id=\"%s\">"
-                          "<name>%s</name>"
-                          "<comment>%s</comment>"
-                          "<package format=\"installer\">"
+                         ("<package format=\"installer\">"
                           "<filename>%s</filename>"
                           "%s"
                           "</package>"
                           "<in_use>0</in_use>"
                           "</agent>",
-                          agent_iterator_uuid (&agents),
-                          agent_iterator_name (&agents),
-                          agent_iterator_comment (&agents),
                           agent_iterator_installer_filename (&agents),
                           agent_iterator_installer_64 (&agents));
                         break;
                       case 2: /* howto_install */
+                        SEND_GET_COMMON ("agent", &get_agents_data->get,
+                                         &agents);
                         SENDF_TO_CLIENT_OR_FAIL
-                         ("<agent id=\"%s\">"
-                          "<name>%s</name>"
-                          "<comment>%s</comment>"
-                          "<package format=\"howto_install\">%s</package>"
+                         ("<package format=\"howto_install\">%s</package>"
                           "<in_use>0</in_use>"
                           "</agent>",
-                          agent_iterator_uuid (&agents),
-                          agent_iterator_name (&agents),
-                          agent_iterator_comment (&agents),
                           agent_iterator_howto_install (&agents));
                         break;
                       case 3: /* howto_use */
+                        SEND_GET_COMMON ("agent", &get_agents_data->get,
+                                         &agents);
                         SENDF_TO_CLIENT_OR_FAIL
-                         ("<agent id=\"%s\">"
-                          "<name>%s</name>"
-                          "<comment>%s</comment>"
-                          "<package format=\"howto_use\">%s</package>"
+                         ("<package format=\"howto_use\">%s</package>"
                           "<in_use>0</in_use>"
                           "</agent>",
-                          agent_iterator_uuid (&agents),
-                          agent_iterator_name (&agents),
-                          agent_iterator_comment (&agents),
                           agent_iterator_howto_use (&agents));
                         break;
                       default:
@@ -14442,26 +14592,29 @@
 
                           trust_time = agent_iterator_trust_time (&agents);
 
+                          SEND_GET_COMMON ("agent", &get_agents_data->get,
+                                           &agents);
                           SENDF_TO_CLIENT_OR_FAIL
-                           ("<agent id=\"%s\">"
-                            "<name>%s</name>"
-                            "<comment>%s</comment>"
-                            "<in_use>0</in_use>"
+                           ("<in_use>0</in_use>"
                             "<installer>"
                             "<trust>%s<time>%s</time></trust>"
                             "</installer>"
                             "</agent>",
-                            agent_iterator_uuid (&agents),
-                            agent_iterator_name (&agents),
-                            agent_iterator_comment (&agents),
                             agent_iterator_trust (&agents),
                             iso_time (&trust_time));
                         }
                         break;
                     }
+                  count++;
                 }
               cleanup_iterator (&agents);
-              SEND_TO_CLIENT_OR_FAIL ("</get_agents_response>");
+              filtered = get_agents_data->get.id
+                          ? 1
+                          : 1;
+                          // FIX
+                          //: agent_count (get_agents_data->get.filter,
+                          //               get_agents_data->get.actions);
+              SEND_GET_END ("agent", &get_agents_data->get, count, filtered);
             }
           get_agents_data_reset (get_agents_data);
           set_client_state (CLIENT_AUTHENTIC);
@@ -15405,22 +15558,7 @@
                 }
 
               count = 0;
-              SEND_TO_CLIENT_OR_FAIL ("<get_targets_response"
-                                      " status=\"" STATUS_OK "\""
-                                      " status_text=\"" STATUS_OK_TEXT "\">");
-              SENDF_TO_CLIENT_OR_FAIL ("<filters>"
-                                       "<term>%s</term>"
-                                       "</filters>",
-                                       get_targets_data->get.filter
-                                        ? get_targets_data->get.filter
-                                        : "");
-              if (get_targets_data->get.max == -2)
-                setting_value_int ("5f5a8712-8017-11e1-8556-406186ea4fc5",
-                                   &get_targets_data->get.max);
-              SENDF_TO_CLIENT_OR_FAIL ("<targets start=\"%i\" max=\"%i\"/>",
-                                       /* Add 1 for 1 indexing. */
-                                       get_targets_data->get.first + 1,
-                                       get_targets_data->get.max);
+              SEND_GET_START ("target", &get_targets_data->get);
               while (next (&targets))
                 {
                   char *ssh_lsc_name, *ssh_lsc_uuid, *smb_lsc_name, *smb_lsc_uuid;
@@ -15460,11 +15598,10 @@
                   port_range = target_port_range (target_iterator_target
                                                     (&targets));
 
-                  SENDF_TO_CLIENT_OR_FAIL ("<target id=\"%s\">"
-                                           "<name>%s</name>"
-                                           "<hosts>%s</hosts>"
+                  SEND_GET_COMMON ("target", &get_targets_data->get, &targets);
+
+                  SENDF_TO_CLIENT_OR_FAIL ("<hosts>%s</hosts>"
                                            "<max_hosts>%i</max_hosts>"
-                                           "<comment>%s</comment>"
                                            "<in_use>%i</in_use>"
                                            "<writable>%i</writable>"
                                            "<port_range>%s</port_range>"
@@ -15481,12 +15618,9 @@
                                            "<name>%s</name>"
                                            "<trash>%i</trash>"
                                            "</smb_lsc_credential>",
-                                           target_iterator_uuid (&targets),
-                                           target_iterator_name (&targets),
                                            target_iterator_hosts (&targets),
                                            manage_max_hosts
                                             (target_iterator_hosts (&targets)),
-                                           target_iterator_comment (&targets),
                                            get_targets_data->get.trash
                                             ? trash_target_in_use
                                                (target_iterator_target
@@ -15544,18 +15678,12 @@
                   free (smb_lsc_uuid);
                   free (port_range);
                 }
+              cleanup_iterator (&targets);
               filtered = get_targets_data->get.id
                           ? 1
                           : target_count (get_targets_data->get.filter,
                                           get_targets_data->get.actions);
-              SENDF_TO_CLIENT_OR_FAIL ("<target_count>"
-                                       "<filtered>%i</filtered>"
-                                       "<page>%i</page>"
-                                       "</target_count>",
-                                       filtered,
-                                       count);
-              cleanup_iterator (&targets);
-              SEND_TO_CLIENT_OR_FAIL ("</get_targets_response>");
+              SEND_GET_END ("target", &get_targets_data->get, count, filtered);
             }
           get_targets_data_reset (get_targets_data);
           set_client_state (CLIENT_AUTHENTIC);



More information about the Openvas-commits mailing list