blob: e0de368bbc5f3ce7a7a2b59e9138ec57a3f5268e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _PDU_H
#define _PDU_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
typedef uint_t oid;
/*
* SNMP PDU variable list
*/
typedef struct pdu_varlist {
struct pdu_varlist *nextvar;
oid *name;
size_t name_len; /* number of subids in the name */
union {
uint_t *uiptr; /* unused except while parsing */
int *iptr;
uchar_t *str;
oid *objid;
} val;
size_t val_len; /* in bytes even if val is objid */
uchar_t type;
} pdu_varlist_t;
/*
* Essential snmp message/PDU fields
*/
typedef struct snmp_pdu {
int version;
uchar_t *community;
size_t community_len;
int command;
int reqid;
int errstat; /* shared with non-repeaters for GETBULK */
int errindex; /* shared with max-repetitions for GETBULK */
pdu_varlist_t *vars;
uchar_t *req_pkt; /* not really part of PDU */
size_t req_pktsz; /* not really part of PDU */
uchar_t *reply_pkt; /* not really part of PDU */
size_t reply_pktsz; /* not really part of PDU */
} snmp_pdu_t;
#define non_repeaters errstat
#define max_repetitions errindex
/*
* Supported SNMP versions
*/
#define SNMP_VERSION_1 0
#define SNMP_VERSION_2c 1
/*
* Community strings for supported PDUs
*/
#define SNMP_DEF_COMMUNITY "public"
#define SNMP_DEF_COMMUNITY_LEN 6
/*
* PDU types (not all are supported)
*/
#define SNMP_MSG_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x0)
#define SNMP_MSG_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x1)
#define SNMP_MSG_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x2)
#define SNMP_MSG_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x3)
#define SNMP_MSG_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x4)
#define SNMP_MSG_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x5)
#define SNMP_MSG_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x6)
#define SNMP_MSG_TRAP2 (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x7)
#define SNMP_MSG_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | (uchar_t)0x8)
/*
* Exception values (not all are supported)
*/
#define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | (uchar_t)0x0)
#define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | (uchar_t)0x1)
#define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | (uchar_t)0x2)
/*
* Error codes (not all are supported)
*/
#define SNMP_ERR_NOERROR (0)
#define SNMP_ERR_TOOBIG (1)
#define SNMP_ERR_NOSUCHNAME (2)
#define SNMP_ERR_BADVALUE (3)
#define SNMP_ERR_READONLY (4)
#define SNMP_ERR_GENERR (5)
#define SNMP_ERR_NOACCESS (6)
#define SNMP_ERR_WRONGTYPE (7)
#define SNMP_ERR_WRONGLENGTH (8)
#define SNMP_ERR_WRONGENCODING (9)
#define SNMP_ERR_WRONGVALUE (10)
#define SNMP_ERR_NOCREATION (11)
#define SNMP_ERR_INCONSISTENTVALUE (12)
#define SNMP_ERR_RESOURCEUNAVAILABLE (13)
#define SNMP_ERR_COMMITFAILED (14)
#define SNMP_ERR_UNDOFAILED (15)
#define SNMP_ERR_AUTHORIZATIONERROR (16)
#define SNMP_ERR_NOTWRITABLE (17)
#define SNMP_ERR_INCONSISTENTNAME (18)
/*
* Default values
*/
#define SNMP_DEF_NON_REPEATERS 0
#define SNMP_DEF_MAX_REPETITIONS 25
#define SNMP_DEF_PKTBUF_SZ 2048
#define SNMP_PKTBUF_BLKSZ 1024
#define SNMP_MAX_ERR 18
#define MIN_SUBIDS_IN_OID 2
#define MAX_SUBIDS_IN_OID 128
/*
* Exported interfaces used by other parts of snmplib
*/
snmp_pdu_t *snmp_create_pdu(int, int, char *, int, int);
int snmp_make_packet(snmp_pdu_t *);
snmp_pdu_t *snmp_parse_reply(int, uchar_t *, size_t);
void snmp_free_pdu(snmp_pdu_t *);
/*
* Imported from elsewhere
*/
int snmp_get_reqid(void);
#ifdef __cplusplus
}
#endif
#endif /* _PDU_H */
|