]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/bsnmp/snmpd/snmpmod.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / bsnmp / snmpd / snmpmod.h
1 /*
2  * Copyright (c) 2001-2003
3  *      Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4  *      All rights reserved.
5  *
6  * Author: Harti Brandt <harti@freebsd.org>
7  * 
8  * Copyright (c) 2010 The FreeBSD Foundation
9  * All rights reserved.
10  *
11  * Portions of this software were developed by Shteryana Sotirova Shopova
12  * under sponsorship from the FreeBSD Foundation.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  * 
23  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  * $Begemot: bsnmp/snmpd/snmpmod.h,v 1.32 2006/02/14 09:04:20 brandt_h Exp $
36  *
37  * SNMP daemon data and functions exported to modules.
38  */
39 #ifndef snmpmod_h_
40 #define snmpmod_h_
41
42 #include <sys/types.h>
43 #include <sys/socket.h>
44 #include <net/if.h>
45 #include <netinet/in.h>
46 #include "asn1.h"
47 #include "snmp.h"
48 #include "snmpagent.h"
49
50 #define MAX_MOD_ARGS    16
51
52 /*
53  * These macros help to handle object lists for SNMP tables. They use
54  * tail queues to hold the objects in ascending order in the list.
55  * ordering can be done either on an integer/unsigned field, an asn_oid
56  * or an ordering function.
57  */
58 #define INSERT_OBJECT_OID_LINK_INDEX(PTR, LIST, LINK, INDEX) do {       \
59         __typeof (PTR) _lelem;                                          \
60                                                                         \
61         TAILQ_FOREACH(_lelem, (LIST), LINK)                             \
62                 if (asn_compare_oid(&_lelem->INDEX, &(PTR)->INDEX) > 0) \
63                         break;                                          \
64         if (_lelem == NULL)                                             \
65                 TAILQ_INSERT_TAIL((LIST), (PTR), LINK);                 \
66         else                                                            \
67                 TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK);               \
68     } while (0)
69
70 #define INSERT_OBJECT_INT_LINK_INDEX(PTR, LIST, LINK, INDEX) do {       \
71         __typeof (PTR) _lelem;                                          \
72                                                                         \
73         TAILQ_FOREACH(_lelem, (LIST), LINK)                             \
74                 if ((asn_subid_t)_lelem->INDEX > (asn_subid_t)(PTR)->INDEX)\
75                         break;                                          \
76         if (_lelem == NULL)                                             \
77                 TAILQ_INSERT_TAIL((LIST), (PTR), LINK);                 \
78         else                                                            \
79                 TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK);               \
80     } while (0)
81
82 #define INSERT_OBJECT_FUNC_LINK(PTR, LIST, LINK, FUNC) do {             \
83         __typeof (PTR) _lelem;                                          \
84                                                                         \
85         TAILQ_FOREACH(_lelem, (LIST), LINK)                             \
86                 if ((FUNC)(_lelem, (PTR)) > 0)                          \
87                         break;                                          \
88         if (_lelem == NULL)                                             \
89                 TAILQ_INSERT_TAIL((LIST), (PTR), LINK);                 \
90         else                                                            \
91                 TAILQ_INSERT_BEFORE(_lelem, (PTR), LINK);               \
92     } while (0)
93
94 #define INSERT_OBJECT_FUNC_LINK_REV(PTR, LIST, HEAD, LINK, FUNC) do {   \
95         __typeof (PTR) _lelem;                                          \
96                                                                         \
97         TAILQ_FOREACH_REVERSE(_lelem, (LIST), HEAD, LINK)               \
98                 if ((FUNC)(_lelem, (PTR)) < 0)                          \
99                         break;                                          \
100         if (_lelem == NULL)                                             \
101                 TAILQ_INSERT_HEAD((LIST), (PTR), LINK);                 \
102         else                                                            \
103                 TAILQ_INSERT_AFTER((LIST), _lelem, (PTR), LINK);        \
104     } while (0)
105
106 #define FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({      \
107         __typeof (TAILQ_FIRST(LIST)) _lelem;                            \
108                                                                         \
109         TAILQ_FOREACH(_lelem, (LIST), LINK)                             \
110                 if (index_compare(OID, SUB, &_lelem->INDEX) == 0)       \
111                         break;                                          \
112         (_lelem);                                                       \
113     })
114
115 #define NEXT_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({      \
116         __typeof (TAILQ_FIRST(LIST)) _lelem;                            \
117                                                                         \
118         TAILQ_FOREACH(_lelem, (LIST), LINK)                             \
119                 if (index_compare(OID, SUB, &_lelem->INDEX) < 0)        \
120                         break;                                          \
121         (_lelem);                                                       \
122     })
123
124 #define FIND_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({      \
125         __typeof (TAILQ_FIRST(LIST)) _lelem;                            \
126                                                                         \
127         if ((OID)->len - SUB != 1)                                      \
128                 _lelem = NULL;                                          \
129         else                                                            \
130                 TAILQ_FOREACH(_lelem, (LIST), LINK)                     \
131                         if ((OID)->subs[SUB] == (asn_subid_t)_lelem->INDEX)\
132                                 break;                                  \
133         (_lelem);                                                       \
134     })
135
136 #define NEXT_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, INDEX) ({      \
137         __typeof (TAILQ_FIRST(LIST)) _lelem;                            \
138                                                                         \
139         if ((OID)->len - SUB == 0)                                      \
140                 _lelem = TAILQ_FIRST(LIST);                             \
141         else                                                            \
142                 TAILQ_FOREACH(_lelem, (LIST), LINK)                     \
143                         if ((OID)->subs[SUB] < (asn_subid_t)_lelem->INDEX)\
144                                 break;                                  \
145         (_lelem);                                                       \
146     })
147
148 #define FIND_OBJECT_FUNC_LINK(LIST, OID, SUB, LINK, FUNC) ({            \
149         __typeof (TAILQ_FIRST(LIST)) _lelem;                            \
150                                                                         \
151         TAILQ_FOREACH(_lelem, (LIST), LINK)                             \
152                 if ((FUNC)(OID, SUB, _lelem) == 0)                      \
153                         break;                                          \
154         (_lelem);                                                       \
155     })
156
157 #define NEXT_OBJECT_FUNC_LINK(LIST, OID, SUB, LINK, FUNC) ({            \
158         __typeof (TAILQ_FIRST(LIST)) _lelem;                            \
159                                                                         \
160         TAILQ_FOREACH(_lelem, (LIST), LINK)                             \
161                 if ((FUNC)(OID, SUB, _lelem) < 0)                       \
162                         break;                                          \
163         (_lelem);                                                       \
164     })
165
166 /*
167  * Macros for the case where the index field is called 'index'
168  */
169 #define INSERT_OBJECT_OID_LINK(PTR, LIST, LINK)                         \
170     INSERT_OBJECT_OID_LINK_INDEX(PTR, LIST, LINK, index)
171
172 #define INSERT_OBJECT_INT_LINK(PTR, LIST, LINK) do {                    \
173     INSERT_OBJECT_INT_LINK_INDEX(PTR, LIST, LINK, index)
174
175 #define FIND_OBJECT_OID_LINK(LIST, OID, SUB, LINK)                      \
176     FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, index)
177
178 #define NEXT_OBJECT_OID_LINK(LIST, OID, SUB, LINK)                      \
179     NEXT_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, LINK, index)
180
181 #define FIND_OBJECT_INT_LINK(LIST, OID, SUB, LINK)                      \
182     FIND_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, index)
183
184 #define NEXT_OBJECT_INT_LINK(LIST, OID, SUB, LINK)                      \
185     NEXT_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, LINK, index)
186
187 /*
188  * Macros for the case where the index field is called 'index' and the
189  * link field 'link'.
190  */
191 #define INSERT_OBJECT_OID(PTR, LIST)                                    \
192     INSERT_OBJECT_OID_LINK_INDEX(PTR, LIST, link, index)
193
194 #define INSERT_OBJECT_INT(PTR, LIST)                                    \
195     INSERT_OBJECT_INT_LINK_INDEX(PTR, LIST, link, index)
196
197 #define INSERT_OBJECT_FUNC_REV(PTR, LIST, HEAD, FUNC)                   \
198     INSERT_OBJECT_FUNC_LINK_REV(PTR, LIST, HEAD, link, FUNC)
199
200 #define FIND_OBJECT_OID(LIST, OID, SUB)                                 \
201     FIND_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, link, index)
202
203 #define FIND_OBJECT_INT(LIST, OID, SUB)                                 \
204     FIND_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, link, index)
205
206 #define FIND_OBJECT_FUNC(LIST, OID, SUB, FUNC)                          \
207     FIND_OBJECT_FUNC_LINK(LIST, OID, SUB, link, FUNC)
208
209 #define NEXT_OBJECT_OID(LIST, OID, SUB)                                 \
210     NEXT_OBJECT_OID_LINK_INDEX(LIST, OID, SUB, link, index)
211
212 #define NEXT_OBJECT_INT(LIST, OID, SUB)                                 \
213     NEXT_OBJECT_INT_LINK_INDEX(LIST, OID, SUB, link, index)
214
215 #define NEXT_OBJECT_FUNC(LIST, OID, SUB, FUNC)                          \
216     NEXT_OBJECT_FUNC_LINK(LIST, OID, SUB, link, FUNC)
217
218 struct lmodule;
219
220 /* The tick when the program was started. This is the absolute time of
221  * the start in 100th of a second. */
222 extern uint64_t start_tick;
223
224 /* The tick when the current packet was received. This is the absolute
225  * time in 100th of second. */
226 extern uint64_t this_tick;
227
228 /* Get the current absolute time in 100th of a second. */
229 uint64_t get_ticks(void);
230
231 /*
232  * Return code for proxy function
233  */
234 enum snmpd_proxy_err {
235         /* proxy code will process the PDU */
236         SNMPD_PROXY_OK,
237         /* proxy code does not process PDU */
238         SNMPD_PROXY_REJ,
239         /* drop this PDU */
240         SNMPD_PROXY_DROP,
241         /* drop because of bad community */
242         SNMPD_PROXY_BADCOMM,
243         /* drop because of bad community use */
244         SNMPD_PROXY_BADCOMMUSE
245 };
246
247 /*
248  * Input handling
249  */
250 enum snmpd_input_err {
251         /* proceed with packet */
252         SNMPD_INPUT_OK,
253         /* fatal error in packet, ignore it */
254         SNMPD_INPUT_FAILED,
255         /* value encoding has wrong length in a SET operation */
256         SNMPD_INPUT_VALBADLEN,
257         /* value encoding is out of range */
258         SNMPD_INPUT_VALRANGE,
259         /* value has bad encoding */
260         SNMPD_INPUT_VALBADENC,
261         /* need more data (truncated packet) */
262         SNMPD_INPUT_TRUNC,
263         /* unknown community */
264         SNMPD_INPUT_BAD_COMM,
265 };
266
267 /*
268  * Every loadable module must have one of this structures with
269  * the external name 'config'.
270  */
271 struct snmp_module {
272         /* a comment describing what this module implements */
273         const char *comment;
274
275         /* the initialization function */
276         int (*init)(struct lmodule *, int argc, char *argv[]);
277
278         /* the finalisation function */
279         int (*fini)(void);
280
281         /* the idle function */
282         void (*idle)(void);
283
284         /* the dump function */
285         void (*dump)(void);
286
287         /* re-configuration function */
288         void (*config)(void);
289
290         /* start operation */
291         void (*start)(void);
292
293         /* proxy a PDU */
294         enum snmpd_proxy_err (*proxy)(struct snmp_pdu *, void *,
295             const struct asn_oid *, const struct sockaddr *, socklen_t,
296             enum snmpd_input_err, int32_t, int);
297
298         /* the tree this module is going to server */
299         const struct snmp_node *tree;
300         u_int tree_size;
301
302         /* function called, when another module was unloaded/loaded */
303         void (*loading)(const struct lmodule *, int);
304 };
305
306 /*
307  * Stuff exported to modules
308  */
309
310 /*
311  * The system group.
312  */
313 struct systemg {
314         u_char          *descr;
315         struct asn_oid  object_id;
316         u_char          *contact;
317         u_char          *name;
318         u_char          *location;
319         u_int32_t       services;
320         u_int32_t       or_last_change;
321 };
322 extern struct systemg systemg;
323
324 /*
325  * Community support.
326  *
327  * We have 2 fixed communities for SNMP read and write access. Modules
328  * can create their communities dynamically. They are deleted automatically
329  * if the module is unloaded.
330  */
331 #define COMM_INITIALIZE 0
332 #define COMM_READ       1
333 #define COMM_WRITE      2
334
335 u_int comm_define(u_int, const char *descr, struct lmodule *, const char *str);
336 const char * comm_string(u_int);
337
338 /* community for current packet */
339 extern u_int community;
340
341 /*
342  * SNMP User-based Security Model data. Modified via the snmp_usm(3) module.
343  */
344 struct snmpd_usmstat {
345         uint32_t        unsupported_seclevels;
346         uint32_t        not_in_time_windows;
347         uint32_t        unknown_users;
348         uint32_t        unknown_engine_ids;
349         uint32_t        wrong_digests;
350         uint32_t        decrypt_errors;
351 };
352
353 extern struct snmpd_usmstat snmpd_usmstats;
354 struct snmpd_usmstat *bsnmpd_get_usm_stats(void);
355 void bsnmpd_reset_usm_stats(void);
356
357 struct usm_user {
358         struct snmp_user                suser;
359         uint8_t                         user_engine_id[SNMP_ENGINE_ID_SIZ];
360         uint32_t                        user_engine_len;
361         char                            user_public[SNMP_ADM_STR32_SIZ];
362         uint32_t                        user_public_len;
363         int32_t                         status;
364         int32_t                         type;
365         SLIST_ENTRY(usm_user)           up;
366 };
367
368 SLIST_HEAD(usm_userlist, usm_user);
369 struct usm_user *usm_first_user(void);
370 struct usm_user *usm_next_user(struct usm_user *);
371 struct usm_user *usm_find_user(uint8_t *, uint32_t, char *);
372 struct usm_user *usm_new_user(uint8_t *, uint32_t, char *);
373 void usm_delete_user(struct usm_user *);
374 void usm_flush_users(void);
375
376 /* USM user for current packet */
377 extern struct usm_user *usm_user;
378
379 /*
380  * SNMP View-based Access Control Model data. Modified via the snmp_vacm(3) module.
381  */
382 struct vacm_group;
383
384 struct vacm_user {
385         /* Security user name from USM */
386         char                            secname[SNMP_ADM_STR32_SIZ];
387         int32_t                         sec_model;
388         /* Back pointer to user assigned group name */
389         struct vacm_group               *group;
390         int32_t                         type;
391         int32_t                         status;
392         SLIST_ENTRY(vacm_user)          vvu;
393         SLIST_ENTRY(vacm_user)          vvg;
394 };
395
396 SLIST_HEAD(vacm_userlist, vacm_user);
397
398 struct vacm_group {
399         char                            groupname[SNMP_ADM_STR32_SIZ];
400         struct vacm_userlist            group_users;
401         SLIST_ENTRY(vacm_group)         vge;
402 };
403
404 SLIST_HEAD(vacm_grouplist, vacm_group);
405
406 struct vacm_access {
407         /* The group name is index, not a column in the table */
408         struct vacm_group               *group;
409         char                            ctx_prefix[SNMP_ADM_STR32_SIZ];
410         int32_t                         sec_model;
411         int32_t                         sec_level;
412         int32_t                         ctx_match;
413         struct vacm_view                *read_view;
414         struct vacm_view                *write_view;
415         struct vacm_view                *notify_view;
416         int32_t                         type;
417         int32_t                         status;
418         TAILQ_ENTRY(vacm_access)        vva;
419 };
420
421 TAILQ_HEAD(vacm_accesslist, vacm_access);
422
423 struct vacm_view {
424         char                            viewname[SNMP_ADM_STR32_SIZ]; /* key */
425         struct asn_oid                  subtree; /* key */
426         uint8_t                         mask[16];
427         uint8_t                         exclude;
428         int32_t                         type;
429         int32_t                         status;
430         SLIST_ENTRY(vacm_view)          vvl;
431 };
432
433 SLIST_HEAD(vacm_viewlist, vacm_view);
434
435 struct vacm_context {
436         /* The ID of the module that registered this context */
437         int32_t                         regid;
438         char                            ctxname[SNMP_ADM_STR32_SIZ];
439         SLIST_ENTRY(vacm_context)       vcl;
440 };
441
442 SLIST_HEAD(vacm_contextlist, vacm_context);
443
444 void vacm_groups_init(void);
445 struct vacm_user *vacm_first_user(void);
446 struct vacm_user *vacm_next_user(struct vacm_user *);
447 struct vacm_user *vacm_new_user(int32_t, char *);
448 int vacm_delete_user(struct vacm_user *);
449 int vacm_user_set_group(struct vacm_user *, u_char *, u_int);
450 struct vacm_access *vacm_first_access_rule(void);
451 struct vacm_access *vacm_next_access_rule(struct vacm_access *);
452 struct vacm_access *vacm_new_access_rule(char *, char *, int32_t, int32_t);
453 int vacm_delete_access_rule(struct vacm_access *);
454 struct vacm_view *vacm_first_view(void);
455 struct vacm_view *vacm_next_view(struct vacm_view *);
456 struct vacm_view *vacm_new_view(char *, struct asn_oid *);
457 int vacm_delete_view(struct vacm_view *);
458 struct vacm_context *vacm_first_context(void);
459 struct vacm_context *vacm_next_context(struct vacm_context *);
460 struct vacm_context *vacm_add_context(char *, int32_t);
461 void vacm_flush_contexts(int32_t);
462
463 /*
464  * RFC 3413 SNMP Management Target & Notification MIB
465  */
466
467 struct snmpd_target_stats {
468         uint32_t                        unavail_contexts;
469         uint32_t                        unknown_contexts;
470 };
471
472 #define SNMP_UDP_ADDR_SIZ               6
473 #define SNMP_TAG_SIZ                    (255 + 1)
474
475 struct target_address {
476         char                            name[SNMP_ADM_STR32_SIZ];
477         uint8_t                         address[SNMP_UDP_ADDR_SIZ];
478         int32_t                         timeout;
479         int32_t                         retry;
480         char                            taglist[SNMP_TAG_SIZ];
481         char                            paramname[SNMP_ADM_STR32_SIZ];
482         int32_t                         type;
483         int32_t                         socket;
484         int32_t                         status;
485         SLIST_ENTRY(target_address)     ta;
486 };
487
488 SLIST_HEAD(target_addresslist, target_address);
489
490 struct target_param {
491         char                            name[SNMP_ADM_STR32_SIZ];
492         int32_t                         mpmodel;
493         int32_t                         sec_model;
494         char                            secname[SNMP_ADM_STR32_SIZ];
495         enum snmp_usm_level             sec_level;
496         int32_t                         type;
497         int32_t                         status;
498         SLIST_ENTRY(target_param)       tp;
499 };
500
501 SLIST_HEAD(target_paramlist, target_param);
502
503 struct target_notify {
504         char                            name[SNMP_ADM_STR32_SIZ];
505         char                            taglist[SNMP_TAG_SIZ];
506         int32_t                         notify_type;
507         int32_t                         type;
508         int32_t                         status;
509         SLIST_ENTRY(target_notify)      tn;
510 };
511
512 SLIST_HEAD(target_notifylist, target_notify);
513
514 extern struct snmpd_target_stats snmpd_target_stats;
515 struct snmpd_target_stats *bsnmpd_get_target_stats(void);
516 struct target_address *target_first_address(void);
517 struct target_address *target_next_address(struct target_address *);
518 struct target_address *target_new_address(char *);
519 int target_activate_address(struct target_address *);
520 int target_delete_address(struct target_address *);
521 struct target_param *target_first_param(void);
522 struct target_param *target_next_param(struct target_param *);
523 struct target_param *target_new_param(char *);
524 int target_delete_param(struct target_param *);
525 struct target_notify *target_first_notify(void);
526 struct target_notify *target_next_notify(struct target_notify *);
527 struct target_notify *target_new_notify(char *);
528 int target_delete_notify (struct target_notify *);
529 void target_flush_all(void);
530
531 /*
532  * Well known OIDs
533  */
534 extern const struct asn_oid oid_zeroDotZero;
535
536 /* SNMPv3 Engine Discovery */
537 extern const struct asn_oid oid_usmUnknownEngineIDs;
538 extern const struct asn_oid oid_usmNotInTimeWindows;
539
540 /*
541  * Request ID ranges.
542  *
543  * A module can request a range of request ids and associate them with a
544  * type field. All ranges are deleted if a module is unloaded.
545  */
546 u_int reqid_allocate(int size, struct lmodule *);
547 int32_t reqid_next(u_int type);
548 int32_t reqid_base(u_int type);
549 int reqid_istype(int32_t reqid, u_int type);
550 u_int reqid_type(int32_t reqid);
551
552 /*
553  * Timers.
554  */
555 void *timer_start(u_int, void (*)(void *), void *, struct lmodule *);
556 void *timer_start_repeat(u_int, u_int, void (*)(void *), void *,
557     struct lmodule *);
558 void timer_stop(void *);
559
560 /*
561  * File descriptors
562  */
563 void *fd_select(int, void (*)(int, void *), void *, struct lmodule *);
564 void fd_deselect(void *);
565 void fd_suspend(void *);
566 int fd_resume(void *);
567
568 /*
569  * Object resources
570  */
571 u_int or_register(const struct asn_oid *, const char *, struct lmodule *);
572 void or_unregister(u_int);
573
574 /*
575  * Buffers
576  */
577 void *buf_alloc(int tx);
578 size_t buf_size(int tx);
579
580 /* decode PDU and find community */
581 enum snmpd_input_err snmp_input_start(const u_char *, size_t, const char *,
582     struct snmp_pdu *, int32_t *, size_t *);
583
584 /* process the pdu. returns either _OK or _FAILED */
585 enum snmpd_input_err snmp_input_finish(struct snmp_pdu *, const u_char *,
586     size_t, u_char *, size_t *, const char *, enum snmpd_input_err, int32_t,
587     void *);
588
589 void snmp_output(struct snmp_pdu *, u_char *, size_t *, const char *);
590 void snmp_send_port(void *, const struct asn_oid *, struct snmp_pdu *,
591         const struct sockaddr *, socklen_t);
592 enum snmp_code snmp_pdu_auth_access(struct snmp_pdu *, int32_t *);
593
594 /* sending traps */
595 void snmp_send_trap(const struct asn_oid *, ...);
596
597 /*
598  * Action support
599  */
600 int string_save(struct snmp_value *, struct snmp_context *, ssize_t, u_char **);
601 void string_commit(struct snmp_context *);
602 void string_rollback(struct snmp_context *, u_char **);
603 int string_get(struct snmp_value *, const u_char *, ssize_t);
604 int string_get_max(struct snmp_value *, const u_char *, ssize_t, size_t);
605 void string_free(struct snmp_context *);
606
607 int ip_save(struct snmp_value *, struct snmp_context *, u_char *);
608 void ip_rollback(struct snmp_context *, u_char *);
609 void ip_commit(struct snmp_context *);
610 int ip_get(struct snmp_value *, u_char *);
611
612 int oid_save(struct snmp_value *, struct snmp_context *, struct asn_oid *);
613 void oid_rollback(struct snmp_context *, struct asn_oid *);
614 void oid_commit(struct snmp_context *);
615 int oid_get(struct snmp_value *, const struct asn_oid *);
616
617 int index_decode(const struct asn_oid *oid, u_int sub, u_int code, ...);
618 int index_compare(const struct asn_oid *, u_int, const struct asn_oid *);
619 int index_compare_off(const struct asn_oid *, u_int, const struct asn_oid *,
620     u_int);
621 void index_append(struct asn_oid *, u_int, const struct asn_oid *);
622 void index_append_off(struct asn_oid *, u_int, const struct asn_oid *, u_int);
623
624 #endif