Creating a Subagent Using the eSNMP API
3.3 Creating a MIB Source File
1. Declaration Section
The first section of the subtree_TBL.H file is a declaration of the subtree
structure. The subtree is automatically initialized by code in the subtree_TBL.C
file. A pointer to this structure is passed to the
esnmp_register
routine to
register a subtree with the master agent. All access to the object table for this
subtree is through this pointer. The declaration has the following form:
extern SUBTREE subtree_subtree;
2. Index Definitions Section
The second section of the subtree_TBL.H file contains index definitions for each
MIB variable in the subtree of the form:
#define I_mib-variable nnn
These values are unique for each MIB variable in a subtree and are the index into
the object table for this MIB variable. These values are also generally used to
differentiate between variables that are implemented in the same method routine
so they can be used in a switch operation.
3. Enumeration Definitions Section
The third section of the subtree_TBL.H file contains enumeration definitions for
those integer MIB variables that are defined with enumerated values, as follows:
#define D_mib-variable_enumeration-name value
These definitions are useful because they describe the value that enumerated
integer MIB variables may take on. For example:
/* enumerations for gameEntry group */
#define D_gameStatus_complete 1
#define D_gameStatus_underway 2
#define D_gameStatus_delete 3
4. MIB Group Data Structure Definitions Section
The fourth section of the subtree_TBL.H file contains data structure definitions of
the following form:
typedef structxxx {
type mib-variable;
.
.
.
char mib-variable_mark;
.
.
.
} mib-group_type
The MIB compiler generates one of these data structures for each MIB group
in the subtree. Each structure definition contains a field representing each
MIB variable in the group. In addition to the MIB variable fields, the structure
includes a 1-byte mib-variable-mark field for each variable. You can use these for
maintaining status of a MIB variable. For example, the following is the group
structure for the chess MIB:
3–8 Creating a Subagent Using the eSNMP API