structure that describes an SNMP transaction
#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;
};
The snmp_pdu structure describes a
Protocol Data Unit (PDU), a transaction that will be
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
- The source party being used.
- srcPartyLen
- The 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
- The number of OID elements in dstParty.
- context
- The context being used.
- contextLen
- The number of OID elements in context.
- community
- Community for outgoing requests.
- community_len
- Length of community name.
- command
- Type of this PDU.
- reqid
- The 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
- The 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
- A 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
- The object identifier of the variable.
- name_length
- The number of sub IDs in name.
- type
- ASN type of variable.
- val.integer
- The value of the variable if it's an integer.
- val.string
- The value of the variable if it's a string.
- val.objid
- The value of the variable if it's an object ID.
- bitstring
- The value of the variable if it's a bitstring.
- counter64
- The value of the variable if it's a counter64.
- val_len
- The length of the value.
SNMP
<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)