1The Net-SNMP library(3)            net-snmp            The Net-SNMP library(3)
2
3
4

NAME

6       The Net-SNMP library -
7
8   Modules
9       asn1 parsing and datatype manipulation routines.
10           Note on.
11
12       A generic callback mechanism
13       generic linked-list data handling with a string as a key.
14       storage space for defaults
15           The purpose of the default storage is three-fold:.
16
17       mib parsing and datatype manipulation routines.
18       Store and retrieve data referenced by an OID.
19           This is essentially a way of storing data associated with a given
20           OID.
21
22       parsing various configuration files at run time
23           The read_config related functions are a fairly extensible system of
24           parsing various configuration files at the run time.
25
26       generic library based alarm timers for various parts of an application
27       various PDU processing routines
28       generic logging for net-snmp
29       Memory Utility Routines
30
31   Data Structures
32       struct snmp_internal_session
33       struct session_list
34
35   Defines
36       #define MIN(a, b)   (((a) < (b)) ? (a) : (b))
37       #define MIB_CLIENTS_ARE_EVIL   1
38       #define _init_agent_callback_transport()
39       #define SNMP_NEED_REQUEST_LIST
40       #define timercmp(tvp, uvp, cmp)
41       #define timerclear(tvp)   (tvp)->tv_sec = (tvp)->tv_usec = 0
42       #define MAX_PACKET_LENGTH   (0x7fffffff)
43       #define NETSNMP_STREAM_QUEUE_LEN   5
44       #define BSD4_2
45       #define NFDBITS   (sizeof(fd_mask) * NBBY)
46       #define FD_SET(n, p)   ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) %
47           NFDBITS)))
48       #define FD_CLR(n, p)   ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) %
49           NFDBITS)))
50       #define FD_ISSET(n, p)   ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) %
51           NFDBITS)))
52       #define FD_ZERO(p)   memset((p), 0, sizeof(*(p)))
53       #define DEFAULT_COMMUNITY   'public'
54       #define DEFAULT_RETRIES   5
55       #define DEFAULT_TIMEOUT   1000000L
56       #define DEFAULT_REMPORT   SNMP_PORT
57       #define DEFAULT_ENTERPRISE   default_enterprise
58       #define DEFAULT_TIME   0
59       #define MAXIMUM_PACKET_SIZE   0x7fffffff
60       #define DEBUGPRINTPDUTYPE(token, type)   DEBUGDUMPSECTION(token,
61           snmp_pdu_type(type))
62       #define ERROR_STAT_LENGTH   11
63
64   Typedefs
65       typedef long fd_mask
66
67   Functions
68       int init_agent (const char *app)
69           Initialize the agent.
70       void shutdown_agent (void)
71       void add_to_init_list (char *module_list)
72       int should_init (const char *module_name)
73       int snmp_build (u_char **pkt, size_t *pkt_len, size_t *offset,
74           netsnmp_session *pss, netsnmp_pdu *pdu)
75       int snmp_get_errno (void)
76       void snmp_synch_reset (netsnmp_session *notused)
77       void snmp_synch_setup (netsnmp_session *notused)
78       const char * strerror (int err)
79       const char * snmp_pdu_type (int type)
80       long snmp_get_next_reqid (void)
81       long snmp_get_next_msgid (void)
82       long snmp_get_next_sessid (void)
83       long snmp_get_next_transid (void)
84       void snmp_perror (const char *prog_string)
85       void snmp_set_detail (const char *detail_string)
86       const char * snmp_api_errstring (int snmp_errnumber)
87       void snmp_error (netsnmp_session *psess, int *p_errno, int
88           *p_snmp_errno, char **p_str)
89       void snmp_sess_error (void *sessp, int *p_errno, int *p_snmp_errno,
90           char **p_str)
91       void netsnmp_sess_log_error (int priority, const char *prog_string,
92           netsnmp_session *ss)
93       void snmp_sess_perror (const char *prog_string, netsnmp_session *ss)
94       void snmp_sess_init (netsnmp_session *session)
95       void init_snmp_enums (void)
96       void init_snmp (const char *type)
97           Calls the functions to do config file loading and mib module
98           parsing in the correct order.
99       void snmp_store (const char *type)
100       void snmp_shutdown (const char *type)
101           Shuts down the application, saving any needed persistent storage,
102           and appropriate clean up.
103       netsnmp_session * snmp_open (netsnmp_session *session)
104       netsnmp_session * snmp_open_ex (netsnmp_session *session,
105           int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *,
106           int), int(*fparse)(netsnmp_session *, netsnmp_pdu *, u_char *,
107           size_t), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int),
108           int(*fbuild)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t *),
109           int(*frbuild)(netsnmp_session *, netsnmp_pdu *, u_char **, size_t
110           *, size_t *), int(*fcheck)(u_char *, size_t))
111       int snmpv3_engineID_probe (struct session_list *slp, netsnmp_session
112           *in_session)
113           probe for peer engineID
114       netsnmp_session * snmp_add (netsnmp_session *in_session,
115           netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *,
116           netsnmp_transport *, void *, int),
117           int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int))
118       netsnmp_session * snmp_add_full (netsnmp_session *in_session,
119           netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *,
120           netsnmp_transport *, void *, int), int(*fparse)(netsnmp_session *,
121           netsnmp_pdu *, u_char *, size_t), int(*fpost_parse)(netsnmp_session
122           *, netsnmp_pdu *, int), int(*fbuild)(netsnmp_session *, netsnmp_pdu
123           *, u_char *, size_t *), int(*frbuild)(netsnmp_session *,
124           netsnmp_pdu *, u_char **, size_t *, size_t *), int(*fcheck)(u_char
125           *, size_t), netsnmp_pdu *(*fcreate_pdu)(netsnmp_transport *, void
126           *, size_t))
127       void * snmp_sess_add_ex (netsnmp_session *in_session, netsnmp_transport
128           *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport
129           *, void *, int), int(*fparse)(netsnmp_session *, netsnmp_pdu *,
130           u_char *, size_t), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu
131           *, int), int(*fbuild)(netsnmp_session *, netsnmp_pdu *, u_char *,
132           size_t *), int(*frbuild)(netsnmp_session *, netsnmp_pdu *, u_char
133           **, size_t *, size_t *), int(*fcheck)(u_char *, size_t),
134           netsnmp_pdu *(*fcreate_pdu)(netsnmp_transport *, void *, size_t))
135       void * snmp_sess_add (netsnmp_session *in_session, netsnmp_transport
136           *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport
137           *, void *, int), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu
138           *, int))
139       void * snmp_sess_open (netsnmp_session *pss)
140       int create_user_from_session (netsnmp_session *session)
141       int snmp_sess_close (void *sessp)
142       int snmp_close (netsnmp_session *session)
143       int snmp_close_sessions (void)
144       int snmpv3_packet_build (netsnmp_session *session, netsnmp_pdu *pdu,
145           u_char *packet, size_t *out_length, u_char *pdu_data, size_t
146           pdu_data_len)
147       u_char * snmp_pdu_build (netsnmp_pdu *pdu, u_char *cp, size_t
148           *out_length)
149       int snmpv3_parse (netsnmp_pdu *pdu, u_char *data, size_t *length,
150           u_char **after_header, netsnmp_session *sess)
151       int snmpv3_make_report (netsnmp_pdu *pdu, int error)
152       int snmpv3_get_report_type (netsnmp_pdu *pdu)
153       int snmp_pdu_parse (netsnmp_pdu *pdu, u_char *data, size_t *length)
154       u_char * snmpv3_scopedPDU_parse (netsnmp_pdu *pdu, u_char *cp, size_t
155           *length)
156       int snmp_send (netsnmp_session *session, netsnmp_pdu *pdu)
157       int snmp_sess_send (void *sessp, netsnmp_pdu *pdu)
158       int snmp_async_send (netsnmp_session *session, netsnmp_pdu *pdu,
159           snmp_callback callback, void *cb_data)
160       int snmp_sess_async_send (void *sessp, netsnmp_pdu *pdu, snmp_callback
161           callback, void *cb_data)
162       void snmp_free_var (netsnmp_variable_list *var)
163       void snmp_free_varbind (netsnmp_variable_list *var)
164       void snmp_free_pdu (netsnmp_pdu *pdu)
165       netsnmp_pdu * snmp_create_sess_pdu (netsnmp_transport *transport, void
166           *opaque, size_t olength)
167       void snmp_read (fd_set *fdset)
168       int _sess_read (void *sessp, fd_set *fdset)
169       int snmp_sess_read (void *sessp, fd_set *fdset)
170       int snmp_select_info (int *numfds, fd_set *fdset, struct timeval
171           *timeout, int *block)
172       int snmp_sess_select_info (void *sessp, int *numfds, fd_set *fdset,
173           struct timeval *timeout, int *block)
174       void snmp_timeout (void)
175       void snmp_sess_timeout (void *sessp)
176       int snmp_oid_ncompare (const oid *in_name1, size_t len1, const oid
177           *in_name2, size_t len2, size_t max_len)
178       int snmp_oid_compare (const oid *in_name1, size_t len1, const oid
179           *in_name2, size_t len2)
180           lexicographical compare two object identifiers.
181       int netsnmp_oid_compare_ll (const oid *in_name1, size_t len1, const oid
182           *in_name2, size_t len2, size_t *offpt)
183           lexicographical compare two object identifiers and return the point
184           where they differ
185       int snmp_oidtree_compare (const oid *in_name1, size_t len1, const oid
186           *in_name2, size_t len2)
187           Compares 2 OIDs to determine if they are equal up until the
188           shortest length.
189       int snmp_oidsubtree_compare (const oid *in_name1, size_t len1, const
190           oid *in_name2, size_t len2)
191       int netsnmp_oid_equals (const oid *in_name1, size_t len1, const oid
192           *in_name2, size_t len2)
193           Compares 2 OIDs to determine if they are exactly equal.
194       int netsnmp_oid_is_subtree (const oid *in_name1, size_t len1, const oid
195           *in_name2, size_t len2)
196           Identical to netsnmp_oid_equals, except only the length up to len1
197           is compared.
198       int netsnmp_oid_find_prefix (const oid *in_name1, size_t len1, const
199           oid *in_name2, size_t len2)
200           Given two OIDs, determine the common prefix to them both.
201       netsnmp_variable_list * snmp_pdu_add_variable (netsnmp_pdu *pdu, const
202           oid *name, size_t name_length, u_char type, const u_char *value,
203           size_t len)
204       netsnmp_variable_list * snmp_varlist_add_variable
205           (netsnmp_variable_list **varlist, const oid *name, size_t
206           name_length, u_char type, const u_char *value, size_t len)
207       int snmp_add_var (netsnmp_pdu *pdu, const oid *name, size_t
208           name_length, char type, const char *value)
209       void * snmp_sess_pointer (netsnmp_session *session)
210       netsnmp_session * snmp_sess_session (void *sessp)
211       netsnmp_transport * snmp_sess_transport (void *sessp)
212       void snmp_sess_transport_set (void *sp, netsnmp_transport *t)
213       oid * snmp_duplicate_objid (const oid *objToCopy, size_t objToCopyLen)
214       u_int snmp_increment_statistic (int which)
215       u_int snmp_increment_statistic_by (int which, int count)
216       u_int snmp_get_statistic (int which)
217       void snmp_init_statistics (void)
218
219   Variables
220       module_init_list * initlist = NULL
221       module_init_list * noinitlist = NULL
222       netsnmp_subtree * subtrees
223       long long_return
224       u_char return_buf [258]
225       timeval starttime
226       int callback_master_num = -1
227       oid nullOid [] = { 0, 0 }
228       int nullOidLen = sizeof(nullOid)
229       session_list * Sessions = NULL
230       int snmp_errno = 0
231

