-
Notifications
You must be signed in to change notification settings - Fork 2
MFD:ifTable:Data_Structures
There are a few basic data structures that the MFD template code uses extensively.
The first structure is the registration pointer. This pointer is supplied by the implementor in the module's initialization routine. It is never used by the MFD code, but is passed as a parameter to virtually every generated function. It is for the convenience of the implementor. By default it will be a netsnmp_data_list pointer.
The next structure is the data context. This structure should contain all the data for a particular row. By default, mib2c will generate this data structure, and it will contain storage for each column in the table. Running mib2c on the ifTable table results in this data context structure:
|
If you have an existing data structure that contains all the data for your table, you can use that instead (we'll cover that in a later tutorial).
When a MIB table is defined, it has an INDEX clause that defines how the data in the table is ordered when queried. mib2c generates a MIB index structure with sufficent storage to represent the index for a table row. Running mib2c on the ifTable table results in this MIB index structure:
|
The next structure is the row context. This structure is used during the processing of a SNMP request. It is contains all the previous structures, and a few additional items. Running mib2c on the ifTable table results in this row request context structure:
|
The registration pointer (ifTable_reg in this example), mib index (tbl_idx) and data context (data) were discussed above. The oid varaibles oid_idx and oid_tmp are used internally, and will likely go away in the future. The data_list is a generic way of dynamically storing one or more pointers, using a string as the storage and retrieval key. It is not currently used internally, but may be in the future. For the implementor, it is a convienent way of storing additional data for a row request, without having to modify the row request structure itself.