The Net-SNMP library(3)

NAME
The Net-SNMP library -

  Modules
generic linked-list data handling with a string as a key.
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.

Memory Utility Routines

  Data Structures
struct session_list
struct snmp_internal_session

  Functions
int snmp_oid_compare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)
lexicographical compare two object identifiers.
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 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.

DEFINE DOCUMENTATION

  #define DEBUGPRINTPDUTYPE(token, type)

Value:

switch(type) {       case SNMP_MSG_GET:         DEBUGDUMPSECTION(token, 'PDU-GET');         break;       case SNMP_MSG_GETNEXT:         DEBUGDUMPSECTION(token, 'PDU-GETNEXT');         break;       case SNMP_MSG_RESPONSE:         DEBUGDUMPSECTION(token, 'PDU-RESPONSE');         break;       case SNMP_MSG_SET:         DEBUGDUMPSECTION(token, 'PDU-SET');         break;       case SNMP_MSG_GETBULK:         DEBUGDUMPSECTION(token, 'PDU-GETBULK');         break;       case SNMP_MSG_INFORM:         DEBUGDUMPSECTION(token, 'PDU-INFORM');         break;       case SNMP_MSG_TRAP2:         DEBUGDUMPSECTION(token, 'PDU-TRAP2');         break;       case SNMP_MSG_REPORT:         DEBUGDUMPSECTION(token, 'PDU-REPORT');         break;       default:         DEBUGDUMPSECTION(token, 'PDU-UNKNOWN');         break;     }

Definition at line 364 of file snmp_api.c.

  #define timercmp(tvp, uvp, cmp)

Value:

        ((tvp)->tv_sec cmp (uvp)->tv_sec ||         ((tvp)->tv_sec == (uvp)->tv_sec &&                   (tvp)->tv_usec cmp (uvp)->tv_usec))

Definition at line 135 of file snmp_api.c.

FUNCTION DOCUMENTATION

  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_name1
    A pointer to the first oid.

len1
    length of the first OID (in segments, not bytes)

in_name2
    A pointer to the second oid.

len2
    length of the second OID (in segments, not bytes)

Returns:
0 if they are equal, 1 if they are not.

Definition at line 6067 of file snmp_api.c.

Referenced by netsnmp_old_api_helper().

  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_name1
    A pointer to the first oid.

len1
    Length of the first oid.

in_name2
    A pointer to the second oid.

len2
    Length of the second oid.

Returns:
length of largest common index of commonality. 1 = first, 0 if none * or -1 on error.

Definition at line 6123 of file snmp_api.c.

References SNMP_MIN.

  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_name1
    A pointer to the first oid.

len1
    length of the first OID (in segments, not bytes)

in_name2
    A pointer to the second oid.

len2
    length of the second OID (in segments, not bytes)

Returns:
0 if one is a common prefix of the other.

Definition at line 6103 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 5999 of file snmp_api.c.

Referenced by netsnmp_check_getnext_reply(), netsnmp_row_merge_helper_handler(), netsnmp_table_data_add_row(), netsnmp_table_data_get_from_oid(), netsnmp_table_data_helper_handler(), netsnmp_table_iterator_helper_handler(), snmp_oidtree_compare(), and table_helper_handler().

  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_name1
    A pointer to the first oid.

len1
    length of the first OID (in segments, not bytes)

in_name2
    A pointer to the second oid.

len2
    length 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 6048 of file snmp_api.c.

References snmp_oid_compare().