Solaris System Management Agent Developer's Guide

Modifications for Simple Table Data Retrieval

In demo_module_2.c, the init_demo_module_2 routine calls the initialize_table_me1FileTable() function. The initialize_table_me1FileTable() function registers the OID for the table handled by the function. The function also calls some Net-SNMP functions to initialize the tables.

You should provide the table data in this initialize_table_me1FileTable() function if needed. The initialize_table_me1FileTable() function performs the following:

Initialization

The initialize_table_me1FileTable() function performs the real table initialization, by performing tasks such as setting the maximum number of rows and columns.

OID Table Definition

The initialize_table_me1FileTable() function defines the table OID:

static oid me1FileTable_oid[] =
  {1,3,6,1,4,1,42,2,2,4,4,1,2,1};
Table Definition

The initialize_table_me1FileTable() function sets up the table's definition. This function specifies another function to call, me1FileTable_get_first_data_point(), to process the first row of data in the table. The function me1FileTable_get_next_data_point() is called to process the remaining rows in the table.

netsnmp_table_helper_add_indexes(table_info,
ASN_UNSIGNED, /* index: me1FileIndex */
0);

     table_info->min_column = 1;
     table_info->max_column = 4;

  /* iterator access routines */
iinfo->get_first_data_point = 
           me1FileTable_get_first_data_point;
iinfo->get_next_data_point = 
           me1FileTable_get_next_data_point;
iinfo->table_reginfo = 
           table_info;

iinfo is a pointer to a netsnmp_iterator_info structure.

Master Agent Registration

The initialize_table_me1FileTable() function registers the table with the master agent:

netsnmp_register_table_iterator(my_handler, iinfo);

The table iterator is a helper function that modules can use to index through rows in a table. Functionally, the table iterator is a specialized version of the more generic table helper. The table iterator eases the burden of GETNEXT processing. The table iterator loops through all the data indexes retrieved through those function calls that should be supplied by the module that requests help. See the API documentation at /usr/sfw/doc/sma_snmp/html/group__table__iterator.html for more information on table iterator APIs.

Note that the input MIB file contains the specification of table and scalar data. However, when you run mib2c with mib2c.iterate.conf and specify the table node name, only template code for the simple table in the MIB is generated.