4.3   Data Types and Data Structures

4.3.1   General Types

Most of the general types are defined as type definitions (#typedef) in the header file asn1conf.h. You should not modify this file.

ALENGTH_T
The fully decoded value of an ASN.1 length field.

ATVALUE_T
The fully decoded value of an ASN.1 tag, excluding the context and constructor bits.

INT_16_T
Signed 16-bit integer.

INT_32_T
Signed 32-bit integer. MIB variables of type Integer ought to be of this type.

OCTET_T
Unsigned 8-bit character.

OIDC_T
An object identifier component. By default this is a 32-bit unsigned integer.

UINT_8_T
Unsigned 8-bit integer.

UINT_16_T
Unsigned 16-bit integer.

UINT_32_T
Unsigned 32-bit integer. MIB variables of type Counter, Gauge, and TimeTicks ought to be of this type.

EBUFFER_T
Variables of type EBUFFER_T are used to hold strings of bytes generated by the ASN.1 encoding routines. EBUFFER_T is also used as a general mechanism for managing variable length byte strings.

The EBUFFER_T type does not itself include the storage to hold the byte string. That storage is provided by the user of the EBUFFER_T. Such storage may be dynamic or static (relative to the lifetime of the EBUFFER_T variable itself.)

OBJ_ID_T
An ASN.1 object identifier, in local representation. Manipulation of data structures of this type comprises a significant portion of the execution time used by this SNMP implementation.

PTR_T
A generic void pointer.

SNMPADDR_T
This type is used to hold network addresses in a general way. It is very similar to the sockaddr structure used with the Berkeley socket interface.

4.3.2   MIB Tree Types

MIBLEAF_T
Each instance of type MIBLEAF_T represents a scalar (non-tabular) management variable, or an attribute (column) in a table of management variables. The MIBLEAF_T instance points to procedures and other information needed to access the associated management variable.

MIBNODE_T
Each instance of type MIBNODE_T represents an internal node of the management information base tree. Each MIBNODE_T is associated with a list of elements of type MIBARC_T. This list indicates the MIBNODE_T and MIBLEAF_T variables at the next lower level of the MIB tree.

MIBARC_T
Instances of MIBARC_T are used to designate the nodes and leaves of the management information tree which descend from a particular internal node of the tree.

4.3.3   SNMP Packet Representation

SNMP_PKT_T
An SNMP packet is represented internally by an element of type SNMP_PKT_T. This type contains a tagged union with two principal variations, one for REQUEST and RESPONSE PDUs, the other for TRAP PDUs.

Various additional fields are present to give the MIB developer a means to determine access privileges, MIB views, etc. (for more detailed information, see the definition for the internal representation of an SNMP packet in the file snmpdefs.h). In addition, a pointer is provided (user_private) through which a developer may attach a private data structure. This memory can be released using a private-memory-deallocation hook (see 4.8 Hooks) when the packet has finished processing (the hook is installed during initialization, in the routine snmpdInitFinish( )).

VB_T
Each VarBind (see 4.11 Request Processing) in an SNMP PDU's VarBindList is held in an item of type VB_T. This type contains a tagged union capable of holding all of the data types defined by the RFC 1155 and RFC 1902 SMIs.

The VB_T structure contains additional fields which are intended to be used by a MIB designer when processing incoming PDUs (during the method-routine phase). One of these fields is a linked-list pointer giving the MIB developer the means to generate a relationship between items in a VarBindList. Two other fields are provided to allow the MIB developer to associate space with a VB_T item, and to have that space deallocated when the VB_T is freed. These are intended for use when a test routine must acquire some resources to determine if a SET may be accomplished. The vb_priv field in the VB_T may be used to point to these resources while the vb_free_priv field is used to point to a routine which frees user-defined memory. If vb_free_priv is non-null when a packet is being deallocated, the routine pointed to by vb_free_priv is called and may free up any resources that the VB_T specifies.

VBL_T
In general, the VarBindList found in SNMP PDUs is represented as an array of elements of type VB_T. The location and size of such an array is held in an item of type VBL_T. While processing a GET BULK request, where the number of VB_T variables is not known when the packet is created, additional VBL_T variables may be chained in a list using a pointer in the VBL_T structure.