Greenbone Vulnerability Management Libraries  11.0.1
gmp.c File Reference

API for Greenbone Management Protocol communication. More...

#include "gmp.h"
#include "../util/serverutils.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for gmp.c:

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "lib gmp"
 GLib log domain. More...
 
#define GMP_FMT_BOOL_ATTRIB(var, attrib)   (var.attrib == 0 ? " " #attrib "=\"0\"" : " " #attrib "=\"1\"")
 
#define GMP_FMT_STRING_ATTRIB(var, attrib)
 

Functions

const char * gmp_task_status (entity_t response)
 Get the task status from a GMP GET_TASKS response. More...
 
int gmp_check_response (gnutls_session_t *session, entity_t *entity)
 Read response and convert status of response to a return value. More...
 
int gmp_ping (gnutls_session_t *session, int timeout)
 "Ping" the manager. More...
 
int gmp_ping_c (gvm_connection_t *connection, int timeout, gchar **version)
 "Ping" the manager. More...
 
int gmp_authenticate (gnutls_session_t *session, const char *username, const char *password)
 Authenticate with the manager. More...
 
int gmp_authenticate_info_ext (gnutls_session_t *session, gmp_authenticate_info_opts_t opts)
 Authenticate with the manager. More...
 
int gmp_authenticate_info_ext_c (gvm_connection_t *connection, gmp_authenticate_info_opts_t opts)
 Authenticate with the manager. More...
 
int gmp_create_task_ext (gnutls_session_t *session, gmp_create_task_opts_t opts, gchar **id)
 Create a task. More...
 
int gmp_create_task (gnutls_session_t *session, const char *name, const char *config, const char *target, const char *comment, gchar **id)
 Create a task given a config and target. More...
 
int gmp_start_task_report (gnutls_session_t *session, const char *task_id, char **report_id)
 Start a task and read the manager response. More...
 
int gmp_start_task_report_c (gvm_connection_t *connection, const char *task_id, char **report_id)
 Start a task and read the manager response. More...
 
int gmp_check_response_c (gvm_connection_t *connection)
 Read response and convert status of response to a return value. More...
 
int gmp_read_create_response (gnutls_session_t *session, gchar **uuid)
 Read response status and resource UUID. More...
 
int gmp_stop_task (gnutls_session_t *session, const char *id)
 Stop a task and read the manager response. More...
 
int gmp_stop_task_c (gvm_connection_t *connection, const char *id)
 Stop a task and read the manager response. More...
 
int gmp_resume_task_report (gnutls_session_t *session, const char *task_id, char **report_id)
 Resume a task and read the manager response. More...
 
int gmp_resume_task_report_c (gvm_connection_t *connection, const char *task_id, char **report_id)
 Resume a task and read the manager response. More...
 
