SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-36
Common Utility Functions
typedef struct OBJ_ID_S
{int num_components;
OIDC_T *component_list;
} OBJ_ID_T;
Refer to Section 4, Using Header Files, Data Structures, and Defines, for more
information on OBJ_ID_T.
print_pkt()
The print_pkt() function prints the contents of an unencoded-packet buffer of type
SNMP_PKT_T.
packet
is a pointer to an unencoded-packet buffer of type SNMP_PKT_T, defined in
snmpdefs.h and assigned values by previous Manager Services library calls.
Request packets are constructed using SNMP_Create_Request() or
SNMP_Create_Trap(), and SNMP_Bind_() functions. Response or trap packets are
constructed when you call SNMP_Decode_packet_WER(). Section 4, Using
Header Files, Data Structures, and Defines, describes SNMP_PKT_T in detail.
Section 5, Constructing and Interpreting Packets, and Section 6, Encoding and
Decoding Packets, describe the packet-handling functions.
Here is an example of the output this function generates; the packet being described
contains a Get PDU:
Packet Length=69, Version=0, Community: Length=6, Value=public
PDU Type=get-request Length=69, RQ_ID=1, Err_stat=noError, Err_ndx=0
VBLlen=43, VBcount=1
VarBind #0, content size=43, Flags & type=0x05, encoded length=5
OBJECT IDENTIFIER: sysDescr.0
NULL
The fields provide information about the contents and format of the packet:
#include "printh"
print_pkt(packet);
void
print_pkt(SNMP_PKT_T *);
Packet Length The number of bytes in the packet.
Version The SNMP version being used. The value 0 indicates support of
SNMP version 1.
Community The number of bytes in the community string and its value.
PDU Type The kind of PDU in the packet.
Length The number of bytes in the PDU.
RQ_ID The identifier distinguishing the request.