00001 /* 00002 * table_iterator.h 00003 */ 00004 #ifndef _TABLE_DATA_SET_HANDLER_H_ 00005 #define _TABLE_DATA_SET_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 void netsnmp_init_table_dataset(void); 00020 00021 #define TABLE_DATA_SET_NAME "netsnmp_table_data_set" 00022 00023 /* 00024 * return SNMP_ERR_NOERROR or some SNMP specific protocol error id 00025 */ 00026 typedef int (Netsnmp_Value_Change_Ok) (char *old_value, 00027 size_t old_value_len, 00028 char *new_value, 00029 size_t new_value_len, 00030 void *mydata); 00031 00032 /* 00033 * stored within a given row 00034 */ 00035 typedef struct netsnmp_table_data_set_storage_s { 00036 unsigned int column; 00037 00038 /* 00039 * info about it? 00040 */ 00041 char writable; 00042 Netsnmp_Value_Change_Ok *change_ok_fn; 00043 void *my_change_data; 00044 00045 /* 00046 * data actually stored 00047 */ 00048 u_char type; 00049 union { /* value of variable */ 00050 void *voidp; 00051 long *integer; 00052 u_char *string; 00053 oid *objid; 00054 u_char *bitstring; 00055 struct counter64 *counter64; 00056 #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES 00057 float *floatVal; 00058 double *doubleVal; 00059 #endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */ 00060 } data; 00061 u_long data_len; 00062 00063 struct netsnmp_table_data_set_storage_s *next; 00064 } netsnmp_table_data_set_storage; 00065 00066 typedef struct netsnmp_table_data_set_s { 00067 netsnmp_table_data *table; 00068 netsnmp_table_data_set_storage *default_row; 00069 int allow_creation; /* set to 1 to allow creation of new rows */ 00070 unsigned int rowstatus_column; 00071 } netsnmp_table_data_set; 00072 00073 00074 /* ============================ 00075 * DataSet API: Table maintenance 00076 * ============================ */ 00077 00078 netsnmp_table_data_set *netsnmp_create_table_data_set(const char *); 00079 netsnmp_table_row *netsnmp_table_data_set_clone_row( netsnmp_table_row *row); 00080 void netsnmp_table_dataset_delete_all_data( 00081 netsnmp_table_data_set_storage *data); 00082 void netsnmp_table_dataset_delete_row(netsnmp_table_row *row); 00083 00084 void netsnmp_table_dataset_add_row(netsnmp_table_data_set 00085 *table, 00086 netsnmp_table_row *row); 00087 void 00088 netsnmp_table_dataset_replace_row(netsnmp_table_data_set *table, 00089 netsnmp_table_row *origrow, 00090 netsnmp_table_row *newrow); 00091 void netsnmp_table_dataset_remove_row(netsnmp_table_data_set 00092 *table, 00093 netsnmp_table_row *row); 00094 void 00095 netsnmp_table_dataset_remove_and_delete_row(netsnmp_table_data_set 00096 *table, 00097 netsnmp_table_row *row); 00098 00099 /* ============================ 00100 * DataSet API: Default row operations 00101 * ============================ */ 00102 00103 /* 00104 * to set, add column, type, (writable) ? 1 : 0 00105 */ 00106 /* 00107 * default value, if not NULL, is the default value used in row 00108 * creation. It is copied into the storage template (free your 00109 * calling argument). 00110 */ 00111 int netsnmp_table_set_add_default_row(netsnmp_table_data_set *, 00112 unsigned int, int, int, 00113 void *default_value, 00114 size_t default_value_len); 00115 void netsnmp_table_set_multi_add_default_row(netsnmp_table_data_set *, 00116 ...); 00117 00118 00119 /* ============================ 00120 * DataSet API: MIB maintenance 00121 * ============================ */ 00122 00123 netsnmp_mib_handler 00124 *netsnmp_get_table_data_set_handler(netsnmp_table_data_set *); 00125 Netsnmp_Node_Handler netsnmp_table_data_set_helper_handler; 00126 int netsnmp_register_table_data_set(netsnmp_handler_registration *, 00127 netsnmp_table_data_set *, 00128 netsnmp_table_registration_info *); 00129 netsnmp_table_data_set 00130 *netsnmp_extract_table_data_set(netsnmp_request_info *request); 00131 netsnmp_table_data_set_storage 00132 *netsnmp_extract_table_data_set_column(netsnmp_request_info *, 00133 unsigned int); 00134 00135 00136 /* ============================ 00137 * DataSet API: Config-based operations 00138 * ============================ */ 00139 00140 void netsnmp_register_auto_data_table(netsnmp_table_data_set *table_set, 00141 char *registration_name); 00142 void netsnmp_config_parse_table_set(const char *token, char *line); 00143 void netsnmp_config_parse_add_row( const char *token, char *line); 00144 00145 00146 /* ============================ 00147 * DataSet API: Row operations 00148 * ============================ */ 00149 00150 netsnmp_table_row *netsnmp_table_data_set_get_first_row(netsnmp_table_data_set *table); 00151 netsnmp_table_row *netsnmp_table_data_set_get_next_row( netsnmp_table_data_set *table, 00152 netsnmp_table_row *row); 00153 int netsnmp_table_set_num_rows(netsnmp_table_data_set *table); 00154 00155 00156 /* ============================ 00157 * DataSet API: Column operations 00158 * ============================ */ 00159 00160 netsnmp_table_data_set_storage 00161 *netsnmp_table_data_set_find_column(netsnmp_table_data_set_storage *, 00162 unsigned int); 00163 int netsnmp_mark_row_column_writable( netsnmp_table_row *row, 00164 int column, int writable); 00165 int netsnmp_set_row_column( netsnmp_table_row *, 00166 unsigned int, int, const char *, 00167 size_t); 00168 00169 /* ============================ 00170 * DataSet API: Index operations 00171 * ============================ */ 00172 00173 void netsnmp_table_dataset_add_index(netsnmp_table_data_set 00174 *table, u_char type); 00175 void netsnmp_table_set_add_indexes(netsnmp_table_data_set *tset, ...); 00176 00177 #ifdef __cplusplus 00178 } 00179 #endif 00180 00181 #define netsnmp_table_row_add_column(row, type, value, value_len) snmp_varlist_add_variable(&row->indexes, NULL, 0, type, (u_char *) value, value_len) 00182 00183 #endif /* _TABLE_DATA_SET_HANDLER_H_ */
Last modified: Wednesday, 01-Aug-2018 04:41:28 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.