[Previous] [Contents] [Index] [Next]

snmp_pdu

Structure that describes an SNMP transaction

Synopsis:

#include <snmp/snmp_api.h>

struct snmp_pdu {
    int version;
    ipaddr address;
    oid * srcParty;
    int srcPartyLen;
    oid * dstParty;
    int dstPartyLen;
    oid * context;
    int contextLen;
    u_char * community;
    int community_len;
    int command;
    long reqid;
    long errstat;
    long errindex;

    /* Trap information */
    oid * enterprise;
    int enterprise_length;
    ipaddr agent_addr;
    int trap_type;
    int specific_type;
    u_long time;

    struct variable_list * variables;
};

Description:

The snmp_pdu structure describes a Protocol Data Unit (PDU), a transaction that's performed over an open session. It contains the headers and variables of an SNMP packet. The structure includes the following members:

version
The version of SNMP: either SNMP_VERSION_1 or SNMP_VERSION_2.
address
Destination IP address.
srcParty
Source party being used.
srcPartyLen
Number of object identifier (OID) elements in srcParty. For example, if srcParty is .1.3.6, the length is 3.
dstParty
The destination party being used.
dstPartyLen
Number of OID elements in dstParty.
context
The context being used.
contextLen
Number of OID elements in context.
community
Community for outgoing requests.
community_len
Length of community name.
command
Type of this PDU.
reqid
Request ID. The default is SNMP_DEFAULT_REQID (0).
errstat
Error status (non_repeaters in GetBulk). The default is SNMP_DEFAULT_ERRSTAT (-1).
errindex
Error index (max_repetitions in GetBulk). The default is SNMP_DEFAULT_ERRINDEX (-1).
enterprise
System OID.
enterprise_length
Number of OID elements in enterprise. The default is SNMP_DEFAULT_ENTERPRISE_LENGTH (0).
agent_addr
Address of the object generating the trap.
trap_type
Trap type
specific_type
Specific type.
time
Uptime. The default is SNMP_DEFAULT_TIME (0).
variables
Linked list of variables, of type variable_list.

The variable_list structure is defined as:

typedef    struct    sockaddr_in ipaddr;

struct variable_list {
    struct variable_list* next_variable;
    oid*       name;
    int        name_length;
    u_char     type;
    union { 
        long*     integer;
        u_char*   string;
        oid*      objid;
        u_char*   bitstring;
        struct counter64* counter64;
    } val;
    int        val_len;
};

The members are:

next_variable
A pointer to the next variable. This is NULL for the last variable in the list.
name
Object identifier of the variable.
name_length
Number of sub IDs in name.
type
ASN type of variable.
val.integer
Value of the variable if it's an integer.
val.string
Value of the variable if it's a string.
val.objid
Value of the variable if it's an object ID.
bitstring
Value of the variable if it's a bitstring.
counter64
Value of the variable if it's a counter64.
val_len
Length of the value.

Classification:

SNMP

See also:

<snmp_api.h>, snmp_close(), snmp_free_pdu(), snmp_open(), snmp_send(), snmp_session

RFC 1157, FAQ in Internet newsgroup comp.protocols.snmp

Marshall T. Rose, The Simple Book: An Introduction to Internet Management, Revised 2nd ed. (Prentice-Hall, 1996, ISBN 0-13-451659-1)


[Previous] [Contents] [Index] [Next]