SNMP Manager Programmer's Guide

Constructing and Interpreting Packets
SNMP Manager Programmer’s Guide–134249
5-29
SNMP_Bind_String()
data-type
indicates the SNMP data type of the object being bound. Assign one of these
values:
VT_STRING
VT_OPAQUE
VT_NSAPADDRESS
value-length
is the number of bytes in the value.
value
is a pointer to a buffer containing the string value.
buffer-flag
is an indication of whether you want Manager Services to allocate dynamic memory
for holding a copy of your string value or to use a the buffer you have already
allocated for it. Specify one of these values:
0 indicates dynamic memory
1 indicates existing buffer
The following example, taken from SNMPSET, binds an octet string value to a request
packet. Related declarations include a global define and OID structure declaration. The
Manager Services define MAX_OID_COUNT is used to set the number of elements in
the OID component arrays and the component count variables to 32.
#define MAXOIDS 16
OIDC_T base_component_list[MAX_OID_COUNT];
OBJ_ID_T base_oid = { MAX_OID_COUNT, base_component_list };
Other related variables are declared in the main block. The variable named longform
indicates that the invocation line specifies MIB objects that are not defined in MIB-II.
Manager Services has an internal table it can use to find the data type of MIB-II objects:
int longform = 0;
int mibtype = 0;
int oidcnt;
char *oidstr[MAXOIDS];
struct namerec *p;
SNMP_PKT_T *send_pkt;
char *typestr[MAXOIDS];
char *valstr[MAXOIDS];