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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [snmp/] [lib/] [current/] [include/] [snmpusm.h] - Blame information for rev 844

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
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 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
 * snmpusm.h
93
 *
94
 * Header file for USM support.
95
 */
96
 
97
#ifndef SNMPUSM_H
98
#define SNMPUSM_H
99
 
100
#ifdef __cplusplus
101
extern "C" {
102
#endif
103
 
104
#define WILDCARDSTRING "*"
105
 
106
/*
107
 * General.
108
 */
109
#define USM_MAX_ID_LENGTH               1024            /* In bytes. */
110
#define USM_MAX_SALT_LENGTH             64              /* In BITS. */
111
#define USM_MAX_KEYEDHASH_LENGTH        128             /* In BITS. */
112
 
113
#define USM_TIME_WINDOW                 150
114
#define USM_MD5_AND_SHA_AUTH_LEN        12      /* bytes */
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-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.