OpenVAS Libraries
8.0.3
|
OMP client interface. More...
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include "omp.h"
#include "xml.h"
#include "openvas_server.h"
Macros | |
#define | G_LOG_DOMAIN "lib omp" |
GLib log domain. More... | |
#define | OMP_FMT_BOOL_ATTRIB(var, attrib) (var.attrib == 0 ? " " #attrib "=\"0\"" : " " #attrib "=\"1\"") |
#define | OMP_FMT_STRING_ATTRIB(var, attrib) |
#define | DO_CHILDREN(entity, child, temp, body) |
Do something for each child of an entity. More... | |
Functions | |
const char * | omp_task_status (entity_t response) |
Get the task status from an OMP GET_TASKS response. More... | |
int | omp_ping (gnutls_session_t *session, int timeout) |
"Ping" the manager. More... | |
int | omp_authenticate (gnutls_session_t *session, const char *username, const char *password) |
Authenticate with the manager. More... | |
int | omp_authenticate_info_ext (gnutls_session_t *session, omp_authenticate_info_opts_t opts) |
Authenticate with the manager. More... | |
int | omp_create_task_ext (gnutls_session_t *session, omp_create_task_opts_t opts, gchar **id) |
Create a task. More... | |
int | omp_create_task (gnutls_session_t *session, const char *name, const char *config, const char *target, const char *comment, gchar **id) |
Create a task given a config and target. More... | |
int | omp_start_task_report (gnutls_session_t *session, const char *task_id, char **report_id) |
Start a task and read the manager response. More... | |
int | check_response (gnutls_session_t *session) |
Read response and convert status of response to a return value. More... | |
int | omp_read_create_response (gnutls_session_t *session, gchar **uuid) |
Read response status and resource UUID. More... | |
int | omp_stop_task (gnutls_session_t *session, const char *id) |
Stop a task and read the manager response. More... | |
int | omp_resume_task_report (gnutls_session_t *session, const char *task_id, char **report_id) |
Resume a task and read the manager response. More... | |
int | omp_delete_task_ext (gnutls_session_t *session, const char *id, omp_delete_opts_t opts) |
Delete a task and read the manager response. More... | |
int | omp_get_tasks (gnutls_session_t *session, const char *id, int details, int include_rcfile, entity_t *status) |
Get the status of a task. More... | |
int | omp_get_task_ext (gnutls_session_t *session, omp_get_task_opts_t opts, entity_t *response) |
Get a task (generic version). More... | |
int | omp_get_tasks_ext (gnutls_session_t *session, omp_get_tasks_opts_t opts, entity_t *response) |
Get all tasks (generic version). More... | |
int | omp_modify_task_file (gnutls_session_t *session, const char *id, const char *name, const void *content, gsize content_len) |
Modify a file on a task. More... | |
int | omp_delete_task (gnutls_session_t *session, const char *id) |
Delete a task and read the manager response. More... | |
int | omp_get_targets (gnutls_session_t *session, const char *id, int tasks, int include_rcfile, entity_t *target) |
Get a target. More... | |
int | omp_get_report_ext (gnutls_session_t *session, omp_get_report_opts_t opts, entity_t *response) |
Get a report (generic version). More... | |
int | omp_delete_port_list_ext (gnutls_session_t *session, const char *id, omp_delete_opts_t opts) |
Delete a port list. More... | |
int | omp_delete_report (gnutls_session_t *session, const char *id) |
Remove a report. More... | |
int | omp_create_target_ext (gnutls_session_t *session, omp_create_target_opts_t opts, gchar **id) |
Create a target. More... | |
int | omp_delete_target_ext (gnutls_session_t *session, const char *id, omp_delete_opts_t opts) |
Delete a target. More... | |
int | omp_delete_config_ext (gnutls_session_t *session, const char *id, omp_delete_opts_t opts) |
Delete a config. More... | |
int | omp_create_lsc_credential (gnutls_session_t *session, const char *name, const char *login, const char *password, const char *comment, gchar **uuid) |
Create an LSC Credential. More... | |
int | omp_create_lsc_credential_key (gnutls_session_t *session, const char *name, const char *login, const char *passphrase, const char *private_key, const char *comment, gchar **uuid) |
Create an LSC Credential with a key. More... | |
int | omp_create_lsc_credential_ext (gnutls_session_t *session, omp_create_lsc_credential_opts_t opts, gchar **id) |
Create an LSC credential. More... | |
int | omp_delete_lsc_credential_ext (gnutls_session_t *session, const char *id, omp_delete_opts_t opts) |
Delete a LSC credential. More... | |
int | omp_get_system_reports (gnutls_session_t *session, const char *name, int brief, entity_t *reports) |
Get system reports. More... | |
int | omp_get_system_reports_ext (gnutls_session_t *session, omp_get_system_reports_opts_t opts, entity_t *reports) |
Get system reports. More... | |
OMP client interface.
This provides higher level, OMP-aware, facilities for working with with the OpenVAS manager.
There are examples of using this interface in the openvas-manager tests.
#define DO_CHILDREN | ( | entity, | |
child, | |||
temp, | |||
body | |||
) |
Do something for each child of an entity.
Calling "break" during body exits the loop.
[in] | entity | The entity. |
[in] | child | Name to use for child variable. |
[in] | temp | Name to use for internal variable. |
[in] | body | The code to run for each child. |
#define G_LOG_DOMAIN "lib omp" |
GLib log domain.
#define OMP_FMT_BOOL_ATTRIB | ( | var, | |
attrib | |||
) | (var.attrib == 0 ? " " #attrib "=\"0\"" : " " #attrib "=\"1\"") |
#define OMP_FMT_STRING_ATTRIB | ( | var, | |
attrib | |||
) |
int check_response | ( | gnutls_session_t * | session | ) |
Read response and convert status of response to a return value.
[in] | session | Pointer to GNUTLS session. |
int omp_authenticate | ( | gnutls_session_t * | session, |
const char * | username, | ||
const char * | password | ||
) |
Authenticate with the manager.
[in] | session | Pointer to GNUTLS session. |
[in] | username | Username. |
[in] | password | Password. |
int omp_authenticate_info_ext | ( | gnutls_session_t * | session, |
omp_authenticate_info_opts_t | opts | ||
) |
Authenticate with the manager.
[in] | session | Pointer to GNUTLS session. |
[in] | username | Username. |
[in] | password | Password. |
[out] | role | Role. |
[out] | timezone | Timezone if any, else NULL. |
[out] | pw_warning | Password warning, NULL if password is okay. |
int omp_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.
[in] | session | Pointer to GNUTLS session. |
[in] | name | Name of LSC Credential. |
[in] | login | Login associated with name. |
[in] | password | Password, or NULL for autogenerated credentials. |
[in] | comment | LSC Credential comment. |
[out] | uuid | Either NULL or address for UUID of created credential. |
int omp_create_lsc_credential_ext | ( | gnutls_session_t * | session, |
omp_create_lsc_credential_opts_t | opts, | ||
gchar ** | id | ||
) |
Create an LSC credential.
[in] | session | Pointer to GNUTLS session. |
[in] | opts | Struct containing the options to apply. |
[out] | id | Pointer for newly allocated ID of new LSC credential, or NULL. Only set on successful return. |
int omp_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.
[in] | session | Pointer to GNUTLS session. |
[in] | name | Name of LSC Credential. |
[in] | login | Login associated with name. |
[in] | passphrase | Passphrase for private key. |
[in] | private_key | Private key. |
[in] | comment | LSC Credential comment. |
[out] | uuid | Either NULL or address for UUID of created credential. |
int omp_create_target_ext | ( | gnutls_session_t * | session, |
omp_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.
[in] | session | Pointer to GNUTLS session. |
[in] | opts | Struct containing the options to apply. |
[out] | id | Pointer for newly allocated ID of new target, or NULL. Only set on successful return. |
int omp_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.
[in] | session | Pointer to GNUTLS session. |
[in] | name | Task name. |
[in] | config | Task config name. |
[in] | target | Task target name. |
[in] | comment | Task comment. |
[out] | id | Pointer for newly allocated ID of new task. Only set on successful return. |
int omp_create_task_ext | ( | gnutls_session_t * | session, |
omp_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.
[in] | session | Pointer to GNUTLS session. |
[in] | opts | Struct containing the options to apply. |
[out] | id | Pointer for newly allocated ID of new task, or NULL. Only set on successful return. |
int omp_delete_config_ext | ( | gnutls_session_t * | session, |
const char * | id, | ||
omp_delete_opts_t | opts | ||
) |
Delete a config.
[in] | session | Pointer to GNUTLS session. |
[in] | id | UUID of config. |
[in] | opts | Struct containing the options to apply. |
int omp_delete_lsc_credential_ext | ( | gnutls_session_t * | session, |
const char * | id, | ||
omp_delete_opts_t | opts | ||
) |
Delete a LSC credential.
[in] | session | Pointer to GNUTLS session. |
[in] | uuid | UUID of LSC credential. |
[in] | opts | Struct containing the options to apply. |
int omp_delete_port_list_ext | ( | gnutls_session_t * | session, |
const char * | id, | ||
omp_delete_opts_t | opts | ||
) |
Delete a port list.
[in] | session | Pointer to GNUTLS session. |
[in] | id | UUID of port list. |
[in] | opts | Struct containing the options to apply. |
int omp_delete_report | ( | gnutls_session_t * | session, |
const char * | id | ||
) |
Remove a report.
[in] | session | Pointer to GNUTLS session. |
[in] | id | ID of report. |
int omp_delete_target_ext | ( | gnutls_session_t * | session, |
const char * | id, | ||
omp_delete_opts_t | opts | ||
) |
Delete a target.
[in] | session | Pointer to GNUTLS session. |
[in] | id | UUID of target. |
[in] | opts | Struct containing the options to apply. |
int omp_delete_task | ( | gnutls_session_t * | session, |
const char * | id | ||
) |
Delete a task and read the manager response.
[in] | session | Pointer to GNUTLS session. |
[in] | id | ID of task. |
int omp_delete_task_ext | ( | gnutls_session_t * | session, |
const char * | id, | ||
omp_delete_opts_t | opts | ||
) |
Delete a task and read the manager response.
[in] | session | Pointer to GNUTLS session. |
[in] | id | ID of task. |
[in] | opts | Struct containing the options to apply. |
int omp_get_report_ext | ( | gnutls_session_t * | session, |
omp_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.
[in] | session | Pointer to GNUTLS session. |
[in] | opts | Struct containing the options to apply. |
[out] | response | Report. On success contains GET_REPORT response. |
int omp_get_system_reports | ( | gnutls_session_t * | session, |
const char * | name, | ||
int | brief, | ||
entity_t * | reports | ||
) |
Get system reports.
[in] | session | Pointer to GNUTLS session. |
[in] | name | Name of system report. NULL for all. |
[in] | brief | Whether to request brief response. |
[out] | reports | Reports return. On success contains GET_SYSTEM_REPORTS response. |
int omp_get_system_reports_ext | ( | gnutls_session_t * | session, |
omp_get_system_reports_opts_t | opts, | ||
entity_t * | reports | ||
) |
Get system reports.
[in] | session | Pointer to GNUTLS session. |
[in] | opts | Struct containing the options to apply. |
[out] | reports | Reports return. On success contains GET_SYSTEM_REPORTS response. |
int omp_get_targets | ( | gnutls_session_t * | session, |
const char * | id, | ||
int | tasks, | ||
int | include_rcfile, | ||
entity_t * | target | ||
) |
Get a target.
[in] | session | Pointer to GNUTLS session. |
[in] | id | ID of target or NULL for all targets. |
[in] | tasks | Whether to include tasks that use the target. |
[in] | include_rcfile | Not used. |
[out] | target | Target return. On success contains GET_TARGETS response. |
int omp_get_task_ext | ( | gnutls_session_t * | session, |
omp_get_task_opts_t | opts, | ||
entity_t * | response | ||
) |
Get a task (generic version).
[in] | session | Pointer to GNUTLS session. |
[in] | opts | Struct containing the options to apply. |
[out] | response | Task. On success contains GET_TASKS response. |
int omp_get_tasks | ( | gnutls_session_t * | session, |
const char * | id, | ||
int | details, | ||
int | include_rcfile, | ||
entity_t * | status | ||
) |
Get the status of a task.
[in] | session | Pointer to GNUTLS session. |
[in] | id | ID of task or NULL for all tasks. |
[in] | details | Whether to request task details. |
[in] | include_rcfile | Ignored. Removed since OMP 6.0. |
[out] | status | Status return. On success contains GET_TASKS response. |
int omp_get_tasks_ext | ( | gnutls_session_t * | session, |
omp_get_tasks_opts_t | opts, | ||
entity_t * | response | ||
) |
Get all tasks (generic version).
[in] | session | Pointer to GNUTLS session. |
[in] | opts | Struct containing the options to apply. |
[out] | response | Tasks. On success contains GET_TASKS response. |
int omp_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.
[in] | session | Pointer to GNUTLS session. |
[in] | id | ID of task. |
[in] | name | Name of file. |
[in] | content | New content. NULL to remove file. |
[in] | content_len | Length of content. |
int omp_ping | ( | gnutls_session_t * | session, |
int | timeout | ||
) |
"Ping" the manager.
[in] | session | Pointer to GNUTLS session. |
[in] | timeout | Server idle time before giving up, in milliseconds. 0 to wait forever. |
int omp_read_create_response | ( | gnutls_session_t * | session, |
gchar ** | uuid | ||
) |
Read response status and resource UUID.
[in] | session | Pointer to GNUTLS session. |
[out] | uuid | Either NULL or address for freshly allocated UUID of created response. |
int omp_resume_task_report | ( | gnutls_session_t * | session, |
const char * | task_id, | ||
char ** | report_id | ||
) |
Resume a task and read the manager response.
[in] | session | Pointer to GNUTLS session. |
[in] | task_id | ID of task. |
[out] | report_id | ID of report. |
int omp_start_task_report | ( | gnutls_session_t * | session, |
const char * | task_id, | ||
char ** | report_id | ||
) |
Start a task and read the manager response.
[in] | session | Pointer to GNUTLS session. |
[in] | task_id | ID of task. |
[out] | report_id | ID of report. |
int omp_stop_task | ( | gnutls_session_t * | session, |
const char * | id | ||
) |
Stop a task and read the manager response.
[in] | session | Pointer to GNUTLS session. |
[in] | id | ID of task. |
const char* omp_task_status | ( | entity_t | response | ) |
Get the task status from an OMP GET_TASKS response.
[in] | response | GET_TASKS response. |