added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / agent / table_dataset.h
1 /*
2  * table_iterator.h 
3  */
4 #ifndef _TABLE_DATA_SET_HANDLER_H_
5 #define _TABLE_DATA_SET_HANDLER_H_
6
7 #ifdef __cplusplus
8 extern          "C" {
9 #endif
10
11     /*
12      * This helper is designed to completely automate the task of storing
13      * tables of data within the agent that are not tied to external data
14      * sources (like the kernel, hardware, or other processes, etc).  IE,
15      * all rows within a table are expected to be added manually using
16      * functions found below.
17      */
18
19 #define TABLE_DATA_SET_NAME "netsnmp_table_data_set"
20
21     /*
22      * return SNMP_ERR_NOERROR or some SNMP specific protocol error id 
23      */
24     typedef int     (Netsnmp_Value_Change_Ok) (char *old_value,
25                                                size_t old_value_len,
26                                                char *new_value,
27                                                size_t new_value_len,
28                                                void *mydata);
29
30     /*
31      * stored within a given row 
32      */
33     typedef struct netsnmp_table_data_set_storage_s {
34         unsigned int    column;
35
36         /*
37          * info about it? 
38          */
39         char            writable;
40         Netsnmp_Value_Change_Ok *change_ok_fn;
41         void           *my_change_data;
42
43         /*
44          * data actually stored 
45          */
46         u_char          type;
47         union {                 /* value of variable */
48             void           *voidp;
49             long           *integer;
50             u_char         *string;
51             oid            *objid;
52             u_char         *bitstring;
53             struct counter64 *counter64;
54 #ifdef OPAQUE_SPECIAL_TYPES
55             float          *floatVal;
56             double         *doubleVal;
57 #endif                          /* OPAQUE_SPECIAL_TYPES */
58         } data;
59         u_long          data_len;
60
61         struct netsnmp_table_data_set_storage_s *next;
62     } netsnmp_table_data_set_storage;
63
64     typedef struct netsnmp_table_data_set_s {
65         netsnmp_table_data *table;
66         netsnmp_table_data_set_storage *default_row;
67         int             allow_creation; /* set to 1 to allow creation of new rows */
68         unsigned int    rowstatus_column;
69     } netsnmp_table_data_set;
70
71     Netsnmp_Node_Handler netsnmp_table_data_set_helper_handler;
72
73     /*
74      * to set, add column, type, (writable) ? 1 : 0 
75      */
76     /*
77      * default value, if not NULL, is the default value used in row
78      * creation.  It is copied into the storage template (free your
79      * calling argument). 
80      */
81     int            
82         netsnmp_table_set_add_default_row(netsnmp_table_data_set *,
83                                           unsigned int, int, int,
84                                           void *default_value,
85                                           size_t default_value_len);
86
87     /*
88      * to set, add column, type, (writable) ? 1 : 0, ... 
89      */
90 #if HAVE_STDARG_H
91     void           
92         netsnmp_table_set_multi_add_default_row(netsnmp_table_data_set *,
93                                                 ...);
94 #else
95     void            netsnmp_table_set_multi_add_default_row(va_alist);
96 #endif
97     int             netsnmp_set_row_column(netsnmp_table_row *,
98                                            unsigned int, int, const char *,
99                                            size_t);
100     netsnmp_table_data_set_storage
101         *netsnmp_table_data_set_find_column(netsnmp_table_data_set_storage
102                                             *, unsigned int);
103     netsnmp_table_data_set_storage
104        *netsnmp_extract_table_data_set_column(netsnmp_request_info *,
105                                               unsigned int);
106     int            
107         netsnmp_register_table_data_set(netsnmp_handler_registration *,
108                                         netsnmp_table_data_set *,
109                                         netsnmp_table_registration_info *);
110     netsnmp_mib_handler
111         *netsnmp_get_table_data_set_handler(netsnmp_table_data_set *);
112     netsnmp_table_data_set *netsnmp_create_table_data_set(const char *);
113     int             netsnmp_mark_row_column_writable(netsnmp_table_row
114                                                      *row, int column,
115                                                      int writable);
116     NETSNMP_INLINE netsnmp_table_data_set
117         *netsnmp_extract_table_data_set(netsnmp_request_info *request);
118     void            netsnmp_config_parse_table_set(const char *token,
119                                                    char *line);
120     void            netsnmp_config_parse_add_row(const char *token,
121                                                  char *line);
122     NETSNMP_INLINE void     netsnmp_table_dataset_add_index(netsnmp_table_data_set
123                                                     *table, u_char type);
124     NETSNMP_INLINE void     netsnmp_table_dataset_add_row(netsnmp_table_data_set
125                                                   *table,
126                                                   netsnmp_table_row *row);
127     NETSNMP_INLINE void     netsnmp_table_dataset_remove_row(netsnmp_table_data_set
128                                                      *table,
129                                                      netsnmp_table_row
130                                                      *row);
131     NETSNMP_INLINE void     netsnmp_table_dataset_delete_row(netsnmp_table_row
132                                                      *row);
133     NETSNMP_INLINE void    
134         netsnmp_table_dataset_remove_and_delete_row(netsnmp_table_data_set
135                                                     *table,
136                                                     netsnmp_table_row
137                                                     *row);
138     NETSNMP_INLINE void    
139         netsnmp_table_dataset_delete_all_data
140         (netsnmp_table_data_set_storage *data);
141     NETSNMP_INLINE void    
142         netsnmp_table_dataset_replace_row(netsnmp_table_data_set *table,
143                                           netsnmp_table_row *origrow,
144                                           netsnmp_table_row *newrow);
145     netsnmp_table_row *netsnmp_table_data_set_clone_row(netsnmp_table_row
146                                                         *row);
147     void            netsnmp_register_auto_data_table(netsnmp_table_data_set
148                                                      *table_set,
149                                                      char
150                                                      *registration_name);
151
152 #if HAVE_STDARG_H
153     void           
154         netsnmp_table_set_add_indexes(netsnmp_table_data_set *tset, ...);
155 #else
156     void            netsnmp_table_helper_add_indexes(va_alist);
157 #endif
158
159 #ifdef __cplusplus
160 };
161 #endif
162
163 #define netsnmp_table_row_add_column(row, type, value, value_len) snmp_varlist_add_variable(&row->indexes, NULL, 0, type, (u_char *) value, value_len)
164
165 #endif                          /* _TABLE_DATA_SET_HANDLER_H_ */