Define Documentation

233   #define timercmp(tvp, uvp, cmp)
234       Value:
235
236       /* CSTYLED */         ((tvp)->tv_sec cmp (uvp)->tv_sec ||         ((tvp)->tv_sec == (uvp)->tv_sec &&         /* CSTYLED */         (tvp)->tv_usec cmp (uvp)->tv_usec))
237
238       Definition at line 148 of file snmp_api.c.
239
240       Referenced by snmp_sess_timeout().
241

Function Documentation

243   int _sess_read (void * sessp, fd_set * fdset)
244       XXX-rks: why no SNMP_FREE(isp->packet); ??
245
246       XXX-rks: why no SNMP_FREE(isp->packet); ??
247
248       Definition at line 5424 of file snmp_api.c.
249
250       References asn_check_packet(), snmp_session::callback,
251       snmp_session::callback_magic, snmp_internal_session::check_packet,
252       netsnmp_transport_s::f_accept, netsnmp_transport_s::f_close,
253       netsnmp_transport_s::f_recv, FD_ISSET, netsnmp_transport_s::flags,
254       snmp_internal_session::hook_build,
255       snmp_internal_session::hook_create_pdu,
256       snmp_internal_session::hook_parse, snmp_internal_session::hook_post,
257       snmp_internal_session::hook_pre,
258       snmp_internal_session::hook_realloc_build, session_list::internal,
259       MAX_PACKET_LENGTH, MAXIMUM_PACKET_SIZE, session_list::next, NULL,
260       snmp_internal_session::packet, snmp_internal_session::packet_len,
261       snmp_internal_session::packet_size, snmp_session::s_errno,
262       snmp_session::s_snmp_errno, session_list::session, Sessions, SNMP_FREE,
263       snmp_log(), snmp_sess_add_ex(), snmp_set_detail(),
264       netsnmp_transport_s::sock, strerror(), and session_list::transport.
265
266       Referenced by snmp_sess_read().
267
268   int init_agent (const char * app)
269       Initialize the agent.
270
271       Calls into init_agent_read_config to set tha app's configuration file
272       in the appropriate default storage space, NETSNMP_DS_LIB_APPTYPE. Need
273       to call init_agent before calling init_snmp.
274
275       Parameters:
276           app the configuration file to be read in, gets stored in default
277           storage
278
279       Returns:
280           Returns non-zero on failure and zero on success.
281
282       See also:
283           init_snmp
284
285       Definition at line 270 of file snmp_vars.c.
286
287       References _init_agent_callback_transport, init_traps(),
288       netsnmp_ds_get_boolean(), netsnmp_ds_set_boolean(),
289       netsnmp_init_helpers(), NULL, setup_tree(), snmp_log(), and starttime.
290
291   void init_snmp (const char * type)
292       Calls the functions to do config file loading and mib module parsing in
293       the correct order.
294
295       Parameters:
296           type label for the config file 'type'
297
298       Returns:
299           void
300
301       See also:
302           init_agent
303
304       Definition at line 811 of file snmp_api.c.
305
306       References init_callbacks(), init_snmp_alarm(), init_snmp_enums(),
307       init_snmp_logging(), netsnmp_ds_get_string(), netsnmp_ds_set_string(),
308       netsnmp_init_mib(), read_configs(), read_premib_configs(),
309       register_mib_handlers(), and snmp_init_statistics().
310
311   int netsnmp_oid_compare_ll (const oid * in_name1, size_t len1, const oid *
312       in_name2, size_t len2, size_t * offpt)
313       lexicographical compare two object identifiers and return the point
314       where they differ
315
316       Caution: this method is called often by command responder applications
317       (ie, agent).
318
319       Returns:
320           -1 if name1 < name2, 0 if name1 = name2, 1 if name1 > name2 and
321           offpt = len where name1 != name2
322
323       Definition at line 6365 of file snmp_api.c.
324
325       Referenced by netsnmp_subtree_change_next(),
326       netsnmp_subtree_change_prev(), and netsnmp_subtree_find_prev().
327
328   int netsnmp_oid_equals (const oid * in_name1, size_t len1, const oid *
329       in_name2, size_t len2)
330       Compares 2 OIDs to determine if they are exactly equal.
331
332       This should be faster than doing a snmp_oid_compare for different
333       length OIDs, since the length is checked first and if != returns
334       immediately. Might be very slighly faster if lengths are ==.
335
336       Parameters:
337           in_name1 A pointer to the first oid.
338           len1 length of the first OID (in segments, not bytes)
339           in_name2 A pointer to the second oid.
340           len2 length of the second OID (in segments, not bytes)
341
342       Returns:
343           0 if they are equal, 1 if they are not.
344
345       Definition at line 6446 of file snmp_api.c.
346
347       Referenced by netsnmp_cache_find_by_oid(), netsnmp_subtree_free(),
348       netsnmp_subtree_load(), and unregister_mib_context().
349
350   int netsnmp_oid_find_prefix (const oid * in_name1, size_t len1, const oid *
351       in_name2, size_t len2)
352       Given two OIDs, determine the common prefix to them both.
353
354       Parameters:
355           in_name1 A pointer to the first oid.
356           len1 Length of the first oid.
357           in_name2 A pointer to the second oid.
358           len2 Length of the second oid.
359
360       Returns:
361           length of largest common index of commonality. 1 = first, 0 if none
362           * or -1 on error.
363
364       Definition at line 6502 of file snmp_api.c.
365
366       References SNMP_MIN.
367
368       Referenced by netsnmp_add_varbind_to_cache().
369
370   int netsnmp_oid_is_subtree (const oid * in_name1, size_t len1, const oid *
371       in_name2, size_t len2)
372       Identical to netsnmp_oid_equals, except only the length up to len1 is
373       compared.
374
375       Functionally, this determines if in_name2 is equal or a subtree of
376       in_name1
377
378       Parameters:
379           in_name1 A pointer to the first oid.
380           len1 length of the first OID (in segments, not bytes)
381           in_name2 A pointer to the second oid.
382           len2 length of the second OID (in segments, not bytes)
383
384       Returns:
385           0 if one is a common prefix of the other.
386
387       Definition at line 6482 of file snmp_api.c.
388
389   int snmp_oid_compare (const oid * in_name1, size_t len1, const oid *
390       in_name2, size_t len2)
391       lexicographical compare two object identifiers.
392
393       Caution: this method is called often by command responder applications
394       (ie, agent).
395
396       Returns:
397           -1 if name1 < name2, 0 if name1 = name2, 1 if name1 > name2
398
399       Definition at line 6316 of file snmp_api.c.
400
401       Referenced by convert_v2pdu_to_v1(), find_varbind_in_list(),
402       lookup_cache_find(), netsnmp_bulk_to_next_fix_requests(),
403       netsnmp_check_getnext_reply(), netsnmp_container_table_row_insert(),
404       netsnmp_insert_iterator_context(), netsnmp_insert_table_row(),
405       netsnmp_instance_helper_handler(), netsnmp_iterator_row_get_byoid(),
406       netsnmp_iterator_row_next_byoid(),
407       netsnmp_scalar_group_helper_handler(), netsnmp_scalar_helper_handler(),
408       netsnmp_send_traps(), netsnmp_stash_to_next_helper(),
409       netsnmp_subtree_compare(), netsnmp_subtree_find(),
410       netsnmp_subtree_find_next(), netsnmp_subtree_find_prev(),
411       netsnmp_subtree_load(), netsnmp_subtree_split(),
412       netsnmp_table_data_add_row(), netsnmp_table_data_get_from_oid(),
413       netsnmp_table_data_row_next_byoid(), netsnmp_tdata_compare_oid(),
414       netsnmp_watched_spinlock_handler(),
415       netsnmp_watched_timestamp_handler(), netsnmp_watcher_helper_handler(),
416       snmp_oidsubtree_compare(), snmp_oidtree_compare(), and
417       table_helper_handler().
418
419   int snmp_oidtree_compare (const oid * in_name1, size_t len1, const oid *
420       in_name2, size_t len2)
421       Compares 2 OIDs to determine if they are equal up until the shortest
422       length.
423
424       Parameters:
425           in_name1 A pointer to the first oid.
426           len1 length of the first OID (in segments, not bytes)
427           in_name2 A pointer to the second oid.
428           len2 length of the second OID (in segments, not bytes)
429
430       Returns:
431           0 if they are equal, 1 if in_name1 is > in_name2, or -1 if <.
432
433       Definition at line 6418 of file snmp_api.c.
434
435       References snmp_oid_compare().
436
437       Referenced by netsnmp_query_walk(), and
438       netsnmp_tdata_compare_subtree_oid().
439
440   void snmp_shutdown (const char * type)
441       Shuts down the application, saving any needed persistent storage, and
442       appropriate clean up.
443
444       Parameters:
445           type Label for the config file 'type' used
446
447       Returns:
448           void
449
450       Definition at line 880 of file snmp_api.c.
451
452       References clear_callback(), netsnmp_ds_shutdown(), NULL,
453       shutdown_mib(), shutdown_snmp_logging(), snmp_alarm_unregister_all(),
454       snmp_call_callbacks(), snmp_close_sessions(), snmp_store(), and
455       unregister_all_config_handlers().
456
457   int snmpv3_engineID_probe (struct session_list * slp, netsnmp_session *
458       in_session)
459       probe for peer engineID
460
461       Parameters:
462           slp session list pointer.
463           in_session session for errors
464
465       Note:
466
467           · called by _sess_open(), snmp_sess_add_ex()
468
469           · in_session is the user supplied session provided to those
470             functions.
471
472           · the first session in slp should the internal allocated copy of
473             in_session
474
475       Returns:
476           0 : error
477
478           1 : ok
479
480       Definition at line 1299 of file snmp_api.c.
481
482       References create_user_from_session(), snmp_session::engineBoots,
483       snmp_session::engineTime, snmp_session::flags, NULL,
484       snmp_session::s_snmp_errno, snmp_session::securityEngineID,
485       snmp_session::securityEngineIDLen, session_list::session,
486       snmp_api_errstring(), snmp_errstring(), snmp_sess_synch_response(),
487       TRUE, and snmp_session::version.
488
489       Referenced by snmp_sess_add_ex().
490
491
492
493Version 5.4                       24 Nov 2006          The Net-SNMP library(3)
Impressum