int gmp_delete_task_ext (gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
 Delete a task and read the manager response. More...
 
int gmp_get_tasks (gnutls_session_t *session, const char *id, int details, int include_rcfile, entity_t *status)
 Get the status of a task. More...
 
int gmp_get_task_ext (gnutls_session_t *session, gmp_get_task_opts_t opts, entity_t *response)
 Get a task (generic version). More...
 
int gmp_get_tasks_ext (gnutls_session_t *session, gmp_get_tasks_opts_t opts, entity_t *response)
 Get all tasks (generic version). More...
 
int gmp_modify_task_file (gnutls_session_t *session, const char *id, const char *name, const void *content, gsize content_len)
 Modify a file on a task. More...
 
int gmp_delete_task (gnutls_session_t *session, const char *id)
 Delete a task and read the manager response. More...
 
int gmp_get_targets (gnutls_session_t *session, const char *id, int tasks, int include_rcfile, entity_t *target)
 Get a target. More...
 
int gmp_get_report_ext (gnutls_session_t *session, gmp_get_report_opts_t opts, entity_t *response)
 Get a report (generic version). More...
 
int gmp_delete_port_list_ext (gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
 Delete a port list. More...
 
int gmp_delete_report (gnutls_session_t *session, const char *id)
 Remove a report. More...
 
int gmp_create_target_ext (gnutls_session_t *session, gmp_create_target_opts_t opts, gchar **id)
 Create a target. More...
 
int gmp_delete_target_ext (gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
 Delete a target. More...
 
int gmp_delete_config_ext (gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
 Delete a config. More...
 
int gmp_create_lsc_credential (gnutls_session_t *session, const char *name, const char *login, const char *password, const char *comment, gchar **uuid)
 Create an LSC Credential. More...
 
int gmp_create_lsc_credential_key (gnutls_session_t *session, const char *name, const char *login, const char *passphrase, const char *private_key, const char *comment, gchar **uuid)
 Create an LSC Credential with a key. More...
 
int gmp_create_lsc_credential_ext (gnutls_session_t *session, gmp_create_lsc_credential_opts_t opts, gchar **id)
 Create an LSC credential. More...
 
int gmp_delete_lsc_credential_ext (gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
 Delete a LSC credential. More...
 
int gmp_get_system_reports (gnutls_session_t *session, const char *name, int brief, entity_t *reports)
 Get system reports. More...
 
int gmp_get_system_reports_ext (gnutls_session_t *session, gmp_get_system_reports_opts_t opts, entity_t *reports)
 Get system reports. More...
 

Detailed Description

API for Greenbone Management Protocol communication.

This provides higher level, GMP-aware, facilities for working with with the Greenbone Vulnerability Manager.

There are examples of using this interface in the gvm tests.

Definition in file gmp.c.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib gmp"

GLib log domain.

Definition at line 42 of file gmp.c.

◆ GMP_FMT_BOOL_ATTRIB

#define GMP_FMT_BOOL_ATTRIB (   var,
  attrib 
)    (var.attrib == 0 ? " " #attrib "=\"0\"" : " " #attrib "=\"1\"")

Definition at line 44 of file gmp.c.

◆ GMP_FMT_STRING_ATTRIB

#define GMP_FMT_STRING_ATTRIB (   var,
  attrib 
)
Value:
(var.attrib ? " " #attrib "= \"" : ""), (var.attrib ? var.attrib : ""), \
(var.attrib ? "\"" : "")

Definition at line 47 of file gmp.c.

Function Documentation

◆ gmp_authenticate()

int gmp_authenticate ( gnutls_session_t *  session,
const char *  username,
const char *  password 
)

Authenticate with the manager.

Parameters
[in]sessionPointer to GNUTLS session.
[in]usernameUsername.
[in]passwordPassword.
Returns
0 on success, 1 if manager closed connection, 2 if auth failed, -1 on error.

Definition at line 260 of file gmp.c.

262 {
263  entity_t entity;
264  int ret;
265 
266  /* Send the auth request. */
267  ret = gvm_server_sendf_xml_quiet (session,
268  "<authenticate><credentials>"
269  "<username>%s</username>"
270  "<password>%s</password>"
271  "</credentials></authenticate>",
272  username ? username : "",
273  password ? password : "");
274  if (ret)
275  return ret;
276 
277  /* Read the response. */
278 
279  entity = NULL;
280  ret = gmp_check_response (session, &entity);
281  if (ret == 0)
282  {
283  free_entity (entity);
284  return ret;
285  }
286  else if (ret == -1)
287  return ret;
288  return 2;
289 }

References free_entity(), gmp_check_response(), and gvm_server_sendf_xml_quiet().

Here is the call graph for this function:

◆ gmp_authenticate_info_ext()

int gmp_authenticate_info_ext ( gnutls_session_t *  session,
gmp_authenticate_info_opts_t  opts 
)

Authenticate with the manager.

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]optsAdditional account information if authentication was successful.
Returns
0 on success, 1 if manager closed connection, 2 if auth failed, 3 on timeout, -1 on error.

Definition at line 303 of file gmp.c.

305 {
306  entity_t entity;
307  const char *status;
308  char first;
309  int ret;
310 
311  *(opts.timezone) = NULL;
312 
313  /* Send the auth request. */
314 
315  ret = gvm_server_sendf_xml_quiet (session,
316  "<authenticate><credentials>"
317  "<username>%s</username>"
318  "<password>%s</password>"
319  "</credentials></authenticate>",
320  opts.username, opts.password);
321  if (ret)
322  return ret;
323 
324  /* Read the response. */
325 
326  entity = NULL;
327  switch (try_read_entity (session, opts.timeout, &entity))
328  {
329  case 0:
330  break;
331  case -4:
332  return 3;
333  default:
334  return -1;
335  }
336 
337  /* Check the response. */
338 
339  status = entity_attribute (entity, "status");
340  if (status == NULL)
341  {
342  free_entity (entity);
343  return -1;
344  }
345  if (strlen (status) == 0)
346  {
347  free_entity (entity);
348  return -1;
349  }
350  first = status[0];
351  if (first == '2')
352  {
353  entity_t timezone_entity, role_entity, severity_entity, pw_warn_entity;
354  /* Get the extra info. */
355  timezone_entity = entity_child (entity, "timezone");
356  if (timezone_entity)
357  *opts.timezone = g_strdup (entity_text (timezone_entity));
358  role_entity = entity_child (entity, "role");
359  if (role_entity)
360  *opts.role = g_strdup (entity_text (role_entity));
361  severity_entity = entity_child (entity, "severity");
362  if (severity_entity)
363  *opts.severity = g_strdup (entity_text (severity_entity));
364  pw_warn_entity = entity_child (entity, "password_warning");
365  if (pw_warn_entity)
366  *(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
367  else
368  *(opts.pw_warning) = NULL;
369 
370  free_entity (entity);
371  return 0;
372  }
373  free_entity (entity);
374  return 2;
375 }

References entity_attribute(), entity_child(), entity_text(), free_entity(), gvm_server_sendf_xml_quiet(), gmp_authenticate_info_opts_t::password, gmp_authenticate_info_opts_t::pw_warning, gmp_authenticate_info_opts_t::role, gmp_authenticate_info_opts_t::severity, gmp_authenticate_info_opts_t::timeout, gmp_authenticate_info_opts_t::timezone, try_read_entity(), and gmp_authenticate_info_opts_t::username.

Here is the call graph for this function:

◆ gmp_authenticate_info_ext_c()

int gmp_authenticate_info_ext_c ( gvm_connection_t connection,
gmp_authenticate_info_opts_t  opts 
)

Authenticate with the manager.

Parameters
[in]connectionConnection
[in]optsStruct containing the options to apply.
Returns
0 on success, 1 if manager closed connection, 2 if auth failed, 3 on timeout, -1 on error.

Definition at line 387 of file gmp.c.

389 {
390  entity_t entity;
391  const char *status;
392  char first;
393  int ret;
394 
395  if (opts.timezone)
396  *(opts.timezone) = NULL;
397 
398  /* Send the auth request. */
399 
400  ret = gvm_connection_sendf_xml_quiet (connection,
401  "<authenticate>"
402  "<credentials>"
403  "<username>%s</username>"
404  "<password>%s</password>"
405  "</credentials>"
406  "</authenticate>",
407  opts.username, opts.password);
408  if (ret)
409  return ret;
410 
411  /* Read the response. */
412 
413  entity = NULL;
414  switch (try_read_entity_c (connection, opts.timeout, &entity))
415  {
416  case 0:
417  break;
418  case -4:
419  return 3;
420  default:
421  return -1;
422  }
423 
424  /* Check the response. */
425 
426  status = entity_attribute (entity, "status");
427  if (status == NULL)
428  {
429  free_entity (entity);
430  return -1;
431  }
432  if (strlen (status) == 0)
433  {
434  free_entity (entity);
435  return -1;
436  }
437  first = status[0];
438  if (first == '2')
439  {
440  entity_t timezone_entity, role_entity, severity_entity;
441  /* Get the extra info. */
442  timezone_entity = entity_child (entity, "timezone");
443  if (timezone_entity && opts.timezone)
444  *opts.timezone = g_strdup (entity_text (timezone_entity));
445  role_entity = entity_child (entity, "role");
446  if (role_entity && opts.role)
447  *opts.role = g_strdup (entity_text (role_entity));
448  severity_entity = entity_child (entity, "severity");
449  if (severity_entity && opts.severity)
450  *opts.severity = g_strdup (entity_text (severity_entity));
451  if (opts.pw_warning)
452  {
453  entity_t pw_warn_entity;
454  pw_warn_entity = entity_child (entity, "password_warning");
455  if (pw_warn_entity)
456  *(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
457  else
458  *(opts.pw_warning) = NULL;
459  }
460 
461  free_entity (entity);
462  return 0;
463  }
464  free_entity (entity);
465  return 2;
466 }

References entity_attribute(), entity_child(), entity_text(), free_entity(), gvm_connection_sendf_xml_quiet(), gmp_authenticate_info_opts_t::password, gmp_authenticate_info_opts_t::pw_warning, gmp_authenticate_info_opts_t::role, gmp_authenticate_info_opts_t::severity, gmp_authenticate_info_opts_t::timeout, gmp_authenticate_info_opts_t::timezone, try_read_entity_c(), and gmp_authenticate_info_opts_t::username.

Here is the call graph for this function:

◆ gmp_check_response()

int gmp_check_response ( gnutls_session_t *  session,
entity_t entity 
)

Read response and convert status of response to a return value.

Parameters
[in]sessionPointer to GNUTLS session.
[in]entityEntity containing response.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 83 of file gmp.c.

84 {
85  int ret;
86  const char *status;
87 
88  /* Read the response. */
89 
90  *entity = NULL;
91  if (read_entity (session, entity))
92  return -1;
93 
94  /* Check the response. */
95 
96  status = entity_attribute (*entity, "status");
97  if (status == NULL)
98  {
99  free_entity (*entity);
100  return -1;
101  }
102  if (strlen (status) == 0)
103  {
104  free_entity (*entity);
105  return -1;
106  }
107  if (status[0] == '2')
108  {
109  return 0;
110  }
111  ret = (int) strtol (status, NULL, 10);
112  free_entity (*entity);
113  if (errno == ERANGE)
114  return -1;
115  return ret;
116 }

References entity_attribute(), free_entity(), and read_entity().

Referenced by gmp_authenticate(), gmp_delete_config_ext(), gmp_delete_lsc_credential_ext(), gmp_delete_port_list_ext(), gmp_delete_report(), gmp_delete_target_ext(), gmp_delete_task(), gmp_delete_task_ext(), gmp_get_system_reports(), gmp_get_system_reports_ext(), gmp_get_targets(), gmp_get_task_ext(), gmp_get_tasks(), gmp_modify_task_file(), gmp_resume_task_report(), gmp_start_task_report(), and gmp_stop_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gmp_check_response_c()

int gmp_check_response_c ( gvm_connection_t connection)

Read response and convert status of response to a return value.

Parameters
[in]connectionConnection.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 801 of file gmp.c.

802 {
803  int ret;
804  const char *status;
805  entity_t entity;
806 
807  /* Read the response. */
808 
809  entity = NULL;
810  if (read_entity_c (connection, &entity))
811  return -1;
812 
813  /* Check the response. */
814 
815  status = entity_attribute (entity, "status");
816  if (status == NULL)
817  {
818  free_entity (entity);
819  return -1;
820  }
821  if (strlen (status) == 0)
822  {
823  free_entity (entity);
824  return -1;
825  }
826  if (status[0] == '2')
827  {
828  free_entity (entity);
829  return 0;
830  }
831  ret = (int) strtol (status, NULL, 10);
832  free_entity (entity);
833  if (errno == ERANGE)
834  return -1;
835  return ret;
836 }

References entity_attribute(), free_entity(), and read_entity_c().

Referenced by gmp_stop_task_c().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gmp_create_lsc_credential()

int gmp_create_lsc_credential ( gnutls_session_t *  session,
const char *  name,
const char *  login,
const char *  password,
const char *  comment,
gchar **  uuid 
)

Create an LSC Credential.

Parameters
[in]sessionPointer to GNUTLS session.
[in]nameName of LSC Credential.
[in]loginLogin associated with name.
[in]passwordPassword, or NULL for autogenerated credentials.
[in]commentLSC Credential comment.
[out]uuidEither NULL or address for UUID of created credential.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1684 of file gmp.c.

1687 {
1688  int ret;
1689 
1690  if (password)
1691  {
1692  if (comment)
1693  ret = gvm_server_sendf_xml_quiet (session,
1694  "<create_credential>"
1695  "<name>%s</name>"
1696  "<login>%s</login>"
1697  "<password>%s</password>"
1698  "<comment>%s</comment>"
1699  "</create_credential>",
1700  name, login, password, comment);
1701  else
1702  ret = gvm_server_sendf_xml_quiet (session,
1703  "<create_credential>"
1704  "<name>%s</name>"
1705  "<login>%s</login>"
1706  "<password>%s</password>"
1707  "</create_credential>",
1708  name, login, password);
1709  }
1710  else
1711  {
1712  if (comment)
1713  ret = gvm_server_sendf_xml (session,
1714  "<create_credential>"
1715  "<name>%s</name>"
1716  "<login>%s</login>"
1717  "<comment>%s</comment>"
1718  "</create_credential>",
1719  name, login, comment);
1720  else
1721  ret = gvm_server_sendf_xml (session,
1722  "<create_credential>"
1723  "<name>%s</name>"
1724  "<login>%s</login>"
1725  "</create_credential>",
1726  name, login);
1727  }
1728  if (ret)
1729  return -1;
1730 
1731  ret = gmp_read_create_response (session, uuid);
1732  if (ret == 201)
1733  return 0;
1734  return ret;
1735 }

References gmp_read_create_response(), gvm_server_sendf_xml(), gvm_server_sendf_xml_quiet(), and nvti::name.

Here is the call graph for this function:

◆ gmp_create_lsc_credential_ext()

int gmp_create_lsc_credential_ext ( gnutls_session_t *  session,
gmp_create_lsc_credential_opts_t  opts,
gchar **  id 
)

Create an LSC credential.

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]idPointer for newly allocated ID of new LSC credential, or NULL. Only set on successful return.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1805 of file gmp.c.

1808 {
1809  gchar *comment, *pass, *start, *snmp_elems;
1810  int ret;
1811 
1812  /* Create the GMP request. */
1813 
1814  if (opts.login == NULL)
1815  return -1;
1816 
1817  start =
1818  g_markup_printf_escaped ("<create_credential>"
1819  "<name>%s</name>"
1820  "<login>%s</login>",
1821  opts.name ? opts.name : "unnamed", opts.login);
1822 
1823  if (opts.comment)
1824  comment = g_markup_printf_escaped ("<comment>"
1825  "%s"
1826  "</comment>",
1827  opts.comment);
1828  else
1829  comment = NULL;
1830 
1831  if (opts.private_key)
1832  pass = g_markup_printf_escaped ("<key>"
1833  "<phrase>%s</phrase>"
1834  "<private>%s</private>"
1835  "</key>",
1836  opts.passphrase ? opts.passphrase : "",
1837  opts.private_key);
1838  else
1839  {
1840  if (opts.passphrase)
1841  pass = g_markup_printf_escaped ("<password>"
1842  "%s"
1843  "</password>",
1844  opts.passphrase);
1845  else
1846  pass = NULL;
1847  }
1848 
1849  if (opts.community && opts.auth_algorithm && opts.privacy_password
1850  && opts.privacy_algorithm)
1851  snmp_elems =
1852  g_markup_printf_escaped ("<community>"
1853  "%s"
1854  "</community>"
1855  "<auth_algorithm>"
1856  "%s"
1857  "</auth_algorithm>"
1858  "<privacy>"
1859  "<password>%s</password>"
1860  "<algorithm>%s</algorithm>"
1861  "</privacy>",
1862  opts.community, opts.auth_algorithm,
1863  opts.privacy_password, opts.privacy_algorithm);
1864  else
1865  snmp_elems = NULL;
1866 
1867  /* Send the request. */
1868 
1869  ret = gvm_server_sendf (session, "%s%s%s%s</create_credential>", start,
1870  comment ? comment : "", pass ? pass : "",
1871  snmp_elems ? snmp_elems : "");
1872 
1873  g_free (start);
1874  g_free (comment);
1875  g_free (pass);
1876  if (ret)
1877  return -1;
1878 
1879  /* Read the response. */
1880 
1881  ret = gmp_read_create_response (session, id);
1882  if (ret == 201)
1883  return 0;
1884  return ret;
1885 }

References gmp_create_lsc_credential_opts_t::auth_algorithm, gmp_create_lsc_credential_opts_t::comment, gmp_create_lsc_credential_opts_t::community, gmp_read_create_response(), gvm_server_sendf(), gmp_create_lsc_credential_opts_t::login, gmp_create_lsc_credential_opts_t::name, gmp_create_lsc_credential_opts_t::passphrase, gmp_create_lsc_credential_opts_t::privacy_algorithm, gmp_create_lsc_credential_opts_t::privacy_password, and gmp_create_lsc_credential_opts_t::private_key.

Here is the call graph for this function:

◆ gmp_create_lsc_credential_key()

int gmp_create_lsc_credential_key ( gnutls_session_t *  session,
const char *  name,
const char *  login,
const char *  passphrase,
const char *  private_key,
const char *  comment,
gchar **  uuid 
)

Create an LSC Credential with a key.

Parameters
[in]sessionPointer to GNUTLS session.
[in]nameName of LSC Credential.
[in]loginLogin associated with name.
[in]passphrasePassphrase for private key.
[in]private_keyPrivate key.
[in]commentLSC Credential comment.
[out]uuidEither NULL or address for UUID of created credential.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1752 of file gmp.c.

1756 {
1757  int ret;
1758 
1759  if (comment)
1760  ret = gvm_server_sendf_xml (session,
1761  "<create_credential>"
1762  "<name>%s</name>"
1763  "<login>%s</login>"
1764  "<key>"
1765  "<phrase>%s</phrase>"
1766  "<private>%s</private>"
1767  "</key>"
1768  "<comment>%s</comment>"
1769  "</create_credential>",
1770  name, login, passphrase ? passphrase : "",
1771  private_key, comment);
1772  else
1773  ret = gvm_server_sendf_xml (session,
1774  "<create_credential>"
1775  "<name>%s</name>"
1776  "<login>%s</login>"
1777  "<key>"
1778  "<phrase>%s</phrase>"
1779  "<private>%s</private>"
1780  "</key>"
1781  "</create_credential>",
1782  name, login, passphrase ? passphrase : "",
1783  private_key);
1784 
1785  if (ret)
1786  return -1;
1787 
1788  ret = gmp_read_create_response (session, uuid);
1789  if (ret == 201)
1790  return 0;
1791  return ret;
1792 }

References gmp_read_create_response(), gvm_server_sendf_xml(), and nvti::name.

Here is the call graph for this function:

◆ gmp_create_target_ext()

int gmp_create_target_ext ( gnutls_session_t *  session,
gmp_create_target_opts_t  opts,
gchar **  id 
)

Create a target.

FIXME: Using the according opts it should be possible to generate any type of create_target request defined by the spec.

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]idPointer for newly allocated ID of new target, or NULL. Only set on successful return.
Returns
0 on success (GMP 201), -2 on connection error, GMP response code on GMP error, -1 other error.

Definition at line 1502 of file gmp.c.

1504 {
1505  gchar *comment, *ssh, *smb, *esxi, *snmp, *port_range, *start;
1506  gchar *exclude_hosts, *alive_tests;
1507  int ret;
1508 
1509  /* Create the GMP request. */
1510 
1511  if (opts.hosts == NULL)
1512  return -1;
1513 
1514  start =
1515  g_markup_printf_escaped ("<create_target>"
1516  "<name>%s</name>"
1517  "<hosts>%s</hosts>",
1518  opts.name ? opts.name : "unnamed", opts.hosts);
1519 
1520  if (opts.exclude_hosts)
1521  exclude_hosts = g_markup_printf_escaped ("<exclude_hosts>"
1522  "%s"
1523  "</exclude_hosts>",
1524  opts.exclude_hosts);
1525  else
1526  exclude_hosts = NULL;
1527 
1528  if (opts.alive_tests)
1529  alive_tests = g_markup_printf_escaped ("<alive_tests>"
1530  "%s"
1531  "</alive_tests>",
1532  opts.alive_tests);
1533  else
1534  alive_tests = NULL;
1535 
1536  if (opts.comment)
1537  comment = g_markup_printf_escaped ("<comment>"
1538  "%s"
1539  "</comment>",
1540  opts.comment);
1541  else
1542  comment = NULL;
1543 
1544  if (opts.ssh_credential_id)
1545  {
1546  if (opts.ssh_credential_port)
1547  ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\">"
1548  "<port>%i</port>"
1549  "</ssh_lsc_credential>",
1550  opts.ssh_credential_id,
1551  opts.ssh_credential_port);
1552  else
1553  ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\"/>",
1554  opts.ssh_credential_id);
1555  }
1556  else
1557  ssh = NULL;
1558 
1559  if (opts.smb_credential_id)
1560  smb = g_markup_printf_escaped ("<smb_lsc_credential id=\"%s\"/>",
1561  opts.smb_credential_id);
1562  else
1563  smb = NULL;
1564 
1565  if (opts.esxi_credential_id)
1566  esxi = g_markup_printf_escaped ("<esxi_lsc_credential id=\"%s\"/>",
1567  opts.esxi_credential_id);
1568  else
1569  esxi = NULL;
1570 
1571  if (opts.snmp_credential_id)
1572  snmp = g_markup_printf_escaped ("<snmp_credential id=\"%s\"/>",
1573  opts.snmp_credential_id);
1574  else
1575  snmp = NULL;
1576 
1577  if (opts.port_range)
1578  port_range =
1579  g_markup_printf_escaped ("<port_range>%s</port_range>", opts.port_range);
1580  else
1581  port_range = NULL;
1582 
1583  /* Send the request. */
1584  ret = gvm_server_sendf (session,
1585  "%s%s%s%s%s%s%s%s%s"
1586  "<reverse_lookup_only>%d</reverse_lookup_only>"
1587  "<reverse_lookup_unify>%d</reverse_lookup_unify>"
1588  "</create_target>",
1589  start, exclude_hosts ? exclude_hosts : "",
1590  alive_tests ? alive_tests : "", ssh ? ssh : "",
1591  smb ? smb : "", esxi ? esxi : "", snmp ? snmp : "",
1592  port_range ? port_range : "", comment ? comment : "",
1594  g_free (start);
1595  g_free (exclude_hosts);
1596  g_free (alive_tests);
1597  g_free (ssh);
1598  g_free (smb);
1599  g_free (esxi);
1600  g_free (port_range);
1601  g_free (comment);
1602  if (ret)
1603  return -2;
1604 
1605  /* Read the response. */
1606 
1607  ret = gmp_read_create_response (session, id);
1608  if (ret == 201)
1609  return 0;
1610  return ret;
1611 }

References gmp_create_target_opts_t::alive_tests, gmp_create_target_opts_t::comment, gmp_create_target_opts_t::esxi_credential_id, gmp_create_target_opts_t::exclude_hosts, gmp_read_create_response(), gvm_server_sendf(), gmp_create_target_opts_t::hosts, gmp_create_target_opts_t::name, gmp_create_target_opts_t::port_range, gmp_create_target_opts_t::reverse_lookup_only, gmp_create_target_opts_t::reverse_lookup_unify, gmp_create_target_opts_t::smb_credential_id, gmp_create_target_opts_t::snmp_credential_id, gmp_create_target_opts_t::ssh_credential_id, and gmp_create_target_opts_t::ssh_credential_port.

Here is the call graph for this function:

◆ gmp_create_task()

int gmp_create_task ( gnutls_session_t *  session,
const char *  name,
const char *  config,
const char *  target,
const char *  comment,
gchar **  id 
)

Create a task given a config and target.

Parameters
[in]sessionPointer to GNUTLS session.
[in]nameTask name.
[in]configTask config name.
[in]targetTask target name.
[in]commentTask comment.
[out]idPointer for newly allocated ID of new task. Only set on successful return.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 662 of file gmp.c.

665 {
666  int ret;
667 
668  ret = gvm_server_sendf_xml (session,
669  "<create_task>"
670  "<config id=\"%s\"/>"
671  "<target id=\"%s\"/>"
672  "<name>%s</name>"
673  "<comment>%s</comment>"
674  "</create_task>",
675  config, target, name, comment);
676  if (ret)
677  return -1;
678 
679  /* Read the response. */
680 
681  ret = gmp_read_create_response (session, id);
682  if (ret == 201)
683  return 0;
684  return ret;
685 }

References gmp_read_create_response(), gvm_server_sendf_xml(), and nvti::name.

Here is the call graph for this function:

◆ gmp_create_task_ext()

int gmp_create_task_ext ( gnutls_session_t *  session,
gmp_create_task_opts_t  opts,
gchar **  id 
)

Create a task.

FIXME: Using the according opts it should be possible to generate any type of create_task request defined by the spec.

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]idPointer for newly allocated ID of new task, or NULL. Only set on successful return.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 482 of file gmp.c.

484 {
485  /* Create the GMP request. */
486 
487  gchar *prefs, *start, *hosts_ordering, *scanner, *schedule, *slave;
488  GString *alerts, *observers;
489  int ret;
490  if ((opts.config_id == NULL) || (opts.target_id == NULL))
491  return -1;
492 
493  prefs = NULL;
494  start = g_markup_printf_escaped (
495  "<create_task>"
496  "<config id=\"%s\"/>"
497  "<target id=\"%s\"/>"
498  "<name>%s</name>"
499  "<comment>%s</comment>"
500  "<alterable>%d</alterable>",
501  opts.config_id, opts.target_id, opts.name ? opts.name : "unnamed",
502  opts.comment ? opts.comment : "", opts.alterable ? 1 : 0);
503 
504  if (opts.hosts_ordering)
505  hosts_ordering = g_strdup_printf ("<hosts_ordering>%s</hosts_ordering>",
506  opts.hosts_ordering);
507  else
508  hosts_ordering = NULL;
509 
510  if (opts.scanner_id)
511  scanner = g_strdup_printf ("<scanner id=\"%s\"/>", opts.scanner_id);
512  else
513  scanner = NULL;
514 
515  if (opts.schedule_id)
516  schedule = g_strdup_printf ("<schedule id=\"%s\"/>"
517  "<schedule_periods>%d</schedule_periods>",
518  opts.schedule_id, opts.schedule_periods);
519  else
520  schedule = NULL;
521 
522  if (opts.slave_id)
523  slave = g_strdup_printf ("<slave id=\"%s\"/>", opts.slave_id);
524  else
525  slave = NULL;
526 
527  if (opts.max_checks || opts.max_hosts || opts.in_assets || opts.source_iface)
528  {
529  gchar *in_assets, *checks, *hosts, *source_iface;
530 
531  in_assets = checks = hosts = source_iface = NULL;
532 
533  if (opts.in_assets)
534  in_assets = g_markup_printf_escaped ("<preference>"
535  "<scanner_name>"
536  "in_assets"
537  "</scanner_name>"
538  "<value>"
539  "%s"
540  "</value>"
541  "</preference>",
542  opts.in_assets);
543 
544  if (opts.max_hosts)
545  hosts = g_markup_printf_escaped ("<preference>"
546  "<scanner_name>"
547  "max_hosts"
548  "</scanner_name>"
549  "<value>"
550  "%s"
551  "</value>"
552  "</preference>",
553  opts.max_hosts);
554 
555  if (opts.max_checks)
556  checks = g_markup_printf_escaped ("<preference>"
557  "<scanner_name>"
558  "max_checks"
559  "</scanner_name>"
560  "<value>"
561  "%s"
562  "</value>"
563  "</preference>",
564  opts.max_checks);
565 
566  if (opts.source_iface)
567  source_iface = g_markup_printf_escaped ("<preference>"
568  "<scanner_name>"
569  "source_iface"
570  "</scanner_name>"
571  "<value>"
572  "%s"
573  "</value>"
574  "</preference>",
575  opts.source_iface);
576 
577  prefs =
578  g_strdup_printf ("<preferences>%s%s%s%s</preferences>",
579  in_assets ? in_assets : "", checks ? checks : "",
580  hosts ? hosts : "", source_iface ? source_iface : "");
581  g_free (in_assets);
582  g_free (checks);
583  g_free (hosts);
584  g_free (source_iface);
585  }
586 
587  if (opts.alert_ids)
588  {
589  unsigned int i;
590  alerts = g_string_new ("");
591  for (i = 0; i < opts.alert_ids->len; i++)
592  {
593  char *alert = (char *) g_ptr_array_index (opts.alert_ids, i);
594  g_string_append_printf (alerts, "<alert id=\"%s\"/>", alert);
595  }
596  }
597  else
598  alerts = g_string_new ("");
599 
600  if (opts.observers || opts.observer_groups)
601  {
602  observers = g_string_new ("<observers>");
603 
604  if (opts.observers)
605  g_string_append (observers, opts.observers);
606 
607  if (opts.observer_groups)
608  {
609  unsigned int i;
610  for (i = 0; i < opts.observer_groups->len; i++)
611  {
612  char *group =
613  (char *) g_ptr_array_index (opts.observer_groups, i);
614  g_string_append_printf (observers, "<group id=\"%s\"/>", group);
615  }
616  }
617  g_string_append (observers, "</observers>");
618  }
619  else
620  observers = g_string_new ("");
621 
622  /* Send the request. */
623  ret = gvm_server_sendf (
624  session, "%s%s%s%s%s%s%s%s</create_task>", start, prefs ? prefs : "",
625  hosts_ordering ? hosts_ordering : "", scanner ? scanner : "",
626  schedule ? schedule : "", slave ? slave : "", alerts ? alerts->str : "",
627  observers ? observers->str : "");
628  g_free (start);
629  g_free (prefs);
630  g_free (hosts_ordering);
631  g_free (scanner);
632  g_free (schedule);
633  g_free (slave);
634  g_string_free (alerts, TRUE);
635  g_string_free (observers, TRUE);
636 
637  if (ret)
638  return -1;
639 
640  /* Read the response. */
641 
642  ret = gmp_read_create_response (session, id);
643  if (ret == 201)
644  return 0;
645  return ret;
646 }

References gmp_create_task_opts_t::alert_ids, gmp_create_task_opts_t::alterable, gmp_create_task_opts_t::comment, gmp_create_task_opts_t::config_id, gmp_read_create_response(), gvm_server_sendf(), gmp_create_task_opts_t::hosts_ordering, gmp_create_task_opts_t::in_assets, gmp_create_task_opts_t::max_checks, gmp_create_task_opts_t::max_hosts, gmp_create_task_opts_t::name, gmp_create_task_opts_t::observer_groups, gmp_create_task_opts_t::observers, nvti::prefs, gmp_create_task_opts_t::scanner_id, gmp_create_task_opts_t::schedule_id, gmp_create_task_opts_t::schedule_periods, gmp_create_task_opts_t::slave_id, gmp_create_task_opts_t::source_iface, and gmp_create_task_opts_t::target_id.

Here is the call graph for this function:

◆ gmp_delete_config_ext()

int gmp_delete_config_ext ( gnutls_session_t *  session,
const char *  id,
gmp_delete_opts_t  opts 
)

Delete a config.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idUUID of config.
[in]optsStruct containing the options to apply.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1652 of file gmp.c.

1654 {
1655  entity_t entity;
1656  int ret;
1657 
1658  if (gvm_server_sendf (session,
1659  "<delete_config config_id=\"%s\" ultimate=\"%d\"/>", id,
1660  opts.ultimate)
1661  == -1)
1662  return -1;
1663 
1664  entity = NULL;
1665  ret = gmp_check_response (session, &entity);
1666  if (ret == 0)
1667  free_entity (entity);
1668  return ret;
1669 }

References free_entity(), gmp_check_response(), gvm_server_sendf(), and gmp_delete_opts_t::ultimate.

Here is the call graph for this function:

◆ gmp_delete_lsc_credential_ext()

int gmp_delete_lsc_credential_ext ( gnutls_session_t *  session,
const char *  id,
gmp_delete_opts_t  opts 
)

Delete a LSC credential.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idUUID of LSC credential.
[in]optsStruct containing the options to apply.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1897 of file gmp.c.

1899 {
1900  entity_t entity;
1901  int ret;
1902 
1903  if (gvm_server_sendf (session,
1904  "<delete_credential credential_id=\"%s\""
1905  " ultimate=\"%d\"/>",
1906  id, opts.ultimate)
1907  == -1)
1908  return -1;
1909 
1910  entity = NULL;
1911  ret = gmp_check_response (session, &entity);
1912  if (ret == 0)
1913  free_entity (entity);
1914  return ret;
1915 }

References free_entity(), gmp_check_response(), gvm_server_sendf(), and gmp_delete_opts_t::ultimate.

Here is the call graph for this function:

◆ gmp_delete_port_list_ext()

int gmp_delete_port_list_ext ( gnutls_session_t *  session,
const char *  id,
gmp_delete_opts_t  opts 
)

Delete a port list.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idUUID of port list.
[in]optsStruct containing the options to apply.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1444 of file gmp.c.

1446 {
1447  entity_t entity;
1448  int ret;
1449 
1450  if (gvm_server_sendf (
1451  session, "<delete_port_list port_list_id=\"%s\" ultimate=\"%d\"/>", id,
1452  opts.ultimate)
1453  == -1)
1454  return -1;
1455 
1456  entity = NULL;
1457  ret = gmp_check_response (session, &entity);
1458  if (ret == 0)
1459  free_entity (entity);
1460  return ret;
1461 }

References free_entity(), gmp_check_response(), gvm_server_sendf(), and gmp_delete_opts_t::ultimate.

Here is the call graph for this function:

◆ gmp_delete_report()

int gmp_delete_report ( gnutls_session_t *  session,
const char *  id 
)

Remove a report.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idID of report.
Returns
0 on success, GMP response code on failure, -1 on error.

Definition at line 1472 of file gmp.c.

1473 {
1474  entity_t entity;
1475  int ret;
1476 
1477  if (gvm_server_sendf (session, "<delete_report report_id=\"%s\"/>", id))
1478  return -1;
1479 
1480  entity = NULL;
1481  ret = gmp_check_response (session, &entity);
1482  if (ret == 0)
1483  free_entity (entity);
1484  return ret;
1485 }

References free_entity(), gmp_check_response(), and gvm_server_sendf().

Here is the call graph for this function:

◆ gmp_delete_target_ext()

int gmp_delete_target_ext ( gnutls_session_t *  session,
const char *  id,
gmp_delete_opts_t  opts 
)

Delete a target.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idUUID of target.
[in]optsStruct containing the options to apply.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1623 of file gmp.c.

1625 {
1626  entity_t entity;
1627  int ret;
1628 
1629  if (gvm_server_sendf (session,
1630  "<delete_target target_id=\"%s\" ultimate=\"%d\"/>", id,
1631  opts.ultimate)
1632  == -1)
1633  return -1;
1634 
1635  entity = NULL;
1636  ret = gmp_check_response (session, &entity);
1637  if (ret == 0)
1638  free_entity (entity);
1639  return ret;
1640 }

References free_entity(), gmp_check_response(), gvm_server_sendf(), and gmp_delete_opts_t::ultimate.

Here is the call graph for this function:

◆ gmp_delete_task()

int gmp_delete_task ( gnutls_session_t *  session,
const char *  id 
)

Delete a task and read the manager response.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idID of task.
Returns
0 on success, GMP response code on failure, -1 on error.

Definition at line 1280 of file gmp.c.

1281 {
1282  entity_t entity;
1283  int ret;
1284 
1285  if (gvm_server_sendf (session, "<delete_task task_id=\"%s\"/>", id) == -1)
1286  return -1;
1287 
1288  entity = NULL;
1289  ret = gmp_check_response (session, &entity);
1290  if (ret == 0)
1291  free_entity (entity);
1292  return ret;
1293 }

References free_entity(), gmp_check_response(), and gvm_server_sendf().

Here is the call graph for this function:

◆ gmp_delete_task_ext()

int gmp_delete_task_ext ( gnutls_session_t *  session,
const char *  id,
gmp_delete_opts_t  opts 
)

Delete a task and read the manager response.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idID of task.
[in]optsStruct containing the options to apply.
Returns
0 on success, GMP response code on failure, -1 on error.

Definition at line 1052 of file gmp.c.

1054 {
1055  entity_t entity;
1056  int ret;
1057 
1058  if (gvm_server_sendf (session,
1059  "<delete_task task_id=\"%s\" ultimate=\"%d\"/>", id,
1060  opts.ultimate)
1061  == -1)
1062  return -1;
1063 
1064  entity = NULL;
1065  ret = gmp_check_response (session, &entity);
1066  if (ret == 0)
1067  free_entity (entity);
1068  return ret;
1069 }

References free_entity(), gmp_check_response(), gvm_server_sendf(), and gmp_delete_opts_t::ultimate.

Here is the call graph for this function:

◆ gmp_get_report_ext()

int gmp_get_report_ext ( gnutls_session_t *  session,
gmp_get_report_opts_t  opts,
entity_t response 
)

Get a report (generic version).

FIXME: Using the according opts it should be possible to generate any type of get_reports request defined by the spec.

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]responseReport. On success contains GET_REPORT response.
Returns
0 on success, 2 on timeout, -1 or GMP response code on error.

Definition at line 1346 of file gmp.c.

1348 {
1349  int ret;
1350  const char *status_code;
1351 
1352  if (response == NULL)
1353  return -1;
1354 
1355  if (gvm_server_sendf (
1356  session,
1357  "<get_reports"
1358  " details=\"1\""
1359  " report_id=\"%s\""
1360  " format_id=\"%s\""
1361  " host_first_result=\"%i\""
1362  " host_max_results=\"%i\""
1363  "%s%s%s"
1364  "%s%s%s"
1365  "%s%s%s"
1366  "%s%s%s"
1367  "%s%s%s"
1368  "%s%s%s"
1369  "%s%s%s"
1370  "%s%s%s"
1371  "%s%s%s"
1372  "%s%s%s"
1373  "%s%s%s"
1374  "%s%s%s"
1375  "%s%s%s"
1376  "%s%s%s"
1377  "%s%s%s%s%s%s%s/>",
1378  opts.report_id, opts.format_id, opts.host_first_result,
1379  opts.host_max_results, GMP_FMT_STRING_ATTRIB (opts, type),
1380  GMP_FMT_STRING_ATTRIB (opts, filter),
1381  GMP_FMT_STRING_ATTRIB (opts, filt_id),
1382  GMP_FMT_STRING_ATTRIB (opts, host), GMP_FMT_STRING_ATTRIB (opts, pos),
1383  GMP_FMT_STRING_ATTRIB (opts, timezone),
1384  GMP_FMT_STRING_ATTRIB (opts, alert_id),
1385  GMP_FMT_STRING_ATTRIB (opts, delta_report_id),
1386  GMP_FMT_STRING_ATTRIB (opts, delta_states),
1387  GMP_FMT_STRING_ATTRIB (opts, host_levels),
1388  GMP_FMT_STRING_ATTRIB (opts, search_phrase),
1389  GMP_FMT_STRING_ATTRIB (opts, host_search_phrase),
1390  GMP_FMT_STRING_ATTRIB (opts, min_cvss_base),
1391  GMP_FMT_STRING_ATTRIB (opts, min_qod),
1392  GMP_FMT_BOOL_ATTRIB (opts, notes),
1393  GMP_FMT_BOOL_ATTRIB (opts, notes_details),
1394  GMP_FMT_BOOL_ATTRIB (opts, overrides),
1395  GMP_FMT_BOOL_ATTRIB (opts, override_details),
1396  GMP_FMT_BOOL_ATTRIB (opts, apply_overrides),
1397  GMP_FMT_BOOL_ATTRIB (opts, result_hosts_only),
1398  GMP_FMT_BOOL_ATTRIB (opts, ignore_pagination)))
1399  return -1;
1400 
1401  *response = NULL;
1402  switch (try_read_entity (session, opts.timeout, response))
1403  {
1404  case 0:
1405  break;
1406  case -4:
1407  return 2;
1408  default:
1409  return -1;
1410  }
1411 
1412  /* Check the response. */
1413 
1414  status_code = entity_attribute (*response, "status");
1415  if (status_code == NULL)
1416  {
1417  free_entity (*response);
1418  return -1;
1419  }
1420  if (strlen (status_code) == 0)
1421  {
1422  free_entity (*response);
1423  return -1;
1424  }
1425  if (status_code[0] == '2')
1426  return 0;
1427  ret = (int) strtol (status_code, NULL, 10);
1428  free_entity (*response);
1429  if (errno == ERANGE)
1430  return -1;
1431  return ret;
1432 }

References entity_attribute(), gmp_get_report_opts_t::format_id, free_entity(), GMP_FMT_BOOL_ATTRIB, GMP_FMT_STRING_ATTRIB, gvm_server_sendf(), gmp_get_report_opts_t::host_first_result, gmp_get_report_opts_t::host_max_results, gmp_get_report_opts_t::report_id, gmp_get_report_opts_t::timeout, and try_read_entity().

Here is the call graph for this function:

◆ gmp_get_system_reports()

int gmp_get_system_reports ( gnutls_session_t *  session,
const char *  name,
int  brief,
entity_t reports 
)

Get system reports.

Parameters
[in]sessionPointer to GNUTLS session.
[in]nameName of system report. NULL for all.
[in]briefWhether to request brief response.
[out]reportsReports return. On success contains GET_SYSTEM_REPORTS response.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1929 of file gmp.c.

1931 {
1932  if (name)
1933  {
1934  if (gvm_server_sendf (session,
1935  "<get_system_reports name=\"%s\" brief=\"%i\"/>",
1936  name, brief)
1937  == -1)
1938  return -1;
1939  }
1940  else if (gvm_server_sendf (session, "<get_system_reports brief=\"%i\"/>",
1941  brief)
1942  == -1)
1943  return -1;
1944 
1945  /* Read and check the response. */
1946  return gmp_check_response (session, reports);
1947 }

References gmp_check_response(), gvm_server_sendf(), and nvti::name.

Here is the call graph for this function:

◆ gmp_get_system_reports_ext()

int gmp_get_system_reports_ext ( gnutls_session_t *  session,
gmp_get_system_reports_opts_t  opts,
entity_t reports 
)

Get system reports.

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]reportsReports return. On success contains GET_SYSTEM_REPORTS response.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1960 of file gmp.c.

