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 /* 00012 * @file snmp_agent.h 00013 * 00014 * @addtogroup agent 00015 * @addtogroup table 00016 * External definitions for functions and variables in snmp_agent.c. 00017 * 00018 * @{ 00019 */ 00020 00021 #ifndef SNMP_AGENT_H 00022 #define SNMP_AGENT_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 #include <net-snmp/library/snmp_impl.h> 00029 #include <net-snmp/library/tools.h> 00030 #include <net-snmp/library/data_list.h> 00031 00032 #define SNMP_MAX_PDU_SIZE 64000 /* local constraint on PDU size sent by agent 00033 * (see also SNMP_MAX_MSG_SIZE in snmp_api.h) */ 00034 00035 /* 00036 * If non-zero, causes the addresses of peers to be logged when receptions 00037 * occur. 00038 */ 00039 00040 extern int log_addresses; 00041 00042 /* 00043 * How many ticks since we last aged the address cache entries. 00044 */ 00045 00046 extern int lastAddrAge; 00047 00054 typedef struct netsnmp_request_info_s { 00058 netsnmp_variable_list *requestvb; 00059 00064 netsnmp_data_list *parent_data; 00065 00066 /* 00067 * pointer to the agent_request_info for this request 00068 */ 00069 struct netsnmp_agent_request_info_s *agent_req_info; 00070 00072 oid *range_end; 00073 size_t range_end_len; 00074 00075 /* 00076 * flags 00077 */ 00078 int delegated; 00079 int processed; 00080 int inclusive; 00081 00082 int status; 00084 int index; 00085 00087 int repeat; 00088 int orig_repeat; 00089 netsnmp_variable_list *requestvb_start; 00090 00091 /* internal use */ 00092 struct netsnmp_request_info_s *next; 00093 struct netsnmp_request_info_s *prev; 00094 struct netsnmp_subtree_s *subtree; 00095 } netsnmp_request_info; 00096 00097 typedef struct netsnmp_set_info_s { 00098 int action; 00099 void *stateRef; 00100 00101 /* 00102 * don't use yet: 00103 */ 00104 void **oldData; 00105 int setCleanupFlags; 00106 #define AUTO_FREE_STATEREF 0x01 /* calls free(stateRef) */ 00107 #define AUTO_FREE_OLDDATA 0x02 /* calls free(*oldData) */ 00108 #define AUTO_UNDO 0x03 /* ... */ 00109 } netsnmp_set_info; 00110 00111 typedef struct netsnmp_tree_cache_s { 00112 struct netsnmp_subtree_s *subtree; 00113 netsnmp_request_info *requests_begin; 00114 netsnmp_request_info *requests_end; 00115 } netsnmp_tree_cache; 00116 00117 #define MODE_GET SNMP_MSG_GET 00118 #define MODE_GETNEXT SNMP_MSG_GETNEXT 00119 #define MODE_GETBULK SNMP_MSG_GETBULK 00120 #define MODE_GET_STASH SNMP_MSG_INTERNAL_GET_STASH 00121 #define MODE_IS_GET(x) ((x >= 128) && (x != -1) && (x != SNMP_MSG_SET)) 00122 /* #define MODE_IS_GET(x) ((x == SNMP_MSG_GET) || (x == SNMP_MSG_GETNEXT) || (x == SNMP_MSG_GETBULK) || (x == SNMP_MSG_INTERNAL_GET_STASH)) */ 00123 00124 #define MODE_SET_BEGIN SNMP_MSG_INTERNAL_SET_BEGIN 00125 #define MODE_SET_RESERVE1 SNMP_MSG_INTERNAL_SET_RESERVE1 00126 #define MODE_SET_RESERVE2 SNMP_MSG_INTERNAL_SET_RESERVE2 00127 #define MODE_SET_ACTION SNMP_MSG_INTERNAL_SET_ACTION 00128 #define MODE_SET_COMMIT SNMP_MSG_INTERNAL_SET_COMMIT 00129 #define MODE_SET_FREE SNMP_MSG_INTERNAL_SET_FREE 00130 #define MODE_SET_UNDO SNMP_MSG_INTERNAL_SET_UNDO 00131 #define MODE_IS_SET(x) ((x < 128) || (x == -1) || (x == SNMP_MSG_SET)) 00132 /* #define MODE_IS_SET(x) (!MODE_IS_GET(x)) */ 00133 00134 #define MODE_BSTEP_PRE_REQUEST SNMP_MSG_INTERNAL_PRE_REQUEST 00135 #define MODE_BSTEP_POST_REQUEST SNMP_MSG_INTERNAL_POST_REQUEST 00136 00137 #define MODE_BSTEP_OBJECT_LOOKUP SNMP_MSG_INTERNAL_OBJECT_LOOKUP 00138 #define MODE_BSTEP_CHECK_VALUE SNMP_MSG_INTERNAL_CHECK_VALUE 00139 #define MODE_BSTEP_ROW_CREATE SNMP_MSG_INTERNAL_ROW_CREATE 00140 #define MODE_BSTEP_UNDO_SETUP SNMP_MSG_INTERNAL_UNDO_SETUP 00141 #define MODE_BSTEP_SET_VALUE SNMP_MSG_INTERNAL_SET_VALUE 00142 #define MODE_BSTEP_CHECK_CONSISTENCY SNMP_MSG_INTERNAL_CHECK_CONSISTENCY 00143 #define MODE_BSTEP_UNDO_SET SNMP_MSG_INTERNAL_UNDO_SET 00144 #define MODE_BSTEP_COMMIT SNMP_MSG_INTERNAL_COMMIT 00145 #define MODE_BSTEP_UNDO_COMMIT SNMP_MSG_INTERNAL_UNDO_COMMIT 00146 #define MODE_BSTEP_IRREVERSIBLE_COMMIT SNMP_MSG_INTERNAL_IRREVERSIBLE_COMMIT 00147 #define MODE_BSTEP_UNDO_CLEANUP SNMP_MSG_INTERNAL_UNDO_CLEANUP 00148 00149 00158 typedef struct netsnmp_agent_request_info_s { 00159 int mode; 00161 /* netsnmp_pdu *pdu; */ 00162 struct netsnmp_agent_session_s *asp; /* may not be needed */ 00163 /* 00164 * can be used to pass information on a per-pdu basis from a 00165 * helper to the later handlers 00166 */ 00167 netsnmp_data_list *agent_data; 00168 } netsnmp_agent_request_info; 00169 00170 typedef struct netsnmp_cachemap_s { 00171 int globalid; 00172 int cacheid; 00173 struct netsnmp_cachemap_s *next; 00174 } netsnmp_cachemap; 00175 00176 typedef struct netsnmp_agent_session_s { 00177 int mode; 00178 netsnmp_session *session; 00179 netsnmp_pdu *pdu; 00180 netsnmp_pdu *orig_pdu; 00181 int rw; 00182 int exact; 00183 int status; 00184 int index; 00185 int oldmode; 00186 00187 struct netsnmp_agent_session_s *next; 00188 00189 /* 00190 * new API pointers 00191 */ 00192 netsnmp_agent_request_info *reqinfo; 00193 netsnmp_request_info *requests; 00194 netsnmp_tree_cache *treecache; 00195 netsnmp_variable_list **bulkcache; 00196 int treecache_len; /* length of cache array */ 00197 int treecache_num; /* number of current cache entries */ 00198 netsnmp_cachemap *cache_store; 00199 int vbcount; 00200 } netsnmp_agent_session; 00201 00202 /* 00203 * Address cache handling functions. 00204 */ 00205 00206 void netsnmp_addrcache_initialise(void); 00207 void netsnmp_addrcache_destroy(void); 00208 void netsnmp_addrcache_age(void); 00209 00210 00211 /* 00212 * config file parsing routines 00213 */ 00214 int handle_snmp_packet(int, netsnmp_session *, int, 00215 netsnmp_pdu *, void *); 00216 void snmp_agent_parse_config(char *, char *); 00217 netsnmp_agent_session *init_agent_snmp_session(netsnmp_session *, 00218 netsnmp_pdu *); 00219 void free_agent_snmp_session(netsnmp_agent_session *); 00220 void 00221 netsnmp_remove_and_free_agent_snmp_session(netsnmp_agent_session 00222 *asp); 00223 #ifdef SNMP_NEED_REQUEST_LIST 00224 void 00225 netsnmp_free_agent_snmp_session_by_session(netsnmp_session * sess, 00226 void (*free_request) 00227 (netsnmp_request_list 00228 *)); 00229 #endif 00230 int getNextSessID(void); 00231 void dump_sess_list(void); 00232 int init_master_agent(void); 00233 void shutdown_master_agent(void); 00234 int agent_check_and_process(int block); 00235 void netsnmp_check_outstanding_agent_requests(void); 00236 00237 int netsnmp_request_set_error(netsnmp_request_info *request, 00238 int error_value); 00239 int netsnmp_check_requests_error(netsnmp_request_info *reqs); 00240 int netsnmp_check_all_requests_error(netsnmp_agent_session *asp, 00241 int look_for_specific); 00242 int 00243 netsnmp_set_all_requests_error(netsnmp_agent_request_info *reqinfo, 00244 netsnmp_request_info *requests, 00245 int error_value); 00246 int netsnmp_request_set_error_idx(netsnmp_request_info *requests, 00247 int error_value, int idx); 00248 int 00249 netsnmp_request_set_error_all(netsnmp_request_info *requests, 00250 int error_value); 00251 00253 int netsnmp_set_request_error(netsnmp_agent_request_info 00254 *reqinfo, 00255 netsnmp_request_info 00256 *request, int error_value); 00258 int netsnmp_set_mode_request_error(int mode, 00259 netsnmp_request_info 00260 *request, 00261 int error_value); 00262 00263 u_long netsnmp_marker_uptime(marker_t pm); 00264 u_long netsnmp_timeval_uptime(struct timeval *tv); 00265 u_long netsnmp_get_agent_uptime(void); 00266 int netsnmp_check_transaction_id(int transaction_id); 00267 int netsnmp_agent_check_packet(netsnmp_session *, 00268 struct netsnmp_transport_s 00269 *, void *, int); 00270 int netsnmp_agent_check_parse(netsnmp_session *, 00271 netsnmp_pdu *, int); 00272 int netsnmp_allocate_globalcacheid(void); 00273 00274 int netsnmp_remove_delegated_requests_for_session(netsnmp_session *sess); 00275 00276 /* 00277 * Register and de-register agent NSAPs. 00278 */ 00279 00280 struct netsnmp_transport_s; 00281 00282 int netsnmp_register_agent_nsap(struct netsnmp_transport_s 00283 *t); 00284 void netsnmp_deregister_agent_nsap(int handle); 00285 00286 void 00287 netsnmp_agent_add_list_data(netsnmp_agent_request_info *agent, 00288 netsnmp_data_list *node); 00289 00290 int 00291 netsnmp_agent_remove_list_data(netsnmp_agent_request_info *ari, 00292 const char * name); 00293 00294 void * 00295 netsnmp_agent_get_list_data(netsnmp_agent_request_info 00296 *agent, const char *name); 00297 00298 void 00299 netsnmp_free_agent_data_set(netsnmp_agent_request_info *agent); 00300 00301 void 00302 netsnmp_free_agent_data_sets(netsnmp_agent_request_info *agent); 00303 void 00304 netsnmp_free_agent_request_info(netsnmp_agent_request_info *ari); 00305 00306 #ifdef __cplusplus 00307 } 00308 #endif 00309 #endif 00310
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.