net-snmp 5.7
|
00001 /* 00002 * table_iterator.h 00003 */ 00004 #ifndef _TABLE_DATA_HANDLER_H_ 00005 #define _TABLE_DATA_HANDLER_H_ 00006 00007 #ifdef __cplusplus 00008 extern "C" { 00009 #endif 00010 00011 /* 00012 * This helper is designed to completely automate the task of storing 00013 * tables of data within the agent that are not tied to external data 00014 * sources (like the kernel, hardware, or other processes, etc). IE, 00015 * all rows within a table are expected to be added manually using 00016 * functions found below. 00017 */ 00018 00019 #define TABLE_DATA_NAME "table_data" 00020 #define TABLE_DATA_ROW "table_data" 00021 #define TABLE_DATA_TABLE "table_data_table" 00022 00023 typedef struct netsnmp_table_row_s { 00024 netsnmp_variable_list *indexes; /* stored permanently if store_indexes = 1 */ 00025 oid *index_oid; 00026 size_t index_oid_len; 00027 void *data; /* the data to store */ 00028 00029 struct netsnmp_table_row_s *next, *prev; /* if used in a list */ 00030 } netsnmp_table_row; 00031 00032 typedef struct netsnmp_table_data_s { 00033 netsnmp_variable_list *indexes_template; /* containing only types */ 00034 char *name; /* if !NULL, it's registered globally */ 00035 int flags; /* not currently used */ 00036 int store_indexes; 00037 netsnmp_table_row *first_row; 00038 netsnmp_table_row *last_row; 00039 } netsnmp_table_data; 00040 00041 /* ================================= 00042 * Table Data API: Table maintenance 00043 * ================================= */ 00044 00045 void netsnmp_table_data_generate_index_oid( netsnmp_table_row *row); 00046 00047 netsnmp_table_data *netsnmp_create_table_data(const char *name); 00048 netsnmp_table_row *netsnmp_create_table_data_row(void); 00049 netsnmp_table_row *netsnmp_table_data_clone_row( netsnmp_table_row *row); 00050 void *netsnmp_table_data_delete_row(netsnmp_table_row *row); 00051 int netsnmp_table_data_add_row( netsnmp_table_data *table, 00052 netsnmp_table_row *row); 00053 void 00054 netsnmp_table_data_replace_row(netsnmp_table_data *table, 00055 netsnmp_table_row *origrow, 00056 netsnmp_table_row *newrow); 00057 netsnmp_table_row *netsnmp_table_data_remove_row(netsnmp_table_data *table, 00058 netsnmp_table_row *row); 00059 void *netsnmp_table_data_remove_and_delete_row(netsnmp_table_data *table, 00060 netsnmp_table_row *row); 00061 void netsnmp_table_data_delete_table( netsnmp_table_data *table ); 00062 00063 /* ================================= 00064 * Table Data API: MIB maintenance 00065 * ================================= */ 00066 00067 netsnmp_mib_handler * 00068 netsnmp_get_table_data_handler(netsnmp_table_data *table); 00069 00070 int netsnmp_register_table_data(netsnmp_handler_registration *reginfo, 00071 netsnmp_table_data *table, 00072 netsnmp_table_registration_info *table_info); 00073 int netsnmp_register_read_only_table_data( 00074 netsnmp_handler_registration *reginfo, 00075 netsnmp_table_data *table, 00076 netsnmp_table_registration_info *table_info); 00077 Netsnmp_Node_Handler netsnmp_table_data_helper_handler; 00078 00079 netsnmp_table_data *netsnmp_extract_table( netsnmp_request_info *); 00080 netsnmp_table_row *netsnmp_extract_table_row(netsnmp_request_info *); 00081 void *netsnmp_extract_table_row_data(netsnmp_request_info *); 00082 void netsnmp_insert_table_row(netsnmp_request_info *, netsnmp_table_row *); 00083 00084 int netsnmp_table_data_build_result(netsnmp_handler_registration *reginfo, 00085 netsnmp_agent_request_info *reqinfo, 00086 netsnmp_request_info *request, 00087 netsnmp_table_row *row, int column, 00088 u_char type, u_char * result_data, 00089 size_t result_data_len); 00090 00091 /* ================================= 00092 * Table Data API: Row operations 00093 * ================================= */ 00094 00095 netsnmp_table_row *netsnmp_table_data_get_first_row( 00096 netsnmp_table_data *table); 00097 netsnmp_table_row *netsnmp_table_data_get_next_row( 00098 netsnmp_table_data *table, 00099 netsnmp_table_row *row); 00100 00101 netsnmp_table_row *netsnmp_table_data_get(netsnmp_table_data *table, 00102 netsnmp_variable_list *indexes); 00103 00104 netsnmp_table_row *netsnmp_table_data_get_from_oid( 00105 netsnmp_table_data *table, 00106 oid * searchfor, 00107 size_t searchfor_len); 00108 00109 int netsnmp_table_data_num_rows(netsnmp_table_data *table); 00110 00111 00112 /* ================================= 00113 * Table Data API: Index operations 00114 * ================================= */ 00115 00116 #define netsnmp_table_data_add_index(thetable, type) snmp_varlist_add_variable(&thetable->indexes_template, NULL, 0, type, NULL, 0) 00117 #define netsnmp_table_row_add_index(row, type, value, value_len) snmp_varlist_add_variable(&row->indexes, NULL, 0, type, (const u_char *) value, value_len) 00118 00119 00120 #ifdef __cplusplus 00121 } 00122 #endif 00123 00124 #endif /* _TABLE_DATA_HANDLER_H_ */