1 //==========================================================================
3 // ./lib/current/include/vacm.h
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.
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.
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
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.
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.
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.
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####
41 // -------------------------------------------
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.
49 // The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
50 // -------------------------------------------
52 //####UCDSNMPCOPYRIGHTEND####
53 //==========================================================================
54 //#####DESCRIPTIONBEGIN####
59 // Purpose: Port of UCD-SNMP distribution to eCos.
63 //####DESCRIPTIONEND####
65 //==========================================================================
66 /********************************************************************
67 Copyright 1989, 1991, 1992 by Carnegie Mellon University
70 Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
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
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 *********************************************************************/
95 * SNMPv3 View-based Access Control Model
105 #define SECURITYMODEL 1
106 #define SECURITYNAME 2
107 #define SECURITYGROUP 3
108 #define SECURITYSTORAGE 4
109 #define SECURITYSTATUS 5
111 #define ACCESSPREFIX 1
112 #define ACCESSMODEL 2
113 #define ACCESSLEVEL 3
114 #define ACCESSMATCH 4
116 #define ACCESSWRITE 6
117 #define ACCESSNOTIFY 7
118 #define ACCESSSTORAGE 8
119 #define ACCESSSTATUS 9
122 #define VIEWSUBTREE 2
125 #define VIEWSTORAGE 5
128 #define VACM_MAX_STRING 32
129 #define VACMSTRINGLEN 34 /* VACM_MAX_STRING + 2 */
131 struct vacm_securityEntry {
132 char securityName[VACMSTRINGLEN];
133 snmp_ipaddr sourceIp;
134 snmp_ipaddr sourceMask;
135 char community[VACMSTRINGLEN];
136 struct vacm_securityEntry *next;
139 struct vacm_groupEntry {
141 char securityName[VACMSTRINGLEN];
142 char groupName[VACMSTRINGLEN];
147 struct vacm_groupEntry *reserved;
148 struct vacm_groupEntry *next;
151 struct vacm_accessEntry {
152 char groupName[VACMSTRINGLEN];
153 char contextPrefix[VACMSTRINGLEN];
157 char readView[VACMSTRINGLEN];
158 char writeView[VACMSTRINGLEN];
159 char notifyView[VACMSTRINGLEN];
164 struct vacm_accessEntry *reserved;
165 struct vacm_accessEntry *next;
168 struct vacm_viewEntry {
169 char viewName[VACMSTRINGLEN];
170 oid viewSubtree[MAX_OID_LEN];
171 size_t viewSubtreeLen;
172 u_char viewMask[VACMSTRINGLEN];
180 struct vacm_viewEntry *reserved;
181 struct vacm_viewEntry *next;
184 void vacm_destroyViewEntry (const char *, oid *, size_t);
185 void vacm_destroyAllViewEntries (void);
187 struct vacm_viewEntry *
188 vacm_getViewEntry (const char *, oid *, size_t);
190 * Returns a pointer to the viewEntry with the
191 * same viewName and viewSubtree
192 * Returns NULL if that entry does not exist.
196 vacm_scanViewInit (void);
198 * Initialized the scan routines so that they will begin at the
199 * beginning of the list of viewEntries.
204 struct vacm_viewEntry *
205 vacm_scanViewNext (void);
207 * Returns a pointer to the next viewEntry.
208 * These entries are returned in no particular order,
209 * but if N entries exist, N calls to view_scanNext() will
210 * return all N entries once.
211 * Returns NULL if all entries have been returned.
212 * view_scanInit() starts the scan over.
215 struct vacm_viewEntry *
216 vacm_createViewEntry (const char *, oid *, size_t);
218 * Creates a viewEntry with the given index
219 * and returns a pointer to it.
220 * The status of this entry is created as invalid.
223 void vacm_destroyGroupEntry (int, const char *);
224 void vacm_destroyAllGroupEntries (void);
225 struct vacm_groupEntry *vacm_createGroupEntry (int, const char *);
226 struct vacm_groupEntry *vacm_getGroupEntry (int, const char *);
227 void vacm_scanGroupInit (void);
228 struct vacm_groupEntry *vacm_scanGroupNext (void);
230 void vacm_destroyAccessEntry (const char *, const char *, int, int);
231 void vacm_destroyAllAccessEntries (void);
232 struct vacm_accessEntry *vacm_createAccessEntry (const char *, const char *, int, int);
233 struct vacm_accessEntry *vacm_getAccessEntry (const char *, const char *, int, int);
234 void vacm_scanAccessInit (void);
235 struct vacm_accessEntry *vacm_scanAccessNext (void);
237 void vacm_destroySecurityEntry (const char *);
238 struct vacm_securityEntry *vacm_createSecurityEntry (const char *);
239 struct vacm_securityEntry *vacm_getSecurityEntry (const char *);
240 void vacm_scanSecurityInit (void);
241 struct vacm_securityEntry *vacm_scanSecurityEntry (void);
242 int vacm_is_configured(void);