Solaris System Management Agent Developer's Guide

General Tables

A general table differs from a simple table in at least one of the following ways:

The command that you use to generate code templates for general tables is the same command used for simple tables:


mib2c -c mib2c.iterate.conf mibnode1 mibnode2 ...

The demo_module_3 code example shows how modify the templates appropriately to retrieve data from general tables.

demo_module_3 Code Example for General Tables

The demo_module_3 code example is provided to help you understand how to modify the code generated by the mib2c command to perform a data retrieval in a general table. The table example provides information for monitoring a list of files. The demo_module_3 code example is located by default in the directory /usr/demo/sma_snmp/demo_module_3.

The README_demo_module_3 file contains instructions that describe how to perform the following tasks:

The demo_module_3 is set up to allow you to generate code templates me1ContactInfoTable.c and me1ContactInfoTable.h. You can then compare the generated files to the files demo_module_3.c and demo_module_3.h.

The me1ContactInfoTable.c and me1ContactInfoTable.h have been modified appropriately to retrieve data from general tables. You can use these files as a model for learning how to work with general tables in your own module. The instructions then explain how to compile the modified source files to create a functioning module.

The demo_module_3 code was generated by using mib2c with the -c mib2c.iterate.conf option. Some functions have been added to implement a link list to provide the test data.

The example uses some dummy data to perform data retrieval for a two-index table. The code is similar to the demo_module_2.c with one extra index. The following code sets up the table with two indexes:

netsnmp_table_helper_add_indexes(table_info,
ASN_INTEGER, /* index: me1FloorNumber */
ASN_INTEGER, /* index: me1RoomNumber */
0);

Use care in returning the “NEXT” data when function me1ContactInfoTable_get_next_data_point() is called. For instance, the data in this table is presorted so the next data is conveniently pointed by the pNext pointer in this example code:

me1ContactEntry* nextNode = (me1ContactEntry*) *my_loop_context;
          nextNode = nextNode->pNext;

If your implementation is more complicated, make sure the OIDs are increased incrementally, (xxx.1.1, xxx.1.2, ).

The input MIB file contains the specification of tables and scalars. When you run mib2c -c mib2c.iterate.conf on a general table node, template code is generated only for the general table in the MIB.