1 #ifndef AGENT_REGISTRY_H 2 #define AGENT_REGISTRY_H 3 4 /***********************************************************************/ 5 /* 6 * new version2 agent handler API structures 7 */ 8 /***********************************************************************/ 9 10 #include <net-snmp/agent/snmp_agent.h> 11 #include <net-snmp/library/fd_event_manager.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /***********************************************************************/ 18 /* 19 * requests api definitions 20 */ 21 /***********************************************************************/ 22 23 /* 24 * the structure of parameters passed to registered ACM modules 25 */ 26 struct view_parameters { 27 netsnmp_pdu *pdu; 28 oid *name; 29 size_t namelen; 30 int test; 31 int errorcode; /* Do not change unless you're 32 specifying an error, as it starts 33 in a success state. */ 34 int check_subtree; 35 }; 36 37 struct register_parameters { 38 oid *name; 39 size_t namelen; 40 int priority; 41 int range_subid; 42 oid range_ubound; 43 int timeout; 44 u_char flags; 45 const char *contextName; 46 netsnmp_session *session; 47 netsnmp_handler_registration *reginfo; 48 }; 49 50 typedef struct subtree_context_cache_s { 51 const char *context_name; 52 struct netsnmp_subtree_s *first_subtree; 53 struct subtree_context_cache_s *next; 54 } subtree_context_cache; 55 56 57 58 void setup_tree (void); 59 void shutdown_tree (void); 60 void dump_registry(void); 61 62 63 netsnmp_subtree *netsnmp_subtree_find (const oid *, size_t, 64 netsnmp_subtree *, 65 const char *context_name); 66 67 netsnmp_subtree *netsnmp_subtree_find_next(const oid *, size_t, 68 netsnmp_subtree *, 69 const char *context_name); 70 71 netsnmp_subtree *netsnmp_subtree_find_prev(const oid *, size_t, 72 netsnmp_subtree *, 73 const char *context_name); 74 75 netsnmp_subtree *netsnmp_subtree_find_first(const char *context_name); 76 77 netsnmp_session *get_session_for_oid (const oid *, size_t, 78 const char *context_name); 79 80 subtree_context_cache *get_top_context_cache(void); 81 82 void netsnmp_set_lookup_cache_size(int newsize); 83 int netsnmp_get_lookup_cache_size(void); 84 85 #define MIB_REGISTERED_OK 0 86 #define MIB_DUPLICATE_REGISTRATION -1 87 #define MIB_REGISTRATION_FAILED -2 88 #define MIB_UNREGISTERED_OK 0 89 #define MIB_NO_SUCH_REGISTRATION -1 90 #define MIB_UNREGISTRATION_FAILED -2 91 #define DEFAULT_MIB_PRIORITY 127 92 93 int register_mib (const char *, 94 const struct variable *, 95 size_t, size_t, const oid *, 96 size_t); 97 98 int register_mib_priority (const char *, 99 const struct variable *, 100 size_t, size_t, const oid *, size_t, 101 int); 102 103 int register_mib_range (const char *, 104 const struct variable *, 105 size_t, size_t, const oid *, 106 size_t, int, int, oid, 107 netsnmp_session *); 108 109 int register_mib_context (const char *, 110 const struct variable *, 111 size_t, size_t, const oid *, size_t, 112 int, int, oid, netsnmp_session *, 113 const char *, int, int); 114 115 int netsnmp_register_mib_table_row (const char *, 116 const struct variable *, 117 size_t, size_t, oid *, 118 size_t, int, int, netsnmp_session *, 119 const char *, int, int); 120 121 int unregister_mib (oid *, size_t); 122 123 int unregister_mib_priority (oid *, size_t, int); 124 int unregister_mib_range (oid *, size_t, int, int, oid); 125 int unregister_mib_context (oid *, size_t, int, int, oid, 126 const char *); 127 void clear_context (void); 128 void unregister_mibs_by_session (netsnmp_session *); 129 int netsnmp_unregister_mib_table_row (oid *mibloc, size_t mibloclen, 130 int priority, int var_subid, 131 oid range_ubound, 132 const char *context); 133 134 int compare_tree (const oid *, size_t, 135 const oid *, size_t); 136 int in_a_view (oid *, size_t *, 137 netsnmp_pdu *, int); 138 int check_access (netsnmp_pdu *pdu); 139 int netsnmp_acm_check_subtree (netsnmp_pdu *, oid *, size_t); 140 void register_mib_reattach (void); 141 void register_mib_detach (void); 142 143 /* 144 * REGISTER_MIB(): This macro simply loads register_mib with less pain: 145 * 146 * descr: A short description of the mib group being loaded. 147 * var: The variable structure to load. 148 * vartype: The variable structure used to define it (variable[2, 4, ...]) 149 * theoid: An *initialized* *exact length* oid pointer. 150 * (sizeof(theoid) *must* return the number of elements!) 151 */ 152 153 #define REGISTER_MIB(descr, var, vartype, theoid) \ 154 if (register_mib(descr, (const struct variable *) var, \ 155 sizeof(struct vartype), \ 156 sizeof(var)/sizeof(struct vartype), \ 157 theoid, sizeof(theoid)/sizeof(oid)) != \ 158 MIB_REGISTERED_OK) \ 159 DEBUGMSGTL(("register_mib", "%s registration failed\n", descr)); 160 161 162 #define NUM_EXTERNAL_SIGS 32 163 #define SIG_REGISTERED_OK 0 164 #define SIG_REGISTRATION_FAILED -2 165 #define SIG_UNREGISTERED_OK 0 166 167 extern int external_signal_scheduled[NUM_EXTERNAL_SIGS]; 168 extern void (*external_signal_handler[NUM_EXTERNAL_SIGS])(int); 169 170 int register_signal(int, void (*func)(int)); 171 int unregister_signal(int); 172 173 174 175 /* 176 * internal API. Don't use this. Use netsnmp_register_handler instead 177 */ 178 179 struct netsnmp_handler_registration_s; 180 181 int netsnmp_register_mib(const char *, struct variable *, 182 size_t, size_t, oid *, size_t, 183 int, int, oid, netsnmp_session *, 184 const char *, int, int, 185 struct netsnmp_handler_registration_s *, 186 int); 187 188 #ifdef __cplusplus 189 } 190 #endif 191 192 #endif /* AGENT_REGISTRY_H */ 193