net-snmp 5.7
Data Structures | Modules | Defines | Functions | Variables
The Net-SNMP library

Data Structures

struct  snmp_internal_session

Modules

 asn1 parsing and datatype manipulation routines.
 

Note on.


 A generic callback mechanism
 generic linked-list data handling with a string as a key.
 storage space for defaults
 

The purpose of the default storage is three-fold:


 mib parsing and datatype manipulation routines.
 Store and retrieve data referenced by an OID.
 

This is essentially a way of storing data associated with a given OID.


 parsing various configuration files at run time
 

The read_config related functions are a fairly extensible system of parsing various configuration files at the run time.


 generic library based alarm timers for various parts of an application
 various PDU processing routines
 generic logging for net-snmp
 Memory Utility Routines

Defines

#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
#define MIB_CLIENTS_ARE_EVIL   1
#define _init_agent_callback_transport()
#define SNMP_NEED_REQUEST_LIST
#define DEFAULT_COMMUNITY   "public"
#define DEFAULT_RETRIES   5
#define DEFAULT_TIMEOUT   ONE_SEC
#define DEFAULT_REMPORT   SNMP_PORT
#define DEFAULT_ENTERPRISE   default_enterprise
#define DEFAULT_TIME   0
#define MAXIMUM_PACKET_SIZE   0x7fffffff
#define DEBUGPRINTPDUTYPE(token, type)   DEBUGDUMPSECTION(token, snmp_pdu_type(type))
#define ERROR_STAT_LENGTH   11

Functions

int init_agent (const char *app)
 Initialize the agent.
void shutdown_agent (void)
void add_to_init_list (char *module_list)
int should_init (const char *module_name)
 netsnmp_feature_child_of (statistics, libnetsnmp)
int snmp_build (u_char **pkt, size_t *pkt_len, size_t *offset, netsnmp_session *pss, netsnmp_pdu *pdu)
int snmp_get_errno (void)
NETSNMP_IMPORT void snmp_synch_reset (netsnmp_session *notused)
NETSNMP_IMPORT void snmp_synch_setup (netsnmp_session *notused)
const char * strerror (int err)
const char * snmp_pdu_type (int type)
long snmp_get_next_reqid (void)
long snmp_get_next_msgid (void)
long snmp_get_next_sessid (void)
long snmp_get_next_transid (void)
void snmp_perror (const char *prog_string)
void snmp_set_detail (const char *detail_string)
const char * snmp_api_errstring (int snmp_errnumber)
void snmp_error (netsnmp_session *psess, int *p_errno, int *p_snmp_errno, char **p_str)
 Library API routines concerned with logging and message output (including error handling and debugging).
void snmp_sess_error (void *sessp, int *p_errno, int *p_snmp_errno, char **p_str)
void netsnmp_sess_log_error (int priority, const char *prog_string, netsnmp_session *ss)
void snmp_sess_perror (const char *prog_string, netsnmp_session *ss)
void snmp_sess_init (netsnmp_session *session)
 Library API routines concerned with specifying and using SNMP "sessions" including sending and receiving requests.
void init_snmp (const char *type)
 Calls the functions to do config file loading and mib module parsing in the correct order.
void snmp_store_needed (const char *type)
 set a flag indicating that the persistent store needs to be saved.
void snmp_store_if_needed (void)
void snmp_store (const char *type)
void snmp_shutdown (const char *type)
 Shuts down the application, saving any needed persistent storage, and appropriate clean up.
netsnmp_sessionsnmp_open (netsnmp_session *session)
 netsnmp_feature_child_of (snmp_open_ex, netsnmp_unused)
int snmpv3_probe_contextEngineID_rfc5343 (void *slp, netsnmp_session *session)
 probe for engineID using RFC 5343 probing mechanisms
int snmpv3_engineID_probe (struct session_list *slp, netsnmp_session *in_session)
 probe for peer engineID
int netsnmp_sess_config_transport (netsnmp_container *transport_configuration, netsnmp_transport *transport)
int netsnmp_sess_config_and_open_transport (netsnmp_session *in_session, netsnmp_transport *transport)
 Copies configuration from the session and calls f_open This function copies any configuration stored in the session pointer to the transport if it has a f_config pointer and then calls the transport's f_open function to actually open the connection.
