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 #define MIB_HANDLER_INSTANCE 0x00000004 00035 00036 #define MIB_HANDLER_CUSTOM4 0x10000000 00037 #define MIB_HANDLER_CUSTOM3 0x20000000 00038 #define MIB_HANDLER_CUSTOM2 0x40000000 00039 #define MIB_HANDLER_CUSTOM1 0x80000000 00040 00041 00048 typedef struct netsnmp_mib_handler_s { 00049 char *handler_name; 00051 void *myvoid; 00053 int flags; 00054 00058 int (*access_method) (struct netsnmp_mib_handler_s *, 00059 struct 00060 netsnmp_handler_registration_s *, 00061 struct 00062 netsnmp_agent_request_info_s *, 00063 struct netsnmp_request_info_s *); 00064 void (*data_free)(void *myvoid); 00066 struct netsnmp_mib_handler_s *next; 00067 struct netsnmp_mib_handler_s *prev; 00068 } netsnmp_mib_handler; 00069 00070 /* 00071 * per registration flags 00072 */ 00073 #define HANDLER_CAN_GETANDGETNEXT 0x01 /* must be able to do both */ 00074 #define HANDLER_CAN_SET 0x02 /* implies create, too */ 00075 #define HANDLER_CAN_GETBULK 0x04 00076 #define HANDLER_CAN_NOT_CREATE 0x08 /* auto set if ! CAN_SET */ 00077 #define HANDLER_CAN_BABY_STEP 0x10 00078 #define HANDLER_CAN_STASH 0x20 00079 00080 00081 #define HANDLER_CAN_RONLY (HANDLER_CAN_GETANDGETNEXT) 00082 #define HANDLER_CAN_RWRITE (HANDLER_CAN_GETANDGETNEXT | HANDLER_CAN_SET) 00083 #define HANDLER_CAN_SET_ONLY (HANDLER_CAN_SET | HANDLER_CAN_NOT_CREATE) 00084 #define HANDLER_CAN_DEFAULT (HANDLER_CAN_RONLY | HANDLER_CAN_NOT_CREATE) 00085 00095 typedef struct netsnmp_handler_registration_s { 00096 00098 char *handlerName; 00100 char *contextName; 00101 00105 oid *rootoid; 00106 size_t rootoid_len; 00107 00111 netsnmp_mib_handler *handler; 00112 int modes; 00113 00117 int priority; 00118 int range_subid; 00119 oid range_ubound; 00120 int timeout; 00121 int global_cacheid; 00122 00126 void * my_reg_void; 00127 00128 } netsnmp_handler_registration; 00129 00130 /* 00131 * function handler definitions 00132 */ 00133 00134 typedef int (Netsnmp_Node_Handler) (netsnmp_mib_handler *handler, 00136 netsnmp_handler_registration *reginfo, 00138 netsnmp_agent_request_info *reqinfo, 00139 netsnmp_request_info *requests); 00140 00141 typedef struct netsnmp_handler_args_s { 00142 netsnmp_mib_handler *handler; 00143 netsnmp_handler_registration *reginfo; 00144 netsnmp_agent_request_info *reqinfo; 00145 netsnmp_request_info *requests; 00146 } netsnmp_handler_args; 00147 00148 typedef struct netsnmp_delegated_cache_s { 00149 int transaction_id; 00150 netsnmp_mib_handler *handler; 00151 netsnmp_handler_registration *reginfo; 00152 netsnmp_agent_request_info *reqinfo; 00153 netsnmp_request_info *requests; 00154 void *localinfo; 00155 } netsnmp_delegated_cache; 00156 00157 /* 00158 * handler API functions 00159 */ 00160 void netsnmp_init_handler_conf(void); 00161 int netsnmp_register_handler(netsnmp_handler_registration 00162 *reginfo); 00163 int netsnmp_unregister_handler(netsnmp_handler_registration 00164 *reginfo); 00165 int 00166 netsnmp_register_handler_nocallback(netsnmp_handler_registration 00167 *reginfo); 00168 int netsnmp_inject_handler(netsnmp_handler_registration 00169 *reginfo, 00170 netsnmp_mib_handler *handler); 00171 int 00172 netsnmp_inject_handler_before(netsnmp_handler_registration *reginfo, 00173 netsnmp_mib_handler *handler, 00174 const char *before_what); 00175 netsnmp_mib_handler 00176 *netsnmp_find_handler_by_name(netsnmp_handler_registration 00177 *reginfo, const char *name); 00178 void 00179 *netsnmp_find_handler_data_by_name(netsnmp_handler_registration 00180 *reginfo, const char *name); 00181 int netsnmp_call_handlers(netsnmp_handler_registration 00182 *reginfo, 00183 netsnmp_agent_request_info 00184 *reqinfo, 00185 netsnmp_request_info *requests); 00186 int netsnmp_call_handler(netsnmp_mib_handler *next_handler, 00187 netsnmp_handler_registration 00188 *reginfo, 00189 netsnmp_agent_request_info 00190 *reqinfo, 00191 netsnmp_request_info *requests); 00192 int netsnmp_call_next_handler(netsnmp_mib_handler *current, 00193 netsnmp_handler_registration 00194 *reginfo, 00195 netsnmp_agent_request_info 00196 *reqinfo, 00197 netsnmp_request_info 00198 *requests); 00199 int netsnmp_call_next_handler_one_request(netsnmp_mib_handler *current, 00200 netsnmp_handler_registration *reginfo, 00201 netsnmp_agent_request_info *reqinfo, 00202 netsnmp_request_info *requests); 00203 00204 netsnmp_mib_handler *netsnmp_create_handler(const char *name, 00205 Netsnmp_Node_Handler * 00206 handler_access_method); 00207 netsnmp_handler_registration * 00208 netsnmp_handler_registration_create(const char *name, 00209 netsnmp_mib_handler *handler, 00210 const oid * reg_oid, size_t reg_oid_len, 00211 int modes); 00212 netsnmp_handler_registration * 00213 netsnmp_create_handler_registration(const char *name, Netsnmp_Node_Handler* 00214 handler_access_method, 00215 const oid *reg_oid, size_t reg_oid_len, 00216 int modes); 00217 00218 netsnmp_delegated_cache 00219 *netsnmp_create_delegated_cache(netsnmp_mib_handler *, 00220 netsnmp_handler_registration *, 00221 netsnmp_agent_request_info *, 00222 netsnmp_request_info *, void *); 00223 void netsnmp_free_delegated_cache(netsnmp_delegated_cache *dcache); 00224 netsnmp_delegated_cache 00225 *netsnmp_handler_check_cache(netsnmp_delegated_cache *dcache); 00226 void netsnmp_register_handler_by_name(const char *, 00227 netsnmp_mib_handler 00228 *); 00229 00230 void netsnmp_clear_handler_list(void); 00231 00232 void 00233 netsnmp_request_add_list_data(netsnmp_request_info *request, 00234 netsnmp_data_list *node); 00235 00236 int 00237 netsnmp_request_remove_list_data(netsnmp_request_info *request, 00238 const char *name); 00239 00240 void *netsnmp_request_get_list_data(netsnmp_request_info 00241 *request, 00242 const char *name); 00243 00244 void 00245 netsnmp_free_request_data_set(netsnmp_request_info *request); 00246 00247 void 00248 netsnmp_free_request_data_sets(netsnmp_request_info *request); 00249 00250 void netsnmp_handler_free(netsnmp_mib_handler *); 00251 netsnmp_mib_handler *netsnmp_handler_dup(netsnmp_mib_handler *); 00252 netsnmp_handler_registration 00253 *netsnmp_handler_registration_dup(netsnmp_handler_registration *); 00254 void 00255 netsnmp_handler_registration_free(netsnmp_handler_registration *); 00256 00257 #define REQUEST_IS_DELEGATED 1 00258 #define REQUEST_IS_NOT_DELEGATED 0 00259 void 00260 netsnmp_handler_mark_requests_as_delegated(netsnmp_request_info *, 00261 int); 00262 void *netsnmp_handler_get_parent_data(netsnmp_request_info *, 00263 const char *); 00264 00265 #ifdef __cplusplus 00266 } 00267 #endif 00268 00269 #endif /* AGENT_HANDLER_H */ 00270
Last modified: Wednesday, 01-Aug-2018 04:41:28 UTC
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.