Greenbone Vulnerability Management Libraries  22.8.0
gmp.h File Reference

API for Greenbone Management Protocol communication. More...

#include "../base/array.h"
#include "../util/serverutils.h"
#include "../util/xmlutils.h"
#include <glib.h>
#include <glib/gtypes.h>
#include <gnutls/gnutls.h>
#include <stddef.h>
Include dependency graph for gmp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gmp_authenticate_info_opts_t
 Struct holding options for authentication. More...
 
struct  gmp_get_report_opts_t
 Struct holding options for gmp get_report command. More...
 
struct  gmp_get_tasks_opts_t
 Struct holding options for gmp get_tasks command. More...
 
struct  gmp_get_task_opts_t
 Struct holding options for gmp get_tasks command. More...
 
struct  gmp_create_task_opts_t
 Struct holding options for gmp create_task command. More...
 
struct  gmp_create_target_opts_t
 Struct holding options for gmp create_target command. More...
 
struct  gmp_get_system_reports_opts_t
 Struct holding options for gmp get_system_reports command. More...
 
struct  gmp_create_lsc_credential_opts_t
 Struct holding options for gmp create_lsc_credential command. More...
 
struct  gmp_delete_opts_t
 Struct holding options for various gmp delete_[...] commands. More...
 
struct  gmp_start_task_opts_t
 Struct holding options for gmp start_task command. More...
 

Functions

int gmp_read_create_response (gnutls_session_t *, gchar **)
 Read response status and resource UUID. More...
 
const char * gmp_task_status (entity_t status_response)
 Get the task status from a GMP GET_TASKS response. More...
 
int gmp_ping (gnutls_session_t *, int)
 "Ping" the manager. More...
 
int gmp_ping_c (gvm_connection_t *, int, gchar **)
 "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 *, gmp_authenticate_info_opts_t)
 Authenticate with the manager. More...
 
int gmp_authenticate_info_ext_c (gvm_connection_t *, gmp_authenticate_info_opts_t)
 Authenticate with the manager. More...
 
int gmp_create_task (gnutls_session_t *, const char *, const char *, const char *, const char *, gchar **)
 Create a task given a config and target. More...
 
int gmp_create_task_ext (gnutls_session_t *, gmp_create_task_opts_t, gchar **)
 Create a task. More...
 
int gmp_start_task_report (gnutls_session_t *, const char *, char **)
 Start a task and read the manager response. More...
 
int gmp_start_task_report_c (gvm_connection_t *, const char *, char **)
 Start a task and read the manager response. More...
 
int gmp_start_task_ext_c (gvm_connection_t *, gmp_start_task_opts_t)
 Start a task and read the manager response. More...
 
int gmp_stop_task (gnutls_session_t *, const char *)
 Stop a task and read the manager response. More...
 
int gmp_stop_task_c (gvm_connection_t *, const char *)
 Stop a task and read the manager response. More...
 
int gmp_resume_task_report (gnutls_session_t *, const char *, char **)
 Resume a task and read the manager response. More...
 
int gmp_resume_task_report_c (gvm_connection_t *, const char *, char **)
 Resume a task and read the manager response. More...
 
int gmp_get_tasks (gnutls_session_t *, const char *, int, int, entity_t *)
 Get the status of a task. More...
 
int gmp_get_tasks_ext (gnutls_session_t *, gmp_get_tasks_opts_t, entity_t *)
 Get all tasks (generic version). More...
 
int gmp_get_task_ext (gnutls_session_t *, gmp_get_task_opts_t, entity_t *)
 Get a task (generic version). More...
 
int gmp_get_targets (gnutls_session_t *, const char *, int, int, entity_t *)
 Get a target. More...
 
int gmp_get_report_ext (gnutls_session_t *, gmp_get_report_opts_t, entity_t *)
 Get a report (generic version). More...
 
int gmp_delete_port_list_ext (gnutls_session_t *, const char *, gmp_delete_opts_t)
 Delete a port list. More...
 
int gmp_delete_task (gnutls_session_t *, const char *)
 Delete a task and read the manager response. More...
 
int gmp_delete_task_ext (gnutls_session_t *, const char *, gmp_delete_opts_t)
 Delete a task and read the manager response. More...
 
int gmp_modify_task_file (gnutls_session_t *, const char *, const char *, const void *, gsize)
 Modify a file on a task. More...
 
int gmp_delete_report (gnutls_session_t *, const char *)
 Remove a report. More...
 
int gmp_create_target_ext (gnutls_session_t *, gmp_create_target_opts_t, gchar **)
 Create a target. More...
 
int gmp_delete_target_ext (gnutls_session_t *, const char *, gmp_delete_opts_t)
 Delete a target. More...
 
int gmp_delete_config_ext (gnutls_session_t *, const char *, gmp_delete_opts_t)
 Delete a config. More...
 
int gmp_create_lsc_credential_ext (gnutls_session_t *, gmp_create_lsc_credential_opts_t, gchar **)
 Create an LSC credential. More...
 
int gmp_create_lsc_credential (gnutls_session_t *, const char *, const char *, const char *, const char *, gchar **)
 Create an LSC Credential. More...
 
int gmp_create_lsc_credential_key (gnutls_session_t *, const char *, const char *, const char *, const char *, const char *, gchar **)
 Create an LSC Credential with a key. More...
 
int gmp_delete_lsc_credential_ext (gnutls_session_t *, const char *, gmp_delete_opts_t)
 Delete a LSC credential. More...
 
int gmp_get_system_reports (gnutls_session_t *, const char *, int, entity_t *)
 Get system reports. More...
 
int gmp_get_system_reports_ext (gnutls_session_t *, gmp_get_system_reports_opts_t, entity_t *)
 Get system reports. More...
 

Variables

static const gmp_authenticate_info_opts_t gmp_authenticate_info_opts_defaults
 Sensible default values for gmp_authenticate_info_opts_t. More...
 
static const gmp_get_report_opts_t gmp_get_report_opts_defaults
 Sensible default values for gmp_get_report_opts_t. More...
 
static const gmp_get_tasks_opts_t gmp_get_tasks_opts_defaults
 Sensible default values for gmp_get_tasks_opts_t. More...
 
static const gmp_get_task_opts_t gmp_get_task_opts_defaults
 Sensible default values for gmp_get_tasks_opts_t. More...
 
static const gmp_create_task_opts_t gmp_create_task_opts_defaults
 Sensible default values for gmp_get_report_opts_t. More...
 
static const gmp_create_target_opts_t gmp_create_target_opts_defaults
 Sensible default values for gmp_get_report_opts_t. More...
 
static const gmp_get_system_reports_opts_t gmp_get_system_reports_opts_defaults = {NULL, NULL, NULL, NULL, NULL, 0}
 Sensible default values for gmp_get_report_opts_t. More...
 
static const gmp_create_lsc_credential_opts_t gmp_create_lsc_credential_opts_defaults
 Sensible default values for gmp_create_lsc_credential_opts_t. More...
 
static const gmp_delete_opts_t gmp_delete_opts_defaults = {0}
 Sensible default values for gmp_get_report_opts_t. More...
 
static const gmp_delete_opts_t gmp_delete_opts_ultimate_defaults = {1}
 Default values for gmp_get_report_opts_t for ultimate deletion. More...
 
static const gmp_start_task_opts_t gmp_start_task_opts_defaults = {NULL}
 

Detailed Description

API for Greenbone Management Protocol communication.

Definition in file gmp.h.

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 317 of file gmp.c.