netsnmp_sessionsnmp_add (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int))
netsnmp_sessionsnmp_add_full (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fparse)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int), int(*fbuild)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t *), int(*frbuild)(netsnmp_session *, netsnmp_pdu *, u_char **, size_t *, size_t *), int(*fcheck)(u_char *, size_t), netsnmp_pdu *(*fcreate_pdu)(netsnmp_transport *, void *, size_t))
void * snmp_sess_add_ex (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fparse)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int), int(*fbuild)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t *), int(*frbuild)(netsnmp_session *, netsnmp_pdu *, u_char **, size_t *, size_t *), int(*fcheck)(u_char *, size_t), netsnmp_pdu *(*fcreate_pdu)(netsnmp_transport *, void *, size_t))
void * snmp_sess_add (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int))
void * snmp_sess_open (netsnmp_session *pss)
int create_user_from_session (netsnmp_session *session)
int snmp_sess_close (void *sessp)
int snmp_close (netsnmp_session *session)
int snmp_close_sessions (void)
int snmpv3_packet_build (netsnmp_session *session, netsnmp_pdu *pdu, u_char *packet, size_t *out_length, u_char *pdu_data, size_t pdu_data_len)
u_char * snmp_pdu_build (netsnmp_pdu *pdu, u_char *cp, size_t *out_length)
int snmpv3_parse (netsnmp_pdu *pdu, u_char *data, size_t *length, u_char **after_header, netsnmp_session *sess)
int snmpv3_make_report (netsnmp_pdu *pdu, int error)
int snmpv3_get_report_type (netsnmp_pdu *pdu)
int snmp_pdu_parse (netsnmp_pdu *pdu, u_char *data, size_t *length)
u_char * snmpv3_scopedPDU_parse (netsnmp_pdu *pdu, u_char *cp, size_t *length)
int snmp_send (netsnmp_session *session, netsnmp_pdu *pdu)
int snmp_sess_send (void *sessp, netsnmp_pdu *pdu)
int snmp_async_send (netsnmp_session *session, netsnmp_pdu *pdu, snmp_callback callback, void *cb_data)
int snmp_sess_async_send (void *sessp, netsnmp_pdu *pdu, snmp_callback callback, void *cb_data)
void snmp_free_var_internals (netsnmp_variable_list *var)
void snmp_free_var (netsnmp_variable_list *var)
void snmp_free_varbind (netsnmp_variable_list *var)
void snmp_free_pdu (netsnmp_pdu *pdu)
netsnmp_pdusnmp_create_sess_pdu (netsnmp_transport *transport, void *opaque, size_t olength)
void snmp_read (fd_set *fdset)
void snmp_read2 (netsnmp_large_fd_set *fdset)
int _sess_read (void *sessp, netsnmp_large_fd_set *fdset)
int snmp_sess_read (void *sessp, fd_set *fdset)
int snmp_sess_read2 (void *sessp, netsnmp_large_fd_set *fdset)
int snmp_select_info (int *numfds, fd_set *fdset, struct timeval *timeout, int *block)
int snmp_select_info2 (int *numfds, netsnmp_large_fd_set *fdset, struct timeval *timeout, int *block)
int snmp_sess_select_info (void *sessp, int *numfds, fd_set *fdset, struct timeval *timeout, int *block)
int snmp_sess_select_info_flags (void *sessp, int *numfds, fd_set *fdset, struct timeval *timeout, int *block, int flags)
int snmp_sess_select_info2 (void *sessp, int *numfds, netsnmp_large_fd_set *fdset, struct timeval *timeout, int *block)
int snmp_sess_select_info2_flags (void *sessp, int *numfds, netsnmp_large_fd_set *fdset, struct timeval *timeout, int *block, int flags)
void snmp_timeout (void)
void snmp_sess_timeout (void *sessp)
int snmp_oid_ncompare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2, size_t max_len)
int snmp_oid_compare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)
 lexicographical compare two object identifiers.
int netsnmp_oid_compare_ll (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2, size_t *offpt)
 lexicographical compare two object identifiers and return the point where they differ
int snmp_oidtree_compare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)
 Compares 2 OIDs to determine if they are equal up until the shortest length.
int snmp_oidsubtree_compare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)
int netsnmp_oid_equals (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)
 Compares 2 OIDs to determine if they are exactly equal.
