and added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / agent / table.h
1 /*
2  * testhandler.h 
3  */
4 #ifndef _TABLE_HANDLER_H_
5 #define _TABLE_HANDLER_H_
6
7 #ifdef __cplusplus
8 extern          "C" {
9 #endif
10
11     /*
12      * The table helper is designed to simplify the task of writing a
13      * * table handler for the net-snmp agent.  You should create a normal
14      * * handler and register it using the netsnmp_register_table() function instead
15      * * of the netsnmp_register_handler() function.
16      */
17
18     /*
19      * Notes:
20      *
21      *   1) illegal indexes automatically get handled for get/set cases.
22      *      Simply check to make sure the value is type ASN_NULL before
23      *      you answer a request.
24      */
25
26     /*
27      * used as an index to parent_data lookups 
28      */
29 #define TABLE_HANDLER_NAME "table"
30
31     /*
32      * column info struct.  OVERLAPPING RANGES ARE NOT SUPPORTED.
33      */
34     typedef struct netsnmp_column_info_t {
35         char            isRange;
36         char            list_count;     /* only useful if isRange == 0 */
37
38         union {
39             unsigned int    range[2];
40             unsigned int   *list;
41         } details;
42
43         struct netsnmp_column_info_t *next;
44
45     } netsnmp_column_info;
46
47     typedef struct netsnmp_table_registration_info_s {
48         netsnmp_variable_list *indexes; /* list of varbinds with only 'type' set */
49         unsigned int    number_indexes; /* calculated automatically */
50
51         /*
52          * the minimum and maximum columns numbers. If there are columns
53          * * in-between which are not valid, use valid_columns to get
54          * * automatic column range checking.
55          */
56         unsigned int    min_column;
57         unsigned int    max_column;
58
59         netsnmp_column_info *valid_columns;     /* more details on columns */
60
61     } netsnmp_table_registration_info;
62
63     typedef struct netsnmp_table_request_info_s {
64         unsigned int    colnum; /* 0 if OID not long enough */
65         unsigned int    number_indexes; /* 0 if failure to parse any */
66         netsnmp_variable_list *indexes; /* contents freed by helper upon exit */
67         oid             index_oid[MAX_OID_LEN];
68         size_t          index_oid_len;
69         netsnmp_table_registration_info *reg_info;
70     } netsnmp_table_request_info;
71
72     netsnmp_mib_handler
73         *netsnmp_get_table_handler(netsnmp_table_registration_info
74                                    *tabreq);
75     int             netsnmp_register_table(netsnmp_handler_registration
76                                            *reginfo,
77                                            netsnmp_table_registration_info
78                                            *tabreq);
79     int             netsnmp_table_build_oid(netsnmp_handler_registration
80                                             *reginfo,
81                                             netsnmp_request_info *reqinfo,
82                                             netsnmp_table_request_info
83                                             *table_info);
84     int            
85         netsnmp_table_build_oid_from_index(netsnmp_handler_registration
86                                            *reginfo,
87                                            netsnmp_request_info *reqinfo,
88                                            netsnmp_table_request_info
89                                            *table_info);
90     int             netsnmp_table_build_result(netsnmp_handler_registration
91                                                *reginfo,
92                                                netsnmp_request_info
93                                                *reqinfo,
94                                                netsnmp_table_request_info
95                                                *table_info, u_char type,
96                                                u_char * result,
97                                                size_t result_len);
98     int            
99         netsnmp_update_variable_list_from_index(netsnmp_table_request_info
100                                                 *);
101     int            
102         netsnmp_update_indexes_from_variable_list
103         (netsnmp_table_request_info *tri);
104     netsnmp_table_registration_info
105         *netsnmp_find_table_registration_info(netsnmp_handler_registration
106                                               *reginfo);
107
108     unsigned int    netsnmp_closest_column(unsigned int current,
109                                            netsnmp_column_info
110                                            *valid_columns);
111
112     Netsnmp_Node_Handler table_helper_handler;
113
114 #define netsnmp_table_helper_add_index(tinfo, type) snmp_varlist_add_variable(&tinfo->indexes, NULL, 0, (u_char)type, NULL, 0);
115
116 #if HAVE_STDARG_H
117     void           
118         netsnmp_table_helper_add_indexes(netsnmp_table_registration_info
119                                          *tinfo, ...);
120 #else
121     void            netsnmp_table_helper_add_indexes(va_alist);
122 #endif
123
124     int
125      
126         
127         
128         
129         
130         
131         
132         
133         
134         
135         
136         
137         
138         
139         
140         netsnmp_check_getnext_reply(netsnmp_request_info *request,
141                                     oid * prefix, size_t prefix_len,
142                                     netsnmp_variable_list * newvar,
143                                     netsnmp_variable_list ** outvar);
144
145     netsnmp_table_request_info
146         *netsnmp_extract_table_info(netsnmp_request_info *);
147     netsnmp_oid_stash_node
148         **netsnmp_table_get_or_create_row_stash(netsnmp_agent_request_info
149                                                 *reqinfo,
150                                                 const u_char *
151                                                 storage_name);
152
153 #ifdef __cplusplus
154 };
155 #endif
156
157 #endif                          /* _TABLE_HANDLER_H_ */