net-snmp 5.7
table_container.h
00001 /*
00002  * table_container.h
00003  * $Id$
00004  */
00005 #ifndef _TABLE_CONTAINER_HANDLER_H_
00006 #define _TABLE_CONTAINER_HANDLER_H_
00007 
00008 #ifdef __cplusplus
00009 extern          "C" {
00010 #endif
00011 
00012     /*
00013      * The table container helper is designed to simplify the task of
00014      * writing a table handler for the net-snmp agent when the data being
00015      * accessed is accessible via a netsnmp_container.
00016      * 
00017      * Functionally, it is a specialized version of the more
00018      * generic table helper but easies the burden of GETNEXT processing by
00019      * retrieving the appropriate row for each index through
00020      * function calls which should be supplied by the module that wishes
00021      * help.  The module the table_container helps should, afterwards,
00022      * never be called for the case of "MODE_GETNEXT" and only for the GET
00023      * and SET related modes instead.
00024      */
00025     
00026 #include <net-snmp/library/container.h>
00027 #include <net-snmp/agent/table.h>
00028     
00029 #define TABLE_CONTAINER_ROW       "table_container:row"
00030 #define TABLE_CONTAINER_CONTAINER "table_container:container"
00031     
00032 #define TABLE_CONTAINER_KEY_NETSNMP_INDEX         1 /* default */
00033 #define TABLE_CONTAINER_KEY_VARBIND_INDEX         2
00034 #define TABLE_CONTAINER_KEY_VARBIND_RAW           3
00035 
00036 /* ====================================
00037  * Container Table API: MIB maintenance
00038  * ==================================== */
00039 
00040     /*
00041      * get an injectable container table handler
00042      */
00043     netsnmp_mib_handler *
00044     netsnmp_container_table_handler_get(netsnmp_table_registration_info *tabreq,
00045                                         netsnmp_container *container,
00046                                         char key_type);
00047     /*
00048      * register a container table
00049      */
00050     int            
00051     netsnmp_container_table_register(netsnmp_handler_registration *reginfo,
00052                                      netsnmp_table_registration_info *tabreq,
00053                                      netsnmp_container *container,
00054                                      char key_type);
00055     int            
00056     netsnmp_container_table_unregister(netsnmp_handler_registration *reginfo);
00057     
00059     netsnmp_container*
00060     netsnmp_container_table_container_extract(netsnmp_request_info *request);
00061 
00063 #ifdef NETSNMP_USE_INLINE
00064     NETSNMP_STATIC_INLINE void *
00065     netsnmp_container_table_row_extract(netsnmp_request_info *request)
00066     {
00067         /*
00068          * NOTE: this function must match in table_container.c and table_container.h.
00069          *       if you change one, change them both!
00070          */
00071         return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
00072     }
00073 
00074     NETSNMP_STATIC_INLINE void *
00075     netsnmp_container_table_extract_context(netsnmp_request_info *request)
00076     {
00077         /*
00078          * NOTE: this function must match in table_container.c and table_container.h.
00079          *       if you change one, change them both!
00080          */
00081         return netsnmp_request_get_list_data(request, TABLE_CONTAINER_ROW);
00082     }
00083 #else
00084     void *
00085     netsnmp_container_table_row_extract(netsnmp_request_info *request);
00086     void *
00087     netsnmp_container_table_extract_context(netsnmp_request_info *request);
00088 #endif /* inline */
00089 
00090     void netsnmp_container_table_row_insert(netsnmp_request_info *request,
00091                                             netsnmp_index *row);
00092     void netsnmp_container_table_row_remove(netsnmp_request_info *request,
00093                                             netsnmp_index        *row);
00094 
00095 /* ===================================
00096  * Container Table API: Row operations
00097  * =================================== */
00098 
00099     void *
00100     netsnmp_container_table_find_next_row(netsnmp_request_info *request,
00101                                           netsnmp_table_request_info *tblreq,
00102                                           netsnmp_container *container,
00103                                           char key_type );
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #endif                          /* _TABLE_CONTAINER_HANDLER_H_ */