00001 #ifndef AGENT_HANDLER_H 00002 #define AGENT_HANDLER_H 00003 00004 #ifdef __cplusplus 00005 extern "C" { 00006 #endif 00007 00008 struct handler_registration_s; 00009 00010 typedef struct mib_handler_s { 00011 char *handler_name; 00012 void *myvoid; /* for handler's internal use */ 00013 00014 int (*access_method)(struct mib_handler_s *, 00015 struct handler_registration_s *, 00016 struct agent_request_info_s *, 00017 struct request_info_s *); 00018 00019 struct mib_handler_s *next; 00020 struct mib_handler_s *prev; 00021 } mib_handler; 00022 00023 #define HANDLER_CAN_GETANDGETNEXT 0x1 /* must be able to do both */ 00024 #define HANDLER_CAN_SET 0x2 00025 #define HANDLER_CAN_GETBULK 0x4 00026 00027 #define HANDLER_CAN_RONLY (HANDLER_CAN_GETANDGETNEXT) 00028 #define HANDLER_CAN_RWRITE (HANDLER_CAN_GETANDGETNEXT | HANDLER_CAN_SET) 00029 #define HANDLER_CAN_DEFAULT HANDLER_CAN_RONLY 00030 00031 /* root registration info */ 00032 typedef struct handler_registration_s { 00033 00034 char *handlerName; /* for mrTable listings, and other uses */ 00035 char *contextName; /* NULL = default context */ 00036 00037 /* where are we registered at? */ 00038 oid *rootoid; 00039 size_t rootoid_len; 00040 00041 /* handler details */ 00042 mib_handler *handler; 00043 int modes; 00044 00045 /* more optional stuff */ 00046 int priority; 00047 int range_subid; 00048 oid range_ubound; 00049 int timeout; 00050 00051 } handler_registration; 00052 00053 /* function handler definitions */ 00054 typedef int (NodeHandler)( 00055 mib_handler *handler, 00056 handler_registration *reginfo, /* pointer to registration struct */ 00057 agent_request_info *reqinfo, /* pointer to current transaction */ 00058 request_info *requests 00059 ); 00060 00061 typedef struct delegated_cache_s { 00062 int transaction_id; 00063 mib_handler *handler; 00064 handler_registration *reginfo; 00065 agent_request_info *reqinfo; 00066 request_info *requests; 00067 void *localinfo; 00068 } delegated_cache; 00069 00070 /* handler API functions */ 00071 int register_handler(handler_registration *reginfo); 00072 int inject_handler(handler_registration *reginfo, mib_handler *handler); 00073 mib_handler *find_handler_by_name(handler_registration *reginfo, char *name); 00074 void *find_handler_data_by_name(handler_registration *reginfo, char *name); 00075 int call_handlers(handler_registration *reginfo, 00076 agent_request_info *reqinfo, 00077 request_info *requests); 00078 int call_handler(mib_handler *next_handler, 00079 handler_registration *reginfo, 00080 agent_request_info *reqinfo, 00081 request_info *requests); 00082 int call_next_handler(mib_handler *current, 00083 handler_registration *reginfo, 00084 agent_request_info *reqinfo, 00085 request_info *requests); 00086 mib_handler *create_handler(const char *name, 00087 NodeHandler *handler_access_method); 00088 handler_registration * 00089 create_handler_registration(const char *name, 00090 NodeHandler *handler_access_method, 00091 oid *reg_oid, size_t reg_oid_len, int modes); 00092 delegated_cache * 00093 create_delegated_cache(mib_handler *, 00094 handler_registration *, 00095 agent_request_info *, 00096 request_info *, 00097 void *); 00098 inline delegated_cache *handler_check_cache(delegated_cache *dcache); 00099 00100 inline void 00101 request_add_list_data(request_info *request, data_list *node); 00102 00103 inline void * 00104 request_get_list_data(request_info *request, const char *name); 00105 00106 inline void 00107 free_request_data_set(request_info *request); 00108 00109 inline void 00110 free_request_data_sets(request_info *request); 00111 00112 #define REQUEST_IS_DELEGATED 1 00113 #define REQUEST_IS_NOT_DELEGATED 0 00114 void handler_mark_requests_as_delegated(request_info *, int); 00115 void *handler_get_parent_data(request_info *, const char *); 00116 00117 #ifdef __cplusplus 00118 }; 00119 #endif 00120 00121 #endif /* AGENT_HANDLER_H */
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.