00001 /* Portions of this file are subject to the following copyright(s). See 00002 * the Net-SNMP's COPYING file for more details and other copyrights 00003 * that may apply: 00004 */ 00005 /* 00006 * Portions of this file are copyrighted by: 00007 * Copyright © 2003 Sun Microsystems, Inc. All rights reserved. 00008 * Use is subject to license terms specified in the COPYING file 00009 * distributed with the Net-SNMP package. 00010 */ 00011 #ifndef AGENT_HANDLER_H 00012 #define AGENT_HANDLER_H 00013 00014 #ifdef __cplusplus 00015 extern "C" { 00016 #endif 00017 00025 struct netsnmp_handler_registration_s; 00026 00027 /* 00028 * per mib handler flags. 00029 * NOTE: Lower bits are reserved for the agent handler's use. 00030 * The high 4 bits (31-28) are reserved for use by the handler. 00031 */ 00032 #define MIB_HANDLER_AUTO_NEXT 0x00000001 00033 #define MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE 0x00000002 00034 00035 #define MIB_HANDLER_CUSTOM4 0x10000000 00036 #define MIB_HANDLER_CUSTOM3 0x20000000 00037 #define MIB_HANDLER_CUSTOM2 0x40000000 00038 #define MIB_HANDLER_CUSTOM1 0x80000000 00039 00040 00047 typedef struct netsnmp_mib_handler_s { 00048 char *handler_name; 00050 void *myvoid; 00052 int flags; 00053 00057 int (*access_method) (struct netsnmp_mib_handler_s *, 00058 struct 00059 netsnmp_handler_registration_s *, 00060 struct 00061 netsnmp_agent_request_info_s *, 00062 struct netsnmp_request_info_s *); 00063 00064 struct netsnmp_mib_handler_s *next; 00065 struct netsnmp_mib_handler_s *prev; 00066 } netsnmp_mib_handler; 00067 00068 /* 00069 * per registration flags 00070 */ 00071 #define HANDLER_CAN_GETANDGETNEXT 0x01 /* must be able to do both */ 00072 #define HANDLER_CAN_SET 0x02 /* implies create, too */ 00073 #define HANDLER_CAN_GETBULK 0x04 00074 #define HANDLER_CAN_NOT_CREATE 0x08 /* auto set if ! CAN_SET */ 00075 #define HANDLER_CAN_BABY_STEP 0x10 00076 #define HANDLER_CAN_STASH 0x20 00077 00078 00079 #define HANDLER_CAN_RONLY (HANDLER_CAN_GETANDGETNEXT) 00080 #define HANDLER_CAN_RWRITE (HANDLER_CAN_GETANDGETNEXT | HANDLER_CAN_SET) 00081 #define HANDLER_CAN_SET_ONLY (HANDLER_CAN_SET | HANDLER_CAN_NOT_CREATE) 00082 #define HANDLER_CAN_DEFAULT (HANDLER_CAN_RONLY | HANDLER_CAN_NOT_CREATE) 00083 00093 typedef struct netsnmp_handler_registration_s { 00094 00096 char *handlerName; 00098 char *contextName; 00099 00103 oid *rootoid; 00104 size_t rootoid_len; 00105 00109 netsnmp_mib_handler *handler; 00110 int modes; 00111 00115 int priority; 00116 int range_subid; 00117 oid range_ubound; 00118 int timeout; 00119 int global_cacheid; 00120 00124 void * my_reg_void; 00125 00126 } netsnmp_handler_registration; 00127 00128 /* 00129 * function handler definitions 00130 */ 00131 00132 typedef int (Netsnmp_Node_Handler) (netsnmp_mib_handler *handler, 00134 netsnmp_handler_registration *reginfo, 00136 netsnmp_agent_request_info *reqinfo, 00137 netsnmp_request_info *requests); 00138 00139 typedef struct netsnmp_handler_args_s { 00140 netsnmp_mib_handler *handler; 00141 netsnmp_handler_registration *reginfo; 00142 netsnmp_agent_request_info *reqinfo; 00143 netsnmp_request_info *requests; 00144 } netsnmp_handler_args; 00145 00146 typedef struct netsnmp_delegated_cache_s { 00147 int transaction_id; 00148 netsnmp_mib_handler *handler; 00149 netsnmp_handler_registration *reginfo; 00150 netsnmp_agent_request_info *reqinfo; 00151 netsnmp_request_info *requests; 00152 void *localinfo; 00153 } netsnmp_delegated_cache; 00154 00155 /* 00156 * handler API functions 00157 */ 00158 void netsnmp_init_handler_conf(void); 00159 int netsnmp_register_handler(netsnmp_handler_registration 00160 *reginfo); 00161 int netsnmp_unregister_handler(netsnmp_handler_registration 00162 *reginfo); 00163 int 00164 netsnmp_register_handler_nocallback(netsnmp_handler_registration 00165 *reginfo); 00166 int netsnmp_inject_handler(netsnmp_handler_registration 00167 *reginfo, 00168 netsnmp_mib_handler *handler); 00169 int 00170 netsnmp_inject_handler_before(netsnmp_handler_registration *reginfo, 00171 netsnmp_mib_handler *handler, 00172 const char *before_what); 00173 netsnmp_mib_handler 00174 *netsnmp_find_handler_by_name(netsnmp_handler_registration 00175 *reginfo, const char *name); 00176 void 00177 *netsnmp_find_handler_data_by_name(netsnmp_handler_registration 00178 *reginfo, const char *name); 00179 int netsnmp_call_handlers(netsnmp_handler_registration 00180 *reginfo, 00181 netsnmp_agent_request_info 00182 *reqinfo, 00183 netsnmp_request_info *requests); 00184 int netsnmp_call_handler(netsnmp_mib_handler *next_handler, 00185 netsnmp_handler_registration 00186 *reginfo, 00187 netsnmp_agent_request_info 00188 *reqinfo, 00189 netsnmp_request_info *requests); 00190 int netsnmp_call_next_handler(netsnmp_mib_handler *current, 00191 netsnmp_handler_registration 00192 *reginfo, 00193 netsnmp_agent_request_info 00194 *reqinfo, 00195 netsnmp_request_info 00196 *requests); 00197 int netsnmp_call_next_handler_one_request(netsnmp_mib_handler *current, 00198 netsnmp_handler_registration *reginfo, 00199 netsnmp_agent_request_info *reqinfo, 00200 netsnmp_request_info *requests); 00201 00202 netsnmp_mib_handler *netsnmp_create_handler(const char *name, 00203 Netsnmp_Node_Handler * 00204 handler_access_method); 00205 netsnmp_handler_registration * 00206 netsnmp_handler_registration_create(const char *name, 00207 netsnmp_mib_handler *handler, 00208 oid * reg_oid, size_t reg_oid_len, 00209 int modes); 00210 netsnmp_handler_registration * 00211 netsnmp_create_handler_registration(const char *name, Netsnmp_Node_Handler* 00212 handler_access_method, oid *reg_oid, 00213 size_t reg_oid_len, int modes); 00214 00215 NETSNMP_INLINE netsnmp_delegated_cache 00216 *netsnmp_create_delegated_cache(netsnmp_mib_handler *, 00217 netsnmp_handler_registration *, 00218 netsnmp_agent_request_info *, 00219 netsnmp_request_info *, void *); 00220 NETSNMP_INLINE void netsnmp_free_delegated_cache(netsnmp_delegated_cache 00221 *dcache); 00222 NETSNMP_INLINE netsnmp_delegated_cache 00223 *netsnmp_handler_check_cache(netsnmp_delegated_cache *dcache); 00224 void netsnmp_register_handler_by_name(const char *, 00225 netsnmp_mib_handler 00226 *); 00227 00228 void netsnmp_clear_handler_list(void); 00229 00230 NETSNMP_INLINE void 00231 netsnmp_request_add_list_data(netsnmp_request_info *request, 00232 netsnmp_data_list *node); 00233 00234 NETSNMP_INLINE int 00235 netsnmp_request_remove_list_data(netsnmp_request_info *request, 00236 const char *name); 00237 00238 NETSNMP_INLINE void *netsnmp_request_get_list_data(netsnmp_request_info 00239 *request, 00240 const char *name); 00241 00242 NETSNMP_INLINE void 00243 netsnmp_free_request_data_set(netsnmp_request_info *request); 00244 00245 NETSNMP_INLINE void 00246 netsnmp_free_request_data_sets(netsnmp_request_info *request); 00247 00248 void netsnmp_handler_free(netsnmp_mib_handler *); 00249 netsnmp_mib_handler *netsnmp_handler_dup(netsnmp_mib_handler *); 00250 netsnmp_handler_registration 00251 *netsnmp_handler_registration_dup(netsnmp_handler_registration *); 00252 void 00253 netsnmp_handler_registration_free(netsnmp_handler_registration *); 00254 00255 #define REQUEST_IS_DELEGATED 1 00256 #define REQUEST_IS_NOT_DELEGATED 0 00257 void 00258 netsnmp_handler_mark_requests_as_delegated(netsnmp_request_info *, 00259 int); 00260 void *netsnmp_handler_get_parent_data(netsnmp_request_info *, 00261 const char *); 00262 00263 #ifdef __cplusplus 00264 } 00265 #endif 00266 00267 #endif /* AGENT_HANDLER_H */ 00268
1.3.9.1
Last modified: Thursday, 01-Mar-2007 16:20:02 PST
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.