added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / agent / agent_handler.h
1 #ifndef AGENT_HANDLER_H
2 #define AGENT_HANDLER_H
3
4 #ifdef __cplusplus
5 extern          "C" {
6 #endif
7
8 /** @addgroup handler */
9
10     struct netsnmp_handler_registration_s;
11
12     typedef struct netsnmp_mib_handler_s {
13         char           *handler_name;
14         void           *myvoid; /* for handler's internal use */
15
16         int             (*access_method) (struct netsnmp_mib_handler_s *,
17                                           struct
18                                           netsnmp_handler_registration_s *,
19                                           struct
20                                           netsnmp_agent_request_info_s *,
21                                           struct netsnmp_request_info_s *);
22
23         struct netsnmp_mib_handler_s *next;
24         struct netsnmp_mib_handler_s *prev;
25     } netsnmp_mib_handler;
26
27 #define HANDLER_CAN_GETANDGETNEXT     0x1       /* must be able to do both */
28 #define HANDLER_CAN_SET               0x2
29 #define HANDLER_CAN_GETBULK           0x4
30
31 #define HANDLER_CAN_RONLY   (HANDLER_CAN_GETANDGETNEXT)
32 #define HANDLER_CAN_RWRITE  (HANDLER_CAN_GETANDGETNEXT | HANDLER_CAN_SET)
33 #define HANDLER_CAN_DEFAULT HANDLER_CAN_RONLY
34
35     /*
36      * root registration info 
37      */
38     typedef struct netsnmp_handler_registration_s {
39
40         char           *handlerName;    /* for mrTable listings, and other uses */
41         char           *contextName;    /* NULL = default context */
42
43         /*
44          * where are we registered at? 
45          */
46         oid            *rootoid;
47         size_t          rootoid_len;
48
49         /*
50          * handler details 
51          */
52         netsnmp_mib_handler *handler;
53         int             modes;
54
55         /*
56          * more optional stuff 
57          */
58         int             priority;
59         int             range_subid;
60         oid             range_ubound;
61         int             timeout;
62         int             global_cacheid;
63
64     } netsnmp_handler_registration;
65
66     /*
67      * function handler definitions 
68      */
69     typedef int     (Netsnmp_Node_Handler) (netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo,        /* pointer to registration struct */
70                                             netsnmp_agent_request_info *reqinfo,        /* pointer to current transaction */
71                                             netsnmp_request_info
72                                             *requests);
73
74     typedef struct netsnmp_delegated_cache_s {
75         int             transaction_id;
76         netsnmp_mib_handler *handler;
77         netsnmp_handler_registration *reginfo;
78         netsnmp_agent_request_info *reqinfo;
79         netsnmp_request_info *requests;
80         void           *localinfo;
81     } netsnmp_delegated_cache;
82
83     /*
84      * handler API functions 
85      */
86     void            netsnmp_init_handler_conf(void);
87     int             netsnmp_register_handler(netsnmp_handler_registration
88                                              *reginfo);
89     int            
90         netsnmp_register_handler_nocallback(netsnmp_handler_registration
91                                             *reginfo);
92     int             netsnmp_inject_handler(netsnmp_handler_registration
93                                            *reginfo,
94                                            netsnmp_mib_handler *handler);
95     netsnmp_mib_handler
96         *netsnmp_find_handler_by_name(netsnmp_handler_registration
97                                       *reginfo, const char *name);
98     void          
99         *netsnmp_find_handler_data_by_name(netsnmp_handler_registration
100                                            *reginfo, const char *name);
101     int             netsnmp_call_handlers(netsnmp_handler_registration
102                                           *reginfo,
103                                           netsnmp_agent_request_info
104                                           *reqinfo,
105                                           netsnmp_request_info *requests);
106     int             netsnmp_call_handler(netsnmp_mib_handler *next_handler,
107                                          netsnmp_handler_registration
108                                          *reginfo,
109                                          netsnmp_agent_request_info
110                                          *reqinfo,
111                                          netsnmp_request_info *requests);
112     int             netsnmp_call_next_handler(netsnmp_mib_handler *current,
113                                               netsnmp_handler_registration
114                                               *reginfo,
115                                               netsnmp_agent_request_info
116                                               *reqinfo,
117                                               netsnmp_request_info
118                                               *requests);
119     int             netsnmp_call_next_handler_one_request(netsnmp_mib_handler *current,
120                                                           netsnmp_handler_registration *reginfo,
121                                                           netsnmp_agent_request_info *reqinfo,
122                                                           netsnmp_request_info *requests);
123     
124     netsnmp_mib_handler *netsnmp_create_handler(const char *name,
125                                                 Netsnmp_Node_Handler *
126                                                 handler_access_method);
127     netsnmp_handler_registration *
128         netsnmp_create_handler_registration(const char *name,
129                                             Netsnmp_Node_Handler *
130                                                handler_access_method,
131                                             oid * reg_oid,
132                                             size_t reg_oid_len,
133                                             int modes);
134
135     NETSNMP_INLINE netsnmp_delegated_cache
136         *netsnmp_create_delegated_cache(netsnmp_mib_handler *,
137                                         netsnmp_handler_registration *,
138                                         netsnmp_agent_request_info *,
139                                         netsnmp_request_info *, void *);
140     NETSNMP_INLINE void     netsnmp_free_delegated_cache(netsnmp_delegated_cache
141                                                  *dcache);
142     NETSNMP_INLINE netsnmp_delegated_cache
143         *netsnmp_handler_check_cache(netsnmp_delegated_cache *dcache);
144     void            netsnmp_register_handler_by_name(const char *,
145                                                      netsnmp_mib_handler
146                                                      *);
147
148     NETSNMP_INLINE void
149         netsnmp_request_add_list_data(netsnmp_request_info *request,
150                                       netsnmp_data_list *node);
151
152     NETSNMP_INLINE void    *netsnmp_request_get_list_data(netsnmp_request_info
153                                                   *request,
154                                                   const char *name);
155
156     NETSNMP_INLINE void
157               netsnmp_free_request_data_set(netsnmp_request_info *request);
158
159     NETSNMP_INLINE void
160              netsnmp_free_request_data_sets(netsnmp_request_info *request);
161
162     void            netsnmp_handler_free(netsnmp_mib_handler *);
163     netsnmp_mib_handler *netsnmp_handler_dup(netsnmp_mib_handler *);
164     netsnmp_handler_registration
165         *netsnmp_handler_registration_dup(netsnmp_handler_registration *);
166     void           
167         netsnmp_handler_registration_free(netsnmp_handler_registration *);
168
169 #define REQUEST_IS_DELEGATED     1
170 #define REQUEST_IS_NOT_DELEGATED 0
171     void           
172         netsnmp_handler_mark_requests_as_delegated(netsnmp_request_info *,
173                                                    int);
174     void           *netsnmp_handler_get_parent_data(netsnmp_request_info *,
175                                                     const char *);
176
177 #ifdef __cplusplus
178 };
179 #endif
180
181 #endif                          /* AGENT_HANDLER_H */