1963 {
1964  GString *request;
1965 
1966  request = g_string_new ("<get_system_reports");
1967 
1968  if (opts.slave_id)
1969  xml_string_append (request, " slave_id=\"%s\"", opts.slave_id);
1970 
1971  if (opts.name)
1972  xml_string_append (request, " name=\"%s\"", opts.name);
1973 
1974  if (opts.duration)
1975  xml_string_append (request, " duration=\"%s\"", opts.duration);
1976 
1977  if (opts.start_time)
1978  xml_string_append (request, " start_time=\"%s\"", opts.start_time);
1979 
1980  if (opts.end_time)
1981  xml_string_append (request, " end_time=\"%s\"", opts.end_time);
1982 
1983  g_string_append (request, "/>");
1984 
1985  /* Create the GMP request. */
1986 
1987  if (gvm_server_sendf (session, "%s", request->str) == -1)
1988  {
1989  g_string_free (request, 1);
1990  return -1;
1991  }
1992  g_string_free (request, 1);
1993 
1994  /* Read and check the response. */
1995  return gmp_check_response (session, reports);
1996 }

References gmp_get_system_reports_opts_t::duration, gmp_get_system_reports_opts_t::end_time, gmp_check_response(), gvm_server_sendf(), gmp_get_system_reports_opts_t::name, gmp_get_system_reports_opts_t::slave_id, gmp_get_system_reports_opts_t::start_time, and xml_string_append().

