SNMP Manager Programmer's Guide
Encoding and Decoding Packets
SNMP Manager Programmer’s Guide–134249
6-3
Initializing the Encoded-Packet Buffer Descriptors
Manager Services Memory Allocation
If your manager has not allocated memory when you call SNMP_Encode_Packet() or 
tdm_SNMP_Encode_Packet(), Manager Services dynamically allocates enough memory 
to hold the encoded packet. Before calling one of these encoding functions, however, 
you need to set up the buffer descriptors by calling EBufferInitialize():
EbufferInitialize(&ebuff);
This function sets all the buffer descriptors to zero:
Manager Memory Allocation
Manager Services supports both static and dynamic buffer memory allocation by your 
manager.
To allocate static memory, compile a static buffer declaration into your manager:
length = 2000;
char ebuff[length];
char *buffp = ebuff;
To allocate dynamic memory, use SNMP_memory_alloc() before calling 
EBufferSetup():
char *buffp;
int need;
need = 2000;
if ((buffp = (char *)SNMP_memory_alloc(need)) ==0
 return (-1);
Then use EBufferSetup() to set up the buffer descriptors before calling 
SNMP_Encode_Packet() or tdm_SNMP_Encode_Packet().  If you allocate static 
memory for the buffer, the call would look like this:
EBufferSetup(BFL_IS_STATIC, &ebuff, buffp, length);
If you allocate dynamic memory for the buffer, the call would look like this:
EBufferSetup(BFL_IS_DYNAMIC, &ebuff, buffp, need);
Although these examples use a 2000-byte buffer, you may need to allocate a larger 
buffer when using IPC-encoded packets.  The NonStop agent supports buffers as large as 
4096 bytes.
603
start_bp
next_bp
remaining = 0
ebuff










