SNMP Manager Programmer's Guide

Encoding and Decoding Packets
SNMP Manager Programmer’s Guide–134249
6-9
EBufferInitialize()
This function is useful when you need to save buffers, as when your manager handles
multiple request or trap packets and you want to use previously encoded buffers in the
event a retry operation is indicated. An example of this function is:
EBUFFER_T buffsrc;
EBUFFER_T buffdup1;
rcode = EBufferClone(&buffsrc, &buffdup1);
EBufferInitialize()
This function initializes the buffer descriptors of an EBUFFER_T buffer to zero. Use
this function to initialize your encoded-packet buffer if you do not allocate memory for
the buffer before calling an encoding function.
buffer
a pointer to the descriptor structure for the buffer you want initialized.
The sample manager SNMPGT calls EBufferInitialize() before calling
SNMP_Encode_Packet(), which BER-encodes the packet in send_pkt into the buffer
described by ebuff after dynamically allocating the required memory and setting the
values of the buffer descriptors as follows:
SNMP_PKT_T *send_pkt;
EBUFFER_T ebuff;
EBufferInitialize(&ebuff):
rcode = SNMP_Encode_Packet(send_pkt, &ebuff);
EBufferNext()
This function returns the value of next_bp, the descriptor that points to the next unused
byte in an EBUFFER_T buffer.
EBufferInitialize(buffer);
void EBufferInitialize(EBUFFER_T *buffer);
nxt-ptr = EBufferNext(buffer);
OCTET_T* EbufferNext(EBUFFER_T *buffer);
207
ebuff
start_bp
next_bp
remaining