OpenVAS Scanner  21.4.1
Macros | Functions
nasl_snmp.c File Reference

Implementation of an API for SNMP used by NASL scripts. More...

#include "../misc/plugutils.h"
#include "nasl_lex_ctxt.h"
#include <assert.h>
#include <errno.h>
#include <gvm/base/logging.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Macros

#define SNMP_VERSION_1   0
 
#define SNMP_VERSION_2c   1
 

Functions

static int proto_is_valid (const char *proto)
 
static tree_cellarray_from_snmp_result (int ret, char *result)
 
static void parse_snmp_error (char **result)
 Parse the snmp error. More...
 
static int check_spwan_output (int fd, char **result)
 Read data from a file descriptor. More...
 
static int snmpv1v2c_get (const char *peername, const char *community, const char *oid_str, int version, char **result)
 SNMP v1 or v2c Get query value. More...
 
static int snmpv3_get (const char *peername, const char *username, const char *authpass, int authproto, const char *privpass, int privproto, const char *oid_str, char **result)
 SNMPv3 Get query value. More...
 
tree_cellnasl_snmpv1v2c_get (lex_ctxt *lexic, int version)
 
tree_cellnasl_snmpv1_get (lex_ctxt *lexic)
 
tree_cellnasl_snmpv2c_get (lex_ctxt *lexic)
 
tree_cellnasl_snmpv3_get (lex_ctxt *lexic)
 

Detailed Description

Implementation of an API for SNMP used by NASL scripts.

Macro Definition Documentation

◆ SNMP_VERSION_1

#define SNMP_VERSION_1   0

◆ SNMP_VERSION_2c

#define SNMP_VERSION_2c   1

Function Documentation

◆ array_from_snmp_result()

static tree_cell* array_from_snmp_result ( int  ret,
char *  result 
)
static

◆ check_spwan_output()

static int check_spwan_output ( int  fd,
char **  result 
)
static

Read data from a file descriptor.

Parameters
fd[in]File descriptor to read from.
result[out]String to write to.
Returns
0 success, -1 read error.

◆ nasl_snmpv1_get()

tree_cell* nasl_snmpv1_get ( lex_ctxt lexic)

◆ nasl_snmpv1v2c_get()

tree_cell* nasl_snmpv1v2c_get ( lex_ctxt lexic,
int  version 
)

◆ nasl_snmpv2c_get()

tree_cell* nasl_snmpv2c_get ( lex_ctxt lexic)

◆ nasl_snmpv3_get()

tree_cell* nasl_snmpv3_get ( lex_ctxt lexic)

◆ parse_snmp_error()

static void parse_snmp_error ( char **  result)
static

Parse the snmp error.

Parameters
result[in,out]The result error to be parsed.

◆ proto_is_valid()

static int proto_is_valid ( const char *  proto)
static

◆ snmpv1v2c_get()

static int snmpv1v2c_get ( const char *  peername,
const char *  community,
const char *  oid_str,
int  version,
char **  result 
)
static

SNMP v1 or v2c Get query value.

param[in] peername Target host in [protocol:]address[:port] format. param[in] community SNMP community string. param[in] oid_str OID string of value to get. param[in] version SNMP_VERSION_1 or SNMP_VERSION_2c. param[out] result Result of query.

Returns
0 if success and result value, -1 otherwise.

◆ snmpv3_get()

static int snmpv3_get ( const char *  peername,
const char *  username,
const char *  authpass,
int  authproto,
const char *  privpass,
int  privproto,
const char *  oid_str,
char **  result 
)
static

SNMPv3 Get query value.

param[in] peername Target host in [protocol:]address[:port] format. param[in] username Username value. param[in] authpass Authentication password. param[in] authproto Authentication protocol. 0 for md5, 1 for sha1. param[in] privpass Privacy password. param[in] privproto Privacy protocol. 0 for des, 1 for aes. param[in] oid_str OID of value to get. param[out] result Result of query.

Returns
0 if success and result value, -1 otherwise.