oid(3N) oid(3N)
NAME
oid - Operations on Object Identifiers
SYNOPSIS
#include <snmp/snmp.h>
void free_oid(oid_ptr) OID oid_ptr;
OID make_oid(sid_array, length) unsigned long
sid_array[]; /* sub-identifiers of OID */ long
length; /* number of array elements */
OID make_obj_id_from_hex(hex_string) char
*hex_string; /* Hexadecimal to an OID */
#include <snmp/snmp.h> #include <snmp/snmpuser.h>
short make_dot_from_obj_id(oid_ptr, return_buffer); OID
oid_ptr; /* OID to be converted */ char
return_buffer[]; /* char buffer to write string to */
OID make_obj_id_from_dot(text_string); char
*text_string; /* string representation of OID */
DESCRIPTION
free_oid frees all memory associated with the Object
Identifier, including the memory allocated to the members of
"oid_elements" that are part of the identifier.
make_oid produces a library Object Identifier construct from a
passed sub-identifier array and length. The sub-identifier
array sid_array is an array of unsigned long integers, with
each element corresponding to the value of each integer at
each position in the dot-notation display of an object
identifier. For example, the Object Identifier 1.3.6.1.2.1.1
would have a value 1 in sid_array[0], 3 in sid_array[1], and
so on. length is the number of sub-identifier elements present
in the array. The construct returned can be freed by passing
the pointer to free_oid. Usually, this is unnecessary as the
construct is most often passed to another library routine for
inclusion in a large ASN.1 construct, and that library
routine's freeing counterpart will perform memory recovery.
>From a hex text string, make_obj_id_from_hex is used to
create a library-format Object Identifier data structure which
is used by calls to make_varbind(3) and
Copyright 1994 Novell, Inc. Page 1
oid(3N) oid(3N)
make_authentication(3). The format of these strings is a hex
value (1 or more hex digits, upper or lower case) followed by
a space, with more hex values and spaces to complete the
string. For example, to create an Object Identifier consisting
of three sub-identifiers (say, 1.21.51) the text string could
be ``1 15 3d'' or ``0x1 0x15 0x3D''. The Object Identifier
construct returned by this call can be freed by a call to
free_oid. Usually this is unnecessary as the construct is
most often passed to another library routine for inclusion in
a larger ASN.1 construct, and that library's free counterpart
will perform the memory recovery.
make_dot_from_obj_id is called to convert an Object Identifier
library construct into a dot notation character string,
usually for use in a human interface. The dot notation output
is the usual form (1.2.3.4.1.2.1.1) with a MIB name
substituted for the most possible sub-identifiers starting
from the left (1.3.6.1.2.1.1.1.0 becomes sysDescr.0). The MIB
names included in the library are found in the mib_oid_table
in snmp-mib.h. This include file is used in the compilation
of oid_lib.c, part of the libsnmp.a library, and need not be
included in applications.
make_obj_id_from_dot is used to create a library form object
identifier from a character string. The string input is
usually in the format "integer.integer.integer" (for example,
"1.3.6.1.2.1.1.1.0"), but can be shortened by using the names
as they appear in RFC 1066 (for example, "sysDescr.0"). It
returns a pointer to a malloc'ed data structure containing the
internal library representation for an Object Identifier.
This identifier can then be used in calls to make_varbind(3)
and make_pdu(3) (in the case of traps). This malloc'ed
structure will be freed by calling free_pdu(3) after the
pointer has been used.
SEE ALSO
octetstring(3N), snmp_authentication(3N), snmp_pdu(3N),
varbind(3N).
Copyright 1994 Novell, Inc. Page 2