Here is the call graph for this function:

◆ gmp_get_targets()

int gmp_get_targets ( gnutls_session_t *  session,
const char *  id,
int  tasks,
int  include_rcfile,
entity_t target 
)

Get a target.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idID of target or NULL for all targets.
[in]tasksWhether to include tasks that use the target.
[in]include_rcfileNot used.
[out]targetTarget return. On success contains GET_TARGETS response.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1308 of file gmp.c.

1310 {
1311  (void) include_rcfile;
1312  if (id == NULL)
1313  {
1314  if (gvm_server_sendf (session, "<get_targets tasks=\"%i\"/>", tasks)
1315  == -1)
1316  return -1;
1317  }
1318  else
1319  {
1320  if (gvm_server_sendf (session,
1321  "<get_targets"
1322  " target_id=\"%s\""
1323  " tasks=\"%i\"/>",
1324  id, tasks)
1325  == -1)
1326  return -1;
1327  }
1328 
1329  /* Read the response. */
1330  return gmp_check_response (session, target);
1331 }

References gmp_check_response(), and gvm_server_sendf().

Here is the call graph for this function:

◆ gmp_get_task_ext()

int gmp_get_task_ext ( gnutls_session_t *  session,
gmp_get_task_opts_t  opts,
entity_t response 
)

