readelf: report ARM program and section header types
[freebsd-src.git] / contrib / bsnmp / lib / snmpagent.h
blob66019c9b4380296f5774b63a9605fa9ee9cc2b5f
1 /*
2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4 * All rights reserved.
6 * Author: Harti Brandt <harti@freebsd.org>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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
27 * SUCH DAMAGE.
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.
33 #ifndef snmp_agent_h_
34 #define snmp_agent_h_
36 struct snmp_dependency;
38 enum snmp_ret {
39 /* OK, generate a response */
40 SNMP_RET_OK = 0,
41 /* Error, ignore packet (no response) */
42 SNMP_RET_IGN = 1,
43 /* Error, generate response from original packet */
44 SNMP_RET_ERR = 2
47 /* Semi-Opaque object for SET operations */
48 struct snmp_context {
49 u_int var_index;
50 struct snmp_scratch *scratch;
51 struct snmp_dependency *dep;
52 void *data; /* user data */
53 enum snmp_ret code; /* return code */
56 struct snmp_scratch {
57 void *ptr1;
58 void *ptr2;
59 uint32_t int1;
60 uint32_t int2;
63 enum snmp_depop {
64 SNMP_DEPOP_COMMIT,
65 SNMP_DEPOP_ROLLBACK,
66 SNMP_DEPOP_FINISH
69 typedef int (*snmp_depop_t)(struct snmp_context *, struct snmp_dependency *,
70 enum snmp_depop);
72 struct snmp_dependency {
73 struct asn_oid obj;
74 struct asn_oid idx;
78 * The TREE
80 enum snmp_node_type {
81 SNMP_NODE_LEAF = 1,
82 SNMP_NODE_COLUMN
85 enum snmp_op {
86 SNMP_OP_GET = 1,
87 SNMP_OP_GETNEXT,
88 SNMP_OP_SET,
89 SNMP_OP_COMMIT,
90 SNMP_OP_ROLLBACK,
93 typedef int (*snmp_op_t)(struct snmp_context *, struct snmp_value *,
94 u_int, u_int, enum snmp_op);
96 struct snmp_node {
97 struct asn_oid oid;
98 const char *name; /* name of the leaf */
99 enum snmp_node_type type; /* type of this node */
100 enum snmp_syntax syntax;
101 snmp_op_t op;
102 u_int flags;
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)
119 enum {
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 *,
142 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 *);
152 #endif