table_tdata.h

00001 /*
00002  * table_tdata.h 
00003  */
00004 #ifndef _TABLE_TDATA_HANDLER_H_
00005 #define _TABLE_TDATA_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_TDATA_NAME  "table_tdata"
00020 #define TABLE_TDATA_ROW   "table_tdata"
00021 #define TABLE_TDATA_TABLE "table_tdata_table"
00022 
00023 #define TDATA_FLAG_NO_STORE_INDEXES   0x01
00024 
00025     /*
00026      * The (table-independent) per-row data structure
00027      * This is a wrapper round the table-specific per-row data
00028      *   structure, which is referred to as a "table entry"
00029      *
00030      * It should be regarded as an opaque, private data structure,
00031      *   and shouldn't be accessed directly.
00032      */
00033     typedef struct netsnmp_tdata_row_s {
00034         netsnmp_index   oid_index;      /* table_container index format */
00035         netsnmp_variable_list *indexes; /* stored permanently if store_indexes = 1 */
00036         void           *data;   /* the data to store */
00037     } netsnmp_tdata_row;
00038 
00039     /*
00040      * The data structure to hold a complete table.
00041      *
00042      * This should be regarded as an opaque, private data structure,
00043      *   and shouldn't be accessed directly.
00044      */
00045     typedef struct netsnmp_tdata_s {
00046         netsnmp_variable_list *indexes_template;        /* containing only types */
00047         char           *name;   /* if !NULL, it's registered globally */
00048         int             flags;  /* This field may legitimately be accessed by external code */
00049         netsnmp_container *container;
00050     } netsnmp_tdata;
00051 
00052 /* Backwards compatability with the previous (poorly named) data structures */
00053 typedef  struct netsnmp_tdata_row_s netsnmp_table_data2row;
00054 typedef  struct netsnmp_tdata_s     netsnmp_table_data2;
00055 
00056 
00057 /* ============================
00058  * TData API: Table maintenance
00059  * ============================ */
00060 
00061     netsnmp_tdata     *netsnmp_tdata_create_table(const char *name, long flags);
00062     void               netsnmp_tdata_delete_table(netsnmp_tdata *table);
00063     netsnmp_tdata_row *netsnmp_tdata_create_row(void);
00064     netsnmp_tdata_row *netsnmp_tdata_clone_row( netsnmp_tdata_row *row);
00065     int                netsnmp_tdata_copy_row(  netsnmp_tdata_row *dst_row,
00066                                                 netsnmp_tdata_row *src_row);
00067     void           *netsnmp_tdata_delete_row(   netsnmp_tdata_row *row);
00068 
00069     int             netsnmp_tdata_add_row(      netsnmp_tdata     *table,
00070                                                 netsnmp_tdata_row *row);
00071     void            netsnmp_tdata_replace_row(  netsnmp_tdata     *table,
00072                                                 netsnmp_tdata_row *origrow,
00073                                                 netsnmp_tdata_row *newrow);
00074     netsnmp_tdata_row *netsnmp_tdata_remove_row(netsnmp_tdata     *table,
00075                                                 netsnmp_tdata_row *row);
00076     void   *netsnmp_tdata_remove_and_delete_row(netsnmp_tdata     *table,
00077                                                 netsnmp_tdata_row *row);
00078 
00079 
00080 /* ============================
00081  * TData API: MIB maintenance
00082  * ============================ */
00083 
00084     netsnmp_mib_handler *netsnmp_get_tdata_handler(netsnmp_tdata *table);
00085 
00086     int netsnmp_tdata_register(netsnmp_handler_registration *reginfo,
00087                                netsnmp_tdata                *table,
00088                                netsnmp_table_registration_info *table_info);
00089 
00090     netsnmp_tdata      *netsnmp_tdata_extract_table(    netsnmp_request_info *);
00091     netsnmp_container  *netsnmp_tdata_extract_container(netsnmp_request_info *);
00092     netsnmp_tdata_row  *netsnmp_tdata_extract_row(      netsnmp_request_info *);
00093     void               *netsnmp_tdata_extract_entry(    netsnmp_request_info *);
00094 
00095     void netsnmp_insert_tdata_row(netsnmp_request_info *, netsnmp_tdata_row *);
00096 
00097 
00098 /* ============================
00099  * TData API: Row operations
00100  * ============================ */
00101 
00102     void * netsnmp_tdata_row_entry( netsnmp_tdata_row *row );
00103     netsnmp_tdata_row *netsnmp_tdata_row_first(netsnmp_tdata     *table);
00104     netsnmp_tdata_row *netsnmp_tdata_row_get(  netsnmp_tdata     *table,
00105                                                netsnmp_tdata_row *row);
00106     netsnmp_tdata_row *netsnmp_tdata_row_next( netsnmp_tdata     *table,
00107                                                netsnmp_tdata_row *row);
00108 
00109     netsnmp_tdata_row *netsnmp_tdata_row_get_byidx(netsnmp_tdata      *table,
00110                                                 netsnmp_variable_list *indexes);
00111     netsnmp_tdata_row *netsnmp_tdata_row_get_byoid(netsnmp_tdata      *table,
00112                                                 oid   *searchfor,
00113                                                 size_t searchfor_len);
00114     netsnmp_tdata_row *netsnmp_tdata_row_next_byidx(netsnmp_tdata     *table,
00115                                                 netsnmp_variable_list *indexes);
00116     netsnmp_tdata_row *netsnmp_tdata_row_next_byoid(netsnmp_tdata     *table,
00117                                                 oid   *searchfor,
00118                                                 size_t searchfor_len);
00119 
00120     int netsnmp_tdata_row_count(netsnmp_tdata *table);
00121 
00122 
00123 /* ============================
00124  * TData API: Index operations
00125  * ============================ */
00126 
00127 #define netsnmp_tdata_add_index(thetable, type) snmp_varlist_add_variable(&thetable->indexes_template, NULL, 0, type, NULL, 0)
00128 #define netsnmp_tdata_row_add_index(row, type, value, value_len) snmp_varlist_add_variable(&row->indexes, NULL, 0, type, (const u_char *) value, value_len)
00129 
00130     int netsnmp_tdata_compare_idx(        netsnmp_tdata_row     *row,
00131                                           netsnmp_variable_list *indexes);
00132     int netsnmp_tdata_compare_oid(        netsnmp_tdata_row     *row,
00133                                           oid *compareto, size_t compareto_len);
00134     int netsnmp_tdata_compare_subtree_idx(netsnmp_tdata_row     *row,
00135                                           netsnmp_variable_list *indexes);
00136     int netsnmp_tdata_compare_subtree_oid(netsnmp_tdata_row     *row,
00137                                           oid *compareto, size_t compareto_len);
00138 
00139 
00140 #ifdef __cplusplus
00141 }
00142 #endif
00143 
00144 #endif                          /* _TABLE_TDATA_HANDLER_H_ */

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