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/snmp.h,v 1.30 2004/08/06 08:46:54 brandt Exp $
31 * Header file for SNMP functions.
36 #include <sys/types.h>
38 #define SNMP_COMMUNITY_MAXLEN 128
39 #define SNMP_MAX_BINDINGS 100
43 SNMP_SYNTAX_INTEGER, /* == INTEGER32 */
44 SNMP_SYNTAX_OCTETSTRING,
46 SNMP_SYNTAX_IPADDRESS,
48 SNMP_SYNTAX_GAUGE, /* == UNSIGNED32 */
49 SNMP_SYNTAX_TIMETICKS,
52 SNMP_SYNTAX_COUNTER64,
53 SNMP_SYNTAX_NOSUCHOBJECT, /* exception */
54 SNMP_SYNTAX_NOSUCHINSTANCE, /* exception */
55 SNMP_SYNTAX_ENDOFMIBVIEW, /* exception */
60 enum snmp_syntax syntax;
62 int32_t integer; /* also integer32 */
69 uint32_t uint32; /* also gauge32, counter32,
70 unsigned32, timeticks */
82 char community[SNMP_COMMUNITY_MAXLEN + 1];
83 enum snmp_version version;
87 struct asn_oid enterprise;
90 int32_t specific_trap;
98 /* fixes for encoding */
103 struct snmp_value bindings[SNMP_MAX_BINDINGS];
106 #define snmp_v1_pdu snmp_pdu
108 #define SNMP_PDU_GET 0
109 #define SNMP_PDU_GETNEXT 1
110 #define SNMP_PDU_RESPONSE 2
111 #define SNMP_PDU_SET 3
112 #define SNMP_PDU_TRAP 4 /* v1 */
113 #define SNMP_PDU_GETBULK 5 /* v2 */
114 #define SNMP_PDU_INFORM 6 /* v2 */
115 #define SNMP_PDU_TRAP2 7 /* v2 */
116 #define SNMP_PDU_REPORT 8 /* v2 */
118 #define SNMP_ERR_NOERROR 0
119 #define SNMP_ERR_TOOBIG 1
120 #define SNMP_ERR_NOSUCHNAME 2 /* v1 */
121 #define SNMP_ERR_BADVALUE 3 /* v1 */
122 #define SNMP_ERR_READONLY 4 /* v1 */
123 #define SNMP_ERR_GENERR 5
124 #define SNMP_ERR_NO_ACCESS 6 /* v2 */
125 #define SNMP_ERR_WRONG_TYPE 7 /* v2 */
126 #define SNMP_ERR_WRONG_LENGTH 8 /* v2 */
127 #define SNMP_ERR_WRONG_ENCODING 9 /* v2 */
128 #define SNMP_ERR_WRONG_VALUE 10 /* v2 */
129 #define SNMP_ERR_NO_CREATION 11 /* v2 */
130 #define SNMP_ERR_INCONS_VALUE 12 /* v2 */
131 #define SNMP_ERR_RES_UNAVAIL 13 /* v2 */
132 #define SNMP_ERR_COMMIT_FAILED 14 /* v2 */
133 #define SNMP_ERR_UNDO_FAILED 15 /* v2 */
134 #define SNMP_ERR_AUTH_ERR 16 /* v2 */
135 #define SNMP_ERR_NOT_WRITEABLE 17 /* v2 */
136 #define SNMP_ERR_INCONS_NAME 18 /* v2 */
138 #define SNMP_TRAP_COLDSTART 0
139 #define SNMP_TRAP_WARMSTART 1
140 #define SNMP_TRAP_LINKDOWN 2
141 #define SNMP_TRAP_LINKUP 3
142 #define SNMP_TRAP_AUTHENTICATION_FAILURE 4
143 #define SNMP_TRAP_EGP_NEIGHBOR_LOSS 5
144 #define SNMP_TRAP_ENTERPRISE 6
155 void snmp_value_free(struct snmp_value *);
156 int snmp_value_parse(const char *, enum snmp_syntax, union snmp_values *);
157 int snmp_value_copy(struct snmp_value *, const struct snmp_value *);
159 void snmp_pdu_free(struct snmp_pdu *);
160 enum snmp_code snmp_pdu_decode(struct asn_buf *b, struct snmp_pdu *pdu, int32_t *);
161 enum snmp_code snmp_pdu_encode(struct snmp_pdu *pdu, struct asn_buf *resp_b);
163 int snmp_pdu_snoop(const struct asn_buf *);
165 void snmp_pdu_dump(const struct snmp_pdu *pdu);
167 extern void (*snmp_error)(const char *, ...);
168 extern void (*snmp_printf)(const char *, ...);
170 #define TRUTH_MK(F) ((F) ? 1 : 2)
171 #define TRUTH_GET(T) (((T) == 1) ? 1 : 0)
172 #define TRUTH_OK(T) ((T) == 1 || (T) == 2)