added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / agent / table_array.h
1 /*
2  * table_array.h
3  * $Id: table_array.h,v 5.8 2002/07/30 06:56:23 rstory Exp $
4  */
5 #ifndef _TABLE_ARRAY_HANDLER_H_
6 #define _TABLE_ARRAY_HANDLER_H_
7
8 #ifdef __cplusplus
9 extern          "C" {
10 #endif
11
12     /*
13      * The table array helper is designed to simplify the task of
14      * writing a table handler for the net-snmp agent when the data being
15      * accessed is in an oid sorted form and must be accessed externally.
16      * 
17      * Functionally, it is a specialized version of the more
18      * generic table helper but easies the burden of GETNEXT processing by
19      * retrieving the appropriate row for ead index through
20      * function calls which should be supplied by the module that wishes
21      * help.  The module the table_array helps should, afterwards,
22      * never be called for the case of "MODE_GETNEXT" and only for the GET
23      * and SET related modes instead.
24      */
25
26 #include <net-snmp/library/container.h>
27 #include <net-snmp/agent/table.h>
28
29 #define TABLE_ARRAY_NAME "table_array"
30
31     /*
32      * group_item is to allow us to keep a list of requests without
33      * disrupting the actual netsnmp_request_info list.
34      */
35     typedef struct netsnmp_request_group_item_s {
36         netsnmp_request_info *ri;
37         netsnmp_table_request_info *tri;
38         struct netsnmp_request_group_item_s *next;
39     } netsnmp_request_group_item;
40
41     /*
42      * structure to keep a list of requests for each unique index
43      */
44     typedef struct netsnmp_request_group_s {
45        /*
46         * index for this row. points to someone else's memory, so
47         * don't free it!
48         */
49         netsnmp_index               index;
50
51        /*
52         * container in which rows belong
53         */
54         netsnmp_container           *table;
55
56        /*
57         * actual old and new rows
58         */
59         netsnmp_index               *existing_row;
60         netsnmp_index               *undo_info;
61
62        /*
63         * flags
64         */
65        char                          row_created;
66        char                          row_deleted;
67        char                          fill1;
68        char                          fill2;
69
70        /*
71         * requests for this row
72         */
73         netsnmp_request_group_item  *list;
74
75         int                          status;
76
77         void                        *rg_void;
78
79     } netsnmp_request_group;
80
81     typedef int     (Netsnmp_User_Row_Operation_c) (const void *lhs,
82                                                     const void *rhs);
83     typedef int     (Netsnmp_User_Row_Operation) (void *lhs, void *rhs);
84     typedef int     (Netsnmp_User_Get_Processor) (netsnmp_request_info *,
85                                                   netsnmp_index
86                                                   *,
87                                                   netsnmp_table_request_info
88                                                   *);
89     typedef netsnmp_index
90         *(UserRowMethod) (netsnmp_index *);
91     typedef int     (Netsnmp_User_Row_Action) (netsnmp_index *,
92                                                netsnmp_index *,
93                                                netsnmp_request_group *);
94     typedef void    (Netsnmp_User_Group_Method) (netsnmp_request_group *);
95
96     /*
97      * structure for array callbacks
98      */
99     typedef struct netsnmp_table_array_callbacks_s {
100
101         Netsnmp_User_Row_Operation   *row_copy;
102         Netsnmp_User_Row_Operation_c *row_compare;
103
104         Netsnmp_User_Get_Processor *get_value;
105
106
107         Netsnmp_User_Row_Action *can_activate;
108         Netsnmp_User_Row_Action *activated;
109         Netsnmp_User_Row_Action *can_deactivate;
110         Netsnmp_User_Row_Action *deactivated;
111         Netsnmp_User_Row_Action *can_delete;
112
113         UserRowMethod  *create_row;
114         UserRowMethod  *duplicate_row;
115         UserRowMethod  *delete_row;
116
117         Netsnmp_User_Group_Method *set_reserve1;
118         Netsnmp_User_Group_Method *set_reserve2;
119         Netsnmp_User_Group_Method *set_action;
120         Netsnmp_User_Group_Method *set_commit;
121         Netsnmp_User_Group_Method *set_free;
122         Netsnmp_User_Group_Method *set_undo;
123
124        /** not callbacks, but this is a useful place for them... */
125        netsnmp_container* container;
126        char can_set;
127
128     } netsnmp_table_array_callbacks;
129
130
131     int            
132         netsnmp_table_container_register(netsnmp_handler_registration *reginfo,
133                                      netsnmp_table_registration_info
134                                      *tabreq,
135                                      netsnmp_table_array_callbacks *cb,
136                                      netsnmp_container *container,
137                                      int group_rows);
138
139     netsnmp_container * netsnmp_extract_array_context(netsnmp_request_info *);
140
141     Netsnmp_Node_Handler netsnmp_table_array_helper_handler;
142
143     int
144     netsnmp_table_array_check_row_status(netsnmp_table_array_callbacks *cb,
145                                          netsnmp_request_group *ag,
146                                          long *rs_new, long *rs_old);
147
148 #ifdef __cplusplus
149 };
150 #endif
151
152 #endif                          /* _TABLE_ARRAY_HANDLER_H_ */