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

Variables

static const gmp_authenticate_info_opts_t gmp_authenticate_info_opts_defaults
 Sensible default values for gmp_authenticate_info_opts_t.
static const gmp_get_report_opts_t gmp_get_report_opts_defaults
 Sensible default values for gmp_get_report_opts_t.
static const gmp_get_tasks_opts_t gmp_get_tasks_opts_defaults
 Sensible default values for gmp_get_tasks_opts_t.
static const gmp_get_task_opts_t gmp_get_task_opts_defaults
 Sensible default values for gmp_get_tasks_opts_t.
static const gmp_create_task_opts_t gmp_create_task_opts_defaults
 Sensible default values for gmp_get_report_opts_t.
static const gmp_create_target_opts_t gmp_create_target_opts_defaults
 Sensible default values for gmp_get_report_opts_t.
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.
static const gmp_create_lsc_credential_opts_t gmp_create_lsc_credential_opts_defaults
 Sensible default values for gmp_create_lsc_credential_opts_t.
static const gmp_delete_opts_t gmp_delete_opts_defaults = {0}
 Sensible default values for gmp_get_report_opts_t.
static const gmp_delete_opts_t gmp_delete_opts_ultimate_defaults = {1}
 Default values for gmp_get_report_opts_t for ultimate deletion.
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 321 of file gmp.c.

323{
324 entity_t entity;
325 int ret;
326
327 /* Send the auth request. */
328 ret = gvm_server_sendf_xml_quiet (session,
329 "<authenticate><credentials>"
330 "<username>%s</username>"
331 "<password>%s</password>"
332 "</credentials></authenticate>",
333 username ? username : "",
334 password ? password : "");
335 if (ret)
336 return ret;
337
338 /* Read the response. */
339
340 entity = NULL;
341 ret = gmp_check_response (session, &entity);
342 if (ret == 0)
343 {
344 free_entity (entity);
345 return ret;
346 }
347 else if (ret == -1)
348 return ret;
349 return 2;
350}
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:70
int gvm_server_sendf_xml_quiet(gnutls_session_t *session, const char *format,...)
Format and send an XML string to the server.
void free_entity(entity_t entity)
Free an entity, recursively.
Definition xmlutils.c:115
struct entity_s * entity_t
Definition xmlutils.h:58

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

