Creating a Subagent Using the eSNMP API
3.3 Creating a MIB Source File
3. Initialized Subtree Structure Section
The third section of the subtree_TBL.C file is the SUBTREE structure itself. A
pointer to this structure is passed to the eSNMP library routine
esnmp_register
to register the subtree. It is through this pointer that the library routines find
the object structures. The following is an example of the chess subtree structure:
SUBTREE chess_subtree = { "chess", "1.3.6.1.4.1.36.2.15.2.99",
{ 11, &elems[0] }, objects, I_moveStatus};
The following table describes the elements of the SUBTREE structure, the
definition of each element in the header file (subtree_TBL.H)), and the element in
the chess example:
Description
Header File
Representation
Example
The name of the subtree’s base
element.
name
"chess"
The ASCII string representation
of the subtree’s OID. This is what
actually gets registered.
dots
"1.3.6.1.4.1.36.2.15.2.99"
The OID structure for the base
node of the subtree. This points
back to the array of integers.
oid
11, &elems[0] }
A pointer to the array of objects
in the object table. It is indexed
by the
I_xxxx
definitions found in
the subtree_TBL.H file.
object_oid
objects
The index of the last object in the
object_TBL file. This is used to
determine when the end of the
table has been reached.
last
I_moveStatus
4. Routines Section
The final section of the subtree_TBL.C file. contains short routines for allocating
and freeing the
mib_group_type
. These are provided as a convenience and are
not a required part of the API.
3.4 Including the Routines and Building the Subagent
The MIB compiler does not generate code for implementing the method routines
for your subagent. This includes code for processing
get
,
set
, and other SNMP
requests as well as for generating traps. You must write this code yourself. See
the CHESS_MIB.C module for an example.
To produce executable subagent code, follow these steps:
1.
Compile the C modules generated by the MIB compiler, along with your
implementation code. Use a command in the following format (derived from
the sample provided for building the chess example in TCPIP$BUILD_
CHESS.COM):
$ CC /INCLUDE=TCPIP$SNMP /PREFIX=ALL /STANDARD=VAX CHESS_METHOD.C, -
_$ CHESS_MIB.C, CHESS_TBL.C
Creating a Subagent Using the eSNMP API 3–11