int netsnmp_oid_is_subtree (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)
 Identical to netsnmp_oid_equals, except only the length up to len1 is compared.
int netsnmp_oid_find_prefix (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)
 Given two OIDs, determine the common prefix to them both.
netsnmp_variable_listsnmp_pdu_add_variable (netsnmp_pdu *pdu, const oid *name, size_t name_length, u_char type, const void *value, size_t len)
 Library API routines concerned with variable bindings and values.
netsnmp_variable_listsnmp_varlist_add_variable (netsnmp_variable_list **varlist, const oid *name, size_t name_length, u_char type, const void *value, size_t len)
int snmp_add_var (netsnmp_pdu *pdu, const oid *name, size_t name_length, char type, const char *value)
void * snmp_sess_pointer (netsnmp_session *session)
netsnmp_sessionsnmp_sess_session (void *sessp)
netsnmp_sessionsnmp_sess_session_lookup (void *sessp)
 Look up a session that already may have been closed.
netsnmp_transportsnmp_sess_transport (void *sessp)
void snmp_sess_transport_set (void *sp, netsnmp_transport *t)
oid * snmp_duplicate_objid (const oid *objToCopy, size_t objToCopyLen)
u_int snmp_increment_statistic (int which)
u_int snmp_increment_statistic_by (int which, int count)
u_int snmp_get_statistic (int which)
void snmp_init_statistics (void)

Variables

struct module_init_listinitlist = NULL
struct module_init_listnoinitlist = NULL
netsnmp_subtreesubtrees
long long_return
u_char return_buf [258]
int callback_master_num = -1
oid nullOid [] = { 0, 0 }
int nullOidLen = sizeof(nullOid)
struct session_listSessions = NULL
int snmp_errno = 0

Function Documentation

int _sess_read ( void *  sessp,
netsnmp_large_fd_set fdset 
)

XXX-rks: why no SNMP_FREE(isp->packet); ??

XXX-rks: why no SNMP_FREE(isp->packet); ??

Definition at line 5482 of file snmp_api.c.

int init_agent ( const char *  app)

Initialize the agent.

Calls into init_agent_read_config to set tha app's configuration file in the appropriate default storage space, NETSNMP_DS_LIB_APPTYPE. Need to call init_agent before calling init_snmp.

Parameters:
appthe configuration file to be read in, gets stored in default storage
Returns:
Returns non-zero on failure and zero on success.
See also:
init_snmp

Definition at line 270 of file snmp_vars.c.

void init_snmp ( const char *  type)

Calls the functions to do config file loading and mib module parsing in the correct order.

Parameters:
typelabel for the config file "type"
Returns:
void
See also:
init_agent

Definition at line 803 of file snmp_api.c.

int netsnmp_oid_compare_ll ( const oid *  in_name1,
size_t  len1,
const oid *  in_name2,
size_t  len2,
size_t *  offpt 
)

lexicographical compare two object identifiers and return the point where they differ

Caution: this method is called often by command responder applications (ie, agent).

Returns:
-1 if name1 < name2, 0 if name1 = name2, 1 if name1 > name2 and offpt = len where name1 != name2

Definition at line 6478 of file snmp_api.c.

int netsnmp_oid_equals ( const oid *  in_name1,
size_t  len1,
const oid *  in_name2,
size_t  len2 
)

Compares 2 OIDs to determine if they are exactly equal.

This should be faster than doing a snmp_oid_compare for different length OIDs, since the length is checked first and if != returns immediately. Might be very slighly faster if lengths are ==.

Parameters:
in_name1A pointer to the first oid.
len1length of the first OID (in segments, not bytes)
in_name2A pointer to the second oid.
len2length of the second OID (in segments, not bytes)
Returns:
0 if they are equal, 1 if they are not.

Definition at line 6559 of file snmp_api.c.

int netsnmp_oid_find_prefix ( const oid *  in_name1,
size_t  len1,
const oid *  in_name2,
size_t  len2 
)

Given two OIDs, determine the common prefix to them both.

Parameters:
in_name1A pointer to the first oid.
len1Length of the first oid.
in_name2A pointer to the second oid.
len2Length of the second oid.
Returns:
length of common prefix 0 if no common prefix, -1 on error.

Definition at line 6625 of file snmp_api.c.

