SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-35
Common Utility Functions
struc namerec {
OBJ_ID_T oid;
char *nmstr;
int type;
Type contains one of the values described under str_to_type().
If the OID in the oid structure is not for a MIB-II object, p is set to 0.
oid
is a pointer to a structure of type OBJ_ID_T, defined in asn1.h, which describes the
OID as a component count and a pointer to an array of OID component values:
typedef struct OBJ_ID_S
{int num_components;
OIDC_T *component_list;
} OBJ_ID_T;
Section 4, Using Header Files, Data Structures, and Defines, provides more
information on OBJ_ID_T.
oidstr_to_oid()
The oidstr_to_oid() function accepts an OID string and describes it using the OBJ_ID_T
type. If the OID string is a MIB-II object name, an internal mapping table is used to
find its OID.
rcode
is an integer describing the outcome of the call. A value of 0 indicates success. A
value of -1 indicates failure.
oidstr
is a pointer to an array containing the OID string in the form of a MIB-II object
name and instance (for example, sysContact.0) or in dotted notation (for example,
1.2.3.0).
oid
is a pointer to a structure of type OBJ_ID_T, defined in asn1.h, which describes the
OID as a component count and a pointer to an array of OID component values:
#include "printh"
rcode = oidstr_to_oid(oidstr, oid);
int
oidstr_to_oid(char *oidstr, OBJ_ID_T *oid);