SNMP Manager Programmer's Guide
Constructing and Interpreting Packets
SNMP Manager Programmer’s Guide–134249
5-32
SNMP_Bind_Unsigned_Integer()
data-type
indicates the SNMP data type of the object being bound. Assign one of these
values:
VT_COUNTER
VT_GAUGE
VT_TIMETICKS
VT_UINTEGER32
value
is an unsigned integer value to be assigned to the variable binding.
The following example, taken from SNMPSET, binds an unsigned integer 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];
A for loop extracts instance identifiers from the invocation line arguments, stores any
data type entered in typestr, and stores the value entered in valstr:
for (i = 0; argc > 0; i++)
{
...
oidstr[i] = *argv++; argc--;
if (longform)
{
typestr[i] = *argv++; argc--;
}
valstr[i] = *argv++; argc--;
}
oidcnt = i;
After the request packet is initialized into send_pkt, a for loop is used to assign
variable bindings to it. For objects that are not members of MIB-II, the common utility
function str_to_type() is used to validate whether the type specified at invocation is a