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 * Redistribution of this software and documentation and use in source and 9 * binary forms, with or without modification, are permitted provided that 10 * the following conditions are met: 11 * 12 * 1. Redistributions of source code or documentation must retain the above 13 * copyright notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the Institute nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY FRAUNHOFER FOKUS 22 * AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25 * FRAUNHOFER FOKUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 28 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 *
| 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 * Redistribution of this software and documentation and use in source and 9 * binary forms, with or without modification, are permitted provided that 10 * the following conditions are met: 11 * 12 * 1. Redistributions of source code or documentation must retain the above 13 * copyright notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of the Institute nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY FRAUNHOFER FOKUS 22 * AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25 * FRAUNHOFER FOKUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 28 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 *
|
33 * $Begemot: bsnmp/lib/snmpagent.h,v 1.10 2003/12/03 09:55:58 hbb Exp $
| 33 * $Begemot: bsnmp/lib/snmpagent.h,v 1.12 2004/04/13 15:18:15 novo Exp $
|
34 * 35 * Header file for SNMP functions. This requires snmp.h to be included. 36 */ 37#ifndef snmp_agent_h_ 38#define snmp_agent_h_ 39 40struct snmp_dependency; 41
| 34 * 35 * Header file for SNMP functions. This requires snmp.h to be included. 36 */ 37#ifndef snmp_agent_h_ 38#define snmp_agent_h_ 39 40struct snmp_dependency; 41
|
| 42enum snmp_ret { 43 /* OK, generate a response */ 44 SNMP_RET_OK = 0, 45 /* Error, ignore packet (no response) */ 46 SNMP_RET_IGN = 1, 47 /* Error, generate response from original packet */ 48 SNMP_RET_ERR = 2 49}; 50
|
42/* Semi-Opaque object for SET operations */ 43struct snmp_context { 44 u_int var_index; 45 struct snmp_scratch *scratch; 46 struct snmp_dependency *dep; 47 void *data; /* user data */
| 51/* Semi-Opaque object for SET operations */ 52struct snmp_context { 53 u_int var_index; 54 struct snmp_scratch *scratch; 55 struct snmp_dependency *dep; 56 void *data; /* user data */
|
| 57 enum snmp_ret code; /* return code */
|
48}; 49 50struct snmp_scratch { 51 void *ptr1; 52 void *ptr2; 53 u_int32_t int1; 54 u_int32_t int2; 55}; 56 57enum snmp_depop { 58 SNMP_DEPOP_COMMIT,
| 58}; 59 60struct snmp_scratch { 61 void *ptr1; 62 void *ptr2; 63 u_int32_t int1; 64 u_int32_t int2; 65}; 66 67enum snmp_depop { 68 SNMP_DEPOP_COMMIT,
|
59 SNMP_DEPOP_ROLLBACK
| 69 SNMP_DEPOP_ROLLBACK, 70 SNMP_DEPOP_FINISH
|
60}; 61 62typedef int (*snmp_depop_t)(struct snmp_context *, struct snmp_dependency *, 63 enum snmp_depop); 64 65struct snmp_dependency { 66 struct asn_oid obj; 67 struct asn_oid idx; 68}; 69 70/*
| 71}; 72 73typedef int (*snmp_depop_t)(struct snmp_context *, struct snmp_dependency *, 74 enum snmp_depop); 75 76struct snmp_dependency { 77 struct asn_oid obj; 78 struct asn_oid idx; 79}; 80 81/*
|
71 * Functions to be called at the end of a SET operation. 72 */ 73typedef void (*snmp_set_finish_t)(struct snmp_context *, int fail, void *); 74 75/*
| |
76 * The TREE 77 */ 78enum snmp_node_type { 79 SNMP_NODE_LEAF = 1, 80 SNMP_NODE_COLUMN 81}; 82 83enum snmp_op { 84 SNMP_OP_GET = 1, 85 SNMP_OP_GETNEXT, 86 SNMP_OP_SET, 87 SNMP_OP_COMMIT, 88 SNMP_OP_ROLLBACK, 89}; 90
| 82 * The TREE 83 */ 84enum snmp_node_type { 85 SNMP_NODE_LEAF = 1, 86 SNMP_NODE_COLUMN 87}; 88 89enum snmp_op { 90 SNMP_OP_GET = 1, 91 SNMP_OP_GETNEXT, 92 SNMP_OP_SET, 93 SNMP_OP_COMMIT, 94 SNMP_OP_ROLLBACK, 95}; 96
|
91enum snmp_ret { 92 /* OK, generate a response */ 93 SNMP_RET_OK = 0, 94 /* Error, ignore packet (no response) */ 95 SNMP_RET_IGN = 1, 96 /* Error, generate response from original packet */ 97 SNMP_RET_ERR = 2 98}; 99
| |
100typedef int (*snmp_op_t)(struct snmp_context *, struct snmp_value *, 101 u_int, u_int, enum snmp_op); 102 103struct snmp_node { 104 struct asn_oid oid; 105 const char *name; /* name of the leaf */ 106 enum snmp_node_type type; /* type of this node */ 107 enum snmp_syntax syntax; 108 snmp_op_t op; 109 u_int flags; 110 u_int32_t index; /* index data */ 111 void *data; /* application data */
| 97typedef int (*snmp_op_t)(struct snmp_context *, struct snmp_value *, 98 u_int, u_int, enum snmp_op); 99 100struct snmp_node { 101 struct asn_oid oid; 102 const char *name; /* name of the leaf */ 103 enum snmp_node_type type; /* type of this node */ 104 enum snmp_syntax syntax; 105 snmp_op_t op; 106 u_int flags; 107 u_int32_t index; /* index data */ 108 void *data; /* application data */
|
| 109 void *tree_data; /* application data */
|
112}; 113extern struct snmp_node *tree; 114extern u_int tree_size; 115 116#define SNMP_NODE_CANSET 0x0001 /* SET allowed */ 117 118#define SNMP_INDEXES_MAX 7 119#define SNMP_INDEX_SHIFT 4 120#define SNMP_INDEX_MASK 0xf 121#define SNMP_INDEX_COUNT(V) ((V) & SNMP_INDEX_MASK) 122#define SNMP_INDEX(V,I) \ 123 (((V) >> (((I) + 1) * SNMP_INDEX_SHIFT)) & SNMP_INDEX_MASK) 124 125enum { 126 SNMP_TRACE_GET = 0x00000001, 127 SNMP_TRACE_GETNEXT = 0x00000002, 128 SNMP_TRACE_SET = 0x00000004, 129 SNMP_TRACE_DEPEND = 0x00000008, 130 SNMP_TRACE_FIND = 0x00000010, 131}; 132/* trace flag for the following functions */ 133extern u_int snmp_trace; 134 135/* called to write the trace */ 136extern void (*snmp_debug)(const char *fmt, ...); 137 138enum snmp_ret snmp_get(struct snmp_pdu *pdu, struct asn_buf *resp_b, 139 struct snmp_pdu *resp, void *); 140enum snmp_ret snmp_getnext(struct snmp_pdu *pdu, struct asn_buf *resp_b, 141 struct snmp_pdu *resp, void *); 142enum snmp_ret snmp_getbulk(struct snmp_pdu *pdu, struct asn_buf *resp_b, 143 struct snmp_pdu *resp, void *); 144enum snmp_ret snmp_set(struct snmp_pdu *pdu, struct asn_buf *resp_b, 145 struct snmp_pdu *resp, void *); 146 147enum snmp_ret snmp_make_errresp(const struct snmp_pdu *, struct asn_buf *, 148 struct asn_buf *); 149 150struct snmp_dependency *snmp_dep_lookup(struct snmp_context *, 151 const struct asn_oid *, const struct asn_oid *, size_t, snmp_depop_t); 152
| 110}; 111extern struct snmp_node *tree; 112extern u_int tree_size; 113 114#define SNMP_NODE_CANSET 0x0001 /* SET allowed */ 115 116#define SNMP_INDEXES_MAX 7 117#define SNMP_INDEX_SHIFT 4 118#define SNMP_INDEX_MASK 0xf 119#define SNMP_INDEX_COUNT(V) ((V) & SNMP_INDEX_MASK) 120#define SNMP_INDEX(V,I) \ 121 (((V) >> (((I) + 1) * SNMP_INDEX_SHIFT)) & SNMP_INDEX_MASK) 122 123enum { 124 SNMP_TRACE_GET = 0x00000001, 125 SNMP_TRACE_GETNEXT = 0x00000002, 126 SNMP_TRACE_SET = 0x00000004, 127 SNMP_TRACE_DEPEND = 0x00000008, 128 SNMP_TRACE_FIND = 0x00000010, 129}; 130/* trace flag for the following functions */ 131extern u_int snmp_trace; 132 133/* called to write the trace */ 134extern void (*snmp_debug)(const char *fmt, ...); 135 136enum snmp_ret snmp_get(struct snmp_pdu *pdu, struct asn_buf *resp_b, 137 struct snmp_pdu *resp, void *); 138enum snmp_ret snmp_getnext(struct snmp_pdu *pdu, struct asn_buf *resp_b, 139 struct snmp_pdu *resp, void *); 140enum snmp_ret snmp_getbulk(struct snmp_pdu *pdu, struct asn_buf *resp_b, 141 struct snmp_pdu *resp, void *); 142enum snmp_ret snmp_set(struct snmp_pdu *pdu, struct asn_buf *resp_b, 143 struct snmp_pdu *resp, void *); 144 145enum snmp_ret snmp_make_errresp(const struct snmp_pdu *, struct asn_buf *, 146 struct asn_buf *); 147 148struct snmp_dependency *snmp_dep_lookup(struct snmp_context *, 149 const struct asn_oid *, const struct asn_oid *, size_t, snmp_depop_t); 150
|
153int snmp_set_atfinish(struct snmp_context *, snmp_set_finish_t func, void *arg); 154
| |
155struct snmp_context *snmp_init_context(void); 156int snmp_dep_commit(struct snmp_context *); 157int snmp_dep_rollback(struct snmp_context *);
| 151struct snmp_context *snmp_init_context(void); 152int snmp_dep_commit(struct snmp_context *); 153int snmp_dep_rollback(struct snmp_context *);
|
| 154void snmp_dep_finish(struct snmp_context *);
|
158 159#endif
| 155 156#endif
|