table_array(3) net-snmp table_array(3)
NAME
table_array - Helps you implement a table when data can be stored locally.
Functions
int netsnmp_table_container_register (netsnmp_handler_registration *reginfo,
netsnmp_table_registration_info *tabreg, netsnmp_table_array_callbacks *cb, netsnmp_container
*container, int group_rows)
register specified callbacks for the specified table/oid.
int netsnmp_table_array_register (netsnmp_handler_registration *reginfo,
netsnmp_table_registration_info *tabreg, netsnmp_table_array_callbacks *cb, netsnmp_container
*container, int group_rows)
netsnmp_mib_handler * netsnmp_find_table_array_handler (netsnmp_handler_registration *reginfo)
find the handler for the table_array helper.
netsnmp_container * netsnmp_extract_array_context (netsnmp_request_info *request)
find the context data used by the table_array helper
int netsnmp_table_array_check_row_status (netsnmp_table_array_callbacks *cb, netsnmp_request_group
*ag, long *rs_new, long *rs_old)
this function is called to validate RowStatus transitions.
Detailed Description
Helps you implement a table when data can be stored locally.
The data is stored in a sorted array, using a binary search for lookups.
The table_array handler is used (automatically) in conjuntion with the table handler. It is primarily
intended to be used with the mib2c configuration file mib2c.array-user.conf.
The code generated by mib2c is useful when you have control of the data for each row. If you cannot
control when rows are added and deleted (or at least be notified of changes to row data), then this
handler is probably not for you.
This handler makes use of callbacks (function pointers) to handle various tasks. Code is generated
for each callback, but will need to be reviewed and flushed out by the user.
NOTE NOTE NOTE: Once place where mib2c is somewhat lacking is with regards to tables with external
indices. If your table makes use of one or more external indices, please review the generated code
very carefully for comments regarding external indices.
NOTE NOTE NOTE: This helper, the API and callbacks are still being tested and may change.
The generated code will define a structure for storage of table related data. This structure must be
used, as it contains the index OID for the row, which is used for keeping the array sorted. You can
add addition fields or data to the structure for your own use.
The generated code will also have code to handle SNMP-SET processing. If your table does not support
any SET operations, simply comment out the #define <PREFIX>_SET_HANDLING (where <PREFIX> is your
table name) in the header file.
SET processing modifies the row in-place. The duplicate_row callback will be called to save a copy of
the original row. In the event of a failure before the commite phase, the row_copy callback will be
called to restore the original row from the copy.
Code will be generated to handle row creation. This code may be disabled by commenting out the
#define <PREFIX>_ROW_CREATION in the header file.
If your table contains a RowStatus object, by default the code will not allow object in an active row
to be modified. To allow active rows to be modified, remove the comment block around the #define
<PREFIX>_CAN_MODIFY_ACTIVE_ROW in the header file.
Code will be generated to maintain a secondary index for all rows, stored in a binary tree. This is
very useful for finding rows by a key other than the OID index. By default, the functions for
maintaining this tree will be based on a character string. NOTE: this will likely be made into a more
generic mechanism, using new callback methods, in the near future.
The generated code contains many TODO comments. Make sure you check each one to see if it applies to
your code. Examples include checking indices for syntax (ranges, etc), initializing default values in
newly created rows, checking for row activation and deactivation requirements, etc.
Function Documentation
netsnmp_container* netsnmp_extract_array_context (netsnmp_request_info * request)
find the context data used by the table_array helper
Definition at line 229 of file table_array.c.
References netsnmp_request_get_list_data().
netsnmp_mib_handler* netsnmp_find_table_array_handler (netsnmp_handler_registration * reginfo)
find the handler for the table_array helper.
Definition at line 212 of file table_array.c.
References netsnmp_mib_handler_s::access_method, netsnmp_handler_registration_s::handler,
netsnmp_mib_handler_s::next, and NULL.
int netsnmp_table_array_check_row_status (netsnmp_table_array_callbacks * cb, netsnmp_request_group * ag,
long * rs_new, long * rs_old)
this function is called to validate RowStatus transitions.
Definition at line 236 of file table_array.c.
References netsnmp_table_array_callbacks_s::can_activate,
netsnmp_table_array_callbacks_s::can_deactivate, netsnmp_table_array_callbacks_s::can_delete,
netsnmp_request_group_s::existing_row, NULL, netsnmp_request_group_s::row_deleted, and
netsnmp_request_group_s::undo_info.
int netsnmp_table_container_register (netsnmp_handler_registration * reginfo,
netsnmp_table_registration_info * tabreg, netsnmp_table_array_callbacks * cb, netsnmp_container *
container, int group_rows)
register specified callbacks for the specified table/oid.
If the group_rows parameter is set, the row related callbacks will be called once for each unique row
index. Otherwise, each callback will be called only once, for all objects.
Definition at line 149 of file table_array.c.
References netsnmp_table_array_callbacks_s::can_set, table_container_data_s::cb,
netsnmp_container_s::compare, netsnmp_table_array_callbacks_s::delete_row,
netsnmp_table_array_callbacks_s::duplicate_row, netsnmp_handler_registration_s::handler,
netsnmp_mib_handler_s::myvoid, netsnmp_container_s::ncompare, netsnmp_register_table(), NULL,
netsnmp_table_array_callbacks_s::row_copy, snmp_log(), SNMP_MALLOC_TYPEDEF,
table_container_data_s::table, and table_container_data_s::tblreg_info.
Referenced by netsnmp_table_array_register().
Version 5.4.1 27 Jul 2007 table_array(3)
|