SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-37
Common Utility Functions
read_mib()
The read_mib() function loads the contents of a MIB compiler -readtree output file at
run time and converts it into an in-memory structure that string2oid() can parse. The in-
memory structure has the same format as the MIB compiler -nametree output.
readtree-filename
is a pointer to the name of the file containing the MIB compiler -readtree output.
SNMPWALK, the sample manager that uses read_mib(), presumes the file is named
mibrt.
Err_stat An indication of whether an exception occurred. Values are
prescribed by RFC 1157: noError, tooBig, noSuchName,
badValue, readOnly, and genErr.
Err_ndx An indication of which variable binding is involved in the
exception.
VBLlen The number of bytes used by all variable bindings in the packet.
VBcount The number of variable bindings in the packet.
VarBind # The sequential number of the variable binding, starting at 0.
content size The number of bytes used by one variable binding.
Flags & type The hexadecimal value assigned to ASN.1 data types. Values are:
0x02 for INTEGER
0x04 for OCTET_STRING
0x13 for DisplayString
0x06 for OBJECT_IDENTIFIER
0x05 for NULL
0x40 for IpAddress
0x41 for Counter
0x42 for Gauge
0x43 for TimeTicks
0x44 for Opaque
encoded length The number of bytes in an encoded variable binding.
Information for
each variable
binding
The name and instance, type, and value of the variable binding.
#include "readmibh"
read_mib(readtree-filename);
int
read_mib(char* readtree-filename);