Compaq AAR04BCTE manual Creating a Subagent Using the eSNMP API, Creating a MIB Source File

Models: AAR04BCTE

1 132
Download 132 pages 53.41 Kb
Page 40
Image 40
2. Array of OBJECT Structures Section

Creating a Subagent Using the eSNMP API

3.3 Creating a MIB Source File

2. Array of OBJECT Structures Section

The second section of the subtree_TBL.C file is an array of OBJECT structures. Each MIB variable within the subtree has one OBJECT. The chess example produces the following:

static OBJECT objects[] = {

 

{I_chessProductID

,{12, &elems[ 11]}, ESNMP_TYPE_ObjectId ,chess_get, NULL},

. . .

 

An OBJECT structure represents a MIB variable and has the following fields:

object_index — The constant I_mib-variablefrom the subtree_TBL.H file, which identifies this variable (in the chess example, I_chessProductID.)

oid — The variable’s OID (points to a part of elems[ ]).

This variable is of type OID, which is a structure containing two elements: the number of elements in the OID and a pointer to the correct starting place in the array of elements (elems[ ] in the chess example).

In the chess example, oid is designated by {12, &elemens[ 11]}. This indicates that:

The OID has 12 integers separated by dots in the ASCII text representation ("1.3.6.1.4.1.36.2.15.2.99.2")

The integer with index 11 in the array elems[ ] is the first element.

type — The variable’s eSNMP data type.

getfunc — The address of the method routine to call for Get requests (null if no routine exists).

setfunc — The address of the method routine to call for Set requests (null if no routine exists).

The master agent does not access object tables or MIB variables directly. It only maintains a registry of subtrees. When a request for a particular MIB variable arrives, it is processed as shown in the following steps (where the MIB variable is mib_var and the subtree is subtree_1):

1.The master agent finds subtree_1 as the authoritative region for the mib_var in the register of subtrees. The authoritative region is determined as the registered MIB subtree that has the longest prefix and the highest priority.

2.The master agent sends a message to the subagent that registered subtree_1.

3.The subagent consults its list of registered subtrees and locates subtree_1. It searches the object table of subtree_1 and locates the following:

mib_var (for Get and Set routines)

The first object lexicographically after mib_var (for Next or Bulk routines)

4.The appropriate method routine is called. If the method routine completes successfully, the data is returned to the master agent. If the method routine fails when doing a Get or Set, an error is returned. If the method routine fails when doing a GetNext, the code keeps trying subsequent objects in the object table of subtree_1 until either a method routine returns successfully or the table is exhausted. In either case, a response is returned.

5.If the master agent detects that subtree_1 could not return data on a Next routine, it recursively tries the subtree lexicographically after subtree_1 until a subagent returns a value or the registry of subtrees is exhausted.

3–10Creating a Subagent Using the eSNMP API

Page 40
Image 40
Compaq AAR04BCTE Creating a Subagent Using the eSNMP API, Creating a MIB Source File, Array of OBJECT Structures Section