|
OpenVAS Scanner 23.32.3
|
Implementation of an API for SNMP used by NASL scripts. More...
#include "nasl_snmp.h"#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>
Go to the source code of this file.
Data Structures | |
| struct | snmpv1v2_request |
| SNMP Request struct for snmp v1 and v2c. More... | |
| struct | snmpv3_request |
| SNMP Request struct for snmp v3. More... | |
| struct | snmp_result |
Macros | |
| #define | G_LOG_DOMAIN "lib nasl" |
| GLib logging domain. | |
| #define | SNMP_VERSION_1 0 |
| SNMP V1. | |
| #define | SNMP_VERSION_2c 1 |
| SNMP V2c. | |
| #define | FD_STDERR_FLAG 1 |
| #define | FD_STDOUT_FLAG 0 |
| #define | NASL_SNMP_GET 0 |
| #define | NASL_SNMP_GETNEXT 1 |
Typedefs | |
| typedef struct snmpv1v2_request * | snmpv1v2_request_t |
| typedef struct snmpv3_request * | snmpv3_request_t |
| typedef struct snmp_result * | snmp_result_t |
Functions | |
| static void | destroy_snmp_result (snmp_result_t result) |
| static int | proto_is_valid (const char *proto) |
| static tree_cell * | array_from_snmp_result (int ret, const snmp_result_t result) |
| static tree_cell * | array_from_snmp_error (int ret, const char *err) |
| static void | parse_snmp_error (snmp_result_t result) |
| Parse the snmp error. | |
| static int | check_spwan_output (int fd, snmp_result_t result, int fd_flag) |
| Read data from a file descriptor. | |
| static int | snmpv1v2c_get (const snmpv1v2_request_t request, snmp_result_t result) |
| SNMP v1 or v2c Get query value. snmpget cmd wrapper. | |
| static int | snmpv3_get (const snmpv3_request_t request, snmp_result_t result) |
| SNMPv3 Get query value. snmpget cmd wrapper. | |
| static tree_cell * | nasl_snmpv1v2c_get (lex_ctxt *lexic, int version, u_char action) |
| tree_cell * | nasl_snmpv1_get (lex_ctxt *lexic) |
| tree_cell * | nasl_snmpv1_getnext (lex_ctxt *lexic) |
| tree_cell * | nasl_snmpv2c_get (lex_ctxt *lexic) |
| tree_cell * | nasl_snmpv2c_getnext (lex_ctxt *lexic) |
| static tree_cell * | nasl_snmpv3_get_action (lex_ctxt *lexic, u_char action) |
| tree_cell * | nasl_snmpv3_get (lex_ctxt *lexic) |
| tree_cell * | nasl_snmpv3_getnext (lex_ctxt *lexic) |
Implementation of an API for SNMP used by NASL scripts.
Definition in file nasl_snmp.c.
| #define FD_STDERR_FLAG 1 |
Definition at line 40 of file nasl_snmp.c.
Referenced by snmpv1v2c_get(), and snmpv3_get().
| #define FD_STDOUT_FLAG 0 |
Definition at line 41 of file nasl_snmp.c.
Referenced by check_spwan_output(), snmpv1v2c_get(), and snmpv3_get().
| #define G_LOG_DOMAIN "lib nasl" |
GLib logging domain.
Definition at line 28 of file nasl_snmp.c.
| #define NASL_SNMP_GET 0 |
Definition at line 358 of file nasl_snmp.c.
Referenced by nasl_snmpv1_get(), nasl_snmpv2c_get(), nasl_snmpv3_get(), snmpv1v2c_get(), and snmpv3_get().
| #define NASL_SNMP_GETNEXT 1 |
Definition at line 359 of file nasl_snmp.c.
Referenced by nasl_snmpv1_getnext(), nasl_snmpv1v2c_get(), nasl_snmpv2c_getnext(), nasl_snmpv3_get_action(), nasl_snmpv3_getnext(), and snmpv1v2c_get().
| #define SNMP_VERSION_1 0 |
SNMP V1.
Definition at line 33 of file nasl_snmp.c.
Referenced by nasl_snmpv1_get(), nasl_snmpv1_getnext(), and snmpv1v2c_get().
| #define SNMP_VERSION_2c 1 |
SNMP V2c.
Definition at line 38 of file nasl_snmp.c.
Referenced by nasl_snmpv2c_get(), nasl_snmpv2c_getnext(), and snmpv1v2c_get().
| typedef struct snmp_result* snmp_result_t |
Definition at line 80 of file nasl_snmp.c.
| typedef struct snmpv1v2_request* snmpv1v2_request_t |
Definition at line 55 of file nasl_snmp.c.
| typedef struct snmpv3_request* snmpv3_request_t |
Definition at line 72 of file nasl_snmp.c.
|
static |
Definition at line 150 of file nasl_snmp.c.
References add_var_to_list(), alloc_typed_cell(), DYN_ARRAY, TC::ref_val, st_nasl_string::s_siz, st_nasl_string::s_val, st_a_nasl_var::v, st_a_nasl_var::v_int, st_a_nasl_var::v_str, VAR2_INT, VAR2_STRING, st_a_nasl_var::var_type, and TC::x.
Referenced by nasl_snmpv1v2c_get(), and nasl_snmpv3_get_action().