Get a task (generic version).

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]responseTask. On success contains GET_TASKS response.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1119 of file gmp.c.

1121 {
1122  if ((response == NULL) || (opts.task_id == NULL))
1123  return -1;
1124 
1125  if (opts.actions)
1126  {
1127  if (gvm_server_sendf (session,
1128  "<get_tasks"
1129  " task_id=\"%s\""
1130  " actions=\"%s\""
1131  "%s/>",
1132  opts.task_id, opts.actions,
1133  GMP_FMT_BOOL_ATTRIB (opts, details)))
1134  return -1;
1135  }
1136  else if (gvm_server_sendf (session,
1137  "<get_tasks"
1138  " task_id=\"%s\""
1139  "%s/>",
1140  opts.task_id, GMP_FMT_BOOL_ATTRIB (opts, details)))
1141  return -1;
1142 
1143  return gmp_check_response (session, response);
1144 }

References gmp_get_task_opts_t::actions, gmp_check_response(), GMP_FMT_BOOL_ATTRIB, gvm_server_sendf(), and gmp_get_task_opts_t::task_id.

Here is the call graph for this function:

◆ gmp_get_tasks()

int gmp_get_tasks ( gnutls_session_t *  session,
const char *  id,
int  details,
int  include_rcfile,
entity_t status 
)

