net-snmp 5.7
|
00001 /* 00002 * table_array.h 00003 * $Id$ 00004 */ 00005 #ifndef _TABLE_ARRAY_HANDLER_H_ 00006 #define _TABLE_ARRAY_HANDLER_H_ 00007 00008 #ifdef __cplusplus 00009 extern "C" { 00010 #endif 00011 00012 /* 00013 * The table array helper is designed to simplify the task of 00014 * writing a table handler for the net-snmp agent when the data being 00015 * accessed is in an oid sorted form and must be accessed externally. 00016 * 00017 * Functionally, it is a specialized version of the more 00018 * generic table helper but easies the burden of GETNEXT processing by 00019 * retrieving the appropriate row for ead index through 00020 * function calls which should be supplied by the module that wishes 00021 * help. The module the table_array helps should, afterwards, 00022 * never be called for the case of "MODE_GETNEXT" and only for the GET 00023 * and SET related modes instead. 00024 */ 00025 00026 #include <net-snmp/library/container.h> 00027 #include <net-snmp/agent/table.h> 00028 00029 #define TABLE_ARRAY_NAME "table_array" 00030 00031 /* 00032 * group_item is to allow us to keep a list of requests without 00033 * disrupting the actual netsnmp_request_info list. 00034 */ 00035 typedef struct netsnmp_request_group_item_s { 00036 netsnmp_request_info *ri; 00037 netsnmp_table_request_info *tri; 00038 struct netsnmp_request_group_item_s *next; 00039 } netsnmp_request_group_item; 00040 00041 /* 00042 * structure to keep a list of requests for each unique index 00043 */ 00044 typedef struct netsnmp_request_group_s { 00045 /* 00046 * index for this row. points to someone else's memory, so 00047 * don't free it! 00048 */ 00049 netsnmp_index index; 00050 00051 /* 00052 * container in which rows belong 00053 */ 00054 netsnmp_container *table; 00055 00056 /* 00057 * actual old and new rows 00058 */ 00059 netsnmp_index *existing_row; 00060 netsnmp_index *undo_info; 00061 00062 /* 00063 * flags 00064 */ 00065 char row_created; 00066 char row_deleted; 00067 char fill1; 00068 char fill2; 00069 00070 /* 00071 * requests for this row 00072 */ 00073 netsnmp_request_group_item *list; 00074 00075 int status; 00076 00077 void *rg_void; 00078 00079 } netsnmp_request_group; 00080 00081 typedef int (Netsnmp_User_Row_Operation_c) (const void *lhs, 00082 const void *rhs); 00083 typedef int (Netsnmp_User_Row_Operation) (void *lhs, void *rhs); 00084 typedef int (Netsnmp_User_Get_Processor) (netsnmp_request_info *, 00085 netsnmp_index 00086 *, 00087 netsnmp_table_request_info 00088 *); 00089 typedef netsnmp_index 00090 *(UserRowMethod) (netsnmp_index *); 00091 typedef int (Netsnmp_User_Row_Action) (netsnmp_index *, 00092 netsnmp_index *, 00093 netsnmp_request_group *); 00094 typedef void (Netsnmp_User_Group_Method) (netsnmp_request_group *); 00095 00096 /* 00097 * structure for array callbacks 00098 */ 00099 typedef struct netsnmp_table_array_callbacks_s { 00100 00101 Netsnmp_User_Row_Operation *row_copy; 00102 Netsnmp_User_Row_Operation_c *row_compare; 00103 00104 Netsnmp_User_Get_Processor *get_value; 00105 00106 00107 Netsnmp_User_Row_Action *can_activate; 00108 Netsnmp_User_Row_Action *activated; 00109 Netsnmp_User_Row_Action *can_deactivate; 00110 Netsnmp_User_Row_Action *deactivated; 00111 Netsnmp_User_Row_Action *can_delete; 00112 00113 UserRowMethod *create_row; 00114 UserRowMethod *duplicate_row; 00115 UserRowMethod *delete_row; /* always returns NULL */ 00116 00117 Netsnmp_User_Group_Method *set_reserve1; 00118 Netsnmp_User_Group_Method *set_reserve2; 00119 Netsnmp_User_Group_Method *set_action; 00120 Netsnmp_User_Group_Method *set_commit; 00121 Netsnmp_User_Group_Method *set_free; 00122 Netsnmp_User_Group_Method *set_undo; 00123 00125 netsnmp_container* container; 00126 char can_set; 00127 00128 } netsnmp_table_array_callbacks; 00129 00130 00131 int 00132 netsnmp_table_container_register(netsnmp_handler_registration *reginfo, 00133 netsnmp_table_registration_info 00134 *tabreq, 00135 netsnmp_table_array_callbacks *cb, 00136 netsnmp_container *container, 00137 int group_rows); 00138 00139 int netsnmp_table_array_register(netsnmp_handler_registration *reginfo, 00140 netsnmp_table_registration_info *tabreq, 00141 netsnmp_table_array_callbacks *cb, 00142 netsnmp_container *container, 00143 int group_rows); 00144 00145 netsnmp_container * netsnmp_extract_array_context(netsnmp_request_info *); 00146 00147 Netsnmp_Node_Handler netsnmp_table_array_helper_handler; 00148 00149 int 00150 netsnmp_table_array_check_row_status(netsnmp_table_array_callbacks *cb, 00151 netsnmp_request_group *ag, 00152 long *rs_new, long *rs_old); 00153 00154 #ifdef __cplusplus 00155 } 00156 #endif 00157 00158 #endif /* _TABLE_ARRAY_HANDLER_H_ */