|
static |
Definition at line 117 of file nasl_snmp.c.
References add_var_to_list(), alloc_typed_cell(), DYN_ARRAY, snmp_result::name, snmp_result::oid_str, TC::ref_val, st_nasl_string::s_siz, st_nasl_string::s_val, st_a_nasl_var::v, st_a_nasl_var::v_int, st_a_nasl_var::v_str, VAR2_INT, VAR2_STRING, st_a_nasl_var::var_type, and TC::x.
Referenced by nasl_snmpv1v2c_get(), and nasl_snmpv3_get_action().


|
static |
Read data from a file descriptor.
| fd[in] | File descriptor to read from. |
| result[out] | String to write to. |
Definition at line 414 of file nasl_snmp.c.
References FD_STDOUT_FLAG, snmp_result::name, and snmp_result::oid_str.
Referenced by snmpv1v2c_get(), and snmpv3_get().

|
static |
Definition at line 83 of file nasl_snmp.c.
References snmp_result::name, and snmp_result::oid_str.
Referenced by nasl_snmpv1v2c_get(), and nasl_snmpv3_get_action().

Definition at line 703 of file nasl_snmp.c.
References NASL_SNMP_GET, nasl_snmpv1v2c_get(), and SNMP_VERSION_1.

Definition at line 709 of file nasl_snmp.c.
References NASL_SNMP_GETNEXT, nasl_snmpv1v2c_get(), and SNMP_VERSION_1.

Definition at line 633 of file nasl_snmp.c.
References snmpv1v2_request::action, array_from_snmp_error(), array_from_snmp_result(), snmpv1v2_request::community, destroy_snmp_result(), get_int_var_by_name(), get_str_var_by_name(), NASL_SNMP_GETNEXT, snmp_result::oid_str, snmpv1v2_request::oid_str, snmpv1v2_request::peername, plug_get_host_ip_str(), proto_is_valid(), struct_lex_ctxt::script_infos, snmpv1v2c_get(), and snmpv1v2_request::version.
Referenced by nasl_snmpv1_get(), nasl_snmpv1_getnext(), nasl_snmpv2c_get(), and nasl_snmpv2c_getnext().


Definition at line 715 of file nasl_snmp.c.
References NASL_SNMP_GET, nasl_snmpv1v2c_get(), and SNMP_VERSION_2c.

Definition at line 721 of file nasl_snmp.c.
References NASL_SNMP_GETNEXT, nasl_snmpv1v2c_get(), and SNMP_VERSION_2c.

Definition at line 832 of file nasl_snmp.c.
References NASL_SNMP_GET, and nasl_snmpv3_get_action().

Definition at line 727 of file nasl_snmp.c.
References snmpv3_request::action, array_from_snmp_error(), array_from_snmp_result(), snmpv3_request::authpass, snmpv3_request::authproto, destroy_snmp_result(), get_int_var_by_name(), get_str_var_by_name(), NASL_SNMP_GETNEXT, snmp_result::oid_str, snmpv3_request::oid_str, snmpv3_request::peername, plug_get_host_ip_str(), snmpv3_request::privpass, snmpv3_request::privproto, proto_is_valid(), struct_lex_ctxt::script_infos, snmpv3_get(), and snmpv3_request::username.
Referenced by nasl_snmpv3_get(), and nasl_snmpv3_getnext().


Definition at line 838 of file nasl_snmp.c.
References NASL_SNMP_GETNEXT, and nasl_snmpv3_get_action().

|
static |
Parse the snmp error.
| result[in,out] | The result error to be parsed. |
Definition at line 367 of file nasl_snmp.c.
References snmp_result::name.
Referenced by snmpv1v2c_get(), and snmpv3_get().

|
static |
Definition at line 100 of file nasl_snmp.c.
Referenced by nasl_snmpv1v2c_get(), and nasl_snmpv3_get_action().

|
static |
SNMP v1 or v2c Get query value. snmpget cmd wrapper.
param[in] request Contains all necessary information for SNMPv1 or SNMPv2 query. param[out] result Result of query.
Definition at line 466 of file nasl_snmp.c.
References snmpv1v2_request::action, check_spwan_output(), snmpv1v2_request::community, FD_STDERR_FLAG, FD_STDOUT_FLAG, snmp_result::name, NASL_SNMP_GET, NASL_SNMP_GETNEXT, snmpv1v2_request::oid_str, parse_snmp_error(), snmpv1v2_request::peername, SNMP_VERSION_1, SNMP_VERSION_2c, and snmpv1v2_request::version.
Referenced by nasl_snmpv1v2c_get().


|
static |
SNMPv3 Get query value. snmpget cmd wrapper.
param[in] request Contains all necessary information for SNMPv3 query. param[out] result Result of query.
Definition at line 544 of file nasl_snmp.c.
References snmpv3_request::action, snmpv3_request::authpass, snmpv3_request::authproto, check_spwan_output(), FD_STDERR_FLAG, FD_STDOUT_FLAG, snmp_result::name, NASL_SNMP_GET, snmpv3_request::oid_str, parse_snmp_error(), snmpv3_request::peername, snmpv3_request::privpass, snmpv3_request::privproto, and snmpv3_request::username.
Referenced by nasl_snmpv3_get_action().

