Greenbone Vulnerability Management Libraries  10.0.0
Data Structures | Macros | Functions
osp.c File Reference

API for Open Scanner Protocol communication. More...

#include "osp.h"
#include "../base/hosts.h"
#include "../util/serverutils.h"
#include "../util/xmlutils.h"
#include <assert.h>
#include <gnutls/gnutls.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

Data Structures

struct  osp_connection
 Struct holding options for OSP connection. More...
 
struct  osp_param
 Struct holding options for OSP parameters. More...
 

Macros

#define G_LOG_DOMAIN   "lib osp"
 GLib log domain. More...
 

Functions

static int osp_send_command (osp_connection_t *connection, entity_t *response, const char *fmt,...)
 Send a command to an OSP server. More...
 
void osp_connection_close (osp_connection_t *connection)
 Close a connection to an OSP server. More...
 
int osp_get_version (osp_connection_t *connection, char **s_name, char **s_version, char **d_name, char **d_version, char **p_name, char **p_version)
 Get the scanner version from an OSP server. More...
 
int osp_delete_scan (osp_connection_t *connection, const char *scan_id)
 Delete a scan from an OSP server. More...
 
int osp_get_scan (osp_connection_t *connection, const char *scan_id, char **report_xml, int details, char **error)
 Get a scan from an OSP server. More...
 
int osp_stop_scan (osp_connection_t *connection, const char *scan_id, char **error)
 Stop a scan on an OSP server. More...
 
static void option_concat_as_xml (gpointer key, gpointer value, gpointer pstr)
 Concatenate options as xml. More...
 
int osp_start_scan (osp_connection_t *connection, const char *target, const char *ports, GHashTable *options, const char *scan_id, char **error)
 Start an OSP scan against a target. More...
 
static osp_param_type_t osp_param_str_to_type (const char *str)
 Get an OSP parameter's type from its string format. More...
 
const char * osp_param_type_str (const osp_param_t *param)
 Get an OSP parameter in string format form its type. More...
 
int osp_get_scanner_details (osp_connection_t *connection, char **desc, GSList **params)
 Get an OSP scanner's details. More...
 
osp_param_tosp_param_new (void)
 Create a new OSP parameter. More...
 
const char * osp_param_id (const osp_param_t *param)
 Get an OSP parameter's id. More...
 
const char * osp_param_name (const osp_param_t *param)
 Get an OSP parameter's name. More...
 
const char * osp_param_desc (const osp_param_t *param)
 Get an OSP parameter's description. More...
 
const char * osp_param_default (const osp_param_t *param)
 Get an OSP parameter's default value. More...
 
int osp_param_mandatory (const osp_param_t *param)
 Get an OSP parameter's mandatory value. More...
 
void osp_param_free (osp_param_t *param)
 Free an OSP parameter. More...
 

Detailed Description

API for Open Scanner Protocol communication.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib osp"

GLib log domain.

Function Documentation

◆ option_concat_as_xml()

static void option_concat_as_xml ( gpointer  key,
gpointer  value,
gpointer  pstr 
)
static

Concatenate options as xml.

Parameters
[in]keyTag name for xml element.
[in]valueText for xml element.
[in,out]pstrParameters as xml concatenated xml elements.

◆ osp_connection_close()

void osp_connection_close ( osp_connection_t connection)

Close a connection to an OSP server.

Parameters
[in]connectionConnection to OSP server to close.

◆ osp_delete_scan()

int osp_delete_scan ( osp_connection_t connection,
const char *  scan_id 
)

Delete a scan from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to delete.
Returns
0 if success, 1 if error.

◆ osp_get_scan()

int osp_get_scan ( osp_connection_t connection,
const char *  scan_id,
char **  report_xml,
int  details,
char **  error 
)

Get a scan from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to get.
[out]report_xmlScans report.
[in]details0 for no scan details, 1 otherwise.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.

◆ osp_get_scanner_details()

int osp_get_scanner_details ( osp_connection_t connection,
char **  desc,
GSList **  params 
)

Get an OSP scanner's details.

Parameters
[in]connectionConnection to an OSP server.
[out]descScanner's description.
[out]paramsScanner's parameters.
Returns
0 if success, 1 if failure.

◆ osp_get_version()

int osp_get_version ( osp_connection_t connection,
char **  s_name,
char **  s_version,
char **  d_name,
char **  d_version,
char **  p_name,
char **  p_version 
)

Get the scanner version from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[out]s_nameParsed scanner name.
[out]s_versionParsed scanner version.
[out]d_nameParsed scanner name.
[out]d_versionParsed scanner version.
[out]p_nameParsed scanner name.
[out]p_versionParsed scanner version.
Returns
0 if success, 1 if error.

◆ osp_param_default()

const char* osp_param_default ( const osp_param_t param)

Get an OSP parameter's default value.

Parameters
[in]paramOSP parameter.
Returns
Default value of OSP parameter.

◆ osp_param_desc()

const char* osp_param_desc ( const osp_param_t param)

Get an OSP parameter's description.

Parameters
[in]paramOSP parameter.
Returns
Description of OSP parameter.

◆ osp_param_free()

void osp_param_free ( osp_param_t param)

Free an OSP parameter.

Parameters
[in]paramOSP parameter to destroy.

◆ osp_param_id()

const char* osp_param_id ( const osp_param_t param)

Get an OSP parameter's id.

Parameters
[in]paramOSP parameter.
Returns
ID of OSP parameter.

◆ osp_param_mandatory()

int osp_param_mandatory ( const osp_param_t param)

Get an OSP parameter's mandatory value.

Parameters
[in]paramOSP parameter.
Returns
Mandatory value of OSP parameter.

◆ osp_param_name()

const char* osp_param_name ( const osp_param_t param)

Get an OSP parameter's name.

Parameters
[in]paramOSP parameter.
Returns
Name of OSP parameter.

◆ osp_param_new()

osp_param_t* osp_param_new ( void  )

Create a new OSP parameter.

Returns
New OSP parameter.

◆ osp_param_str_to_type()

static osp_param_type_t osp_param_str_to_type ( const char *  str)
static

Get an OSP parameter's type from its string format.

Parameters
[in]strOSP parameter in string format.
Returns
OSP parameter type.

◆ osp_param_type_str()

const char* osp_param_type_str ( const osp_param_t param)

Get an OSP parameter in string format form its type.

Parameters
[in]paramOSP parameter.
Returns
OSP parameter in string format.

◆ osp_send_command()

int osp_send_command ( osp_connection_t connection,
entity_t response,
const char *  fmt,
  ... 
)
static

Send a command to an OSP server.

Parameters
[in]connectionConnection to OSP server.
[out]responseResponse from OSP server.
[in]fmtOSP Command to send.
Returns
0 and response, 1 if error.

◆ osp_start_scan()

int osp_start_scan ( osp_connection_t connection,
const char *  target,
const char *  ports,
GHashTable *  options,
const char *  scan_id,
char **  error 
)

Start an OSP scan against a target.

Parameters
[in]connectionConnection to an OSP server.
[in]targetTarget host to scan.
[in]portsList of ports to scan.
[in]optionsTable of scan options.
[in]scan_iduuid to set for scan, null otherwise.
[out]errorPointer to error, if any.
Returns
0 on success, -1 otherwise.

◆ osp_stop_scan()

int osp_stop_scan ( osp_connection_t connection,
const char *  scan_id,
char **  error 
)

Stop a scan on an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to delete.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.