int netsnmp_oid_is_subtree ( const oid *  in_name1,
size_t  len1,
const oid *  in_name2,
size_t  len2 
)

Identical to netsnmp_oid_equals, except only the length up to len1 is compared.

Functionally, this determines if in_name2 is equal or a subtree of in_name1

Parameters:
in_name1A pointer to the first oid.
len1length of the first OID (in segments, not bytes)
in_name2A pointer to the second oid.
len2length of the second OID (in segments, not bytes)
Returns:
0 if one is a common prefix of the other.

Definition at line 6603 of file snmp_api.c.

int netsnmp_sess_config_and_open_transport ( netsnmp_session in_session,
netsnmp_transport transport 
)

Copies configuration from the session and calls f_open This function copies any configuration stored in the session pointer to the transport if it has a f_config pointer and then calls the transport's f_open function to actually open the connection.

Parameters:
in_sessionA pointer to the session that config information is in.
transportA pointer to the transport to config/open.
Returns:
SNMPERR_SUCCESS : on success

Definition at line 1476 of file snmp_api.c.

void snmp_error ( netsnmp_session psess,
int *  p_errno,
int *  p_snmp_errno,
char **  p_str 
)

Library API routines concerned with logging and message output (including error handling and debugging).

Definition at line 550 of file snmp_api.c.

int snmp_oid_compare ( const oid *  in_name1,
size_t  len1,
const oid *  in_name2,
size_t  len2 
)

lexicographical compare two object identifiers.

Caution: this method is called often by command responder applications (ie, agent).

Returns:
-1 if name1 < name2, 0 if name1 = name2, 1 if name1 > name2

Definition at line 6429 of file snmp_api.c.

int snmp_oidtree_compare ( const oid *  in_name1,
size_t  len1,
const oid *  in_name2,
size_t  len2 
)

Compares 2 OIDs to determine if they are equal up until the shortest length.

Parameters:
in_name1A pointer to the first oid.
len1length of the first OID (in segments, not bytes)
in_name2A pointer to the second oid.
len2length of the second OID (in segments, not bytes)
Returns:
0 if they are equal, 1 if in_name1 is > in_name2, or -1 if <.

Definition at line 6531 of file snmp_api.c.

netsnmp_variable_list* snmp_pdu_add_variable ( netsnmp_pdu pdu,
const oid *  name,
size_t  name_length,
u_char  type,
const void *  value,
size_t  len 
)

Library API routines concerned with variable bindings and values.

Definition at line 6696 of file snmp_api.c.

void snmp_sess_init ( netsnmp_session session)

Library API routines concerned with specifying and using SNMP "sessions" including sending and receiving requests.

Definition at line 721 of file snmp_api.c.

netsnmp_session* snmp_sess_session_lookup ( void *  sessp)

Look up a session that already may have been closed.

Parameters:
sesspOpaque pointer, returned by snmp_sess_open.
Returns:
Pointer to session upon success or NULL upon failure.
See also:
snmp_sess_session()

Definition at line 7289 of file snmp_api.c.

void snmp_shutdown ( const char *  type)

Shuts down the application, saving any needed persistent storage, and appropriate clean up.

Parameters:
typeLabel for the config file "type" used
Returns:
void

Definition at line 900 of file snmp_api.c.

void snmp_store_needed ( const char *  type)

set a flag indicating that the persistent store needs to be saved.

Definition at line 863 of file snmp_api.c.

int snmpv3_engineID_probe ( struct session_list slp,
netsnmp_session in_session 
)

probe for peer engineID

Parameters:
slpsession list pointer.
in_sessionsession for errors
Note:
  • called by _sess_open(), snmp_sess_add_ex()
  • in_session is the user supplied session provided to those functions.
  • the first session in slp should the internal allocated copy of in_session
Returns:
0 : error
1 : ok

Definition at line 1357 of file snmp_api.c.

int snmpv3_probe_contextEngineID_rfc5343 ( void *  slp,
netsnmp_session session 
)

probe for engineID using RFC 5343 probing mechanisms

Designed to be a callback for within a security model's probe_engineid hook. Since it's likely multiple security models won't have engineIDs to probe for then this function is a callback likely to be used by multiple future security models. E.G. both SSH and DTLS.

Definition at line 1259 of file snmp_api.c.