OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [snmp/] [lib/] [v2_0/] [include/] [snmpusm.h] - Blame information for rev 617

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      ./lib/current/include/snmpusm.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
/*
93
 * snmpusm.h
94
 *
95
 * Header file for USM support.
96
 */
97
 
98
#ifndef SNMPUSM_H
99
#define SNMPUSM_H
100
 
101
#ifdef __cplusplus
102
extern "C" {
103
#endif
104
 
105
#define WILDCARDSTRING "*"
106
 
107
/*
108
 * General.
109
 */
110
#define USM_MAX_ID_LENGTH               1024            /* In bytes. */
111
#define USM_MAX_SALT_LENGTH             64              /* In BITS. */
112
#define USM_MAX_KEYEDHASH_LENGTH        128             /* In BITS. */
113
 
114
#define USM_TIME_WINDOW                 150
115
 
116
 
117
/*
118
 * Structures.
119
 */
120
struct usmStateReference {
121
        char            *usr_name;
122
        size_t           usr_name_length;
123
        u_char          *usr_engine_id;
124
        size_t           usr_engine_id_length;
125
        oid             *usr_auth_protocol;
126
        size_t           usr_auth_protocol_length;
127
        u_char          *usr_auth_key;
128
        size_t           usr_auth_key_length;
129
        oid             *usr_priv_protocol;
130
        size_t           usr_priv_protocol_length;
131
        u_char          *usr_priv_key;
132
        size_t           usr_priv_key_length;
133
        u_int            usr_sec_level;
134
};
135
 
136
 
137
/* struct usmUser: a structure to represent a given user in a list */
138
/* Note: Any changes made to this structure need to be reflected in
139
   the following functions: */
140
 
141
struct usmUser;
142
struct usmUser {
143
   u_char         *engineID;
144
   size_t          engineIDLen;
145
   char           *name;
146
   char           *secName;
147
   oid            *cloneFrom;
148
   size_t          cloneFromLen;
149
   oid            *authProtocol;
150
   size_t          authProtocolLen;
151
   u_char         *authKey;
152
   size_t          authKeyLen;
153
   oid            *privProtocol;
154
   size_t          privProtocolLen;
155
   u_char         *privKey;
156
   size_t          privKeyLen;
157
   u_char         *userPublicString;
158
   int             userStatus;
159
   int             userStorageType;
160
   struct usmUser *next;
161
   struct usmUser *prev;
162
};
163
 
164
 
165
 
166
/*
167
 * Prototypes.
168
 */
169
void    usm_set_reportErrorOnUnknownID (int value);
170
 
171
struct usmStateReference *
172
        usm_malloc_usmStateReference (void);
173
 
174
void    usm_free_usmStateReference (void *old);
175
 
176
int     usm_set_usmStateReference_name (
177
                struct usmStateReference        *ref,
178
                char                            *name,
179
                size_t                           name_len);
180
 
181
int     usm_set_usmStateReference_engine_id (
182
                struct usmStateReference        *ref,
183
                u_char                          *engine_id,
184
                size_t                           engine_id_len);
185
 
186
int     usm_set_usmStateReference_auth_protocol (
187
                struct usmStateReference *ref,
188
                oid *auth_protocol,
189
                size_t auth_protocol_len);
190
 
191
int     usm_set_usmStateReference_auth_key (
192
                struct usmStateReference *ref,
193
                u_char *auth_key,
194
                size_t auth_key_len);
195
 
196
int     usm_set_usmStateReference_priv_protocol (
197
                struct usmStateReference *ref,
198
                oid *priv_protocol,
199
                size_t priv_protocol_len);
200
 
201
int     usm_set_usmStateReference_priv_key (
202
                struct usmStateReference *ref,
203
                u_char *priv_key,
204
                size_t priv_key_len);
205
 
206
int     usm_set_usmStateReference_sec_level (
207
                struct usmStateReference *ref,
208
                int sec_level);
209
 
210
#ifdef SNMP_TESTING_CODE
211
void    emergency_print (u_char *field, u_int length);
212
#endif
213
 
214
int     asn_predict_int_length (int type, long number, size_t len);
215
 
216
int     asn_predict_length (int type, u_char *ptr, size_t u_char_len);
217
 
218
int     usm_set_salt (
219
                u_char          *iv,
220
                size_t          *iv_length,
221
                u_char          *priv_salt,
222
                size_t           priv_salt_length,
223
                u_char          *msgSalt );
224
 
225
int     usm_parse_security_parameters (
226
                u_char  *secParams,
227
                size_t   remaining,
228
                u_char  *secEngineID,
229
                size_t  *secEngineIDLen,
230
                u_int   *boots_uint,
231
                u_int   *time_uint,
232
                char    *secName,
233
                size_t  *secNameLen,
234
                u_char  *signature,
235
                size_t  *signature_length,
236
                u_char  *salt,
237
                size_t  *salt_length,
238
                u_char **data_ptr);
239
 
240
int     usm_check_and_update_timeliness (
241
                u_char *secEngineID,
242
                size_t  secEngineIDLen,
243
                u_int   boots_uint,
244
                u_int   time_uint,
245
                int    *error);
246
 
247
int usm_generate_out_msg (int, u_char *, size_t, int, int, u_char *, size_t,
248
                              char *,  size_t, int, u_char *, size_t, void *,
249
                              u_char *, size_t *, u_char **, size_t *);
250
 
251
int usm_process_in_msg (int, size_t, u_char *, int, int, u_char *, size_t,
252
                            u_char *, size_t *, char *, size_t *, u_char **, size_t *,
253
                            size_t *, void **);
254
 
255
int             usm_check_secLevel(int level, struct usmUser *user);
256
void            usm_update_engine_time(void);
257
struct usmUser *usm_get_userList(void);
258
struct usmUser *usm_get_user(u_char *engineID, size_t engineIDLen, char *name);
259
struct usmUser *usm_get_user_from_list(u_char *engineID, size_t engineIDLen,
260
                                       char *name, struct usmUser *userList,
261
                                       int use_default);
262
struct usmUser *usm_add_user(struct usmUser *user);
263
struct usmUser *usm_add_user_to_list(struct usmUser *user,
264
                                     struct usmUser *userList);
265
struct usmUser *usm_free_user(struct usmUser *user);
266
struct usmUser *usm_create_user(void);
267
struct usmUser *usm_create_initial_user(const char *name,
268
                                     oid *authProtocol, size_t authProtocolLen,
269
                                     oid *privProtocol, size_t privProtocolLen);
270
struct usmUser *usm_cloneFrom_user(struct usmUser *from, struct usmUser *to);
271
struct usmUser *usm_remove_user(struct usmUser *user);
272
struct usmUser *usm_remove_user_from_list(struct usmUser *user,
273
                                          struct usmUser **userList);
274
char           *get_objid(char *line, oid **optr, size_t *len);
275
void            usm_save_users(const char *token, const char *type);
276
void            usm_save_users_from_list(struct usmUser *user, const char *token,
277
                                        const char *type);
278
void            usm_save_user(struct usmUser *user, const char *token, const char *type);
279
SNMPCallback    usm_store_users;
280
struct usmUser *usm_read_user(char *line);
281
void            usm_parse_config_usmUser(const char *token, char *line);
282
 
283
void            usm_set_password(const char *token, char *line);
284
void            usm_set_user_password(struct usmUser *user, const char *token,
285
                                      char *line);
286
void            init_usm(void);
287
int             init_usm_post_config(int majorid, int minorid, void *serverarg,
288
                                     void *clientarg);
289
 
290
#ifdef __cplusplus
291
}
292
#endif
293
 
294
#endif /* SNMPUSM_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.