net-snmp 5.7
table.h
00001 /* Portions of this file are subject to the following copyright(s).  See
00002  * the Net-SNMP's COPYING file for more details and other copyrights
00003  * that may apply:
00004  */
00005 /*
00006  * Portions of this file are copyrighted by:
00007  * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
00008  * Use is subject to license terms specified in the COPYING file
00009  * distributed with the Net-SNMP package.
00010  */
00011 /*
00012  * Portions of this file are copyrighted by:
00013  * Copyright (C) 2007 Apple, Inc. All rights reserved.
00014  * Use is subject to license terms specified in the COPYING file
00015  * distributed with the Net-SNMP package.
00016  */
00017 /*
00018  * @file table.h
00019  *
00020  * @addtogroup table
00021  *
00022  * @{
00023  */
00024 #ifndef _TABLE_HANDLER_H_
00025 #define _TABLE_HANDLER_H_
00026 
00027 #ifdef __cplusplus
00028 extern          "C" {
00029 #endif
00030 
00049 #define TABLE_HANDLER_NAME "table"
00050 
00058     typedef struct netsnmp_column_info_t {
00059         char            isRange;
00061         char            list_count;
00062 
00063         union {
00064             unsigned int    range[2];
00065             unsigned int   *list;
00066         } details;
00067 
00068         struct netsnmp_column_info_t *next;
00069 
00070     } netsnmp_column_info;
00071 
00080     typedef struct netsnmp_table_registration_info_s {
00082         netsnmp_variable_list *indexes;
00084         unsigned int    number_indexes;
00085 
00091         unsigned int    min_column;
00093         unsigned int    max_column;
00094 
00096         netsnmp_column_info *valid_columns;
00097 
00098     } netsnmp_table_registration_info;
00099 
00108     typedef struct netsnmp_table_request_info_s {
00110         unsigned int    colnum;
00112         unsigned int    number_indexes;
00114         netsnmp_variable_list *indexes;
00115 
00116         oid             index_oid[MAX_OID_LEN];
00117         size_t          index_oid_len;
00118         netsnmp_table_registration_info *reg_info;
00119     } netsnmp_table_request_info;
00120 
00121     netsnmp_mib_handler
00122         *netsnmp_get_table_handler(netsnmp_table_registration_info
00123                                    *tabreq);
00124     void  netsnmp_handler_owns_table_info(netsnmp_mib_handler *handler);
00125     void  netsnmp_registration_owns_table_info(netsnmp_handler_registration *reg);
00126     int   netsnmp_register_table(  netsnmp_handler_registration    *reginfo,
00127                                    netsnmp_table_registration_info *tabreq);
00128     int   netsnmp_unregister_table(netsnmp_handler_registration    *reginfo);
00129     int   netsnmp_table_build_oid( netsnmp_handler_registration    *reginfo,
00130                                    netsnmp_request_info            *reqinfo,
00131                                    netsnmp_table_request_info   *table_info);
00132     int            
00133         netsnmp_table_build_oid_from_index(netsnmp_handler_registration
00134                                            *reginfo,
00135                                            netsnmp_request_info *reqinfo,
00136                                            netsnmp_table_request_info
00137                                            *table_info);
00138     int             netsnmp_table_build_result(netsnmp_handler_registration
00139                                                *reginfo,
00140                                                netsnmp_request_info
00141                                                *reqinfo,
00142                                                netsnmp_table_request_info
00143                                                *table_info, u_char type,
00144                                                u_char * result,
00145                                                size_t result_len);
00146     int            
00147         netsnmp_update_variable_list_from_index(netsnmp_table_request_info
00148                                                 *);
00149     int            
00150         netsnmp_update_indexes_from_variable_list
00151         (netsnmp_table_request_info *tri);
00152     netsnmp_table_registration_info
00153         *netsnmp_find_table_registration_info(netsnmp_handler_registration
00154                                               *reginfo);
00155     netsnmp_table_registration_info *
00156         netsnmp_table_registration_info_clone(netsnmp_table_registration_info *tri);
00157     void netsnmp_table_registration_info_free(netsnmp_table_registration_info *);
00158 
00159     netsnmp_index * netsnmp_table_index_find_next_row(netsnmp_container *c,
00160                                                       netsnmp_table_request_info *tblreq);
00161 
00162     unsigned int    netsnmp_closest_column(unsigned int current,
00163                                            netsnmp_column_info
00164                                            *valid_columns);
00165 
00166     Netsnmp_Node_Handler table_helper_handler;
00167 
00168 #define netsnmp_table_helper_add_index(tinfo, type) snmp_varlist_add_variable(&tinfo->indexes, NULL, 0, (u_char)type, NULL, 0);
00169 
00170     void           
00171         netsnmp_table_helper_add_indexes(netsnmp_table_registration_info
00172                                          *tinfo, ...);
00173 
00174     int netsnmp_check_getnext_reply(netsnmp_request_info *request,
00175                                     oid * prefix, size_t prefix_len,
00176                                     netsnmp_variable_list * newvar,
00177                                     netsnmp_variable_list ** outvar);
00178 
00179     netsnmp_table_request_info
00180         *netsnmp_extract_table_info(netsnmp_request_info *);
00181     netsnmp_oid_stash_node
00182         **netsnmp_table_get_or_create_row_stash(netsnmp_agent_request_info
00183                                                 *reqinfo,
00184                                                 const u_char *
00185                                                 storage_name);
00186         unsigned int
00187                 netsnmp_table_next_column(netsnmp_table_request_info *table_info);
00188 
00189 
00190     int   netsnmp_sparse_table_register(netsnmp_handler_registration    *reginfo,
00191                                         netsnmp_table_registration_info *tabreq);
00192 
00193     netsnmp_mib_handler *netsnmp_sparse_table_handler_get(void);
00194 
00195 #ifdef __cplusplus
00196 }
00197 #endif
00198 
00199 #endif                          /* _TABLE_HANDLER_H_ */
00200