1 /* 2 * table_container.h 3 * $Id$ 4 */ 5 #ifndef _TABLE_CONTAINER_HANDLER_H_ 6 #define _TABLE_CONTAINER_HANDLER_H_ 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 /* 13 * The table container helper is designed to simplify the task of 14 * writing a table handler for the net-snmp agent when the data being 15 * accessed is accessible via a netsnmp_container. 16 * 17 * Functionally, it is a specialized version of the more 18 * generic table helper but easies the burden of GETNEXT processing by 19 * retrieving the appropriate row for each index through 20 * function calls which should be supplied by the module that wishes 21 * help. The module the table_container helps should, afterwards, 22 * never be called for the case of "MODE_GETNEXT" and only for the GET 23 * and SET related modes instead. 24 */ 25 26 #include <net-snmp/library/container.h> 27 #include <net-snmp/agent/table.h> 28 29 #define TABLE_CONTAINER_ROW "table_container:row" 30 #define TABLE_CONTAINER_CONTAINER "table_container:container" 31 32 #define TABLE_CONTAINER_KEY_NETSNMP_INDEX 1 /* default */ 33 #define TABLE_CONTAINER_KEY_VARBIND_INDEX 2 34 #define TABLE_CONTAINER_KEY_VARBIND_RAW 3 35 36 /* ==================================== 37 * Container Table API: MIB maintenance 38 * ==================================== */ 39 40 /* 41 * get an injectable container table handler 42 */ 43 netsnmp_mib_handler * 44 netsnmp_container_table_handler_get(netsnmp_table_registration_info *tabreq, 45 netsnmp_container *container, 46 char key_type); 47 /* 48 * register a container table 49 */ 50 int 51 netsnmp_container_table_register(netsnmp_handler_registration *reginfo, 52 netsnmp_table_registration_info *tabreq, 53 netsnmp_container *container, 54 char key_type); 55 int 56 netsnmp_container_table_unregister(netsnmp_handler_registration *reginfo); 57 58 /** retrieve the container used by the table_container helper */ 59 netsnmp_container* 60 netsnmp_container_table_container_extract(netsnmp_request_info *request); 61 62 /** find the context data used by the table_container helper */ 63 #ifdef NETSNMP_USE_INLINE 64 NETSNMP_STATIC_INLINE void * netsnmp_container_table_row_extract(netsnmp_request_info * request)65 netsnmp_container_table_row_extract(netsnmp_request_info *request) 66 { 67 /* 68 * NOTE: this function must match in table_container.c and table_container.h. 69 * if you change one, change them both! 70 */ 71 return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW); 72 } 73 74 NETSNMP_STATIC_INLINE void * netsnmp_container_table_extract_context(netsnmp_request_info * request)75 netsnmp_container_table_extract_context(netsnmp_request_info *request) 76 { 77 /* 78 * NOTE: this function must match in table_container.c and table_container.h. 79 * if you change one, change them both! 80 */ 81 return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW); 82 } 83 #else 84 void * 85 netsnmp_container_table_row_extract(netsnmp_request_info *request); 86 void * 87 netsnmp_container_table_extract_context(netsnmp_request_info *request); 88 #endif /* inline */ 89 90 void netsnmp_container_table_row_insert(netsnmp_request_info *request, 91 netsnmp_index *row); 92 void netsnmp_container_table_row_remove(netsnmp_request_info *request, 93 netsnmp_index *row); 94 95 /* =================================== 96 * Container Table API: Row operations 97 * =================================== */ 98 99 void * 100 netsnmp_container_table_find_next_row(netsnmp_request_info *request, 101 netsnmp_table_request_info *tblreq, 102 netsnmp_container *container, 103 char key_type ); 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif /* _TABLE_CONTAINER_HANDLER_H_ */ 109