table_dataset.h

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 OPAQUE_SPECIAL_TYPES
00057             float          *floatVal;
00058             double         *doubleVal;
00059 #endif                          /* 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     NETSNMP_INLINE void netsnmp_table_dataset_delete_all_data(
00081                             netsnmp_table_data_set_storage *data);
00082     NETSNMP_INLINE void netsnmp_table_dataset_delete_row(netsnmp_table_row *row);
00083 
00084     NETSNMP_INLINE void netsnmp_table_dataset_add_row(netsnmp_table_data_set
00085                                                   *table,
00086                                                   netsnmp_table_row *row);
00087     NETSNMP_INLINE void    
00088         netsnmp_table_dataset_replace_row(netsnmp_table_data_set *table,
00089                                           netsnmp_table_row *origrow,
00090                                           netsnmp_table_row *newrow);
00091     NETSNMP_INLINE void netsnmp_table_dataset_remove_row(netsnmp_table_data_set
00092                                                      *table,
00093                                                      netsnmp_table_row *row);
00094     NETSNMP_INLINE 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 #if HAVE_STDARG_H
00116     void netsnmp_table_set_multi_add_default_row(netsnmp_table_data_set *,
00117                                                 ...);
00118 #else
00119     void netsnmp_table_set_multi_add_default_row(va_alist);
00120 #endif
00121 
00122 
00123 /* ============================
00124  * DataSet API: MIB maintenance
00125  * ============================ */
00126 
00127     netsnmp_mib_handler
00128         *netsnmp_get_table_data_set_handler(netsnmp_table_data_set *);
00129     Netsnmp_Node_Handler netsnmp_table_data_set_helper_handler;
00130     int netsnmp_register_table_data_set(netsnmp_handler_registration *,
00131                                         netsnmp_table_data_set *,
00132                                         netsnmp_table_registration_info *);
00133     NETSNMP_INLINE netsnmp_table_data_set
00134         *netsnmp_extract_table_data_set(netsnmp_request_info *request);
00135     netsnmp_table_data_set_storage
00136         *netsnmp_extract_table_data_set_column(netsnmp_request_info *,
00137                                                unsigned int);
00138 
00139 
00140 /* ============================
00141  * DataSet API: Config-based operations
00142  * ============================ */
00143 
00144     void netsnmp_register_auto_data_table(netsnmp_table_data_set *table_set,
00145                                           char *registration_name);
00146     void netsnmp_config_parse_table_set(const char *token, char *line);
00147     void netsnmp_config_parse_add_row(  const char *token, char *line);
00148 
00149 
00150 /* ============================
00151  * DataSet API: Row operations
00152  * ============================ */
00153 
00154     netsnmp_table_row *netsnmp_table_data_set_get_first_row(netsnmp_table_data_set *table);
00155     netsnmp_table_row *netsnmp_table_data_set_get_next_row( netsnmp_table_data_set *table,
00156                                                             netsnmp_table_row      *row);
00157     int netsnmp_table_set_num_rows(netsnmp_table_data_set *table);
00158 
00159 
00160 /* ============================
00161  * DataSet API: Column operations
00162  * ============================ */
00163 
00164     netsnmp_table_data_set_storage
00165         *netsnmp_table_data_set_find_column(netsnmp_table_data_set_storage *,
00166                                             unsigned int);
00167     int  netsnmp_mark_row_column_writable(  netsnmp_table_row *row,
00168                                             int column, int writable);
00169     int  netsnmp_set_row_column(            netsnmp_table_row *,
00170                                             unsigned int, int, const char *,
00171                                             size_t);
00172 
00173 /* ============================
00174  * DataSet API: Index operations
00175  * ============================ */
00176 
00177     NETSNMP_INLINE void netsnmp_table_dataset_add_index(netsnmp_table_data_set
00178                                                     *table, u_char type);
00179 #if HAVE_STDARG_H
00180     void netsnmp_table_set_add_indexes(netsnmp_table_data_set *tset, ...);
00181 #else
00182     void netsnmp_table_helper_add_indexes(va_alist);
00183 #endif
00184 
00185 #ifdef __cplusplus
00186 }
00187 #endif
00188 
00189 #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)
00190 
00191 #endif                          /* _TABLE_DATA_SET_HANDLER_H_ */

net-snmpに対してSat Sep 5 13:14:27 2009に生成されました。  doxygen 1.4.7