table_data.h
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:5k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  * table_iterator.h 
  3.  */
  4. #ifndef _TABLE_DATA_HANDLER_H_
  5. #define _TABLE_DATA_HANDLER_H_
  6. #ifdef __cplusplus
  7. extern          "C" {
  8. #endif
  9.     /*
  10.      * This helper is designed to completely automate the task of storing
  11.      * tables of data within the agent that are not tied to external data
  12.      * sources (like the kernel, hardware, or other processes, etc).  IE,
  13.      * all rows within a table are expected to be added manually using
  14.      * functions found below.
  15.      */
  16. #define TABLE_DATA_NAME "table_data"
  17. #define TABLE_DATA_ROW  "table_data"
  18. #define TABLE_DATA_TABLE "table_data_table"
  19.     typedef struct netsnmp_table_row_s {
  20.         netsnmp_variable_list *indexes; /* stored permanently if store_indexes = 1 */
  21.         oid            *index_oid;
  22.         size_t          index_oid_len;
  23.         void           *data;   /* the data to store */
  24.         struct netsnmp_table_row_s *next, *prev;        /* if used in a list */
  25.     } netsnmp_table_row;
  26.     typedef struct netsnmp_table_data_s {
  27.         netsnmp_variable_list *indexes_template;        /* containing only types */
  28.         char           *name;   /* if !NULL, it's registered globally */
  29.         int             flags;  /* not currently used */
  30.         int             store_indexes;
  31.         netsnmp_table_row *first_row;
  32.         netsnmp_table_row *last_row;
  33.     } netsnmp_table_data;
  34.     netsnmp_mib_handler *netsnmp_get_table_data_handler(netsnmp_table_data
  35.                                                         *table);
  36.     void            netsnmp_table_data_generate_index_oid(netsnmp_table_row
  37.                                                           *row);
  38.     int             netsnmp_table_data_add_row(netsnmp_table_data *table,
  39.                                                netsnmp_table_row *row);
  40.     netsnmp_table_row *netsnmp_table_data_remove_row(netsnmp_table_data
  41.                                                      *table,
  42.                                                      netsnmp_table_row
  43.                                                      *row);
  44.     void           *netsnmp_table_data_delete_row(netsnmp_table_row *row);
  45.     void          
  46.         *netsnmp_table_data_remove_and_delete_row(netsnmp_table_data
  47.                                                   *table,
  48.                                                   netsnmp_table_row *row);
  49.     netsnmp_table_row *netsnmp_table_data_get(netsnmp_table_data *table,
  50.                                               netsnmp_variable_list *
  51.                                               indexes);
  52.     netsnmp_table_row *netsnmp_table_data_get_from_oid(netsnmp_table_data
  53.                                                        *table,
  54.                                                        oid * searchfor,
  55.                                                        size_t
  56.                                                        searchfor_len);
  57.     netsnmp_table_row *netsnmp_table_data_get_first_row(netsnmp_table_data *table);
  58.     netsnmp_table_row *netsnmp_table_data_get_next_row(netsnmp_table_data *table,
  59.                                                        netsnmp_table_row  *row);
  60.     int            
  61.         netsnmp_register_table_data(netsnmp_handler_registration *reginfo,
  62.                                     netsnmp_table_data *table,
  63.                                     netsnmp_table_registration_info
  64.                                     *table_info);
  65.     int            
  66.         netsnmp_register_read_only_table_data(netsnmp_handler_registration
  67.                                               *reginfo,
  68.                                               netsnmp_table_data *table,
  69.                                               netsnmp_table_registration_info
  70.                                               *table_info);
  71.     netsnmp_table_row  *netsnmp_extract_table_row(netsnmp_request_info *);
  72.     netsnmp_table_data *netsnmp_extract_table(    netsnmp_request_info *);
  73.     void           *netsnmp_extract_table_row_data(netsnmp_request_info *);
  74.     void netsnmp_insert_table_row(netsnmp_request_info *, netsnmp_table_row *);
  75.     netsnmp_table_data *netsnmp_create_table_data(const char *name);
  76.     netsnmp_table_row *netsnmp_create_table_data_row(void);
  77.     netsnmp_table_row *netsnmp_table_data_clone_row(netsnmp_table_row
  78.                                                     *row);
  79.     NETSNMP_INLINE void
  80.        netsnmp_table_data_replace_row(netsnmp_table_data *table,
  81.                                       netsnmp_table_row *origrow,
  82.                                       netsnmp_table_row *newrow);
  83.     int            
  84.         netsnmp_table_data_build_result(netsnmp_handler_registration
  85.                                         *reginfo,
  86.                                         netsnmp_agent_request_info
  87.                                         *reqinfo,
  88.                                         netsnmp_request_info *request,
  89.                                         netsnmp_table_row *row, int column,
  90.                                         u_char type, u_char * result_data,
  91.                                         size_t result_data_len);
  92.     int netsnmp_table_data_num_rows(netsnmp_table_data *table);
  93. #define netsnmp_table_data_add_index(thetable, type) snmp_varlist_add_variable(&thetable->indexes_template, NULL, 0, type, NULL, 0)
  94. #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)
  95.     Netsnmp_Node_Handler netsnmp_table_data_helper_handler;
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif                          /* _TABLE_DATA_HANDLER_H_ */