SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-38
Common Utility Functions
Section 3, Using the MIB Compiler, describes the format of the -readtree and -
nametree output.
string2oid()
The string2oid() function parses the in-memory structure created by a previous call to
read_mib() and returns information about the OID of a MIB object name in a structure
of type OBJ_ID_T.
num-components
is the number of components in the OID. For example, an OID of 1.4.6.0 contains
four components. A value of 0 is returned if the MIB name you pass to this function
is not found in the in-memory structure.
object-name
is a pointer to the name and instance of the MIB object whose OID you need.
oid
is a pointer to a buffer describing the OID.
oidlen
is the number of bytes in the oid buffer.
str_to_trap()
The str_to_trap() function converts the string value of a generic trap to its corresponding
integer value.
generic-trap-number
is one of the following integers, which correspond to the generic trap strings defined
in RFC 1157:
0 (coldStart)
1 (warmStart)
2 (linkDown)
include "rtutilsh"
num-components = string2oid(object-name, oid, oidlen);
int
string2oid(char *object-name, OIDC_T *oid, int oidlen);
include "printh"
generic-trap-number str_to_trap(generic-trap-string);
int
string_to_trap(char *generic-trap-string);