1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// ./lib/current/include/vacm.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 Free Software Foundation, 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
|
15 |
|
|
// version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
18 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License
|
23 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use
|
27 |
|
|
// macros or inline functions from this file, or you compile this file
|
28 |
|
|
// and link it with other works to produce a work based on this file,
|
29 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
30 |
|
|
// the GNU General Public License. However the source code for this file
|
31 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
32 |
|
|
// General Public License v2.
|
33 |
|
|
//
|
34 |
|
|
// This exception does not invalidate any other reasons why a work based
|
35 |
|
|
// on this file might be covered by the GNU General Public License.
|
36 |
|
|
// -------------------------------------------
|
37 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
38 |
|
|
//####UCDSNMPCOPYRIGHTBEGIN####
|
39 |
|
|
//
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
//
|
42 |
|
|
// Portions of this software may have been derived from the UCD-SNMP
|
43 |
|
|
// project, <http://ucd-snmp.ucdavis.edu/> from the University of
|
44 |
|
|
// California at Davis, which was originally based on the Carnegie Mellon
|
45 |
|
|
// University SNMP implementation. Portions of this software are therefore
|
46 |
|
|
// covered by the appropriate copyright disclaimers included herein.
|
47 |
|
|
//
|
48 |
|
|
// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
|
49 |
|
|
// -------------------------------------------
|
50 |
|
|
//
|
51 |
|
|
//####UCDSNMPCOPYRIGHTEND####
|
52 |
|
|
//==========================================================================
|
53 |
|
|
//#####DESCRIPTIONBEGIN####
|
54 |
|
|
//
|
55 |
|
|
// Author(s): hmt
|
56 |
|
|
// Contributors: hmt
|
57 |
|
|
// Date: 2000-05-30
|
58 |
|
|
// Purpose: Port of UCD-SNMP distribution to eCos.
|
59 |
|
|
// Description:
|
60 |
|
|
//
|
61 |
|
|
//
|
62 |
|
|
//####DESCRIPTIONEND####
|
63 |
|
|
//
|
64 |
|
|
//==========================================================================
|
65 |
|
|
/********************************************************************
|
66 |
|
|
Copyright 1989, 1991, 1992 by Carnegie Mellon University
|
67 |
|
|
|
68 |
|
|
Derivative Work -
|
69 |
|
|
Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
|
70 |
|
|
|
71 |
|
|
All Rights Reserved
|
72 |
|
|
|
73 |
|
|
Permission to use, copy, modify and distribute this software and its
|
74 |
|
|
documentation for any purpose and without fee is hereby granted,
|
75 |
|
|
provided that the above copyright notice appears in all copies and
|
76 |
|
|
that both that copyright notice and this permission notice appear in
|
77 |
|
|
supporting documentation, and that the name of CMU and The Regents of
|
78 |
|
|
the University of California not be used in advertising or publicity
|
79 |
|
|
pertaining to distribution of the software without specific written
|
80 |
|
|
permission.
|
81 |
|
|
|
82 |
|
|
CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
|
83 |
|
|
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
|
84 |
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
|
85 |
|
|
THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
|
86 |
|
|
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
87 |
|
|
FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
88 |
|
|
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
89 |
|
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
90 |
|
|
*********************************************************************/
|
91 |
|
|
/*
|
92 |
|
|
* vacm.h
|
93 |
|
|
*
|
94 |
|
|
* SNMPv3 View-based Access Control Model
|
95 |
|
|
*/
|
96 |
|
|
|
97 |
|
|
#ifndef VACM_H
|
98 |
|
|
#define VACM_H
|
99 |
|
|
|
100 |
|
|
#ifdef __cplusplus
|
101 |
|
|
extern "C" {
|
102 |
|
|
#endif
|
103 |
|
|
|
104 |
|
|
#define SECURITYMODEL 1
|
105 |
|
|
#define SECURITYNAME 2
|
106 |
|
|
#define SECURITYGROUP 3
|
107 |
|
|
#define SECURITYSTORAGE 4
|
108 |
|
|
#define SECURITYSTATUS 5
|
109 |
|
|
|
110 |
|
|
#define ACCESSPREFIX 1
|
111 |
|
|
#define ACCESSMODEL 2
|
112 |
|
|
#define ACCESSLEVEL 3
|
113 |
|
|
#define ACCESSMATCH 4
|
114 |
|
|
#define ACCESSREAD 5
|
115 |
|
|
#define ACCESSWRITE 6
|
116 |
|
|
#define ACCESSNOTIFY 7
|
117 |
|
|
#define ACCESSSTORAGE 8
|
118 |
|
|
#define ACCESSSTATUS 9
|
119 |
|
|
|
120 |
|
|
#define VIEWNAME 1
|
121 |
|
|
#define VIEWSUBTREE 2
|
122 |
|
|
#define VIEWMASK 3
|
123 |
|
|
#define VIEWTYPE 4
|
124 |
|
|
#define VIEWSTORAGE 5
|
125 |
|
|
#define VIEWSTATUS 6
|
126 |
|
|
|
127 |
|
|
#define VACM_MAX_STRING 32
|
128 |
|
|
#define VACMSTRINGLEN 34 /* VACM_MAX_STRING + 2 */
|
129 |
|
|
|
130 |
|
|
struct vacm_securityEntry {
|
131 |
|
|
char securityName[VACMSTRINGLEN];
|
132 |
|
|
snmp_ipaddr sourceIp;
|
133 |
|
|
snmp_ipaddr sourceMask;
|
134 |
|
|
char community[VACMSTRINGLEN];
|
135 |
|
|
struct vacm_securityEntry *next;
|
136 |
|
|
};
|
137 |
|
|
|
138 |
|
|
struct vacm_groupEntry {
|
139 |
|
|
int securityModel;
|
140 |
|
|
char securityName[VACMSTRINGLEN];
|
141 |
|
|
char groupName[VACMSTRINGLEN];
|
142 |
|
|
int storageType;
|
143 |
|
|
int status;
|
144 |
|
|
|
145 |
|
|
u_long bitMask;
|
146 |
|
|
struct vacm_groupEntry *reserved;
|
147 |
|
|
struct vacm_groupEntry *next;
|
148 |
|
|
};
|
149 |
|
|
|
150 |
|
|
struct vacm_accessEntry {
|
151 |
|
|
char groupName[VACMSTRINGLEN];
|
152 |
|
|
char contextPrefix[VACMSTRINGLEN];
|
153 |
|
|
int securityModel;
|
154 |
|
|
int securityLevel;
|
155 |
|
|
int contextMatch;
|
156 |
|
|
char readView[VACMSTRINGLEN];
|
157 |
|
|
char writeView[VACMSTRINGLEN];
|
158 |
|
|
char notifyView[VACMSTRINGLEN];
|
159 |
|
|
int storageType;
|
160 |
|
|
int status;
|
161 |
|
|
|
162 |
|
|
u_long bitMask;
|
163 |
|
|
struct vacm_accessEntry *reserved;
|
164 |
|
|
struct vacm_accessEntry *next;
|
165 |
|
|
};
|
166 |
|
|
|
167 |
|
|
struct vacm_viewEntry {
|
168 |
|
|
char viewName[VACMSTRINGLEN];
|
169 |
|
|
oid viewSubtree[MAX_OID_LEN];
|
170 |
|
|
size_t viewSubtreeLen;
|
171 |
|
|
u_char viewMask[VACMSTRINGLEN];
|
172 |
|
|
size_t viewMaskLen;
|
173 |
|
|
int viewType;
|
174 |
|
|
int viewStorageType;
|
175 |
|
|
int viewStatus;
|
176 |
|
|
|
177 |
|
|
u_long bitMask;
|
178 |
|
|
|
179 |
|
|
struct vacm_viewEntry *reserved;
|
180 |
|
|
struct vacm_viewEntry *next;
|
181 |
|
|
};
|
182 |
|
|
|
183 |
|
|
void vacm_destroyViewEntry (const char *, oid *, size_t);
|
184 |
|
|
void vacm_destroyAllViewEntries (void);
|
185 |
|
|
|
186 |
|
|
struct vacm_viewEntry *
|
187 |
|
|
vacm_getViewEntry (const char *, oid *, size_t);
|
188 |
|
|
/*
|
189 |
|
|
* Returns a pointer to the viewEntry with the
|
190 |
|
|
* same viewName and viewSubtree
|
191 |
|
|
* Returns NULL if that entry does not exist.
|
192 |
|
|
*/
|
193 |
|
|
|
194 |
|
|
void
|
195 |
|
|
vacm_scanViewInit (void);
|
196 |
|
|
/*
|
197 |
|
|
* Initialized the scan routines so that they will begin at the
|
198 |
|
|
* beginning of the list of viewEntries.
|
199 |
|
|
*
|
200 |
|
|
*/
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
struct vacm_viewEntry *
|
204 |
|
|
vacm_scanViewNext (void);
|
205 |
|
|
/*
|
206 |
|
|
* Returns a pointer to the next viewEntry.
|
207 |
|
|
* These entries are returned in no particular order,
|
208 |
|
|
* but if N entries exist, N calls to view_scanNext() will
|
209 |
|
|
* return all N entries once.
|
210 |
|
|
* Returns NULL if all entries have been returned.
|
211 |
|
|
* view_scanInit() starts the scan over.
|
212 |
|
|
*/
|
213 |
|
|
|
214 |
|
|
struct vacm_viewEntry *
|
215 |
|
|
vacm_createViewEntry (const char *, oid *, size_t);
|
216 |
|
|
/*
|
217 |
|
|
* Creates a viewEntry with the given index
|
218 |
|
|
* and returns a pointer to it.
|
219 |
|
|
* The status of this entry is created as invalid.
|
220 |
|
|
*/
|
221 |
|
|
|
222 |
|
|
void vacm_destroyGroupEntry (int, const char *);
|
223 |
|
|
void vacm_destroyAllGroupEntries (void);
|
224 |
|
|
struct vacm_groupEntry *vacm_createGroupEntry (int, const char *);
|
225 |
|
|
struct vacm_groupEntry *vacm_getGroupEntry (int, const char *);
|
226 |
|
|
void vacm_scanGroupInit (void);
|
227 |
|
|
struct vacm_groupEntry *vacm_scanGroupNext (void);
|
228 |
|
|
|
229 |
|
|
void vacm_destroyAccessEntry (const char *, const char *, int, int);
|
230 |
|
|
void vacm_destroyAllAccessEntries (void);
|
231 |
|
|
struct vacm_accessEntry *vacm_createAccessEntry (const char *, const char *, int, int);
|
232 |
|
|
struct vacm_accessEntry *vacm_getAccessEntry (const char *, const char *, int, int);
|
233 |
|
|
void vacm_scanAccessInit (void);
|
234 |
|
|
struct vacm_accessEntry *vacm_scanAccessNext (void);
|
235 |
|
|
|
236 |
|
|
void vacm_destroySecurityEntry (const char *);
|
237 |
|
|
struct vacm_securityEntry *vacm_createSecurityEntry (const char *);
|
238 |
|
|
struct vacm_securityEntry *vacm_getSecurityEntry (const char *);
|
239 |
|
|
void vacm_scanSecurityInit (void);
|
240 |
|
|
struct vacm_securityEntry *vacm_scanSecurityEntry (void);
|
241 |
|
|
int vacm_is_configured(void);
|
242 |
|
|
|
243 |
|
|
#ifdef __cplusplus
|
244 |
|
|
}
|
245 |
|
|
#endif
|
246 |
|
|
|
247 |
|
|
#endif /* VACM_H */
|