[Openvas-commits] r5521 - in trunk/openvas-libraries: . omp
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Oct 13 22:29:34 CEST 2009
Author: mattm
Date: 2009-10-13 22:29:33 +0200 (Tue, 13 Oct 2009)
New Revision: 5521
Modified:
trunk/openvas-libraries/ChangeLog
trunk/openvas-libraries/omp/omp.c
trunk/openvas-libraries/omp/omp.h
Log:
* omp/omp.c (check_response, omp_abort_task): New functions.
* omp/omp.h (omp_abort_task): New header.
Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog 2009-10-13 16:31:33 UTC (rev 5520)
+++ trunk/openvas-libraries/ChangeLog 2009-10-13 20:29:33 UTC (rev 5521)
@@ -1,5 +1,10 @@
2009-10-13 Matthew Mundell <matthew.mundell at intevation.de>
+ * omp/omp.c (check_response, omp_abort_task): New functions.
+ * omp/omp.h (omp_abort_task): New header.
+
+2009-10-13 Matthew Mundell <matthew.mundell at intevation.de>
+
* include/nvt_categories.h (ACT_UNKNOWN, ACT_STRING_INIT)
(ACT_STRING_SCANNER, ACT_STRING_SETTINGS, ACT_STRING_GATHER_INFO)
(ACT_STRING_ATTACK, ACT_STRING_MIXED_ATTACK)
Modified: trunk/openvas-libraries/omp/omp.c
===================================================================
--- trunk/openvas-libraries/omp/omp.c 2009-10-13 16:31:33 UTC (rev 5520)
+++ trunk/openvas-libraries/omp/omp.c 2009-10-13 20:29:33 UTC (rev 5521)
@@ -401,7 +401,66 @@
return -1;
}
+/** @todo Use this in the other functions. */
/**
+ * @brief Read response and convert status of response to a return value.
+ *
+ * @param[in] session Pointer to GNUTLS session.
+ *
+ * @return 0 on success, -1 on error.
+ */
+static int
+check_response (gnutls_session_t* session)
+{
+ char first;
+ const char* status;
+ entity_t entity;
+
+ /* Read the response. */
+
+ entity = NULL;
+ if (read_entity (session, &entity)) return -1;
+
+ /* Check the response. */
+
+ status = entity_attribute (entity, "status");
+ if (status == NULL)
+ {
+ free_entity (entity);
+ return -1;
+ }
+ if (strlen (status) == 0)
+ {
+ free_entity (entity);
+ return -1;
+ }
+ first = status[0];
+ free_entity (entity);
+ if (first == '2') return 0;
+ return -1;
+}
+
+/**
+ * @brief Stop a task and read the manager response.
+ *
+ * @param[in] session Pointer to GNUTLS session.
+ * @param[in] id ID of task.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int
+omp_abort_task (gnutls_session_t* session, const char* id)
+{
+ if (openvas_server_sendf (session,
+ "<abort_task task_id=\"%s\"/>",
+ id)
+ == -1)
+ return -1;
+
+ return check_response (session);
+}
+
+/**
* @brief Wait for a task to start running on the server.
*
* @param[in] session Pointer to GNUTLS session.
@@ -411,7 +470,7 @@
*/
int
omp_wait_for_task_start (gnutls_session_t* session,
- const char* id)
+ const char* id)
{
while (1)
{
Modified: trunk/openvas-libraries/omp/omp.h
===================================================================
--- trunk/openvas-libraries/omp/omp.h 2009-10-13 16:31:33 UTC (rev 5520)
+++ trunk/openvas-libraries/omp/omp.h 2009-10-13 20:29:33 UTC (rev 5521)
@@ -55,6 +55,9 @@
omp_start_task (gnutls_session_t* , const char*);
int
+omp_abort_task (gnutls_session_t*, const char*);
+
+int
omp_wait_for_task_end (gnutls_session_t*, const char*);
int
More information about the Openvas-commits
mailing list