Solaris System Management Agent Developer's Guide

init_module Routine

When a module is loaded in the agent, the agent calls the init_module() routine for the module. The init_module() routine registers the OIDs for the objects that the module handles. After this registration occurs, the agent associates the module name with the registered OIDs. All modules must have this init_module() routine.

The mib2c utility creates the init_module() routine for you. The routine provides the basic code for data retrieval, which you must modify appropriately for the type of data.

If you have several MIB nodes in your MIB, the mib2c utility creates several .c files. Each generated file contains an init_mibnode() routine. A module must have only one initialization routine, which must conform to the convention of init_module(). Therefore, when you have more than one MIB node represented in your module, you must combine the initialization content of all the generated .c files into one file to ensure that the initialization routine for each MIB node is called by init_module().

You can combine files to build a module in one of the following ways:

In both cases, the rest of the code in myMib.c might be similar to the following pseudo code:

/* get/set handlers for scalarGroup found in scalarGroup.c */

/* get_first/get_next/handler for tableGroup - found in tableGroup.c */
 

The following sections discuss how the data retrieval code must be modified in your module for different types of data.