4 * External definitions for functions and variables in snmp_agent.c.
14 #include <net-snmp/library/snmp_impl.h>
15 #include <net-snmp/library/tools.h>
16 #include <net-snmp/library/data_list.h>
18 #define SNMP_MAX_PDU_SIZE 64000 /* local constraint on PDU size sent by agent
19 * (see also SNMP_MAX_MSG_SIZE in snmp_api.h) */
22 * If non-zero, causes the addresses of peers to be logged when receptions
26 extern int log_addresses;
29 * How many ticks since we last aged the address cache entries.
32 extern int lastAddrAge;
34 typedef struct netsnmp_request_info_s {
35 netsnmp_variable_list *requestvb;
38 * can be used to pass information on a per-request basis from a
39 * helper to the later handlers
41 netsnmp_data_list *parent_data;
43 oid *range_end; /* don't free, reference to (struct tree)->end */
49 int index; /* index in original pdu */
50 int repeat; /* get-bulk */
52 struct netsnmp_request_info_s *next;
53 struct netsnmp_request_info_s *prev;
54 struct netsnmp_subtree_s *subtree;
55 } netsnmp_request_info;
57 typedef struct netsnmp_set_info_s {
66 #define AUTO_FREE_STATEREF 0x01 /* calls free(stateRef) */
67 #define AUTO_FREE_OLDDATA 0x02 /* calls free(*oldData) */
68 #define AUTO_UNDO 0x03 /* ... */
71 typedef struct netsnmp_tree_cache_s {
72 struct netsnmp_subtree_s *subtree;
73 netsnmp_request_info *requests_begin;
74 netsnmp_request_info *requests_end;
77 #define MODE_GET SNMP_MSG_GET
78 #define MODE_GETNEXT SNMP_MSG_GETNEXT
79 #define MODE_GETBULK SNMP_MSG_GETBULK
80 #define MODE_IS_GET(x) (x == SNMP_MSG_GET || x == SNMP_MSG_GETNEXT || x == SNMP_MSG_GETBULK)
82 #define MODE_SET_BEGIN SNMP_MSG_INTERNAL_SET_BEGIN
83 #define MODE_SET_RESERVE1 SNMP_MSG_INTERNAL_SET_RESERVE1
84 #define MODE_SET_RESERVE2 SNMP_MSG_INTERNAL_SET_RESERVE2
85 #define MODE_SET_ACTION SNMP_MSG_INTERNAL_SET_ACTION
86 #define MODE_SET_COMMIT SNMP_MSG_INTERNAL_SET_COMMIT
87 #define MODE_SET_FREE SNMP_MSG_INTERNAL_SET_FREE
88 #define MODE_SET_UNDO SNMP_MSG_INTERNAL_SET_UNDO
89 #define MODE_IS_SET(x) (!MODE_IS_GET(x))
91 typedef struct netsnmp_agent_request_info_s {
93 netsnmp_pdu *pdu; /* pdu contains authinfo, eg */
94 struct netsnmp_agent_session_s *asp; /* may not be needed */
96 * can be used to pass information on a per-pdu basis from a
97 * helper to the later handlers
99 netsnmp_data_list *agent_data;
103 } netsnmp_agent_request_info;
105 typedef struct netsnmp_cachemap_s {
108 struct netsnmp_cachemap_s *next;
111 typedef struct netsnmp_agent_session_s {
113 netsnmp_session *session;
115 netsnmp_pdu *orig_pdu;
122 struct netsnmp_agent_session_s *next;
127 netsnmp_agent_request_info *reqinfo;
128 netsnmp_request_info *requests;
129 netsnmp_tree_cache *treecache;
130 netsnmp_variable_list **bulkcache;
131 int treecache_len; /* length of cache array */
132 int treecache_num; /* number of current cache entries */
133 netsnmp_cachemap *cache_store;
135 } netsnmp_agent_session;
138 * Address cache handling functions.
141 void netsnmp_addrcache_initialise(void);
142 void netsnmp_addrcache_age(void);
146 * config file parsing routines
148 int handle_snmp_packet(int, netsnmp_session *, int,
149 netsnmp_pdu *, void *);
150 void snmp_agent_parse_config(char *, char *);
151 netsnmp_agent_session *init_agent_snmp_session(netsnmp_session *,
153 void free_agent_snmp_session(netsnmp_agent_session *);
155 netsnmp_remove_and_free_agent_snmp_session(netsnmp_agent_session
157 #ifdef SNMP_NEED_REQUEST_LIST
159 netsnmp_free_agent_snmp_session_by_session(netsnmp_session * sess,
161 (netsnmp_request_list
164 int getNextSessID(void);
165 void dump_sess_list(void);
166 int init_master_agent(void);
167 int agent_check_and_process(int block);
168 void netsnmp_check_outstanding_agent_requests(void);
169 int netsnmp_set_mode_request_error(int mode,
173 int netsnmp_set_request_error(netsnmp_agent_request_info
176 *request, int error_value);
178 netsnmp_set_all_requests_error(netsnmp_agent_request_info *reqinfo,
179 netsnmp_request_info *requests,
181 u_long netsnmp_marker_uptime(marker_t pm);
182 u_long netsnmp_timeval_uptime(struct timeval *tv);
183 u_long netsnmp_get_agent_uptime(void);
184 int netsnmp_check_transaction_id(int transaction_id);
185 int netsnmp_agent_check_packet(netsnmp_session *,
186 struct netsnmp_transport_s
188 int netsnmp_agent_check_parse(netsnmp_session *,
190 int netsnmp_allocate_globalcacheid(void);
192 int netsnmp_remove_delegated_requests_for_session(netsnmp_session *sess);
195 * Register and de-register agent NSAPs.
198 struct netsnmp_transport_s;
200 int netsnmp_register_agent_nsap(struct netsnmp_transport_s
202 void netsnmp_deregister_agent_nsap(int handle);
205 netsnmp_agent_add_list_data(netsnmp_agent_request_info *agent,
206 netsnmp_data_list *node);
208 NETSNMP_INLINE void *netsnmp_agent_get_list_data(netsnmp_agent_request_info
209 *agent, const char *name);
212 netsnmp_free_agent_data_set(netsnmp_agent_request_info *agent);
215 netsnmp_free_agent_data_sets(netsnmp_agent_request_info *agent);
217 netsnmp_free_agent_request_info(netsnmp_agent_request_info *ari);