DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

oid(SLIB-osr5)


oid -- operations on Object Identifiers

Syntax

cc ... -lsnmp

#include <snmp/snmp.h>

void free_oid(oid_ptr) OID oid_ptr;

OID make_oid(sid_array, length) u_int *sid_array; /* sub-identifiers of the OID */ short length; /* number of array elements */

OID make_obj_id_from_hex(hex_string) u_char *hex_string; /* Hex to be converted to an Object Identifier */

#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 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 the memory recovery.

From a hex text string, make_obj_id_from_hex creates a library-format Object Identifier data structure, which is used by calls to make_varbind(SLIB-osr5) and make_authentication(SLIB-osr5). The format of these text 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 libsnmpuser.a library, and need not be included in applications.

make_obj_id_from_dot is called 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(SLIB-osr5) and make_pdu(SLIB-osr5) (in the case of traps). This malloc'ed data structure will be freed by calls to free_pdu(SLIB-osr5) after the pointer has been used.

See also

octetstring(SLIB-osr5), snmp_authentication(SLIB-osr5), snmp_pdu(SLIB-osr5), varbind(SLIB-osr5)


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005