Get the status of a task.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idID of task or NULL for all tasks.
[in]detailsWhether to request task details.
[in]include_rcfileIgnored. Removed since GMP 6.0.
[out]statusStatus return. On success contains GET_TASKS response.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1084 of file gmp.c.

1086 {
1087  (void) include_rcfile;
1088  if (id == NULL)
1089  {
1090  if (gvm_server_sendf (session, "<get_tasks details=\"%i\"/>", details)
1091  == -1)
1092  return -1;
1093  }
1094  else
1095  {
1096  if (gvm_server_sendf (session,
1097  "<get_tasks"
1098  " task_id=\"%s\""
1099  " details=\"%i\"/>",
1100  id, details)
1101  == -1)
1102  return -1;
1103  }
1104 
1105  /* Read the response. */
1106  return gmp_check_response (session, status);
1107 }

References gmp_check_response(), and gvm_server_sendf().

Here is the call graph for this function:

◆ gmp_get_tasks_ext()

int gmp_get_tasks_ext ( gnutls_session_t *  session,
gmp_get_tasks_opts_t  opts,
entity_t response 
)

Get all tasks (generic version).

Parameters
[in]sessionPointer to GNUTLS session.
[in]optsStruct containing the options to apply.
[out]responseTasks. On success contains GET_TASKS response.
Returns
0 on success, 2 on timeout, -1 or GMP response code on error.

Definition at line 1156 of file gmp.c.

1158 {
1159  int ret;
1160  const char *status_code;
1161  gchar *cmd;
1162 
1163  if (response == NULL)
1164  return -1;
1165 
1166  cmd = g_markup_printf_escaped ("<get_tasks"
1167  " filter=\"%s\"",
1168  opts.filter);
1169 
1170  if (gvm_server_sendf (session, "%s%s/>", cmd,
1171  GMP_FMT_BOOL_ATTRIB (opts, details)))
1172  {
1173  g_free (cmd);
1174  return -1;
1175  }
1176  g_free (cmd);
1177 
1178  *response = NULL;
1179  switch (try_read_entity (session, opts.timeout, response))
1180  {
1181  case 0:
1182  break;
1183  case -4:
1184  return 2;
1185  default:
1186  return -1;
1187  }
1188 
1189  /* Check the response. */
1190 
1191  status_code = entity_attribute (*response, "status");
1192  if (status_code == NULL)
1193  {
1194  free_entity (*response);
1195  return -1;
1196  }
1197  if (strlen (status_code) == 0)
1198  {
1199  free_entity (*response);
1200  return -1;
1201  }
1202  if (status_code[0] == '2')
1203  return 0;
1204  ret = (int) strtol (status_code, NULL, 10);
1205  free_entity (*response);
1206  if (errno == ERANGE)
1207  return -1;
1208  return ret;
1209 }

References entity_attribute(), gmp_get_tasks_opts_t::filter, free_entity(), GMP_FMT_BOOL_ATTRIB, gvm_server_sendf(), gmp_get_tasks_opts_t::timeout, and try_read_entity().

Here is the call graph for this function:

◆ gmp_modify_task_file()

int gmp_modify_task_file ( gnutls_session_t *  session,
const char *  id,
const char *  name,
const void *  content,
gsize  content_len 
)

Modify a file on a task.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idID of task.
[in]nameName of file.
[in]contentNew content. NULL to remove file.
[in]content_lenLength of content.
Returns
0 on success, -1 or GMP response code on error.

Definition at line 1223 of file gmp.c.

1225 {
1226  entity_t entity;
1227  int ret;
1228 
1229  if (name == NULL)
1230  return -1;
1231 
1232  if (gvm_server_sendf (session, "<modify_task task_id=\"%s\">", id))
1233  return -1;
1234 
1235  if (content)
1236  {
1237  if (gvm_server_sendf (session, "<file name=\"%s\" action=\"update\">",
1238  name))
1239  return -1;
1240 
1241  if (content_len)
1242  {
1243  gchar *base64_content =
1244  g_base64_encode ((guchar *) content, content_len);
1245  int ret = gvm_server_sendf (session, "%s", base64_content);
1246  g_free (base64_content);
1247  if (ret)
1248  return -1;
1249  }
1250 
1251  if (gvm_server_sendf (session, "</file>"))
1252  return -1;
1253  }
1254  else
1255  {
1256  if (gvm_server_sendf (session, "<file name=\"%s\" action=\"remove\" />",
1257  name))
1258  return -1;
1259  }
1260 
1261  if (gvm_server_sendf (session, "</modify_task>"))
1262  return -1;
1263 
1264  entity = NULL;
1265  ret = gmp_check_response (session, &entity);
1266  if (ret == 0)
1267  free_entity (entity);
1268  return ret;
1269 }

References free_entity(), gmp_check_response(), gvm_server_sendf(), and nvti::name.

Here is the call graph for this function:

◆ gmp_ping()

int gmp_ping ( gnutls_session_t *  session,
int  timeout 
)

"Ping" the manager.

Parameters
[in]sessionPointer to GNUTLS session.
[in]timeoutServer idle time before giving up, in milliseconds. 0 to wait forever.
Returns
0 on success, 1 if manager closed connection, 2 on timeout, -1 on error.

Definition at line 129 of file gmp.c.

130 {
131  entity_t entity;
132  const char *status;
133  char first;
134  int ret;
135 
136  /* Send a GET_VERSION request. */
137 
138  ret = gvm_server_sendf (session, "<get_version/>");
139  if (ret)
140  return ret;
141 
142  /* Read the response, with a timeout. */
143 
144  entity = NULL;
145  switch (try_read_entity (session, timeout, &entity))
146  {
147  case 0:
148  break;
149  case -4:
150  return 2;
151  default:
152  return -1;
153  }
154 
155  /* Check the response. */
156 
157  status = entity_attribute (entity, "status");
158  if (status == NULL)
159  {
160  free_entity (entity);
161  return -1;
162  }
163  if (strlen (status) == 0)
164  {
165  free_entity (entity);
166  return -1;
167  }
168  first = status[0];
169  free_entity (entity);
170  if (first == '2')
171  return 0;
172  return -1;
173 }

References entity_attribute(), free_entity(), gvm_server_sendf(), nvti::timeout, and try_read_entity().

Here is the call graph for this function:

◆ gmp_ping_c()

int gmp_ping_c ( gvm_connection_t connection,
int  timeout,
gchar **  version 
)

"Ping" the manager.

Parameters
[in]connectionPointer to GNUTLS session.
[in]timeoutServer idle time before giving up, in milliseconds. 0 to wait forever.
[out]versionReturn location for freshly allocated version if required, else NULL.
Returns
0 on success, 1 if manager closed connection, 2 on timeout, -1 on error.

Definition at line 188 of file gmp.c.

189 {
190  entity_t entity;
191  const char *status;
192  int ret;
193 
194  if (version && *version)
195  *version = NULL;
196 
197  /* Send a GET_VERSION request. */
198 
199  ret = gvm_connection_sendf (connection, "<get_version/>");
200  if (ret)
201  return ret;
202 
203  /* Read the response, with a timeout. */
204 
205  entity = NULL;
206  switch (try_read_entity_c (connection, timeout, &entity))
207  {
208  case 0:
209  break;
210  case -4:
211  return 2;
212  default:
213  return -1;
214  }
215 
216  /* Check the response. */
217 
218  status = entity_attribute (entity, "status");
219  if (status == NULL)
220  {
221  free_entity (entity);
222  return -1;
223  }
224  if (strlen (status) == 0)
225  {
226  free_entity (entity);
227  return -1;
228  }
229  if (status[0] == '2')
230  {
231  if (version)
232  {
233  entity_t omp_version;
234  omp_version = entity_child (entity, "version");
235  if (omp_version == NULL)
236  {
237  free_entity (entity);
238  return -1;
239  }
240  *version = strdup (entity_text (omp_version));
241  }
242  free_entity (entity);
243  return 0;
244  }
245  free_entity (entity);
246  return -1;
247 }

