[Openvas-commits] r5460 - in trunk/openvas-libraries: . omp

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 9 13:09:15 CEST 2009


Author: jan
Date: 2009-10-09 13:09:14 +0200 (Fri, 09 Oct 2009)
New Revision: 5460

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/omp/omp.c
   trunk/openvas-libraries/omp/omp.h
Log:
* omp/omp.c (omp_get_nvt_details_503): New.

* omp/omp.h: Extended with proto accordingly.



Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog	2009-10-09 11:06:01 UTC (rev 5459)
+++ trunk/openvas-libraries/ChangeLog	2009-10-09 11:09:14 UTC (rev 5460)
@@ -1,3 +1,9 @@
+2009-10-09  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
+	* omp/omp.c (omp_get_nvt_details_503): New.
+
+	* omp/omp.h: Extended with proto accordingly.
+
 2009-10-08  Michael Wiegand <michael.wiegand at intevation.de>
 
 	* nasl/CMakeList.txt: Added defines for _FILE_OFFSET_BITS and

Modified: trunk/openvas-libraries/omp/omp.c
===================================================================
--- trunk/openvas-libraries/omp/omp.c	2009-10-09 11:06:01 UTC (rev 5459)
+++ trunk/openvas-libraries/omp/omp.c	2009-10-09 11:09:14 UTC (rev 5460)
@@ -1505,3 +1505,58 @@
   if (first == '2') return 0;
   return -1;
 }
+
+/**
+ * @brief Get NVT Information.
+ *
+ * @param[in]  session         Pointer to GNUTLS session.
+ * @param[in]  oid             OID of NVT or NULL for all NVTs.
+ * @param[out] status          Status return.  On success contains GET_STATUS
+ *                             response.
+ *
+ * @return 0 on success, -1 or OMP response code on error.
+ */
+int
+omp_get_nvt_details_503 (gnutls_session_t* session, const char * oid,
+                         entity_t* response)
+{
+  while (1)
+    {
+      const char* status;
+      gchar* request;
+
+      if (oid)
+        request = g_strdup_printf ("<get_nvt_details oid=\"%s\"/>", oid);
+      else
+        request = g_strdup("<get_nvt_details/>");
+
+      int ret = openvas_server_send (session, request);
+      g_free(request);
+      if (ret)
+        return -1;
+
+      *response = NULL;
+      if (read_entity (session, response)) return -1;
+
+      status = entity_attribute (*response, "status");
+      if (status == NULL)
+        {
+          free_entity (*response);
+          return -1;
+        }
+      if (strlen (status) == 0)
+        {
+          free_entity (*response);
+          return -1;
+        }
+      char first = status[0];
+      if (first == '2') return 0;
+      if (strlen (status) == 3 && strcmp (status, "503") == 0)
+        {
+          sleep (1);
+          continue;
+        }
+      free_entity (*response);
+      return -1;
+    }
+}

Modified: trunk/openvas-libraries/omp/omp.h
===================================================================
--- trunk/openvas-libraries/omp/omp.h	2009-10-09 11:06:01 UTC (rev 5459)
+++ trunk/openvas-libraries/omp/omp.h	2009-10-09 11:09:14 UTC (rev 5460)
@@ -119,4 +119,7 @@
 int
 omp_delete_lsc_credential (gnutls_session_t*, const char*);
 
+int
+omp_get_nvt_details_503 (gnutls_session_t*, const char *, entity_t*);
+
 #endif /* not _OPENVAS_LIBRARIES_OMP_H */



More information about the Openvas-commits mailing list