SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-33
Common Utility Functions
Common Utility Functions
Several utility functions used by the sample managers are provided with Manager 
Services. Summarized in Table 2-4, these functions are intended to be used only as 
examples for some of the MIB object handling operations managers need to perform. In 
your own managers, you would replace the common utility calls with calls to your own 
functions tailored to support your application.  The header files indicated are those 
needed in addition to the Manager Services header files used by all managers.
This subsection briefly describes each of the common utility functions. 
Table 2-4. Common Utility Functions
Function
Header 
File Description of Function
Sample Managers 
Using Function
hexcheck() print.h Determines the number of bytes in 
a value encoded in ASCII or 
hexadecimal format.
SNMPSET
SNMPTRAP
oid_to_namerec() print.h Maps a pointer to a structure 
describing a MIB-II OID to a 
pointer to an array containing the 
object’s name and type.
SNMPSET
SNMPTRAP
oidstr_to_oid() print.h Converts an OID string into the 
structure used by Manager 
Services to represent OIDs. The 
OID string can be a MIB-II object 
name or an OID expressed in 
dotted notation. 
All except 
SNMPHOST and 
SNMPMON
print_pkt() print.h Prints the contents of an unencoded 
SNMP packet.
All
read_mib() readmib.h Reads a file created with the   
-readtree option of the MIB 
compiler and converts it into an in-
memory structure that string2oid() 
can parse.
SNMPWALK
string2oid() rtutils.h Converts the OID of a MIB object 
described in the read_mib() input 
file to its corresponding name.
SNMPWALK
str_to_trap() print.h Converts the string value of the 
generic trap field in a trap PDU to 
the corresponding integer value.
SNMPTRAP
str_to_type() print.h Converts a string depicting an 
SNMP type into its corresponding 
Manager Services representation.
SNMPSET
SNMPTRAP










