SNMP Subagent Programmer's Guide

Management Functions
4-12 119728—SNMP Subagent Programmer’s Guide
Writing Subagent Logic
the prefix SMI_GROUP_ to the name in your MIB definition for the MIB, a group
within the MIB, or a table entry. For example, GDMOC assigns the following name
to the structure for objects in the Hello World MIB:
SMI_GROUP_hello
In the case of the Static Directory and Dynamic Directory sample subagents, the
structure for a table entry is assigned the following name:
SMI_GROUP_fileEntry
context
is a pointer to a data structure identified in a C_STRUCT or C_TYPE clause in the
MIB definition for the object; otherwise, it is NULL.
Entry Condition
The mgmt_init_env() function must have completed successfully. If the MIB objects
constitute a group or a table entry, mgmt_new_instance() must first be successfully
completed for the entire MIB.
Errors
If a connection with the NonStop agent has not been established, an internal processing
error occurs, or a memory allocation problem arises, this function returns NULL.
Examples
The following example is taken from the Hello World sample subagent. The MIB for
Hello World is a collection of scalar objects whose values are maintained in simple
global C variables. All the objects can be registered in a single mgmt_new_instance()
call:
if ((mgmt_hello_handle = mgmt_new_instance(mgmt_env,
&SMI_GROUP_hello,
(void *)NULL))
== NULL)
In the case of the Static Directory sample subagent, however, multiple calls to
mgmt_new_instance() are required. The first call registers the MIB object that describes
a subvolume name. This object is a scalar object whose value is stored in a structure.
The second argument in the call identifies the MIB, and the third argument is a pointer
to the filled-in structure holding the value of the MIB object:
group_handle = mgmt_new_instance(mgmt_env,
&SMI_GROUP_staticdir,
(void *) dir);
Subsequent calls are then made to mgmt_new_instance() to register each row of the
table this subagent manages. Static Directory registers every entry because the table is
small and static. The second argument identifies the name GDMOC generates for a
table entry, and the third argument points to the filled-in structure holding entries.
Because each entry is individually registered, the run-time library can handle all the