4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
39 * SNMP PDU variable list
41 typedef struct pdu_varlist
{
42 struct pdu_varlist
*nextvar
;
44 size_t name_len
; /* number of subids in the name */
46 uint_t
*uiptr
; /* unused except while parsing */
51 size_t val_len
; /* in bytes even if val is objid */
56 * Essential snmp message/PDU fields
58 typedef struct snmp_pdu
{
64 int errstat
; /* shared with non-repeaters for GETBULK */
65 int errindex
; /* shared with max-repetitions for GETBULK */
68 uchar_t
*req_pkt
; /* not really part of PDU */
69 size_t req_pktsz
; /* not really part of PDU */
70 uchar_t
*reply_pkt
; /* not really part of PDU */
71 size_t reply_pktsz
; /* not really part of PDU */
73 #define non_repeaters errstat
74 #define max_repetitions errindex
77 * Supported SNMP versions
79 #define SNMP_VERSION_1 0
80 #define SNMP_VERSION_2c 1
83 * Community strings for supported PDUs
85 #define SNMP_DEF_COMMUNITY "public"
86 #define SNMP_DEF_COMMUNITY_LEN 6
89 * PDU types (not all are supported)
91 #define SNMP_MSG_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x0)
92 #define SNMP_MSG_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x1)
93 #define SNMP_MSG_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x2)
94 #define SNMP_MSG_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x3)
95 #define SNMP_MSG_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x4)
96 #define SNMP_MSG_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x5)
97 #define SNMP_MSG_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x6)
98 #define SNMP_MSG_TRAP2 (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x7)
99 #define SNMP_MSG_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x8)
102 * Exception values (not all are supported)
104 #define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | (uchar_t)0x0)
105 #define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | (uchar_t)0x1)
106 #define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | (uchar_t)0x2)
109 * Error codes (not all are supported)
111 #define SNMP_ERR_NOERROR (0)
112 #define SNMP_ERR_TOOBIG (1)
113 #define SNMP_ERR_NOSUCHNAME (2)
114 #define SNMP_ERR_BADVALUE (3)
115 #define SNMP_ERR_READONLY (4)
116 #define SNMP_ERR_GENERR (5)
117 #define SNMP_ERR_NOACCESS (6)
118 #define SNMP_ERR_WRONGTYPE (7)
119 #define SNMP_ERR_WRONGLENGTH (8)
120 #define SNMP_ERR_WRONGENCODING (9)
121 #define SNMP_ERR_WRONGVALUE (10)
122 #define SNMP_ERR_NOCREATION (11)
123 #define SNMP_ERR_INCONSISTENTVALUE (12)
124 #define SNMP_ERR_RESOURCEUNAVAILABLE (13)
125 #define SNMP_ERR_COMMITFAILED (14)
126 #define SNMP_ERR_UNDOFAILED (15)
127 #define SNMP_ERR_AUTHORIZATIONERROR (16)
128 #define SNMP_ERR_NOTWRITABLE (17)
129 #define SNMP_ERR_INCONSISTENTNAME (18)
134 #define SNMP_DEF_NON_REPEATERS 0
135 #define SNMP_DEF_MAX_REPETITIONS 25
136 #define SNMP_DEF_PKTBUF_SZ 2048
137 #define SNMP_PKTBUF_BLKSZ 1024
138 #define SNMP_MAX_ERR 18
139 #define MIN_SUBIDS_IN_OID 2
140 #define MAX_SUBIDS_IN_OID 128
143 * Exported interfaces used by other parts of snmplib
145 snmp_pdu_t
*snmp_create_pdu(int, int, char *, int, int);
146 int snmp_make_packet(snmp_pdu_t
*);
147 snmp_pdu_t
*snmp_parse_reply(int, uchar_t
*, size_t);
148 void snmp_free_pdu(snmp_pdu_t
*);
151 * Imported from elsewhere
153 int snmp_get_reqid(void);