319 {
320  entity_t entity;
321  int ret;
322 
323  /* Send the auth request. */
324  ret = gvm_server_sendf_xml_quiet (session,
325  "<authenticate><credentials>"
326  "<username>%s</username>"
327  "<password>%s</password>"
328  "</credentials></authenticate>",
329  username ? username : "",
330  password ? password : "");
331  if (ret)
332  return ret;
333 
334  /* Read the response. */
335 
336  entity = NULL;
337  ret = gmp_check_response (session, &entity);
338  if (ret == 0)
339  {
340  free_entity (entity);
341  return ret;
342  }
343  else if (ret == -1)
344  return ret;
345  return 2;
346 }

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,out]optsIn: Struct containing the options to apply. Out: Additional 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 360 of file gmp.c.

362 {
363  entity_t entity;
364  const char *status;
365  char first;
366  int ret;
367 
368  *(opts.timezone) = NULL;
369 
370  /* Send the auth request. */
371 
372  ret = gvm_server_sendf_xml_quiet (session,
373  "<authenticate><credentials>"
374  "<username>%s</username>"
375  "<password>%s</password>"
376  "</credentials></authenticate>",
377  opts.username, opts.password);
378  if (ret)
379  return ret;
380 
381  /* Read the response. */
382 
383  entity = NULL;
384  switch (try_read_entity (session, opts.timeout, &entity))
385  {
386  case 0:
387  break;
388  case -4:
389  return 3;
390  default:
391  return -1;
392  }
393 
394  /* Check the response. */
395 
396  status = entity_attribute (entity, "status");
397  if (status == NULL)
398  {
399  free_entity (entity);
400  return -1;
401  }
402  if (strlen (status) == 0)
403  {
404  free_entity (entity);
405  return -1;
406  }
407  first = status[0];
408  if (first == '2')
409  {
410  entity_t timezone_entity, role_entity, pw_warn_entity;
411  /* Get the extra info. */
412  timezone_entity = entity_child (entity, "timezone");
413  if (timezone_entity)
414  *opts.timezone = g_strdup (entity_text (timezone_entity));
415  role_entity = entity_child (entity, "role");
416  if (role_entity)
417  *opts.role = g_strdup (entity_text (role_entity));
418  pw_warn_entity = entity_child (entity, "password_warning");
419  if (pw_warn_entity)
420  *(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
421  else
422  *(opts.pw_warning) = NULL;
423 
424  free_entity (entity);
425  return 0;
426  }
427  free_entity (entity);
428  return 2;
429 }

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::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 441 of file gmp.c.

443 {
444  entity_t entity;
445  const char *status;
446  char first;
447  int ret;
448 
449  if (opts.timezone)
450  *(opts.timezone) = NULL;
451 
452  /* Send the auth request. */
453 
454  ret = gvm_connection_sendf_xml_quiet (connection,
455  "<authenticate>"
456  "<credentials>"
457  "<username>%s</username>"
458  "<password>%s</password>"
459  "</credentials>"
460  "</authenticate>",
461  opts.username, opts.password);
462  if (ret)
463  return ret;
464 
465  /* Read the response. */
466 
467  entity = NULL;
468  switch (try_read_entity_c (connection, opts.timeout, &entity))
469  {
470  case 0:
471  break;
472  case -4:
473  return 3;
474  default:
475  return -1;
476  }
477 
478  /* Check the response. */
479 
480  status = entity_attribute (entity, "status");
481  if (status == NULL)
482  {
483  free_entity (entity);
484  return -1;
485  }
486  if (strlen (status) == 0)
487  {
488  free_entity (entity);
489  return -1;
490  }
491  first = status[0];
492  if (first == '2')
493  {
494  entity_t timezone_entity, role_entity;
495  /* Get the extra info. */
496  timezone_entity = entity_child (entity, "timezone");
497  if (timezone_entity && opts.timezone)
498  *opts.timezone = g_strdup (entity_text (timezone_entity));
499  role_entity = entity_child (entity, "role");
500  if (role_entity && opts.role)
501  *opts.role = g_strdup (entity_text (role_entity));
502  if (opts.pw_warning)
503  {
504  entity_t pw_warn_entity;
505  pw_warn_entity = entity_child (entity, "password_warning");
506  if (pw_warn_entity)
507  *(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
508  else
509  *(opts.pw_warning) = NULL;
510  }
511 
512  free_entity (entity);
513  return 0;
514  }
515  free_entity (entity);
516  return 2;
517 }

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::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_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 1720 of file gmp.c.

1723 {
1724  int ret;
1725 
1726  if (password)
1727  {
1728  if (comment)
1729  ret = gvm_server_sendf_xml_quiet (session,
1730  "<create_credential>"
1731  "<name>%s</name>"
1732  "<login>%s</login>"
1733  "<password>%s</password>"
1734  "<comment>%s</comment>"
1735  "</create_credential>",
1736  name, login, password, comment);
1737  else
1738  ret = gvm_server_sendf_xml_quiet (session,
1739  "<create_credential>"
1740  "<name>%s</name>"
1741  "<login>%s</login>"
1742  "<password>%s</password>"
1743  "</create_credential>",
1744  name, login, password);
1745  }
1746  else
1747  {
1748  if (comment)
1749  ret = gvm_server_sendf_xml (session,
1750  "<create_credential>"
1751  "<name>%s</name>"
1752  "<login>%s</login>"
1753  "<comment>%s</comment>"
1754  "</create_credential>",
1755  name, login, comment);
1756  else
1757  ret = gvm_server_sendf_xml (session,
1758  "<create_credential>"
1759  "<name>%s</name>"
1760  "<login>%s</login>"
1761  "</create_credential>",
1762  name, login);
1763  }
1764  if (ret)
1765  return -1;
1766 
1767  ret = gmp_read_create_response (session, uuid);
1768  if (ret == 201)
1769  return 0;
1770  return ret;
1771 }

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 1841 of file gmp.c.

1844 {
1845  gchar *comment, *pass, *start, *snmp_elems;
1846  int ret;
1847 
1848  /* Create the GMP request. */
1849 
1850  if (opts.login == NULL)
1851  return -1;
1852 
1853  start =
1854  g_markup_printf_escaped ("<create_credential>"
1855  "<name>%s</name>"
1856  "<login>%s</login>",
1857  opts.name ? opts.name : "unnamed", opts.login);
1858 
1859  if (opts.comment)
1860  comment = g_markup_printf_escaped ("<comment>"
1861  "%s"
1862  "</comment>",
1863  opts.comment);
1864  else
1865  comment = NULL;
1866 
1867  if (opts.private_key)
1868  pass = g_markup_printf_escaped ("<key>"
1869  "<phrase>%s</phrase>"
1870  "<private>%s</private>"
1871  "</key>",
1872  opts.passphrase ? opts.passphrase : "",
1873  opts.private_key);
1874  else
1875  {
1876  if (opts.passphrase)
1877  pass = g_markup_printf_escaped ("<password>"
1878  "%s"
1879  "</password>",
1880  opts.passphrase);
1881  else
1882  pass = NULL;
1883  }
1884 
1885  if (opts.community && opts.auth_algorithm && opts.privacy_password
1886  && opts.privacy_algorithm)
1887  snmp_elems =
1888  g_markup_printf_escaped ("<community>"
1889  "%s"
1890  "</community>"
1891  "<auth_algorithm>"
1892  "%s"
1893  "</auth_algorithm>"
1894  "<privacy>"
1895  "<password>%s</password>"
1896  "<algorithm>%s</algorithm>"
1897  "</privacy>",
1898  opts.community, opts.auth_algorithm,
1899  opts.privacy_password, opts.privacy_algorithm);
1900  else
1901  snmp_elems = NULL;
1902 
1903  /* Send the request. */
1904 
1905  ret = gvm_server_sendf (session, "%s%s%s%s</create_credential>", start,
1906  comment ? comment : "", pass ? pass : "",
1907  snmp_elems ? snmp_elems : "");
1908 
1909  g_free (start);
1910  g_free (comment);
1911  g_free (pass);
1912  if (ret)
1913  return -1;
1914 
1915  /* Read the response. */
1916 
1917  ret = gmp_read_create_response (session, id);
1918  if (ret == 201)
1919  return 0;
1920  return ret;
1921 }

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 1788 of file gmp.c.

1792 {
1793  int ret;
1794 
1795  if (comment)
1796  ret = gvm_server_sendf_xml (session,
1797  "<create_credential>"
1798  "<name>%s</name>"
1799  "<login>%s</login>"
1800  "<key>"
1801  "<phrase>%s</phrase>"
1802  "<private>%s</private>"
1803  "</key>"
1804  "<comment>%s</comment>"
1805  "</create_credential>",
1806  name, login, passphrase ? passphrase : "",
1807  private_key, comment);
1808  else
1809  ret = gvm_server_sendf_xml (session,
1810  "<create_credential>"
1811  "<name>%s</name>"
1812  "<login>%s</login>"
1813  "<key>"
1814  "<phrase>%s</phrase>"
1815  "<private>%s</private>"
1816  "</key>"
1817  "</create_credential>",
1818  name, login, passphrase ? passphrase : "",
1819  private_key);
1820 
1821  if (ret)
1822  return -1;
1823 
1824  ret = gmp_read_create_response (session, uuid);
1825  if (ret == 201)
1826  return 0;
1827  return ret;
1828 }

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 1538 of file gmp.c.

1540 {
1541  gchar *comment, *ssh, *smb, *esxi, *snmp, *port_range, *start;
1542  gchar *exclude_hosts, *alive_tests;
1543  int ret;
1544 
1545  /* Create the GMP request. */
1546 
1547  if (opts.hosts == NULL)
1548  return -1;
1549 
1550  start =
1551  g_markup_printf_escaped ("<create_target>"
1552  "<name>%s</name>"
1553  "<hosts>%s</hosts>",
1554  opts.name ? opts.name : "unnamed", opts.hosts);
1555 
1556  if (opts.exclude_hosts)
1557  exclude_hosts = g_markup_printf_escaped ("<exclude_hosts>"
1558  "%s"
1559  "</exclude_hosts>",
1560  opts.exclude_hosts);
1561  else
1562  exclude_hosts = NULL;
1563 
1564  if (opts.alive_tests)
1565  alive_tests = g_markup_printf_escaped ("<alive_tests>"
1566  "%s"
1567  "</alive_tests>",
1568  opts.alive_tests);
1569  else
1570  alive_tests = NULL;
1571 
1572  if (opts.comment)
1573  comment = g_markup_printf_escaped ("<comment>"
1574  "%s"
1575  "</comment>",
1576  opts.comment);
1577  else
1578  comment = NULL;
1579 
1580  if (opts.ssh_credential_id)
1581  {
1582  if (opts.ssh_credential_port)
1583  ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\">"
1584  "<port>%i</port>"
1585  "</ssh_lsc_credential>",
1586  opts.ssh_credential_id,
1587  opts.ssh_credential_port);
1588  else
1589  ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\"/>",
1590  opts.ssh_credential_id);
1591  }
1592  else
1593  ssh = NULL;
1594 
1595  if (opts.smb_credential_id)
1596  smb = g_markup_printf_escaped ("<smb_lsc_credential id=\"%s\"/>",
1597  opts.smb_credential_id);
1598  else
1599  smb = NULL;
1600 
1601  if (opts.esxi_credential_id)
1602  esxi = g_markup_printf_escaped ("<esxi_lsc_credential id=\"%s\"/>",
1603  opts.esxi_credential_id);
1604  else
1605  esxi = NULL;
1606 
1607  if (opts.snmp_credential_id)
1608  snmp = g_markup_printf_escaped ("<snmp_credential id=\"%s\"/>",
1609  opts.snmp_credential_id);
1610  else
1611  snmp = NULL;
1612 
1613  if (opts.port_range)
1614  port_range =
1615  g_markup_printf_escaped ("<port_range>%s</port_range>", opts.port_range);
1616  else
1617  port_range = NULL;
1618 
1619  /* Send the request. */
1620  ret = gvm_server_sendf (session,
1621  "%s%s%s%s%s%s%s%s%s"
1622  "<reverse_lookup_only>%d</reverse_lookup_only>"
1623  "<reverse_lookup_unify>%d</reverse_lookup_unify>"
1624  "</create_target>",
1625  start, exclude_hosts ? exclude_hosts : "",
1626  alive_tests ? alive_tests : "", ssh ? ssh : "",
1627  smb ? smb : "", esxi ? esxi : "", snmp ? snmp : "",
1628  port_range ? port_range : "", comment ? comment : "",
1630  g_free (start);
1631  g_free (exclude_hosts);
1632  g_free (alive_tests);
1633  g_free (ssh);
1634  g_free (smb);
1635  g_free (esxi);
1636  g_free (port_range);
1637  g_free (comment);
1638  if (ret)
1639  return -2;
1640 
1641  /* Read the response. */
1642 
1643  ret = gmp_read_create_response (session, id);
1644  if (ret == 201)
1645  return 0;
1646  return ret;
1647 }

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 713 of file gmp.c.

716 {
717  int ret;
718 
719  ret = gvm_server_sendf_xml (session,
720  "<create_task>"
721  "<config id=\"%s\"/>"
722  "<target id=\"%s\"/>"
723  "<name>%s</name>"
724  "<comment>%s</comment>"
725  "</create_task>",
726  config, target, name, comment);
727  if (ret)
728  return -1;
729 
730  /* Read the response. */
731 
732  ret = gmp_read_create_response (session, id);
733  if (ret == 201)
734  return 0;
735  return ret;
736 }

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 533 of file gmp.c.

535 {
536  /* Create the GMP request. */
537 
538  gchar *prefs, *start, *hosts_ordering, *scanner, *schedule, *slave;
539  GString *alerts, *observers;
540  int ret;
541  if ((opts.config_id == NULL) || (opts.target_id == NULL))
542  return -1;
543 
544  prefs = NULL;
545  start = g_markup_printf_escaped (
546  "<create_task>"
547  "<config id=\"%s\"/>"
548  "<target id=\"%s\"/>"
549  "<name>%s</name>"
550  "<comment>%s</comment>"
551  "<alterable>%d</alterable>",
552  opts.config_id, opts.target_id, opts.name ? opts.name : "unnamed",
553  opts.comment ? opts.comment : "", opts.alterable ? 1 : 0);
554 
555  if (opts.hosts_ordering)
556  hosts_ordering = g_strdup_printf ("<hosts_ordering>%s</hosts_ordering>",
557  opts.hosts_ordering);
558  else
559  hosts_ordering = NULL;
560 
561  if (opts.scanner_id)
562  scanner = g_strdup_printf ("<scanner id=\"%s\"/>", opts.scanner_id);
563  else
564  scanner = NULL;
565 
566  if (opts.schedule_id)
567  schedule = g_strdup_printf ("<schedule id=\"%s\"/>"
568  "<schedule_periods>%d</schedule_periods>",
569  opts.schedule_id, opts.schedule_periods);
570  else
571  schedule = NULL;
572 
573  if (opts.slave_id)
574  slave = g_strdup_printf ("<slave id=\"%s\"/>", opts.slave_id);
575  else
576  slave = NULL;
577 
578  if (opts.max_checks || opts.max_hosts || opts.in_assets || opts.source_iface)
579  {
580  gchar *in_assets, *checks, *hosts, *source_iface;
581 
582  in_assets = checks = hosts = source_iface = NULL;
583 
584  if (opts.in_assets)
585  in_assets = g_markup_printf_escaped ("<preference>"
586  "<scanner_name>"
587  "in_assets"
588  "</scanner_name>"
589  "<value>"
590  "%s"
591  "</value>"
592  "</preference>",
593  opts.in_assets);
594 
595  if (opts.max_hosts)
596  hosts = g_markup_printf_escaped ("<preference>"
597  "<scanner_name>"
598  "max_hosts"
599  "</scanner_name>"
600  "<value>"
601  "%s"
602  "</value>"
603  "</preference>",
604  opts.max_hosts);
605 
606  if (opts.max_checks)
607  checks = g_markup_printf_escaped ("<preference>"
608  "<scanner_name>"
609  "max_checks"
610  "</scanner_name>"
611  "<value>"
612  "%s"
613  "</value>"
614  "</preference>",
615  opts.max_checks);
616 
617  if (opts.source_iface)
618  source_iface = g_markup_printf_escaped ("<preference>"
619  "<scanner_name>"
620  "source_iface"
621  "</scanner_name>"
622  "<value>"
623  "%s"
624  "</value>"
625  "</preference>",
626  opts.source_iface);
627 
628  prefs =
629  g_strdup_printf ("<preferences>%s%s%s%s</preferences>",
630  in_assets ? in_assets : "", checks ? checks : "",
631  hosts ? hosts : "", source_iface ? source_iface : "");
632  g_free (in_assets);
633  g_free (checks);
634  g_free (hosts);
635  g_free (source_iface);
636  }
637 
638  if (opts.alert_ids)
639  {
640  unsigned int i;
641  alerts = g_string_new ("");
642  for (i = 0; i < opts.alert_ids->len; i++)
643  {
644  char *alert = (char *) g_ptr_array_index (opts.alert_ids, i);
645  g_string_append_printf (alerts, "<alert id=\"%s\"/>", alert);
646  }
647  }
648  else
649  alerts = g_string_new ("");
650 
651  if (opts.observers || opts.observer_groups)
652  {
653  observers = g_string_new ("<observers>");
654 
655  if (opts.observers)
656  g_string_append (observers, opts.observers);
657 
658  if (opts.observer_groups)
659  {
660  unsigned int i;
661  for (i = 0; i < opts.observer_groups->len; i++)
662  {
663  char *group =
664  (char *) g_ptr_array_index (opts.observer_groups, i);
665  g_string_append_printf (observers, "<group id=\"%s\"/>", group);
666  }
667  }
668  g_string_append (observers, "</observers>");
669  }
670  else
671  observers = g_string_new ("");
672 
673  /* Send the request. */
674  ret = gvm_server_sendf (
675  session, "%s%s%s%s%s%s%s%s</create_task>", start, prefs ? prefs : "",
676  hosts_ordering ? hosts_ordering : "", scanner ? scanner : "",
677  schedule ? schedule : "", slave ? slave : "", alerts ? alerts->str : "",
678  observers ? observers->str : "");
679  g_free (start);
680  g_free (prefs);
681  g_free (hosts_ordering);
682  g_free (scanner);
683  g_free (schedule);
684  g_free (slave);
685  g_string_free (alerts, TRUE);
686  g_string_free (observers, TRUE);
687 
688  if (ret)
689  return -1;
690 
691  /* Read the response. */
692 
693  ret = gmp_read_create_response (session, id);
694  if (ret == 201)
695  return 0;
696  return ret;
697 }

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 1688 of file gmp.c.

1690 {
1691  entity_t entity;
1692  int ret;
1693 
1694  if (gvm_server_sendf (session,
1695  "<delete_config config_id=\"%s\" ultimate=\"%d\"/>", id,
1696  opts.ultimate)
1697  == -1)
1698  return -1;
1699 
1700  entity = NULL;
1701  ret = gmp_check_response (session, &entity);
1702  if (ret == 0)
1703  free_entity (entity);
1704  return ret;
1705 }

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 1933 of file gmp.c.

1935 {
1936  entity_t entity;
1937  int ret;
1938 
1939  if (gvm_server_sendf (session,
1940  "<delete_credential credential_id=\"%s\""
1941  " ultimate=\"%d\"/>",
1942  id, opts.ultimate)
1943  == -1)
1944  return -1;
1945 
1946  entity = NULL;
1947  ret = gmp_check_response (session, &entity);
1948  if (ret == 0)
1949  free_entity (entity);
1950  return ret;
1951 }

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 1480 of file gmp.c.

1482 {
1483  entity_t entity;
1484  int ret;
1485 
1486  if (gvm_server_sendf (
1487  session, "<delete_port_list port_list_id=\"%s\" ultimate=\"%d\"/>", id,
1488  opts.ultimate)
1489  == -1)
1490  return -1;
1491 
1492  entity = NULL;
1493  ret = gmp_check_response (session, &entity);
1494  if (ret == 0)
1495  free_entity (entity);
1496  return ret;
1497 }

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 1508 of file gmp.c.

1509 {
1510  entity_t entity;
1511  int ret;
1512 
1513  if (gvm_server_sendf (session, "<delete_report report_id=\"%s\"/>", id))
1514  return -1;
1515 
1516  entity = NULL;
1517  ret = gmp_check_response (session, &entity);
1518  if (ret == 0)
1519  free_entity (entity);
1520  return ret;
1521 }

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 1659 of file gmp.c.

1661 {
1662  entity_t entity;
1663  int ret;
1664 
1665  if (gvm_server_sendf (session,
1666  "<delete_target target_id=\"%s\" ultimate=\"%d\"/>", id,
1667  opts.ultimate)
1668  == -1)
1669  return -1;
1670 
1671  entity = NULL;
1672  ret = gmp_check_response (session, &entity);
1673  if (ret == 0)
1674  free_entity (entity);
1675  return ret;
1676 }

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 1316 of file gmp.c.

1317 {
1318  entity_t entity;
1319  int ret;
1320 
1321  if (gvm_server_sendf (session, "<delete_task task_id=\"%s\"/>", id) == -1)
1322  return -1;
1323 
1324  entity = NULL;
1325  ret = gmp_check_response (session, &entity);
1326  if (ret == 0)
1327  free_entity (entity);
1328  return ret;
1329 }

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 1088 of file gmp.c.

1090 {
1091  entity_t entity;
1092  int ret;
1093 
1094  if (gvm_server_sendf (session,
1095  "<delete_task task_id=\"%s\" ultimate=\"%d\"/>", id,
1096  opts.ultimate)
1097  == -1)
1098  return -1;
1099 
1100  entity = NULL;
1101  ret = gmp_check_response (session, &entity);
1102  if (ret == 0)
1103  free_entity (entity);
1104  return ret;
1105 }

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 1382 of file gmp.c.

1384 {
1385  int ret;
1386  const char *status_code;
1387 
1388  if (response == NULL)
1389  return -1;
1390 
1391  if (gvm_server_sendf (
1392  session,
1393  "<get_reports"
1394  " details=\"1\""
1395  " report_id=\"%s\""
1396  " format_id=\"%s\""
1397  " host_first_result=\"%i\""
1398  " host_max_results=\"%i\""
1399  "%s%s%s"
1400  "%s%s%s"
1401  "%s%s%s"
1402  "%s%s%s"
1403  "%s%s%s"
1404  "%s%s%s"
1405  "%s%s%s"
1406  "%s%s%s"
1407  "%s%s%s"
1408  "%s%s%s"
1409  "%s%s%s"
1410  "%s%s%s"
1411  "%s%s%s"
1412  "%s%s%s"
1413  "%s%s%s%s%s%s%s/>",
1414  opts.report_id, opts.format_id, opts.host_first_result,
1415  opts.host_max_results, GMP_FMT_STRING_ATTRIB (opts, type),
1416  GMP_FMT_STRING_ATTRIB (opts, filter),
1417  GMP_FMT_STRING_ATTRIB (opts, filt_id),
1418  GMP_FMT_STRING_ATTRIB (opts, host), GMP_FMT_STRING_ATTRIB (opts, pos),
1419  GMP_FMT_STRING_ATTRIB (opts, timezone),
1420  GMP_FMT_STRING_ATTRIB (opts, alert_id),
1421  GMP_FMT_STRING_ATTRIB (opts, delta_report_id),
1422  GMP_FMT_STRING_ATTRIB (opts, delta_states),
1423  GMP_FMT_STRING_ATTRIB (opts, host_levels),
1424  GMP_FMT_STRING_ATTRIB (opts, search_phrase),
1425  GMP_FMT_STRING_ATTRIB (opts, host_search_phrase),
1426  GMP_FMT_STRING_ATTRIB (opts, min_cvss_base),
1427  GMP_FMT_STRING_ATTRIB (opts, min_qod),
1428  GMP_FMT_BOOL_ATTRIB (opts, notes),
1429  GMP_FMT_BOOL_ATTRIB (opts, notes_details),
1430  GMP_FMT_BOOL_ATTRIB (opts, overrides),
1431  GMP_FMT_BOOL_ATTRIB (opts, override_details),
1432  GMP_FMT_BOOL_ATTRIB (opts, apply_overrides),
1433  GMP_FMT_BOOL_ATTRIB (opts, result_hosts_only),
1434  GMP_FMT_BOOL_ATTRIB (opts, ignore_pagination)))
1435  return -1;
1436 
1437  *response = NULL;
1438  switch (try_read_entity (session, opts.timeout, response))
1439  {
1440  case 0:
1441  break;
1442  case -4:
1443  return 2;
1444  default:
1445  return -1;
1446  }
1447 
1448  /* Check the response. */
1449 
1450  status_code = entity_attribute (*response, "status");
1451  if (status_code == NULL)
1452  {
1453  free_entity (*response);
1454  return -1;
1455  }
1456  if (strlen (status_code) == 0)
1457  {
1458  free_entity (*response);
1459  return -1;
1460  }
1461  if (status_code[0] == '2')
1462  return 0;
1463  ret = (int) strtol (status_code, NULL, 10);
1464  free_entity (*response);
1465  if (errno == ERANGE)
1466  return -1;
1467  return ret;
1468 }

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 1965 of file gmp.c.

1967 {
1968  if (name)
1969  {
1970  if (gvm_server_sendf (session,
1971  "<get_system_reports name=\"%s\" brief=\"%i\"/>",
1972  name, brief)
1973  == -1)
1974  return -1;
1975  }
1976  else if (gvm_server_sendf (session, "<get_system_reports brief=\"%i\"/>",
1977  brief)
1978  == -1)
1979  return -1;
1980 
1981  /* Read and check the response. */
1982  return gmp_check_response (session, reports);
1983 }

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 1996 of file gmp.c.

1999 {
2000  GString *request;
2001 
2002  request = g_string_new ("<get_system_reports");
2003 
2004  if (opts.slave_id)
2005  xml_string_append (request, " slave_id=\"%s\"", opts.slave_id);
2006 
2007  if (opts.name)
2008  xml_string_append (request, " name=\"%s\"", opts.name);
2009 
2010  if (opts.duration)
2011  xml_string_append (request, " duration=\"%s\"", opts.duration);
2012 
2013  if (opts.start_time)
2014  xml_string_append (request, " start_time=\"%s\"", opts.start_time);
2015 
2016  if (opts.end_time)
2017  xml_string_append (request, " end_time=\"%s\"", opts.end_time);
2018 
2019  g_string_append (request, "/>");
2020 
2021  /* Create the GMP request. */
2022 
2023  if (gvm_server_sendf (session, "%s", request->str) == -1)
2024  {
2025  g_string_free (request, 1);
2026  return -1;
2027  }
2028  g_string_free (request, 1);
2029 
2030  /* Read and check the response. */
2031  return gmp_check_response (session, reports);
2032 }

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 1344 of file gmp.c.

1346 {
1347  (void) include_rcfile;
1348  if (id == NULL)
1349  {
1350  if (gvm_server_sendf (session, "<get_targets tasks=\"%i\"/>", tasks)
1351  == -1)
1352  return -1;
1353  }
1354  else
1355  {
1356  if (gvm_server_sendf (session,
1357  "<get_targets"
1358  " target_id=\"%s\""
1359  " tasks=\"%i\"/>",
1360  id, tasks)
1361  == -1)
1362  return -1;
1363  }
1364 
1365  /* Read the response. */
1366  return gmp_check_response (session, target);
1367 }

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 1155 of file gmp.c.

1157 {
1158  if ((response == NULL) || (opts.task_id == NULL))
1159  return -1;
1160 
1161  if (opts.actions)
1162  {
1163  if (gvm_server_sendf (session,
1164  "<get_tasks"
1165  " task_id=\"%s\""
1166  " actions=\"%s\""
1167  "%s/>",
1168  opts.task_id, opts.actions,
1169  GMP_FMT_BOOL_ATTRIB (opts, details)))
1170  return -1;
1171  }
1172  else if (gvm_server_sendf (session,
1173  "<get_tasks"
1174  " task_id=\"%s\""
1175  "%s/>",
1176  opts.task_id, GMP_FMT_BOOL_ATTRIB (opts, details)))
1177  return -1;
1178 
1179  return gmp_check_response (session, response);
1180 }

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 1120 of file gmp.c.

1122 {
1123  (void) include_rcfile;
1124  if (id == NULL)
1125  {
1126  if (gvm_server_sendf (session, "<get_tasks details=\"%i\"/>", details)
1127  == -1)
1128  return -1;
1129  }
1130  else
1131  {
1132  if (gvm_server_sendf (session,
1133  "<get_tasks"
1134  " task_id=\"%s\""
1135  " details=\"%i\"/>",
1136  id, details)
1137  == -1)
1138  return -1;
1139  }
1140 
1141  /* Read the response. */
1142  return gmp_check_response (session, status);
1143 }

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 1192 of file gmp.c.

1194 {
1195  int ret;
1196  const char *status_code;
1197  gchar *cmd;
1198 
1199  if (response == NULL)
1200  return -1;
1201 
1202  cmd = g_markup_printf_escaped ("<get_tasks"
1203  " filter=\"%s\"",
1204  opts.filter);
1205 
1206  if (gvm_server_sendf (session, "%s%s/>", cmd,
1207  GMP_FMT_BOOL_ATTRIB (opts, details)))
1208  {
1209  g_free (cmd);
1210  return -1;
1211  }
1212  g_free (cmd);
1213 
1214  *response = NULL;
1215  switch (try_read_entity (session, opts.timeout, response))
1216  {
1217  case 0:
1218  break;
1219  case -4:
1220  return 2;
1221  default:
1222  return -1;
1223  }
1224 
1225  /* Check the response. */
1226 
1227  status_code = entity_attribute (*response, "status");
1228  if (status_code == NULL)
1229  {
1230  free_entity (*response);
1231  return -1;
1232  }
1233  if (strlen (status_code) == 0)
1234  {
1235  free_entity (*response);
1236  return -1;
1237  }
1238  if (status_code[0] == '2')
1239  return 0;
1240  ret = (int) strtol (status_code, NULL, 10);
1241  free_entity (*response);
1242  if (errno == ERANGE)
1243  return -1;
1244  return ret;
1245 }

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 1259 of file gmp.c.

1261 {
1262  entity_t entity;
1263  int ret;
1264 
1265  if (name == NULL)
1266  return -1;
1267 
1268  if (gvm_server_sendf (session, "<modify_task task_id=\"%s\">", id))
1269  return -1;
1270 
1271  if (content)
1272  {
1273  if (gvm_server_sendf (session, "<file name=\"%s\" action=\"update\">",
1274  name))
1275  return -1;
1276 
1277  if (content_len)
1278  {
1279  gchar *base64_content =
1280  g_base64_encode ((guchar *) content, content_len);
1281  ret = gvm_server_sendf (session, "%s", base64_content);
1282  g_free (base64_content);
1283  if (ret)
1284  return -1;
1285  }
1286 
1287  if (gvm_server_sendf (session, "</file>"))
1288  return -1;
1289  }
1290  else
1291  {
1292  if (gvm_server_sendf (session, "<file name=\"%s\" action=\"remove\" />",
1293  name))
1294  return -1;
1295  }
1296 
1297  if (gvm_server_sendf (session, "</modify_task>"))
1298  return -1;
1299 
1300  entity = NULL;
1301  ret = gmp_check_response (session, &entity);
1302  if (ret == 0)
1303  free_entity (entity);
1304  return ret;
1305 }

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 186 of file gmp.c.

187 {
188  entity_t entity;
189  const char *status;
190  char first;
191  int ret;
192 
193  /* Send a GET_VERSION request. */
194 
195  ret = gvm_server_sendf (session, "<get_version/>");
196  if (ret)
197  return ret;
198 
199  /* Read the response, with a timeout. */
200 
201  entity = NULL;
202  switch (try_read_entity (session, timeout, &entity))
203  {
204  case 0:
205  break;
206  case -4:
207  return 2;
208  default:
209  return -1;
210  }
211 
212  /* Check the response. */
213 
214  status = entity_attribute (entity, "status");
215  if (status == NULL)
216  {
217  free_entity (entity);
218  return -1;
219  }
220  if (strlen (status) == 0)
221  {
222  free_entity (entity);
223  return -1;
224  }
225  first = status[0];
226  free_entity (entity);
227  if (first == '2')
228  return 0;
229  return -1;
230 }

References entity_attribute(), free_entity(), gvm_server_sendf(), 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 245 of file gmp.c.

246 {
247  entity_t entity;
248  const char *status;
249  int ret;
250 
251  if (version && *version)
252  *version = NULL;
253 
254  /* Send a GET_VERSION request. */
255 
256  ret = gvm_connection_sendf (connection, "<get_version/>");
257  if (ret)
258  return ret;
259 
260  /* Read the response, with a timeout. */
261 
262  entity = NULL;
263  switch (try_read_entity_c (connection, timeout, &entity))
264  {
265  case 0:
266  break;
267  case -4:
268  return 2;
269  default:
270  return -1;
271  }
272 
273  /* Check the response. */
274 
275  status = entity_attribute (entity, "status");
276  if (status == NULL)
277  {
278  free_entity (entity);
279  return -1;
280  }
281  if (strlen (status) == 0)
282  {
283  free_entity (entity);
284  return -1;
285  }
286  if (status[0] == '2')
287  {
288  if (version)
289  {
290  entity_t omp_version;
291  omp_version = entity_child (entity, "version");
292  if (omp_version == NULL)
293  {
294  free_entity (entity);
295  return -1;
296  }
297  *version = strdup (entity_text (omp_version));
298  }
299  free_entity (entity);
300  return 0;
301  }
302  free_entity (entity);
303  return -1;
304 }

References entity_attribute(), entity_child(), entity_text(), free_entity(), gvm_connection_sendf(), 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 884 of file gmp.c.

885 {
886  int ret;
887  const char *status;
888  entity_t entity;
889 
890  /* Read the response. */
891 
892  entity = NULL;
893  if (read_entity (session, &entity))
894  return -1;
895 
896  /* Parse the response. */
897 
898  status = entity_attribute (entity, "status");
899  if (status == NULL)
900  {
901  free_entity (entity);
902  return -1;
903  }
904  if (strlen (status) == 0)
905  {
906  free_entity (entity);
907  return -1;
908  }
909 
910  if (uuid)
911  {
912  const char *id;
913 
914  id = entity_attribute (entity, "id");
915  if (id == NULL)
916  {
917  free_entity (entity);
918  return -1;
919  }
920  if (strlen (id) == 0)
921  {
922  free_entity (entity);
923  return -1;
924  }
925  *uuid = g_strdup (id);
926  }
927 
928  ret = atoi (status);
929  free_entity (entity);
930  return ret;
931 }

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 985 of file gmp.c.

987 {
988  int ret;
989  entity_t entity;
990  if (gvm_server_sendf (session, "<resume_task task_id=\"%s\"/>", task_id)
991  == -1)
992  return -1;
993 
994  /* Read the response. */
995 
996  entity = NULL;
997  ret = gmp_check_response (session, &entity);
998 
999  if (ret == 0)
1000  {
1001  if (report_id)
1002  {
1003  entity_t report_id_xml = entity_child (entity, "report_id");
1004  if (report_id_xml)
1005  *report_id = g_strdup (entity_text (report_id_xml));
1006  else
1007  {
1008  free_entity (entity);
1009  return -1;
1010  }
1011  }
1012  free_entity (entity);
1013  return 0;
1014  }
1015  else if (ret == -1)
1016  return ret;
1017  return 1;
1018 }

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 1030 of file gmp.c.

1032 {
1033  if (gvm_connection_sendf (connection, "<resume_task task_id=\"%s\"/>",
1034  task_id)
1035  == -1)
1036  return -1;
1037 
1038  /* Read the response. */
1039 
1040  entity_t entity = NULL;
1041  if (read_entity_c (connection, &entity))
1042  return -1;
1043 
1044  /* Check the response. */
1045 
1046  const char *status = entity_attribute (entity, "status");
1047  if (status == NULL)
1048  {
1049  free_entity (entity);
1050  return -1;
1051  }
1052  if (strlen (status) == 0)
1053  {
1054  free_entity (entity);
1055  return -1;
1056  }
1057  char first = status[0];
1058  if (first == '2')
1059  {
1060  if (report_id)
1061  {
1062  entity_t report_id_xml = entity_child (entity, "report_id");
1063  if (report_id_xml)
1064  *report_id = g_strdup (entity_text (report_id_xml));
1065  else
1066  {
1067  free_entity (entity);
1068  return -1;
1069  }
1070  }
1071  free_entity (entity);
1072  return 0;
1073  }
1074  free_entity (entity);
1075  return 1;
1076 }

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_ext_c()

int gmp_start_task_ext_c ( gvm_connection_t connection,
gmp_start_task_opts_t  opts 
)

Start a task and read the manager response.

Parameters
[in]connectionConnection.
[in]optsOptions to apply.
Returns
0 on success, 99 permission denied, -1 or GMP response code on error.

Definition at line 853 of file gmp.c.

854 {
855  int ret;
856 
857  /* Check args. */
858 
859  if (opts.task_id == NULL)
860  return -1;
861 
862  /* Send request. */
863 
864  ret = gvm_connection_sendf (connection, "<start_task task_id=\"%s\"/>",
865  opts.task_id);
866  if (ret)
867  return -1;
868 
869  /* Read response. */
870 
871  return check_response_c (connection, 1);
872 }

References check_response_c(), gvm_connection_sendf(), and gmp_start_task_opts_t::task_id.

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 748 of file gmp.c.

750 {
751  int ret;
752  entity_t entity;
753  if (gvm_server_sendf (session, "<start_task task_id=\"%s\"/>", task_id) == -1)
754  return -1;
755 
756  /* Read the response. */
757 
758  entity = NULL;
759  ret = gmp_check_response (session, &entity);
760 
761  if (ret == 0)
762  {
763  if (report_id)
764  {
765  entity_t report_id_xml = entity_child (entity, "report_id");
766  if (report_id_xml)
767  *report_id = g_strdup (entity_text (report_id_xml));
768  else
769  {
770  free_entity (entity);
771  return -1;
772  }
773  }
774  free_entity (entity);
775  return ret;
776  }
777  else if (ret == -1)
778  return ret;
779 
780  return 1;
781 }

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 793 of file gmp.c.

795 {
796  entity_t entity;
797  const char *status;
798  char first;
799 
800  if (gvm_connection_sendf (connection, "<start_task task_id=\"%s\"/>", task_id)
801  == -1)
802  return -1;
803 
804  /* Read the response. */
805 
806  entity = NULL;
807  if (read_entity_c (connection, &entity))
808  return -1;
809 
810  /* Check the response. */
811 
812  status = entity_attribute (entity, "status");
813  if (status == NULL)
814  {
815  free_entity (entity);
816  return -1;
817  }
818  if (strlen (status) == 0)
819  {
820  free_entity (entity);
821  return -1;
822  }
823  first = status[0];
824  if (first == '2')
825  {
826  if (report_id)
827  {
828  entity_t report_id_xml = entity_child (entity, "report_id");
829  if (report_id_xml)
830  *report_id = g_strdup (entity_text (report_id_xml));
831  else
832  {
833  free_entity (entity);
834  return -1;
835  }
836  }
837  free_entity (entity);
838  return 0;
839  }
840  free_entity (entity);
841  return 1;
842 }

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 942 of file gmp.c.

943 {
944  entity_t entity;
945  int ret;
946 
947  if (gvm_server_sendf (session, "<stop_task task_id=\"%s\"/>", id) == -1)
948  return -1;
949 
950  entity = NULL;
951  ret = gmp_check_response (session, &entity);
952  if (ret == 0)
953  free_entity (entity);
954  return ret;
955 }

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 966 of file gmp.c.

967 {
968  if (gvm_connection_sendf (connection, "<stop_task task_id=\"%s\"/>", id)
969  == -1)
970  return -1;
971 
972  return gmp_check_response_c (connection);
973 }

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 48 of file gmp.c.

49 {
50  entity_t task = entity_child (response, "task");
51  if (task)
52  {
53  entity_t status = entity_child (task, "status");
54  if (status)
55  return entity_text (status);
56  }
57  return NULL;
58 }

References entity_child(), and entity_text().

Here is the call graph for this function:

Variable Documentation

◆ gmp_authenticate_info_opts_defaults

const gmp_authenticate_info_opts_t gmp_authenticate_info_opts_defaults
static
Initial value:
=
{0, NULL, NULL, NULL, NULL, NULL}

Sensible default values for gmp_authenticate_info_opts_t.

Definition at line 39 of file gmp.h.

◆ gmp_create_lsc_credential_opts_defaults

const gmp_create_lsc_credential_opts_t gmp_create_lsc_credential_opts_defaults
static
Initial value:
= {NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL}

Sensible default values for gmp_create_lsc_credential_opts_t.

Definition at line 256 of file gmp.h.

◆ gmp_create_target_opts_defaults

const gmp_create_target_opts_t gmp_create_target_opts_defaults
static
Initial value:
= {
0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0}

Sensible default values for gmp_get_report_opts_t.

Definition at line 214 of file gmp.h.

◆ gmp_create_task_opts_defaults

const gmp_create_task_opts_t gmp_create_task_opts_defaults
static
Initial value:
= {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, 0, NULL, NULL, NULL, NULL, 0}

Sensible default values for gmp_get_report_opts_t.

Definition at line 186 of file gmp.h.

◆ gmp_delete_opts_defaults

const gmp_delete_opts_t gmp_delete_opts_defaults = {0}
static

Sensible default values for gmp_get_report_opts_t.

Definition at line 270 of file gmp.h.

◆ gmp_delete_opts_ultimate_defaults

const gmp_delete_opts_t gmp_delete_opts_ultimate_defaults = {1}
static

Default values for gmp_get_report_opts_t for ultimate deletion.

Definition at line 275 of file gmp.h.

◆ gmp_get_report_opts_defaults

const gmp_get_report_opts_t gmp_get_report_opts_defaults
static

Sensible default values for gmp_get_report_opts_t.

Definition at line 86 of file gmp.h.

◆ gmp_get_system_reports_opts_defaults

const gmp_get_system_reports_opts_t gmp_get_system_reports_opts_defaults = {NULL, NULL, NULL, NULL, NULL, 0}
static

Sensible default values for gmp_get_report_opts_t.

Definition at line 234 of file gmp.h.

◆ gmp_get_task_opts_defaults

const gmp_get_task_opts_t gmp_get_task_opts_defaults
static
Initial value:
= {NULL, NULL, 0,
0}

Sensible default values for gmp_get_tasks_opts_t.

Definition at line 154 of file gmp.h.

◆ gmp_get_tasks_opts_defaults

const gmp_get_tasks_opts_t gmp_get_tasks_opts_defaults
static
Initial value:
= {"", 0, NULL, 0,
0}

Sensible default values for gmp_get_tasks_opts_t.

Definition at line 136 of file gmp.h.

◆ gmp_start_task_opts_defaults

const gmp_start_task_opts_t gmp_start_task_opts_defaults = {NULL}
static

Definition at line 320 of file gmp.h.

gmp_create_target_opts_t::ssh_credential_id
const char * ssh_credential_id
ID of SSH credential.
Definition: gmp.h:196
entity_attribute
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition: xmlutils.c:216
gmp_get_report_opts_t::host_first_result
int host_first_result
Skip over results before this result number.
Definition: gmp.h:55
gmp_create_task_opts_t::slave_id
const char * slave_id
ID of task schedule.
Definition: gmp.h:166
entity_child
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition: xmlutils.c:193
GMP_FMT_BOOL_ATTRIB
#define GMP_FMT_BOOL_ATTRIB(var, attrib)
Definition: gmp.c:30
gmp_create_lsc_credential_opts_t::privacy_algorithm
const char * privacy_algorithm
SNMP privacy algorithm.
Definition: gmp.h:248
gmp_create_lsc_credential_opts_t::private_key
const char * private_key
Private key.
Definition: gmp.h:245
gmp_get_task_opts_t::task_id
const char * task_id
ID of single task to get.
Definition: gmp.h:145
GMP_FMT_STRING_ATTRIB
#define GMP_FMT_STRING_ATTRIB(var, attrib)
Definition: gmp.c:33
gmp_get_report_opts_t::format_id
const char * format_id
ID of required report format.
Definition: gmp.h:49
gmp_create_target_opts_t::hosts
const char * hosts
Name of target.
Definition: gmp.h:203
gmp_create_lsc_credential_opts_t::auth_algorithm
const char * auth_algorithm
SNMP authentication algorithm.
Definition: gmp.h:246
gmp_start_task_opts_t::task_id
const char * task_id
ID of task.
Definition: gmp.h:317
gmp_authenticate_info_opts_t::username
const char * username
Password.
Definition: gmp.h:29
gmp_get_task_opts_t::actions
const char * actions
Actions argument.
Definition: gmp.h:144
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:824
gmp_create_target_opts_t::exclude_hosts
const char * exclude_hosts
Hosts to exclude.
Definition: gmp.h:204
gmp_create_lsc_credential_opts_t::login
const char * login
Login.
Definition: gmp.h:243
gmp_create_task_opts_t::target_id
const char * target_id
ID of target.
Definition: gmp.h:167
gmp_check_response
static 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:69
entity_text
char * entity_text(entity_t entity)
Get the text an entity.
Definition: xmlutils.c:145
gmp_create_task_opts_t::max_checks
const char * max_checks
Max checks preference.
Definition: gmp.h:177
gmp_check_response_c
static int gmp_check_response_c(gvm_connection_t *connection)
Read response and convert status of response to a return value.
Definition: gmp.c:170
read_entity
int read_entity(gnutls_session_t *session, entity_t *entity)
Read an XML entity tree from the manager.
Definition: xmlutils.c:1469
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:887
gmp_create_target_opts_t::snmp_credential_id
const char * snmp_credential_id
ID of SNMP credential.
Definition: gmp.h:199
free_entity
void free_entity(entity_t entity)
Free an entity, recursively.
Definition: xmlutils.c:115
gmp_get_report_opts_t::report_id
const char * report_id
ID of single report to get.
Definition: gmp.h:51
gmp_create_task_opts_t::hosts_ordering
const char * hosts_ordering
Order for scanning target hosts.
Definition: gmp.h:170
xml_string_append
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition: xmlutils.c:1845
gmp_create_target_opts_t::name
const char * name
Name of target.
Definition: gmp.h:201
gmp_create_task_opts_t::in_assets
const char * in_assets
In assets preference.
Definition: gmp.h:175
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:1497
gmp_get_system_reports_opts_t::duration
const char * duration
Duration.
Definition: gmp.h:223
gmp_get_report_opts_t::timeout
int timeout
Timeout for GMP response.
Definition: gmp.h:54
gmp_create_target_opts_t::reverse_lookup_only
int reverse_lookup_only
Scanner pref reverse_lookup_only.
Definition: gmp.h:207
gmp_get_system_reports_opts_t::slave_id
const char * slave_id
ID of the slave to get report from.
Definition: gmp.h:226
gmp_get_system_reports_opts_t::start_time
const char * start_time
Time of first data point.
Definition: gmp.h:224
gmp_create_lsc_credential_opts_t::name
const char * name
Name of LSC credential.
Definition: gmp.h:241
gmp_create_lsc_credential_opts_t::passphrase
const char * passphrase
Passphrase.
Definition: gmp.h:244
gmp_authenticate_info_opts_t::timeout
int timeout
Timeout for authentication.
Definition: gmp.h:28
gmp_create_target_opts_t::esxi_credential_id
const char * esxi_credential_id
ID of ESXi credential.
Definition: gmp.h:198
gmp_authenticate_info_opts_t::password
const char * password
Username.
Definition: gmp.h:30
check_response_c
static int check_response_c(gvm_connection_t *connection, int convert_99)
Read response and convert status of response to a return value.
Definition: gmp.c:115
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:1436
gmp_authenticate_info_opts_t::timezone
char ** timezone
[out] Timezone if any, else NULL.
Definition: gmp.h:32
gmp_create_lsc_credential_opts_t::community
const char * community
SNMP community.
Definition: gmp.h:242
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:966
gmp_create_task_opts_t::comment
const char * comment
Comment on task.
Definition: gmp.h:169
gmp_create_task_opts_t::alterable
int alterable
Whether the task is alterable.
Definition: gmp.h:180
gmp_create_task_opts_t::alert_ids
array_t * alert_ids
Array of alert IDs.
Definition: gmp.h:162
gmp_create_lsc_credential_opts_t::comment
const char * comment
Comment on LSC credential.
Definition: gmp.h:249
gmp_create_task_opts_t::schedule_id
const char * schedule_id
ID of task schedule.
Definition: gmp.h:165
gmp_create_task_opts_t::max_hosts
const char * max_hosts
Max hosts preference.
Definition: gmp.h:176
gmp_get_tasks_opts_t::filter
const char * filter
Filter argument.
Definition: gmp.h:125
gmp_create_task_opts_t::observer_groups
array_t * observer_groups
IDs of observer groups.
Definition: gmp.h:172
gmp_create_target_opts_t::comment
const char * comment
Comment on target.
Definition: gmp.h:202
gmp_create_task_opts_t::schedule_periods
int schedule_periods
Number of periods the schedule must run for.
Definition: gmp.h:173
gmp_get_report_opts_t::host_max_results
int host_max_results
Maximum number of results to return.
Definition: gmp.h:56
gmp_get_system_reports_opts_t::name
const char * name
Name of report.
Definition: gmp.h:222
gmp_authenticate_info_opts_t::role
char ** role
[out] Role.
Definition: gmp.h:31
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:939
entity_s
XML element.
Definition: xmlutils.h:52
gmp_create_task_opts_t::name
const char * name
Name of task.
Definition: gmp.h:168
gmp_create_task_opts_t::observers
const char * observers
Comma-separated string of observer users.
Definition: gmp.h:171
gmp_read_create_response
int gmp_read_create_response(gnutls_session_t *session, gchar **uuid)
Read response status and resource UUID.
Definition: gmp.c:884
gmp_create_task_opts_t::scanner_id
const char * scanner_id
ID of task scanner.
Definition: gmp.h:164
gmp_create_task_opts_t::config_id
const char * config_id
ID of config.
Definition: gmp.h:163
gmp_get_tasks_opts_t::timeout
int timeout
Timeout for GMP response.
Definition: gmp.h:126
gmp_authenticate_info_opts_t::pw_warning
char ** pw_warning
[out] Password warning, NULL if password is okay.
Definition: gmp.h:33
gmp_create_task_opts_t::source_iface
const char * source_iface
Source iface preference.
Definition: gmp.h:178
gmp_create_target_opts_t::alive_tests
const char * alive_tests
Alive tests.
Definition: gmp.h:205
gmp_get_system_reports_opts_t::end_time
const char * end_time
Time of last data point.
Definition: gmp.h:225
gmp_create_target_opts_t::reverse_lookup_unify
int reverse_lookup_unify
Scanner pref reverse_lookup_unify.
Definition: gmp.h:208
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:804
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:1452
gmp_create_target_opts_t::port_range
const char * port_range
Port range.
Definition: gmp.h:200
gmp_create_target_opts_t::ssh_credential_port
int ssh_credential_port
Port for SSH access.
Definition: gmp.h:195
gmp_delete_opts_t::ultimate
int ultimate
Definition: gmp.h:264
gmp_create_lsc_credential_opts_t::privacy_password
const char * privacy_password
SNMP privacy password.
Definition: gmp.h:247
gmp_create_target_opts_t::smb_credential_id
const char * smb_credential_id
ID of SMB credential.
Definition: gmp.h:197