SNMP_PDU(3)SNMP_PDU(3)NAME
snmp_pdu_create, snmp_pdu_clone, snmp_pdu_fix, snmp_pdu_free,
snmp_pdu_encode, snmp_pdu_decode, snmp_pdu_type, snmp_add_null_var -
SNMP PDU Operations
SYNOPSIS
cc [ flag ... ] file ... -lsnmp [ library ... ]
#include <sys/types.h>
#include <snmp/snmp.h>
struct snmp_pdu *snmp_pdu_new(int Command);
struct snmp_pdu *snmp_pdu_clone(struct snmp_pdu * Src);
struct snmp_pdu *snmp_pdu_fix(struct snmp_pdu * Src intcommand);
void snmp_pdu_free(struct snmp_pdu * Ptr);
u_char *snmp_pdu_encode(u_char * Buf, int * BufLenP, struct snmp_pdu *
PDU);
u_char *snmp_pdu_decode(u_char * Buf, int * BufLenP, struct snmp_pdu **
PDUP);
void snmp_add_null_var(struct snmp_pdu * PDU, oid * OID, int OIDLen);
STRUCTURE
The snmp_pdu structure is:
int command; /∗ Type of this PDU ∗/
ipaddr address; /∗ Address of peer ∗/
int reqid; /∗ Request id ∗/
int errstat; /∗ Error status ∗/
int errindex; /∗ Error index ∗/
struct variable_list *variables;/∗ Variable Bindings ∗/
/∗ SNMPv2 Bulk Request information ∗/
int non_repeaters;
int max_repetitions;
/∗ SNMPv1 Trap Information ∗/
oid *enterprise;/∗ System OID ∗/
int enterprise_length;/∗ System OID Length ∗/
ipaddr agent_addr;/∗ address of object generating trap ∗/
int trap_type;/∗ generic trap type ∗/
int specific_type;/∗ specific type ∗/
u_int time; /∗ Uptime ∗/
DESCRIPTIONsnmp_pdu_new() creates a new snmp_pdu structure representing the SNMP
command command.
snmp_pdu_clone() copies the snmp_pdu structure pointed to by Src. If
the variable_list pointer is filled in, it is copied as well, so both
the original and the clone point to the same variable_list.
snmp_pdu_free() frees the snmp_pdu pointed to by Ptr, as well as all
variables associated with it. This function is identical to
snmp_free_pdu(),whichisincludedforbackwardscompatibility.
snmp_pdu_encode() and snmp_pdu_decode() encode and decode the snmp_pdu
structure into/out of the buffer pointed to by Buf. BufLenP points to
the length of space remaining in Buf. Upon successful completion,
these functions return a pointer to the next available byte in Buf and
adjusts BufLenP to reflect the amount of space left in the buffer after
the encoding / decoding.
snmp_pdu_fix() This functions fixes a PDU by removing the variable
binding that was incorrect, according to the error index. This func‐
tion is identical to snmp_fix_pdu(),whichisincludedforbackwardscompati‐
bility.
snmp_pdu_type() This function returns a string describing the type of
PDU pointed to by PDU.
snmp_add_null_var() Adds a NULL variable with object identifier OID to
the specified PDU.
RETURN VALUES
Upon error, all functions (except snmp_pdu_free() and
snmp_add_null_var()) return NULL. Otherwise, the return value is as
describe above.
ERRORS
If any of these return unsuccessfully, snmp_api_error() will be set.
NOTES
ASN parsing errors are counted and available via snmpInASNParseErrs(3).
RFCS
Related RFCs: 1065, 1066, 1067
Related SNMPv2 RFCs: 1901, 1902, 1902, 1904, 1905, 1906, 1907, 1908,
1909
RELATED URLS
CMU Networking Group: http://www.net.cmu.edu/
CMU SNMP Home Page: http://www.net.cmu.edu/projects/snmp
SEE ALSOsnmp_api(3), snmp_api_errors(3), snmp_client(3), snmp_coexistance(3),
snmp_error(3), snmp_extra(3), snmp_mib(3), snmp_mibii(3),
snmp_mini_client(3), snmp_msg(3), snmp_packet_dump(3), snmp_pdu(3),
snmp_sess_api(3), snmp_vars(3), snmp_version_info(3), snmp_oid(5)snmp(3)4th Berkeley Distribution Tue Sep 24 11:13:15 2002SNMP_PDU(3)