1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// ./lib/current/include/snmp_impl.h
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
//==========================================================================
|
7 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
8 |
|
|
// -------------------------------------------
|
9 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
10 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
11 |
|
|
//
|
12 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
13 |
|
|
// the terms of the GNU General Public License as published by the Free
|
14 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
15 |
|
|
//
|
16 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
17 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
18 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
19 |
|
|
// for more details.
|
20 |
|
|
//
|
21 |
|
|
// You should have received a copy of the GNU General Public License along
|
22 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
23 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
24 |
|
|
//
|
25 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
26 |
|
|
// or inline functions from this file, or you compile this file and link it
|
27 |
|
|
// with other works to produce a work based on this file, this file does not
|
28 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
29 |
|
|
// License. However the source code for this file must still be made available
|
30 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
31 |
|
|
//
|
32 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
33 |
|
|
// this file might be covered by the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
36 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//####UCDSNMPCOPYRIGHTBEGIN####
|
40 |
|
|
//
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//
|
43 |
|
|
// Portions of this software may have been derived from the UCD-SNMP
|
44 |
|
|
// project, <http://ucd-snmp.ucdavis.edu/> from the University of
|
45 |
|
|
// California at Davis, which was originally based on the Carnegie Mellon
|
46 |
|
|
// University SNMP implementation. Portions of this software are therefore
|
47 |
|
|
// covered by the appropriate copyright disclaimers included herein.
|
48 |
|
|
//
|
49 |
|
|
// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
|
50 |
|
|
// -------------------------------------------
|
51 |
|
|
//
|
52 |
|
|
//####UCDSNMPCOPYRIGHTEND####
|
53 |
|
|
//==========================================================================
|
54 |
|
|
//#####DESCRIPTIONBEGIN####
|
55 |
|
|
//
|
56 |
|
|
// Author(s): hmt
|
57 |
|
|
// Contributors: hmt
|
58 |
|
|
// Date: 2000-05-30
|
59 |
|
|
// Purpose: Port of UCD-SNMP distribution to eCos.
|
60 |
|
|
// Description:
|
61 |
|
|
//
|
62 |
|
|
//
|
63 |
|
|
//####DESCRIPTIONEND####
|
64 |
|
|
//
|
65 |
|
|
//==========================================================================
|
66 |
|
|
/********************************************************************
|
67 |
|
|
Copyright 1989, 1991, 1992 by Carnegie Mellon University
|
68 |
|
|
|
69 |
|
|
Derivative Work -
|
70 |
|
|
Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
|
71 |
|
|
|
72 |
|
|
All Rights Reserved
|
73 |
|
|
|
74 |
|
|
Permission to use, copy, modify and distribute this software and its
|
75 |
|
|
documentation for any purpose and without fee is hereby granted,
|
76 |
|
|
provided that the above copyright notice appears in all copies and
|
77 |
|
|
that both that copyright notice and this permission notice appear in
|
78 |
|
|
supporting documentation, and that the name of CMU and The Regents of
|
79 |
|
|
the University of California not be used in advertising or publicity
|
80 |
|
|
pertaining to distribution of the software without specific written
|
81 |
|
|
permission.
|
82 |
|
|
|
83 |
|
|
CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
|
84 |
|
|
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
|
85 |
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
|
86 |
|
|
THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
|
87 |
|
|
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
88 |
|
|
FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
89 |
|
|
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
90 |
|
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
91 |
|
|
*********************************************************************/
|
92 |
|
|
#ifndef SNMP_IMPL_H
|
93 |
|
|
#define SNMP_IMPL_H
|
94 |
|
|
|
95 |
|
|
#ifdef __cplusplus
|
96 |
|
|
extern "C" {
|
97 |
|
|
#endif
|
98 |
|
|
/*
|
99 |
|
|
* file: snmp_impl.h
|
100 |
|
|
*/
|
101 |
|
|
|
102 |
|
|
/*
|
103 |
|
|
* Definitions for SNMP implementation.
|
104 |
|
|
*
|
105 |
|
|
*
|
106 |
|
|
*/
|
107 |
|
|
/***********************************************************
|
108 |
|
|
Copyright 1988, 1989 by Carnegie Mellon University
|
109 |
|
|
|
110 |
|
|
All Rights Reserved
|
111 |
|
|
|
112 |
|
|
Permission to use, copy, modify, and distribute this software and its
|
113 |
|
|
documentation for any purpose and without fee is hereby granted,
|
114 |
|
|
provided that the above copyright notice appear in all copies and that
|
115 |
|
|
both that copyright notice and this permission notice appear in
|
116 |
|
|
supporting documentation, and that the name of CMU not be
|
117 |
|
|
used in advertising or publicity pertaining to distribution of the
|
118 |
|
|
software without specific, written prior permission.
|
119 |
|
|
|
120 |
|
|
CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
121 |
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
122 |
|
|
CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
123 |
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
124 |
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
125 |
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
126 |
|
|
SOFTWARE.
|
127 |
|
|
******************************************************************/
|
128 |
|
|
|
129 |
|
|
#include<stdio.h>
|
130 |
|
|
|
131 |
|
|
#define COMMUNITY_MAX_LEN 256
|
132 |
|
|
|
133 |
|
|
/* Space for character representation of an object identifier */
|
134 |
|
|
#define SPRINT_MAX_LEN 2560
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
#ifndef NULL
|
138 |
|
|
#define NULL 0
|
139 |
|
|
#endif
|
140 |
|
|
|
141 |
|
|
#ifndef TRUE
|
142 |
|
|
#define TRUE 1
|
143 |
|
|
#endif
|
144 |
|
|
#ifndef FALSE
|
145 |
|
|
#define FALSE 0
|
146 |
|
|
#endif
|
147 |
|
|
|
148 |
|
|
#define READ 1
|
149 |
|
|
#define WRITE 0
|
150 |
|
|
|
151 |
|
|
#define RESERVE1 0
|
152 |
|
|
#define RESERVE2 1
|
153 |
|
|
#define ACTION 2
|
154 |
|
|
#define COMMIT 3
|
155 |
|
|
#define FREE 4
|
156 |
|
|
#define UNDO 5
|
157 |
|
|
#define FINISHED_SUCCESS 9
|
158 |
|
|
#define FINISHED_FAILURE 10
|
159 |
|
|
|
160 |
|
|
/* Access control statements for the agent */
|
161 |
|
|
#define RONLY 0x1 /* read access only */
|
162 |
|
|
#define RWRITE 0x2 /* read and write access (must have 0x2 bit set) */
|
163 |
|
|
|
164 |
|
|
#define NOACCESS 0x0000 /* no access for anybody */
|
165 |
|
|
|
166 |
|
|
/* defined types (from the SMI, RFC 1157) */
|
167 |
|
|
#define ASN_IPADDRESS (ASN_APPLICATION | 0)
|
168 |
|
|
#define ASN_COUNTER (ASN_APPLICATION | 1)
|
169 |
|
|
#define ASN_GAUGE (ASN_APPLICATION | 2)
|
170 |
|
|
#define ASN_UNSIGNED (ASN_APPLICATION | 2) /* RFC 1902 - same as GAUGE */
|
171 |
|
|
#define ASN_TIMETICKS (ASN_APPLICATION | 3)
|
172 |
|
|
#define ASN_OPAQUE (ASN_APPLICATION | 4) /* changed so no conflict with other includes */
|
173 |
|
|
|
174 |
|
|
/* defined types (from the SMI, RFC 1442) */
|
175 |
|
|
#define ASN_NSAP (ASN_APPLICATION | 5) /* historic - don't use */
|
176 |
|
|
#define ASN_COUNTER64 (ASN_APPLICATION | 6)
|
177 |
|
|
#define ASN_UINTEGER (ASN_APPLICATION | 7) /* historic - don't use */
|
178 |
|
|
|
179 |
|
|
#ifdef OPAQUE_SPECIAL_TYPES
|
180 |
|
|
/* defined types from draft-perkins-opaque-01.txt */
|
181 |
|
|
#define ASN_FLOAT (ASN_APPLICATION | 8)
|
182 |
|
|
#define ASN_DOUBLE (ASN_APPLICATION | 9)
|
183 |
|
|
#define ASN_INTEGER64 (ASN_APPLICATION | 10)
|
184 |
|
|
#define ASN_UNSIGNED64 (ASN_APPLICATION | 11)
|
185 |
|
|
#endif /* OPAQUE_SPECIAL_TYPES */
|
186 |
|
|
|
187 |
|
|
/* #define CMU_COMPATIBLE */
|
188 |
|
|
#ifdef CMU_COMPATIBLE
|
189 |
|
|
#define INTEGER ASN_INTEGER
|
190 |
|
|
#define STRING ASN_OCTET_STR
|
191 |
|
|
#define OBJID ASN_OBJECT_ID
|
192 |
|
|
#define NULLOBJ ASN_NULL
|
193 |
|
|
#define BITSTRING ASN_BIT_STR /* HISTORIC - don't use */
|
194 |
|
|
#define IPADDRESS ASN_IPADDRESS
|
195 |
|
|
#define COUNTER ASN_COUNTER
|
196 |
|
|
#define GAUGE ASN_GAUGE
|
197 |
|
|
#define UNSIGNED ASN_UNSIGNED
|
198 |
|
|
#define TIMETICKS ASN_TIMETICKS
|
199 |
|
|
#define ASNT_OPAQUE ASN_OPAQUE
|
200 |
|
|
#define NSAP ASN_NSAP
|
201 |
|
|
#define COUNTER64 ASN_COUNTER64
|
202 |
|
|
#define UINTEGER ASN_UINTEGER
|
203 |
|
|
#endif /* CMU_COMPATIBLE */
|
204 |
|
|
|
205 |
|
|
/* changed to ERROR_MSG to eliminate conflict with other includes */
|
206 |
|
|
#define ERROR_MSG(string) snmp_set_detail(string)
|
207 |
|
|
|
208 |
|
|
/* from snmp.c */
|
209 |
|
|
extern u_char sid[]; /* size SID_MAX_LEN */
|
210 |
|
|
extern int snmp_errno;
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
/*
|
214 |
|
|
* For calling secauth_build, FIRST_PASS is an indication that a new nonce
|
215 |
|
|
* and lastTimeStamp should be recorded. LAST_PASS is an indication that
|
216 |
|
|
* the packet should be checksummed and encrypted if applicable, in
|
217 |
|
|
* preparation for transmission.
|
218 |
|
|
* 0 means do neither, FIRST_PASS | LAST_PASS means do both.
|
219 |
|
|
* For secauth_parse, FIRST_PASS means decrypt the packet, otherwise leave it
|
220 |
|
|
* alone. LAST_PASS is ignored.
|
221 |
|
|
*/
|
222 |
|
|
#define FIRST_PASS 1
|
223 |
|
|
#define LAST_PASS 2
|
224 |
|
|
u_char *snmp_comstr_parse(u_char *, size_t *, u_char *, size_t *, long *);
|
225 |
|
|
u_char *snmp_comstr_build (u_char *, size_t *, u_char *, size_t *, long *, size_t);
|
226 |
|
|
|
227 |
|
|
int has_access (u_char, int, int, int);
|
228 |
|
|
#ifdef __cplusplus
|
229 |
|
|
}
|
230 |
|
|
#endif
|
231 |
|
|
|
232 |
|
|
#endif /* SNMP_IMPL_H */
|