References entity_attribute(), entity_child(), entity_text(), free_entity(), gvm_connection_sendf(), nvti::timeout, and try_read_entity_c().

Here is the call graph for this function:

◆ gmp_read_create_response()

int gmp_read_create_response ( gnutls_session_t *  session,
gchar **  uuid 
)

Read response status and resource UUID.

Parameters
[in]sessionPointer to GNUTLS session.
[out]uuidEither NULL or address for freshly allocated UUID of created response.
Returns
GMP response code on success, -1 on error.

Definition at line 848 of file gmp.c.

849 {
850  int ret;
851  const char *status;
852  entity_t entity;
853 
854  /* Read the response. */
855 
856  entity = NULL;
857  if (read_entity (session, &entity))
858  return -1;
859 
860  /* Parse the response. */
861 
862  status = entity_attribute (entity, "status");
863  if (status == NULL)
864  {
865  free_entity (entity);
866  return -1;
867  }
868  if (strlen (status) == 0)
869  {
870  free_entity (entity);
871  return -1;
872  }
873 
874  if (uuid)
875  {
876  const char *id;
877 
878  id = entity_attribute (entity, "id");
879  if (id == NULL)
880  {
881  free_entity (entity);
882  return -1;
883  }
884  if (strlen (id) == 0)
885  {
886  free_entity (entity);
887  return -1;
888  }
889  *uuid = g_strdup (id);
890  }
891 
892  ret = atoi (status);
893  free_entity (entity);
894  return ret;
895 }

References entity_attribute(), free_entity(), and read_entity().

Referenced by gmp_create_lsc_credential(), gmp_create_lsc_credential_ext(), gmp_create_lsc_credential_key(), gmp_create_target_ext(), gmp_create_task(), and gmp_create_task_ext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gmp_resume_task_report()

int gmp_resume_task_report ( gnutls_session_t *  session,
const char *  task_id,
char **  report_id 
)

Resume a task and read the manager response.

Parameters
[in]sessionPointer to GNUTLS session.
[in]task_idID of task.
[out]report_idID of report.
Returns
0 on success, 1 on GMP failure, -1 on error.

Definition at line 949 of file gmp.c.

951 {
952  int ret;
953  entity_t entity;
954  if (gvm_server_sendf (session, "<resume_task task_id=\"%s\"/>", task_id)
955  == -1)
956  return -1;
957 
958  /* Read the response. */
959 
960  entity = NULL;
961  ret = gmp_check_response (session, &entity);
962 
963  if (ret == 0)
964  {
965  if (report_id)
966  {
967  entity_t report_id_xml = entity_child (entity, "report_id");
968  if (report_id_xml)
969  *report_id = g_strdup (entity_text (report_id_xml));
970  else
971  {
972  free_entity (entity);
973  return -1;
974  }
975  }
976  free_entity (entity);
977  return 0;
978  }
979  else if (ret == -1)
980  return ret;
981  return 1;
982 }

References entity_child(), entity_text(), free_entity(), gmp_check_response(), and gvm_server_sendf().

Here is the call graph for this function:

◆ gmp_resume_task_report_c()

int gmp_resume_task_report_c ( gvm_connection_t connection,
const char *  task_id,
char **  report_id 
)

Resume a task and read the manager response.

Parameters
[in]connectionConnection.
[in]task_idID of task.
[out]report_idID of report.
Returns
0 on success, 1 on GMP failure, -1 on error.

Definition at line 994 of file gmp.c.

996 {
997  if (gvm_connection_sendf (connection, "<resume_task task_id=\"%s\"/>",
998  task_id)
999  == -1)
1000  return -1;
1001 
1002  /* Read the response. */
1003 
1004  entity_t entity = NULL;
1005  if (read_entity_c (connection, &entity))
1006  return -1;
1007 
1008  /* Check the response. */
1009 
1010  const char *status = entity_attribute (entity, "status");
1011  if (status == NULL)
1012  {
1013  free_entity (entity);
1014  return -1;
1015  }
1016  if (strlen (status) == 0)
1017  {
1018  free_entity (entity);
1019  return -1;
1020  }
1021  char first = status[0];
1022  if (first == '2')
1023  {
1024  if (report_id)
1025  {
1026  entity_t report_id_xml = entity_child (entity, "report_id");
1027  if (report_id_xml)
1028  *report_id = g_strdup (entity_text (report_id_xml));
1029  else
1030  {
1031  free_entity (entity);
1032  return -1;
1033  }
1034  }
1035  free_entity (entity);
1036  return 0;
1037  }
1038  free_entity (entity);
1039  return 1;
1040 }

References entity_attribute(), entity_child(), entity_text(), free_entity(), gvm_connection_sendf(), and read_entity_c().

Here is the call graph for this function:

◆ gmp_start_task_report()

int gmp_start_task_report ( gnutls_session_t *  session,
const char *  task_id,
char **  report_id 
)

Start a task and read the manager response.

Parameters
[in]sessionPointer to GNUTLS session.
[in]task_idID of task.
[out]report_idID of report.
Returns
0 on success, 1 on failure, -1 on error.

Definition at line 697 of file gmp.c.

699 {
700  int ret;
701  entity_t entity;
702  if (gvm_server_sendf (session, "<start_task task_id=\"%s\"/>", task_id) == -1)
703  return -1;
704 
705  /* Read the response. */
706 
707  entity = NULL;
708  ret = gmp_check_response (session, &entity);
709 
710  if (ret == 0)
711  {
712  if (report_id)
713  {
714  entity_t report_id_xml = entity_child (entity, "report_id");
715  if (report_id_xml)
716  *report_id = g_strdup (entity_text (report_id_xml));
717  else
718  {
719  free_entity (entity);
720  return -1;
721  }
722  }
723  free_entity (entity);
724  return ret;
725  }
726  else if (ret == -1)
727  return ret;
728 
729  return 1;
730 }

References entity_child(), entity_text(), free_entity(), gmp_check_response(), and gvm_server_sendf().

Here is the call graph for this function:

◆ gmp_start_task_report_c()

int gmp_start_task_report_c ( gvm_connection_t connection,
const char *  task_id,
char **  report_id 
)

Start a task and read the manager response.

Parameters
[in]connectionConnection.
[in]task_idID of task.
[out]report_idID of report.
Returns
0 on success, 1 on failure, -1 on error.

Definition at line 742 of file gmp.c.

744 {
745  entity_t entity;
746  const char *status;
747  char first;
748 
749  if (gvm_connection_sendf (connection, "<start_task task_id=\"%s\"/>", task_id)
750  == -1)
751  return -1;
752 
753  /* Read the response. */
754 
755  entity = NULL;
756  if (read_entity_c (connection, &entity))
757  return -1;
758 
759  /* Check the response. */
760 
761  status = entity_attribute (entity, "status");
762  if (status == NULL)
763  {
764  free_entity (entity);
765  return -1;
766  }
767  if (strlen (status) == 0)
768  {
769  free_entity (entity);
770  return -1;
771  }
772  first = status[0];
773  if (first == '2')
774  {
775  if (report_id)
776  {
777  entity_t report_id_xml = entity_child (entity, "report_id");
778  if (report_id_xml)
779  *report_id = g_strdup (entity_text (report_id_xml));
780  else
781  {
782  free_entity (entity);
783  return -1;
784  }
785  }
786  free_entity (entity);
787  return 0;
788  }
789  free_entity (entity);
790  return 1;
791 }

References entity_attribute(), entity_child(), entity_text(), free_entity(), gvm_connection_sendf(), and read_entity_c().

Here is the call graph for this function:

◆ gmp_stop_task()

int gmp_stop_task ( gnutls_session_t *  session,
const char *  id 
)

Stop a task and read the manager response.

Parameters
[in]sessionPointer to GNUTLS session.
[in]idID of task.
Returns
0 on success, GMP response code on failure, -1 on error.

Definition at line 906 of file gmp.c.

907 {
908  entity_t entity;
909  int ret;
910 
911  if (gvm_server_sendf (session, "<stop_task task_id=\"%s\"/>", id) == -1)
912  return -1;
913 
914  entity = NULL;
915  ret = gmp_check_response (session, &entity);
916  if (ret == 0)
917  free_entity (entity);
918  return ret;
919 }

References free_entity(), gmp_check_response(), and gvm_server_sendf().

Here is the call graph for this function:

◆ gmp_stop_task_c()

int gmp_stop_task_c ( gvm_connection_t connection,
const char *  id 
)

Stop a task and read the manager response.

Parameters
[in]connectionConnection.
[in]idID of task.
Returns
0 on success, GMP response code on failure, -1 on error.

Definition at line 930 of file gmp.c.

931 {
932  if (gvm_connection_sendf (connection, "<stop_task task_id=\"%s\"/>", id)
933  == -1)
934  return -1;
935 
936  return gmp_check_response_c (connection);
937 }

References gmp_check_response_c(), and gvm_connection_sendf().

Here is the call graph for this function:

◆ gmp_task_status()

const char* gmp_task_status ( entity_t  response)

Get the task status from a GMP GET_TASKS response.

Parameters
[in]responseGET_TASKS response.
Returns
The entity_text of the status entity if the entity is found, else NULL.

Definition at line 62 of file gmp.c.

63 {
64  entity_t task = entity_child (response, "task");
65  if (task)
66  {
67  entity_t status = entity_child (task, "status");
68  if (status)
69  return entity_text (status);
70  }
71  return NULL;
72 }

References entity_child(), and entity_text().