366{
367 entity_t entity;
368 const char *status;
369 char first;
370 int ret;
371
372 *(opts.timezone) = NULL;
373
374 /* Send the auth request. */
375
376 ret = gvm_server_sendf_xml_quiet (session,
377 "<authenticate><credentials>"
378 "<username>%s</username>"
379 "<password>%s</password>"
380 "</credentials></authenticate>",
381 opts.username, opts.password);
382 if (ret)
383 return ret;
384
385 /* Read the response. */
386
387 entity = NULL;
388 switch (try_read_entity (session, opts.timeout, &entity))
389 {
390 case 0:
391 break;
392 case -4:
393 return 3;
394 default:
395 return -1;
396 }
397
398 /* Check the response. */
399
400 status = entity_attribute (entity, "status");
401 if (status == NULL)
402 {
403 free_entity (entity);
404 return -1;
405 }
406 if (strlen (status) == 0)
407 {
408 free_entity (entity);
409 return -1;
410 }
411 first = status[0];
412 if (first == '2')
413 {
414 entity_t timezone_entity, role_entity, pw_warn_entity;
415 /* Get the extra info. */
416 timezone_entity = entity_child (entity, "timezone");
417 if (timezone_entity)
418 *opts.timezone = g_strdup (entity_text (timezone_entity));
419 role_entity = entity_child (entity, "role");
420 if (role_entity)
421 *opts.role = g_strdup (entity_text (role_entity));
422 pw_warn_entity = entity_child (entity, "password_warning");
423 if (pw_warn_entity)
424 *(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
425 else
426 *(opts.pw_warning) = NULL;
427
428 free_entity (entity);
429 return 0;
430 }
431 free_entity (entity);
432 return 2;
433}
const char * password
Username.
Definition gmp.h:30
int timeout
Timeout for authentication.
Definition gmp.h:28
char ** pw_warning
[out] Password warning, NULL if password is okay.
Definition gmp.h:33
char ** timezone
[out] Timezone if any, else NULL.
Definition gmp.h:32
const char * username
Password.
Definition gmp.h:29
char ** role
[out] Role.
Definition gmp.h:31
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition xmlutils.c:216
char * entity_text(entity_t entity)
Get the text an entity.
Definition xmlutils.c:145
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
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition xmlutils.c:193

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

447{
448 entity_t entity;
449 const char *status;
450 char first;
451 int ret;
452
453 if (opts.role)
454 *opts.role = NULL;
455 if (opts.timezone)
456 *opts.timezone = NULL;
457 if (opts.pw_warning)
458 *opts.pw_warning = NULL;
459 if (opts.jwt)
460 *opts.jwt = NULL;
461
462 /* Send the auth request. */
463
464 ret = gvm_connection_sendf_xml_quiet (connection,
465 "<authenticate token=\"%d\">"
466 "<credentials>"
467 "<username>%s</username>"
468 "<password>%s</password>"
469 "</credentials>"
470 "</authenticate>",
471 opts.jwt_requested, opts.username,
472 opts.password);
473 if (ret)
474 return ret;
475
476 /* Read the response. */
477
478 entity = NULL;
479 switch (try_read_entity_c (connection, opts.timeout, &entity))
480 {
481 case 0:
482 break;
483 case -4:
484 return 3;
485 default:
486 return -1;
487 }
488
489 /* Check the response. */
490
491 status = entity_attribute (entity, "status");
492 if (status == NULL)
493 {
494 free_entity (entity);
495 return -1;
496 }
497 if (strlen (status) == 0)
498 {
499 free_entity (entity);
500 return -1;
501 }
502 first = status[0];
503 if (first == '2')
504 {
505 entity_t timezone_entity, role_entity, token_entity;
506 /* Get the extra info. */
507 timezone_entity = entity_child (entity, "timezone");
508 if (timezone_entity && opts.timezone)
509 *opts.timezone = g_strdup (entity_text (timezone_entity));
510 role_entity = entity_child (entity, "role");
511 if (role_entity && opts.role)
512 *opts.role = g_strdup (entity_text (role_entity));
513 if (opts.pw_warning)
514 {
515 entity_t pw_warn_entity;
516 pw_warn_entity = entity_child (entity, "password_warning");
517 if (pw_warn_entity)
518 *(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
519 else
520 *(opts.pw_warning) = NULL;
521 }
522 token_entity = entity_child (entity, "token");
523 if (token_entity && opts.jwt_requested == 1 && opts.jwt)
524 *opts.jwt = g_strdup (entity_text (token_entity));
525
526 free_entity (entity);
527 return 0;
528 }
529 free_entity (entity);
530 return 2;
531}
int gvm_connection_sendf_xml_quiet(gvm_connection_t *connection, const char *format,...)
Format and send an XML string to the server.
int jwt_requested
Flag for JWT. 0 = false, 1 = true.
Definition gmp.h:34
char ** jwt
[out] JWT token value, NULL if not requested.
Definition gmp.h:35
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

References entity_attribute(), entity_child(), entity_text(), free_entity(), gvm_connection_sendf_xml_quiet(), gmp_authenticate_info_opts_t::jwt, gmp_authenticate_info_opts_t::jwt_requested, 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.

Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().

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

1729{
1730 int ret;
1731
1732 if (password)
1733 {
1734 if (comment)
1735 ret = gvm_server_sendf_xml_quiet (session,
1736 "<create_credential>"
1737 "<name>%s</name>"
1738 "<login>%s</login>"
1739 "<password>%s</password>"
1740 "<comment>%s</comment>"
1741 "</create_credential>",
1742 name, login, password, comment);
1743 else
1744 ret = gvm_server_sendf_xml_quiet (session,
1745 "<create_credential>"
1746 "<name>%s</name>"
1747 "<login>%s</login>"
1748 "<password>%s</password>"
1749 "</create_credential>",
1750 name, login, password);
1751 }
1752 else
1753 {
1754 if (comment)
1755 ret = gvm_server_sendf_xml (session,
1756 "<create_credential>"
1757 "<name>%s</name>"
1758 "<login>%s</login>"
1759 "<comment>%s</comment>"
1760 "</create_credential>",
1761 name, login, comment);
1762 else
1763 ret = gvm_server_sendf_xml (session,
1764 "<create_credential>"
1765 "<name>%s</name>"
1766 "<login>%s</login>"
1767 "</create_credential>",
1768 name, login);
1769 }
1770 if (ret)
1771 return -1;
1772
1773 ret = gmp_read_create_response (session, uuid);
1774 if (ret == 201)
1775 return 0;
1776 return ret;
1777}
int gmp_read_create_response(gnutls_session_t *session, gchar **uuid)
Read response status and resource UUID.
Definition gmp.c:890
int gvm_server_sendf_xml(gnutls_session_t *session, const char *format,...)
Format and send an XML string to the server.

References gmp_read_create_response(), gvm_server_sendf_xml(), and gvm_server_sendf_xml_quiet().

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

1850{
1851 gchar *comment, *pass, *start, *snmp_elems;
1852 int ret;
1853
1854 /* Create the GMP request. */
1855
1856 if (opts.login == NULL)
1857 return -1;
1858
1859 start =
1860 g_markup_printf_escaped ("<create_credential>"
1861 "<name>%s</name>"
1862 "<login>%s</login>",
1863 opts.name ? opts.name : "unnamed", opts.login);
1864
1865 if (opts.comment)
1866 comment = g_markup_printf_escaped ("<comment>"
1867 "%s"
1868 "</comment>",
1869 opts.comment);
1870 else
1871 comment = NULL;
1872
1873 if (opts.private_key)
1874 pass = g_markup_printf_escaped ("<key>"
1875 "<phrase>%s</phrase>"
1876 "<private>%s</private>"
1877 "</key>",
1878 opts.passphrase ? opts.passphrase : "",
1879 opts.private_key);
1880 else
1881 {
1882 if (opts.passphrase)
1883 pass = g_markup_printf_escaped ("<password>"
1884 "%s"
1885 "</password>",
1886 opts.passphrase);
1887 else
1888 pass = NULL;
1889 }
1890
1891 if (opts.community && opts.auth_algorithm && opts.privacy_password
1892 && opts.privacy_algorithm)
1893 snmp_elems =
1894 g_markup_printf_escaped ("<community>"
1895 "%s"
1896 "</community>"
1897 "<auth_algorithm>"
1898 "%s"
1899 "</auth_algorithm>"
1900 "<privacy>"
1901 "<password>%s</password>"
1902 "<algorithm>%s</algorithm>"
1903 "</privacy>",
1904 opts.community, opts.auth_algorithm,
1906 else
1907 snmp_elems = NULL;
1908
1909 /* Send the request. */
1910
1911 ret = gvm_server_sendf (session, "%s%s%s%s</create_credential>", start,
1912 comment ? comment : "", pass ? pass : "",
1913 snmp_elems ? snmp_elems : "");
1914
1915 g_free (start);
1916 g_free (comment);
1917 g_free (pass);
1918 if (ret)
1919 return -1;
1920
1921 /* Read the response. */
1922
1923 ret = gmp_read_create_response (session, id);
1924 if (ret == 201)
1925 return 0;
1926 return ret;
1927}
int gvm_server_sendf(gnutls_session_t *session, const char *format,...)
Format and send a string to the server.
const char * privacy_password
SNMP privacy password.
Definition gmp.h:249
const char * privacy_algorithm
SNMP privacy algorithm.
Definition gmp.h:250
const char * login
Login.
Definition gmp.h:245
const char * community
SNMP community.
Definition gmp.h:244
const char * passphrase
Passphrase.
Definition gmp.h:246
const char * comment
Comment on LSC credential.
Definition gmp.h:251
const char * private_key
Private key.
Definition gmp.h:247
const char * auth_algorithm
SNMP authentication algorithm.
Definition gmp.h:248
const char * name
Name of LSC credential.
Definition gmp.h:243

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

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

References gmp_read_create_response(), and gvm_server_sendf_xml().

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

1546{
1547 gchar *comment, *ssh, *smb, *esxi, *snmp, *port_range, *start;
1548 gchar *exclude_hosts, *alive_tests;
1549 int ret;
1550
1551 /* Create the GMP request. */
1552
1553 if (opts.hosts == NULL)
1554 return -1;
1555
1556 start =
1557 g_markup_printf_escaped ("<create_target>"
1558 "<name>%s</name>"
1559 "<hosts>%s</hosts>",
1560 opts.name ? opts.name : "unnamed", opts.hosts);
1561
1562 if (opts.exclude_hosts)
1563 exclude_hosts = g_markup_printf_escaped ("<exclude_hosts>"
1564 "%s"
1565 "</exclude_hosts>",
1566 opts.exclude_hosts);
1567 else
1568 exclude_hosts = NULL;
1569
1570 if (opts.alive_tests)
1571 alive_tests = g_markup_printf_escaped ("<alive_tests>"
1572 "%s"
1573 "</alive_tests>",
1574 opts.alive_tests);
1575 else
1576 alive_tests = NULL;
1577
1578 if (opts.comment)
1579 comment = g_markup_printf_escaped ("<comment>"
1580 "%s"
1581 "</comment>",
1582 opts.comment);
1583 else
1584 comment = NULL;
1585
1586 if (opts.ssh_credential_id)
1587 {
1588 if (opts.ssh_credential_port)
1589 ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\">"
1590 "<port>%i</port>"
1591 "</ssh_lsc_credential>",
1592 opts.ssh_credential_id,
1593 opts.ssh_credential_port);
1594 else
1595 ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\"/>",
1596 opts.ssh_credential_id);
1597 }
1598 else
1599 ssh = NULL;
1600
1601 if (opts.smb_credential_id)
1602 smb = g_markup_printf_escaped ("<smb_lsc_credential id=\"%s\"/>",
1603 opts.smb_credential_id);
1604 else
1605 smb = NULL;
1606
1607 if (opts.esxi_credential_id)
1608 esxi = g_markup_printf_escaped ("<esxi_lsc_credential id=\"%s\"/>",
1609 opts.esxi_credential_id);
1610 else
1611 esxi = NULL;
1612
1613 if (opts.snmp_credential_id)
1614 snmp = g_markup_printf_escaped ("<snmp_credential id=\"%s\"/>",
1615 opts.snmp_credential_id);
1616 else
1617 snmp = NULL;
1618
1619 if (opts.port_range)
1620 port_range =
1621 g_markup_printf_escaped ("<port_range>%s</port_range>", opts.port_range);
1622 else
1623 port_range = NULL;
1624
1625 /* Send the request. */
1626 ret = gvm_server_sendf (session,
1627 "%s%s%s%s%s%s%s%s%s"
1628 "<reverse_lookup_only>%d</reverse_lookup_only>"
1629 "<reverse_lookup_unify>%d</reverse_lookup_unify>"
1630 "</create_target>",
1631 start, exclude_hosts ? exclude_hosts : "",
1632 alive_tests ? alive_tests : "", ssh ? ssh : "",
1633 smb ? smb : "", esxi ? esxi : "", snmp ? snmp : "",
1634 port_range ? port_range : "", comment ? comment : "",
1636 g_free (start);
1637 g_free (exclude_hosts);
1638 g_free (alive_tests);
1639 g_free (ssh);
1640 g_free (smb);
1641 g_free (esxi);
1642 g_free (port_range);
1643 g_free (comment);
1644 if (ret)
1645 return -2;
1646
1647 /* Read the response. */
1648
1649 ret = gmp_read_create_response (session, id);
1650 if (ret == 201)
1651 return 0;
1652 return ret;
1653}
const char * exclude_hosts
Hosts to exclude.
Definition gmp.h:206
const char * comment
Comment on target.
Definition gmp.h:204
const char * smb_credential_id
ID of SMB credential.
Definition gmp.h:199
int reverse_lookup_only
Scanner pref reverse_lookup_only.
Definition gmp.h:209
int reverse_lookup_unify
Scanner pref reverse_lookup_unify.
Definition gmp.h:210
const char * esxi_credential_id
ID of ESXi credential.
Definition gmp.h:200
const char * snmp_credential_id
ID of SNMP credential.
Definition gmp.h:201
const char * hosts
Name of target.
Definition gmp.h:205
const char * port_range
Port range.
Definition gmp.h:202
int ssh_credential_port
Port for SSH access.
Definition gmp.h:197
const char * alive_tests
Alive tests.
Definition gmp.h:207
const char * ssh_credential_id
ID of SSH credential.
Definition gmp.h:198
const char * name
Name of target.
Definition gmp.h:203

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

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

References gmp_read_create_response(), and gvm_server_sendf_xml().

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

549{
550 /* Create the GMP request. */
551
552 gchar *prefs, *start, *scanner, *schedule, *slave;
553 GString *alerts, *observers;
554 int ret;
555 if ((opts.config_id == NULL) || (opts.target_id == NULL))
556 return -1;
557
558 prefs = NULL;
559 start = g_markup_printf_escaped (
560 "<create_task>"
561 "<config id=\"%s\"/>"
562 "<target id=\"%s\"/>"
563 "<name>%s</name>"
564 "<comment>%s</comment>"
565 "<alterable>%d</alterable>",
566 opts.config_id, opts.target_id, opts.name ? opts.name : "unnamed",
567 opts.comment ? opts.comment : "", opts.alterable ? 1 : 0);
568
569 if (opts.scanner_id)
570 scanner = g_strdup_printf ("<scanner id=\"%s\"/>", opts.scanner_id);
571 else
572 scanner = NULL;
573
574 if (opts.schedule_id)
575 schedule = g_strdup_printf ("<schedule id=\"%s\"/>"
576 "<schedule_periods>%d</schedule_periods>",
577 opts.schedule_id, opts.schedule_periods);
578 else
579 schedule = NULL;
580
581 if (opts.slave_id)
582 slave = g_strdup_printf ("<slave id=\"%s\"/>", opts.slave_id);
583 else
584 slave = NULL;
585
586 if (opts.max_checks || opts.max_hosts || opts.in_assets || opts.source_iface)
587 {
588 gchar *in_assets, *checks, *hosts, *source_iface;
589
590 in_assets = checks = hosts = source_iface = NULL;
591
592 if (opts.in_assets)
593 in_assets = g_markup_printf_escaped ("<preference>"
594 "<scanner_name>"
595 "in_assets"
596 "</scanner_name>"
597 "<value>"
598 "%s"
599 "</value>"
600 "</preference>",
601 opts.in_assets);
602
603 if (opts.max_hosts)
604 hosts = g_markup_printf_escaped ("<preference>"
605 "<scanner_name>"
606 "max_hosts"
607 "</scanner_name>"
608 "<value>"
609 "%s"
610 "</value>"
611 "</preference>",
612 opts.max_hosts);
613
614 if (opts.max_checks)
615 checks = g_markup_printf_escaped ("<preference>"
616 "<scanner_name>"
617 "max_checks"
618 "</scanner_name>"
619 "<value>"
620 "%s"
621 "</value>"
622 "</preference>",
623 opts.max_checks);
624
625 if (opts.source_iface)
626 source_iface = g_markup_printf_escaped ("<preference>"
627 "<scanner_name>"
628 "source_iface"
629 "</scanner_name>"
630 "<value>"
631 "%s"
632 "</value>"
633 "</preference>",
634 opts.source_iface);
635
636 prefs =
637 g_strdup_printf ("<preferences>%s%s%s%s</preferences>",
638 in_assets ? in_assets : "", checks ? checks : "",
639 hosts ? hosts : "", source_iface ? source_iface : "");
640 g_free (in_assets);
641 g_free (checks);
642 g_free (hosts);
643 g_free (source_iface);
644 }
645
646 if (opts.alert_ids)
647 {
648 unsigned int i;
649 alerts = g_string_new ("");
650 for (i = 0; i < opts.alert_ids->len; i++)
651 {
652 char *alert = (char *) g_ptr_array_index (opts.alert_ids, i);
653 g_string_append_printf (alerts, "<alert id=\"%s\"/>", alert);
654 }
655 }
656 else
657 alerts = g_string_new ("");
658
659 if (opts.observers || opts.observer_groups)
660 {
661 observers = g_string_new ("<observers>");
662
663 if (opts.observers)
664 g_string_append (observers, opts.observers);
665
666 if (opts.observer_groups)
667 {
668 unsigned int i;
669 for (i = 0; i < opts.observer_groups->len; i++)
670 {
671 char *group =
672 (char *) g_ptr_array_index (opts.observer_groups, i);
673 g_string_append_printf (observers, "<group id=\"%s\"/>", group);
674 }
675 }
676 g_string_append (observers, "</observers>");
677 }
678 else
679 observers = g_string_new ("");
680
681 /* Send the request. */
682 ret = gvm_server_sendf (
683 session, "%s%s%s%s%s%s%s</create_task>", start, prefs ? prefs : "",
684 scanner ? scanner : "", schedule ? schedule : "", slave ? slave : "",
685 alerts ? alerts->str : "", observers ? observers->str : "");
686 g_free (start);
687 g_free (prefs);
688 g_free (scanner);
689 g_free (schedule);
690 g_free (slave);
691 g_string_free (alerts, TRUE);
692 g_string_free (observers, TRUE);
693
694 if (ret)
695 return -1;
696
697 /* Read the response. */
698
699 ret = gmp_read_create_response (session, id);
700 if (ret == 201)
701 return 0;
702 return ret;
703}
int schedule_periods
Number of periods the schedule must run for.
Definition gmp.h:175
const char * max_checks
Max checks preference.
Definition gmp.h:179
const char * slave_id
ID of task schedule.
Definition gmp.h:168
array_t * alert_ids
Array of alert IDs.
Definition gmp.h:164
const char * config_id
ID of config.
Definition gmp.h:165
const char * in_assets
In assets preference.
Definition gmp.h:177
const char * schedule_id
ID of task schedule.
Definition gmp.h:167
const char * source_iface
Source iface preference.
Definition gmp.h:180
array_t * observer_groups
IDs of observer groups.
Definition gmp.h:174
const char * observers
Comma-separated string of observer users.
Definition gmp.h:173
const char * name
Name of task.
Definition gmp.h:170
const char * target_id
ID of target.
Definition gmp.h:169
const char * scanner_id
ID of task scanner.
Definition gmp.h:166
int alterable
Whether the task is alterable.
Definition gmp.h:182
const char * max_hosts
Max hosts preference.
Definition gmp.h:178
const char * comment
Comment on task.
Definition gmp.h:171

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

1696{
1697 entity_t entity;
1698 int ret;
1699
1700 if (gvm_server_sendf (session,
1701 "<delete_config config_id=\"%s\" ultimate=\"%d\"/>", id,
1702 opts.ultimate)
1703 == -1)
1704 return -1;
1705
1706 entity = NULL;
1707 ret = gmp_check_response (session, &entity);
1708 if (ret == 0)
1709 free_entity (entity);
1710 return ret;
1711}

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

1941{
1942 entity_t entity;
1943 int ret;
1944
1945 if (gvm_server_sendf (session,
1946 "<delete_credential credential_id=\"%s\""
1947 " ultimate=\"%d\"/>",
1948 id, opts.ultimate)
1949 == -1)
1950 return -1;
1951
1952 entity = NULL;
1953 ret = gmp_check_response (session, &entity);
1954 if (ret == 0)
1955 free_entity (entity);
1956 return ret;
1957}

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

1488{
1489 entity_t entity;
1490 int ret;
1491
1492 if (gvm_server_sendf (
1493 session, "<delete_port_list port_list_id=\"%s\" ultimate=\"%d\"/>", id,
1494 opts.ultimate)
1495 == -1)
1496 return -1;
1497
1498 entity = NULL;
1499 ret = gmp_check_response (session, &entity);
1500 if (ret == 0)
1501 free_entity (entity);
1502 return ret;
1503}

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

1515{
1516 entity_t entity;
1517 int ret;
1518
1519 if (gvm_server_sendf (session, "<delete_report report_id=\"%s\"/>", id))
1520 return -1;
1521
1522 entity = NULL;
1523 ret = gmp_check_response (session, &entity);
1524 if (ret == 0)
1525 free_entity (entity);
1526 return ret;
1527}

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

1667{
1668 entity_t entity;
1669 int ret;
1670
1671 if (gvm_server_sendf (session,
1672 "<delete_target target_id=\"%s\" ultimate=\"%d\"/>", id,
1673 opts.ultimate)
1674 == -1)
1675 return -1;
1676
1677 entity = NULL;
1678 ret = gmp_check_response (session, &entity);
1679 if (ret == 0)
1680 free_entity (entity);
1681 return ret;
1682}

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

1323{
1324 entity_t entity;
1325 int ret;
1326
1327 if (gvm_server_sendf (session, "<delete_task task_id=\"%s\"/>", id) == -1)
1328 return -1;
1329
1330 entity = NULL;
1331 ret = gmp_check_response (session, &entity);
1332 if (ret == 0)
1333 free_entity (entity);
1334 return ret;
1335}

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

1096{
1097 entity_t entity;
1098 int ret;
1099
1100 if (gvm_server_sendf (session,
1101 "<delete_task task_id=\"%s\" ultimate=\"%d\"/>", id,
1102 opts.ultimate)
1103 == -1)
1104 return -1;
1105
1106 entity = NULL;
1107 ret = gmp_check_response (session, &entity);
1108 if (ret == 0)
1109 free_entity (entity);
1110 return ret;
1111}

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

1390{
1391 int ret;
1392 const char *status_code;
1393
1394 if (response == NULL)
1395 return -1;
1396
1397 if (gvm_server_sendf (
1398 session,
1399 "<get_reports"
1400 " details=\"1\""
1401 " report_id=\"%s\""
1402 " format_id=\"%s\""
1403 " host_first_result=\"%i\""
1404 " host_max_results=\"%i\""
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"
1414 "%s%s%s"
1415 "%s%s%s"
1416 "%s%s%s"
1417 "%s%s%s"
1418 "%s%s%s"
1419 "%s%s%s%s%s%s%s/>",
1420 opts.report_id, opts.format_id, opts.host_first_result,
1421 opts.host_max_results, GMP_FMT_STRING_ATTRIB (opts, type),
1422 GMP_FMT_STRING_ATTRIB (opts, filter),
1423 GMP_FMT_STRING_ATTRIB (opts, filt_id),
1424 GMP_FMT_STRING_ATTRIB (opts, host), GMP_FMT_STRING_ATTRIB (opts, pos),
1425 GMP_FMT_STRING_ATTRIB (opts, timezone),
1426 GMP_FMT_STRING_ATTRIB (opts, alert_id),
1427 GMP_FMT_STRING_ATTRIB (opts, delta_report_id),
1428 GMP_FMT_STRING_ATTRIB (opts, delta_states),
1429 GMP_FMT_STRING_ATTRIB (opts, host_levels),
1430 GMP_FMT_STRING_ATTRIB (opts, search_phrase),
1431 GMP_FMT_STRING_ATTRIB (opts, host_search_phrase),
1432 GMP_FMT_STRING_ATTRIB (opts, min_cvss_base),
1433 GMP_FMT_STRING_ATTRIB (opts, min_qod),
1434 GMP_FMT_BOOL_ATTRIB (opts, notes),
1435 GMP_FMT_BOOL_ATTRIB (opts, notes_details),
1436 GMP_FMT_BOOL_ATTRIB (opts, overrides),
1437 GMP_FMT_BOOL_ATTRIB (opts, override_details),
1438 GMP_FMT_BOOL_ATTRIB (opts, apply_overrides),
1439 GMP_FMT_BOOL_ATTRIB (opts, result_hosts_only),
1440 GMP_FMT_BOOL_ATTRIB (opts, ignore_pagination)))
1441 return -1;
1442
1443 *response = NULL;
1444 switch (try_read_entity (session, opts.timeout, response))
1445 {
1446 case 0:
1447 break;
1448 case -4:
1449 return 2;
1450 default:
1451 return -1;
1452 }
1453
1454 /* Check the response. */
1455
1456 status_code = entity_attribute (*response, "status");
1457 if (status_code == NULL)
1458 {
1459 free_entity (*response);
1460 return -1;
1461 }
1462 if (strlen (status_code) == 0)
1463 {
1464 free_entity (*response);
1465 return -1;
1466 }
1467 if (status_code[0] == '2')
1468 return 0;
1469 ret = (int) strtol (status_code, NULL, 10);
1470 free_entity (*response);
1471 if (errno == ERANGE)
1472 return -1;
1473 return ret;
1474}
#define GMP_FMT_BOOL_ATTRIB(var, attrib)
Definition gmp.c:30
#define GMP_FMT_STRING_ATTRIB(var, attrib)
Definition gmp.c:33
int timeout
Timeout for GMP response.
Definition gmp.h:56
const char * format_id
ID of required report format.
Definition gmp.h:51
int host_max_results
Maximum number of results to return.
Definition gmp.h:58
const char * report_id
ID of single report to get.
Definition gmp.h:53
int host_first_result
Skip over results before this result number.
Definition gmp.h:57

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

1973{
1974 if (name)
1975 {
1976 if (gvm_server_sendf (session,
1977 "<get_system_reports name=\"%s\" brief=\"%i\"/>",
1978 name, brief)
1979 == -1)
1980 return -1;
1981 }
1982 else if (gvm_server_sendf (session, "<get_system_reports brief=\"%i\"/>",
1983 brief)
1984 == -1)
1985 return -1;
1986
1987 /* Read and check the response. */
1988 return gmp_check_response (session, reports);
1989}

References gmp_check_response(), and gvm_server_sendf().

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

2005{
2006 GString *request;
2007
2008 request = g_string_new ("<get_system_reports");
2009
2010 if (opts.slave_id)
2011 xml_string_append (request, " slave_id=\"%s\"", opts.slave_id);
2012
2013 if (opts.name)
2014 xml_string_append (request, " name=\"%s\"", opts.name);
2015
2016 if (opts.duration)
2017 xml_string_append (request, " duration=\"%s\"", opts.duration);
2018
2019 if (opts.start_time)
2020 xml_string_append (request, " start_time=\"%s\"", opts.start_time);
2021
2022 if (opts.end_time)
2023 xml_string_append (request, " end_time=\"%s\"", opts.end_time);
2024
2025 g_string_append (request, "/>");
2026
2027 /* Create the GMP request. */
2028
2029 if (gvm_server_sendf (session, "%s", request->str) == -1)
2030 {
2031 g_string_free (request, 1);
2032 return -1;
2033 }
2034 g_string_free (request, 1);
2035
2036 /* Read and check the response. */
2037 return gmp_check_response (session, reports);
2038}
const char * duration
Duration.
Definition gmp.h:225
const char * slave_id
ID of the slave to get report from.
Definition gmp.h:228
const char * end_time
Time of last data point.
Definition gmp.h:227
const char * name
Name of report.
Definition gmp.h:224
const char * start_time
Time of first data point.
Definition gmp.h:226
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition xmlutils.c:1849

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

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

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

1163{
1164 if ((response == NULL) || (opts.task_id == NULL))
1165 return -1;
1166
1167 if (opts.actions)
1168 {
1169 if (gvm_server_sendf (session,
1170 "<get_tasks"
1171 " task_id=\"%s\""
1172 " actions=\"%s\""
1173 "%s/>",
1174 opts.task_id, opts.actions,
1175 GMP_FMT_BOOL_ATTRIB (opts, details)))
1176 return -1;
1177 }
1178 else if (gvm_server_sendf (session,
1179 "<get_tasks"
1180 " task_id=\"%s\""
1181 "%s/>",
1182 opts.task_id, GMP_FMT_BOOL_ATTRIB (opts, details)))
1183 return -1;
1184
1185 return gmp_check_response (session, response);
1186}
const char * task_id
ID of single task to get.
Definition gmp.h:147
const char * actions
Actions argument.
Definition gmp.h:146

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

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

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

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

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

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

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

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

191{
192 entity_t entity;
193 const char *status;
194 char first;
195 int ret;
196
197 /* Send a GET_VERSION request. */
198
199 ret = gvm_server_sendf (session, "<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 (session, 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 first = status[0];
230 free_entity (entity);
231 if (first == '2')
232 return 0;
233 return -1;
234}

References entity_attribute(), free_entity(), gvm_server_sendf(), and try_read_entity().

Referenced by Ensure(), Ensure(), Ensure(), and Ensure().

Here is the call graph for this function:
Here is the caller 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 249 of file gmp.c.

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

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

891{
892 int ret;
893 const char *status;
894 entity_t entity;
895
896 /* Read the response. */
897
898 entity = NULL;
899 if (read_entity (session, &entity))
900 return -1;
901
902 /* Parse the response. */
903
904 status = entity_attribute (entity, "status");
905 if (status == NULL)
906 {
907 free_entity (entity);
908 return -1;
909 }
910 if (strlen (status) == 0)
911 {
912 free_entity (entity);
913 return -1;
914 }
915
916 if (uuid)
917 {
918 const char *id;
919
920 id = entity_attribute (entity, "id");
921 if (id == NULL)
922 {
923 free_entity (entity);
924 return -1;
925 }
926 if (strlen (id) == 0)
927 {
928 free_entity (entity);
929 return -1;
930 }
931 *uuid = g_strdup (id);
932 }
933
934 ret = atoi (status);
935 free_entity (entity);
936 return ret;
937}
int read_entity(gnutls_session_t *session, entity_t *entity)
Read an XML entity tree from the manager.
Definition xmlutils.c:1469

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

Referenced by Ensure(), Ensure(), Ensure(), Ensure(), 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 991 of file gmp.c.

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

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

1038{
1039 if (gvm_connection_sendf (connection, "<resume_task task_id=\"%s\"/>",
1040 task_id)
1041 == -1)
1042 return -1;
1043
1044 /* Read the response. */
1045
1046 entity_t entity = NULL;
1047 if (read_entity_c (connection, &entity))
1048 return -1;
1049
1050 /* Check the response. */
1051
1052 const char *status = entity_attribute (entity, "status");
1053 if (status == NULL)
1054 {
1055 free_entity (entity);
1056 return -1;
1057 }
1058 if (strlen (status) == 0)
1059 {
1060 free_entity (entity);
1061 return -1;
1062 }
1063 char first = status[0];
1064 if (first == '2')
1065 {
1066 if (report_id)
1067 {
1068 entity_t report_id_xml = entity_child (entity, "report_id");
1069 if (report_id_xml)
1070 *report_id = g_strdup (entity_text (report_id_xml));
1071 else
1072 {
1073 free_entity (entity);
1074 return -1;
1075 }
1076 }
1077 free_entity (entity);
1078 return 0;
1079 }
1080 free_entity (entity);
1081 return 1;
1082}
int read_entity_c(gvm_connection_t *connection, entity_t *entity)
Read an XML entity tree from the manager.
Definition xmlutils.c:1497

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

860{
861 int ret;
862
863 /* Check args. */
864
865 if (opts.task_id == NULL)
866 return -1;
867
868 /* Send request. */
869
870 ret = gvm_connection_sendf (connection, "<start_task task_id=\"%s\"/>",
871 opts.task_id);
872 if (ret)
873 return -1;
874
875 /* Read response. */
876
877 return check_response_c (connection, 1);
878}
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:119
const char * task_id
ID of task.
Definition gmp.h:319

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

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

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

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

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

949{
950 entity_t entity;
951 int ret;
952
953 if (gvm_server_sendf (session, "<stop_task task_id=\"%s\"/>", id) == -1)
954 return -1;
955
956 entity = NULL;
957 ret = gmp_check_response (session, &entity);
958 if (ret == 0)
959 free_entity (entity);
960 return ret;
961}

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

973{
974 if (gvm_connection_sendf (connection, "<stop_task task_id=\"%s\"/>", id)
975 == -1)
976 return -1;
977
978 return gmp_check_response_c (connection);
979}
static int gmp_check_response_c(gvm_connection_t *connection)
Read response and convert status of response to a return value.
Definition gmp.c:174

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

Referenced by Ensure(), Ensure(), and Ensure().

Here is the call graph for this function:
Here is the caller 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, 0, NULL}

Sensible default values for gmp_authenticate_info_opts_t.

Definition at line 41 of file gmp.h.

41 {0, NULL, NULL, NULL, NULL, NULL, 0, NULL};

Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().

◆ 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 258 of file gmp.h.

258 {NULL, NULL, NULL, NULL, NULL,
259 NULL, NULL, NULL, NULL};

◆ 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 216 of file gmp.h.

216 {
217 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0};

◆ 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 188 of file gmp.h.

188 {
189 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
190 NULL, NULL, 0, NULL, NULL, NULL, NULL, 0};

◆ 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 272 of file gmp.h.

272{0};

◆ 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 277 of file gmp.h.

277{1};

◆ 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 88 of file gmp.h.

88 {
89 "ROWID",
90 "ascending",
91 "a994b278-1f62-11e1-96ac-406186ea4fc5",
92 "hmlgd",
93 NULL,
94 1,
95 -1,
96 0,
97 0,
98 0,
99 0,
100 NULL,
101 NULL,
102 NULL,
103 NULL,
104 NULL,
105 NULL,
106 NULL,
107 NULL,
108 NULL,
109 NULL,
110 NULL,
111 NULL,
112 NULL,
113 NULL,
114 0,
115 0,
116 0,
117 0,
118 0,
119 0,
120 0};

◆ 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 236 of file gmp.h.

236{NULL, NULL, NULL, NULL, NULL, 0};

◆ 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 156 of file gmp.h.

156 {NULL, NULL, 0,
157 0};

◆ 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 138 of file gmp.h.

138 {"", 0, NULL, 0,
139 0};

◆ gmp_start_task_opts_defaults

const gmp_start_task_opts_t gmp_start_task_opts_defaults = {NULL}
static

Definition at line 322 of file gmp.h.

322{NULL};