2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
6 * Author: Harti Brandt <harti@freebsd.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $Begemot: bsnmp/lib/snmpagent.h,v 1.13 2004/08/06 08:46:56 brandt Exp $
31 * Header file for SNMP functions. This requires snmp.h to be included.
36 struct snmp_dependency;
39 /* OK, generate a response */
41 /* Error, ignore packet (no response) */
43 /* Error, generate response from original packet */
47 /* Semi-Opaque object for SET operations */
50 struct snmp_scratch *scratch;
51 struct snmp_dependency *dep;
52 void *data; /* user data */
53 enum snmp_ret code; /* return code */
69 typedef int (*snmp_depop_t)(struct snmp_context *, struct snmp_dependency *,
72 struct snmp_dependency {
93 typedef int (*snmp_op_t)(struct snmp_context *, struct snmp_value *,
94 u_int, u_int, enum snmp_op);
98 const char *name; /* name of the leaf */
99 enum snmp_node_type type; /* type of this node */
100 enum snmp_syntax syntax;
103 uint32_t index; /* index data */
104 void *data; /* application data */
105 void *tree_data; /* application data */
107 extern struct snmp_node *tree;
108 extern u_int tree_size;
110 #define SNMP_NODE_CANSET 0x0001 /* SET allowed */
112 #define SNMP_INDEXES_MAX 7
113 #define SNMP_INDEX_SHIFT 4
114 #define SNMP_INDEX_MASK 0xf
115 #define SNMP_INDEX_COUNT(V) ((V) & SNMP_INDEX_MASK)
116 #define SNMP_INDEX(V,I) \
117 (((V) >> (((I) + 1) * SNMP_INDEX_SHIFT)) & SNMP_INDEX_MASK)
120 SNMP_TRACE_GET = 0x00000001,
121 SNMP_TRACE_GETNEXT = 0x00000002,
122 SNMP_TRACE_SET = 0x00000004,
123 SNMP_TRACE_DEPEND = 0x00000008,
124 SNMP_TRACE_FIND = 0x00000010,
126 /* trace flag for the following functions */
127 extern u_int snmp_trace;
129 /* called to write the trace */
130 extern void (*snmp_debug)(const char *fmt, ...);
132 enum snmp_ret snmp_get(struct snmp_pdu *pdu, struct asn_buf *resp_b,
133 struct snmp_pdu *resp, void *);
134 enum snmp_ret snmp_getnext(struct snmp_pdu *pdu, struct asn_buf *resp_b,
135 struct snmp_pdu *resp, void *);
136 enum snmp_ret snmp_getbulk(struct snmp_pdu *pdu, struct asn_buf *resp_b,
137 struct snmp_pdu *resp, void *);
138 enum snmp_ret snmp_set(struct snmp_pdu *pdu, struct asn_buf *resp_b,
139 struct snmp_pdu *resp, void *);
141 enum snmp_ret snmp_make_errresp(const struct snmp_pdu *, struct asn_buf *,
144 struct snmp_dependency *snmp_dep_lookup(struct snmp_context *,
145 const struct asn_oid *, const struct asn_oid *, size_t, snmp_depop_t);
147 struct snmp_context *snmp_init_context(void);
148 int snmp_dep_commit(struct snmp_context *);
149 int snmp_dep_rollback(struct snmp_context *);
150 void snmp_dep_finish(struct snmp_context *);