Here is the call graph for this function:
gmp_create_target_opts_t::ssh_credential_id
const char * ssh_credential_id
ID of SSH credential.
Definition: gmp.h:211
entity_attribute
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition: xmlutils.c:230
gmp_get_report_opts_t::host_first_result
int host_first_result
Skip over results before this result number.
Definition: gmp.h:70
gmp_create_task_opts_t::slave_id
const char * slave_id
ID of task schedule.
Definition: gmp.h:181
entity_child
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition: xmlutils.c:207
GMP_FMT_BOOL_ATTRIB
#define GMP_FMT_BOOL_ATTRIB(var, attrib)
Definition: gmp.c:44
gmp_create_lsc_credential_opts_t::privacy_algorithm
const char * privacy_algorithm
SNMP privacy algorithm.
Definition: gmp.h:263
gmp_create_lsc_credential_opts_t::private_key
const char * private_key
Private key.
Definition: gmp.h:260
gmp_get_task_opts_t::task_id
const char * task_id
ID of single task to get.
Definition: gmp.h:160
GMP_FMT_STRING_ATTRIB
#define GMP_FMT_STRING_ATTRIB(var, attrib)
Definition: gmp.c:47
gmp_get_report_opts_t::format_id
const char * format_id
ID of required report format.
Definition: gmp.h:64
gmp_create_target_opts_t::hosts
const char * hosts
Name of target.
Definition: gmp.h:218
gmp_create_lsc_credential_opts_t::auth_algorithm
const char * auth_algorithm
SNMP authentication algorithm.
Definition: gmp.h:261
gmp_authenticate_info_opts_t::username
const char * username
Password.
Definition: gmp.h:43
gmp_get_task_opts_t::actions
const char * actions
Actions argument.
Definition: gmp.h:159
gvm_connection_sendf
int gvm_connection_sendf(gvm_connection_t *connection, const char *format,...)
Format and send a string to the server.
Definition: serverutils.c:845
gmp_create_target_opts_t::exclude_hosts
const char * exclude_hosts
Hosts to exclude.
Definition: gmp.h:219
gmp_create_lsc_credential_opts_t::login
const char * login
Login.
Definition: gmp.h:258
gmp_create_task_opts_t::target_id
const char * target_id
ID of target.
Definition: gmp.h:182
entity_text
char * entity_text(entity_t entity)
Get the text an entity.
Definition: xmlutils.c:159
gmp_create_task_opts_t::max_checks
const char * max_checks
Max checks preference.
Definition: gmp.h:192
gmp_authenticate_info_opts_t::severity
char ** severity
[out] Severity class setting.
Definition: gmp.h:46
read_entity
int read_entity(gnutls_session_t *session, entity_t *entity)
Read an XML entity tree from the manager.
Definition: xmlutils.c:1149
gmp_check_response
int gmp_check_response(gnutls_session_t *session, entity_t *entity)
Read response and convert status of response to a return value.
Definition: gmp.c:83
gvm_server_sendf_xml
int gvm_server_sendf_xml(gnutls_session_t *session, const char *format,...)
Format and send an XML string to the server.
Definition: serverutils.c:908
gmp_create_target_opts_t::snmp_credential_id
const char * snmp_credential_id
ID of SNMP credential.
Definition: gmp.h:214
free_entity
void free_entity(entity_t entity)
Free an entity, recursively.
Definition: xmlutils.c:129
gmp_get_report_opts_t::report_id
const char * report_id
ID of single report to get.
Definition: gmp.h:66
gmp_create_task_opts_t::hosts_ordering
const char * hosts_ordering
Order for scanning target hosts.
Definition: gmp.h:185
xml_string_append
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition: xmlutils.c:1527
gmp_create_target_opts_t::name
const char * name
Name of target.
Definition: gmp.h:216
gmp_create_task_opts_t::in_assets
const char * in_assets
In assets preference.
Definition: gmp.h:190
read_entity_c
int read_entity_c(gvm_connection_t *connection, entity_t *entity)
Read an XML entity tree from the manager.
Definition: xmlutils.c:1177
gmp_get_system_reports_opts_t::duration
const char * duration
Duration.
Definition: gmp.h:238
gmp_get_report_opts_t::timeout
int timeout
Timeout for GMP response.
Definition: gmp.h:69
gmp_create_target_opts_t::reverse_lookup_only
int reverse_lookup_only
Scanner pref reverse_lookup_only.
Definition: gmp.h:222
gmp_get_system_reports_opts_t::slave_id
const char * slave_id
ID of the slave to get report from.
Definition: gmp.h:241
gmp_get_system_reports_opts_t::start_time
const char * start_time
Time of first data point.
Definition: gmp.h:239
gmp_create_lsc_credential_opts_t::name
const char * name
Name of LSC credential.
Definition: gmp.h:256
gmp_create_lsc_credential_opts_t::passphrase
const char * passphrase
Passphrase.
Definition: gmp.h:259
gmp_authenticate_info_opts_t::timeout
int timeout
Timeout for authentication.
Definition: gmp.h:42
gmp_create_target_opts_t::esxi_credential_id
const char * esxi_credential_id
ID of ESXi credential.
Definition: gmp.h:213
gmp_authenticate_info_opts_t::password
const char * password
Username.
Definition: gmp.h:44
try_read_entity
int try_read_entity(gnutls_session_t *session, int timeout, entity_t *entity)
Try read an XML entity tree from the manager.
Definition: xmlutils.c:1116
gmp_authenticate_info_opts_t::timezone
char ** timezone
[out] Timezone if any, else NULL.
Definition: gmp.h:47
gmp_create_lsc_credential_opts_t::community
const char * community
SNMP community.
Definition: gmp.h:257
gvm_connection_sendf_xml_quiet
int gvm_connection_sendf_xml_quiet(gvm_connection_t *connection, const char *format,...)
Format and send an XML string to the server.
Definition: serverutils.c:987
gmp_create_task_opts_t::comment
const char * comment
Comment on task.
Definition: gmp.h:184
gmp_create_task_opts_t::alterable
int alterable
Whether the task is alterable.
Definition: gmp.h:195
gmp_create_task_opts_t::alert_ids
array_t * alert_ids
Array of alert IDs.
Definition: gmp.h:177
gmp_check_response_c
int gmp_check_response_c(gvm_connection_t *connection)
Read response and convert status of response to a return value.
Definition: gmp.c:801
gmp_create_lsc_credential_opts_t::comment
const char * comment
Comment on LSC credential.
Definition: gmp.h:264
gmp_create_task_opts_t::schedule_id
const char * schedule_id
ID of task schedule.
Definition: gmp.h:180
gmp_create_task_opts_t::max_hosts
const char * max_hosts
Max hosts preference.
Definition: gmp.h:191
gmp_get_tasks_opts_t::filter
const char * filter
Filter argument.
Definition: gmp.h:140
gmp_create_task_opts_t::observer_groups
array_t * observer_groups
IDs of observer groups.
Definition: gmp.h:187
gmp_create_target_opts_t::comment
const char * comment
Comment on target.
Definition: gmp.h:217
gmp_create_task_opts_t::schedule_periods
int schedule_periods
Number of periods the schedule must run for.
Definition: gmp.h:188
gmp_get_report_opts_t::host_max_results
int host_max_results
Maximum number of results to return.
Definition: gmp.h:71
gmp_get_system_reports_opts_t::name
const char * name
Name of report.
Definition: gmp.h:237
gmp_authenticate_info_opts_t::role
char ** role
[out] Role.
Definition: gmp.h:45
gvm_server_sendf_xml_quiet
int gvm_server_sendf_xml_quiet(gnutls_session_t *session, const char *format,...)
Format and send an XML string to the server.
Definition: serverutils.c:960
entity_s
XML element.
Definition: xmlutils.h:65
gmp_create_task_opts_t::name
const char * name
Name of task.
Definition: gmp.h:183
gmp_create_task_opts_t::observers
const char * observers
Comma-separated string of observer users.
Definition: gmp.h:186
gmp_read_create_response
int gmp_read_create_response(gnutls_session_t *session, gchar **uuid)
Read response status and resource UUID.
Definition: gmp.c:848
gmp_create_task_opts_t::scanner_id
const char * scanner_id
ID of task scanner.
Definition: gmp.h:179
gmp_create_task_opts_t::config_id
const char * config_id
ID of config.
Definition: gmp.h:178
gmp_get_tasks_opts_t::timeout
int timeout
Timeout for GMP response.
Definition: gmp.h:141
gmp_authenticate_info_opts_t::pw_warning
char ** pw_warning
[out] Password warning, NULL if password is okay.
Definition: gmp.h:48
gmp_create_task_opts_t::source_iface
const char * source_iface
Source iface preference.
Definition: gmp.h:193
gmp_create_target_opts_t::alive_tests
const char * alive_tests
Alive tests.
Definition: gmp.h:220
gmp_get_system_reports_opts_t::end_time
const char * end_time
Time of last data point.
Definition: gmp.h:240
gmp_create_target_opts_t::reverse_lookup_unify
int reverse_lookup_unify
Scanner pref reverse_lookup_unify.
Definition: gmp.h:223
gvm_server_sendf
int gvm_server_sendf(gnutls_session_t *session, const char *format,...)
Format and send a string to the server.
Definition: serverutils.c:825
try_read_entity_c
int try_read_entity_c(gvm_connection_t *connection, int timeout, entity_t *entity)
Try read an XML entity tree from the manager.
Definition: xmlutils.c:1132
gmp_create_target_opts_t::port_range
const char * port_range
Port range.
Definition: gmp.h:215
gmp_create_target_opts_t::ssh_credential_port
int ssh_credential_port
Port for SSH access.
Definition: gmp.h:210
gmp_delete_opts_t::ultimate
int ultimate
Definition: gmp.h:279
gmp_create_lsc_credential_opts_t::privacy_password
const char * privacy_password
SNMP privacy password.
Definition: gmp.h:262
gmp_create_target_opts_t::smb_credential_id
const char * smb_credential_id
ID of SMB credential.
Definition: gmp.h:212