1
#line 2 "load_snmp_users_file.c"
3
#line 4 "load_snmp_users_file.c"
5
#define YY_INT_ALIGNED short int
7
/* A lexical scanner generated by flex */
10
#define YY_FLEX_MAJOR_VERSION 2
11
#define YY_FLEX_MINOR_VERSION 5
12
#define YY_FLEX_SUBMINOR_VERSION 31
13
#if YY_FLEX_SUBMINOR_VERSION > 0
17
/* First, we deal with platform-specific or compiler-specific issues. */
19
/* begin standard C headers. */
25
/* end standard C headers. */
27
/* flex integer type definitions */
32
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
34
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
36
typedef int8_t flex_int8_t;
37
typedef uint8_t flex_uint8_t;
38
typedef int16_t flex_int16_t;
39
typedef uint16_t flex_uint16_t;
40
typedef int32_t flex_int32_t;
41
typedef uint32_t flex_uint32_t;
43
typedef signed char flex_int8_t;
44
typedef short int flex_int16_t;
45
typedef int flex_int32_t;
46
typedef unsigned char flex_uint8_t;
47
typedef unsigned short int flex_uint16_t;
48
typedef unsigned int flex_uint32_t;
51
/* Limits of integral types. */
53
#define INT8_MIN (-128)
56
#define INT16_MIN (-32767-1)
59
#define INT32_MIN (-2147483647-1)
62
#define INT8_MAX (127)
65
#define INT16_MAX (32767)
68
#define INT32_MAX (2147483647)
71
#define UINT8_MAX (255U)
74
#define UINT16_MAX (65535U)
77
#define UINT32_MAX (4294967295U)
80
#endif /* ! FLEXINT_H */
84
/* The "const" storage-class-modifier is valid. */
87
#else /* ! __cplusplus */
94
#endif /* ! __cplusplus */
102
/* Returned upon end-of-file. */
105
/* Promotes a possibly negative, possibly signed char to an unsigned
106
* integer for use as an array index. If the signed char is negative,
107
* we want to instead treat it as an 8-bit unsigned char, hence the
110
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
112
/* Enter a start condition. This macro really ought to take a parameter,
113
* but we do it the disgusting crufty way forced on us by the ()-less
114
* definition of BEGIN.
116
#define BEGIN (yy_start) = 1 + 2 *
118
/* Translate the current start state into a value that can be later handed
119
* to BEGIN to return to the state. The YYSTATE alias is for lex
122
#define YY_START (((yy_start) - 1) / 2)
123
#define YYSTATE YY_START
125
/* Action number for EOF rule of a given start state. */
126
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
128
/* Special action meaning "start processing a new file". */
129
#define YY_NEW_FILE Snmp_UE_file_restart(Snmp_UE_file_in )
131
#define YY_END_OF_BUFFER_CHAR 0
133
/* Size of default input buffer. */
135
#define YY_BUF_SIZE 16384
138
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
139
#define YY_TYPEDEF_YY_BUFFER_STATE
140
typedef struct yy_buffer_state *YY_BUFFER_STATE;
143
extern int Snmp_UE_file_leng;
145
extern FILE *Snmp_UE_file_in, *Snmp_UE_file_out;
147
#define EOB_ACT_CONTINUE_SCAN 0
148
#define EOB_ACT_END_OF_FILE 1
149
#define EOB_ACT_LAST_MATCH 2
151
#define YY_LESS_LINENO(n)
153
/* Return all but the first "n" matched characters back to the input stream. */
157
/* Undo effects of setting up Snmp_UE_file_text. */ \
158
int yyless_macro_arg = (n); \
159
YY_LESS_LINENO(yyless_macro_arg);\
160
*yy_cp = (yy_hold_char); \
161
YY_RESTORE_YY_MORE_OFFSET \
162
(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
163
YY_DO_BEFORE_ACTION; /* set up Snmp_UE_file_text again */ \
167
#define unput(c) yyunput( c, (yytext_ptr) )
169
/* The following is because we cannot portably get our hands on size_t
170
* (without autoconf's help, which isn't available because we want
171
* flex-generated scanners to compile on their own).
174
#ifndef YY_TYPEDEF_YY_SIZE_T
175
#define YY_TYPEDEF_YY_SIZE_T
176
typedef unsigned int yy_size_t;
179
#ifndef YY_STRUCT_YY_BUFFER_STATE
180
#define YY_STRUCT_YY_BUFFER_STATE
181
struct yy_buffer_state
185
char *yy_ch_buf; /* input buffer */
186
char *yy_buf_pos; /* current position in input buffer */
188
/* Size of input buffer in bytes, not including room for EOB
191
yy_size_t yy_buf_size;
193
/* Number of characters read into yy_ch_buf, not including EOB
198
/* Whether we "own" the buffer - i.e., we know we created it,
199
* and can realloc() it to grow it, and should free() it to
202
int yy_is_our_buffer;
204
/* Whether this is an "interactive" input source; if so, and
205
* if we're using stdio for input, then we want to use getc()
206
* instead of fread(), to make sure we stop fetching input after
209
int yy_is_interactive;
211
/* Whether we're considered to be at the beginning of a line.
212
* If so, '^' rules will be active on the next match, otherwise
217
int yy_bs_lineno; /**< The line count. */
218
int yy_bs_column; /**< The column count. */
220
/* Whether to try to fill the input buffer when we reach the
225
int yy_buffer_status;
227
#define YY_BUFFER_NEW 0
228
#define YY_BUFFER_NORMAL 1
229
/* When an EOF's been seen but there's still some text to process
230
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
231
* shouldn't try reading from the input source any more. We might
232
* still have a bunch of tokens to match, though, because of
233
* possible backing-up.
235
* When we actually see the EOF, we change the status to "new"
236
* (via Snmp_UE_file_restart()), so that the user can continue scanning by
237
* just pointing Snmp_UE_file_in at a new input file.
239
#define YY_BUFFER_EOF_PENDING 2
242
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
244
/* Stack of input buffers. */
245
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
246
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
247
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
249
/* We provide macros for accessing buffer states in case in the
250
* future we want to put the buffer states in a more general
253
* Returns the top of the stack, or NULL.
255
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
256
? (yy_buffer_stack)[(yy_buffer_stack_top)] \
259
/* Same as previous macro, but useful when we know that the buffer stack is not
260
* NULL or when we need an lvalue. For internal use only.
262
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
264
/* yy_hold_char holds the character lost when Snmp_UE_file_text is formed. */
265
static char yy_hold_char;
266
static int yy_n_chars; /* number of characters read into yy_ch_buf */
267
int Snmp_UE_file_leng;
269
/* Points to current character in buffer. */
270
static char *yy_c_buf_p = (char *) 0;
271
static int yy_init = 1; /* whether we need to initialize */
272
static int yy_start = 0; /* start state number */
274
/* Flag which is used to allow Snmp_UE_file_wrap()'s to do buffer switches
275
* instead of setting up a fresh Snmp_UE_file_in. A bit of a hack ...
277
static int yy_did_buffer_switch_on_eof;
279
void Snmp_UE_file_restart (FILE *input_file );
280
void Snmp_UE_file__switch_to_buffer (YY_BUFFER_STATE new_buffer );
281
YY_BUFFER_STATE Snmp_UE_file__create_buffer (FILE *file,int size );
282
void Snmp_UE_file__delete_buffer (YY_BUFFER_STATE b );
283
void Snmp_UE_file__flush_buffer (YY_BUFFER_STATE b );
284
void Snmp_UE_file_push_buffer_state (YY_BUFFER_STATE new_buffer );
285
void Snmp_UE_file_pop_buffer_state (void );
287
static void Snmp_UE_file_ensure_buffer_stack (void );
288
static void Snmp_UE_file__load_buffer_state (void );
289
static void Snmp_UE_file__init_buffer (YY_BUFFER_STATE b,FILE *file );
291
#define YY_FLUSH_BUFFER Snmp_UE_file__flush_buffer(YY_CURRENT_BUFFER )
293
YY_BUFFER_STATE Snmp_UE_file__scan_buffer (char *base,yy_size_t size );
294
YY_BUFFER_STATE Snmp_UE_file__scan_string (yyconst char *yy_str );
295
YY_BUFFER_STATE Snmp_UE_file__scan_bytes (yyconst char *bytes,int len );
297
void *Snmp_UE_file_alloc (yy_size_t );
298
void *Snmp_UE_file_realloc (void *,yy_size_t );
299
void Snmp_UE_file_free (void * );
301
#define yy_new_buffer Snmp_UE_file__create_buffer
303
#define yy_set_interactive(is_interactive) \
305
if ( ! YY_CURRENT_BUFFER ){ \
306
Snmp_UE_file_ensure_buffer_stack (); \
307
YY_CURRENT_BUFFER_LVALUE = \
308
Snmp_UE_file__create_buffer(Snmp_UE_file_in,YY_BUF_SIZE ); \
310
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
313
#define yy_set_bol(at_bol) \
315
if ( ! YY_CURRENT_BUFFER ){\
316
Snmp_UE_file_ensure_buffer_stack (); \
317
YY_CURRENT_BUFFER_LVALUE = \
318
Snmp_UE_file__create_buffer(Snmp_UE_file_in,YY_BUF_SIZE ); \
320
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
323
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
325
/* Begin user sect3 */
327
#define Snmp_UE_file_wrap() 1
328
#define YY_SKIP_YYWRAP
330
typedef unsigned char YY_CHAR;
332
FILE *Snmp_UE_file_in = (FILE *) 0, *Snmp_UE_file_out = (FILE *) 0;
334
typedef int yy_state_type;
336
extern int Snmp_UE_file_lineno;
338
int Snmp_UE_file_lineno = 1;
340
extern char *Snmp_UE_file_text;
341
#define yytext_ptr Snmp_UE_file_text
343
static yy_state_type yy_get_previous_state (void );
344
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
345
static int yy_get_next_buffer (void );
346
static void yy_fatal_error (yyconst char msg[] );
348
/* Done after the current pattern has been matched and before the
349
* corresponding action - sets up Snmp_UE_file_text.
351
#define YY_DO_BEFORE_ACTION \
352
(yytext_ptr) = yy_bp; \
353
Snmp_UE_file_leng = (size_t) (yy_cp - yy_bp); \
354
(yy_hold_char) = *yy_cp; \
356
(yy_c_buf_p) = yy_cp;
358
#define YY_NUM_RULES 30
359
#define YY_END_OF_BUFFER 31
360
/* This struct is not used in this scanner,
361
but its presence is necessary. */
364
flex_int32_t yy_verify;
367
static yyconst flex_int16_t yy_accept[102] =
369
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
370
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
371
0, 0, 31, 30, 8, 8, 3, 8, 8, 8,
372
7, 6, 9, 12, 12, 11, 13, 16, 16, 15,
373
17, 20, 20, 19, 21, 22, 30, 29, 23, 28,
374
29, 29, 29, 29, 29, 1, 2, 1, 0, 0,
375
3, 0, 5, 0, 0, 4, 6, 9, 0, 10,
376
0, 11, 13, 0, 14, 0, 15, 17, 0, 18,
377
0, 19, 21, 22, 23, 28, 0, 0, 0, 0,
378
2, 5, 10, 14, 18, 27, 26, 24, 25, 25,
383
static yyconst flex_int32_t yy_ec[256] =
385
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
386
1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
387
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
388
1, 2, 1, 5, 6, 1, 1, 1, 1, 1,
389
1, 7, 1, 1, 1, 1, 1, 8, 9, 8,
390
8, 8, 10, 8, 8, 8, 8, 1, 1, 1,
391
1, 1, 1, 1, 12, 8, 8, 13, 14, 8,
392
1, 15, 1, 1, 1, 1, 16, 1, 1, 1,
393
1, 1, 17, 1, 1, 1, 1, 1, 1, 1,
394
1, 11, 1, 1, 1, 1, 12, 8, 8, 13,
396
14, 8, 1, 15, 1, 1, 1, 1, 16, 1,
397
1, 1, 1, 1, 17, 1, 1, 1, 1, 1,
398
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
399
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
401
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
404
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
411
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415
static yyconst flex_int32_t yy_meta[18] =
417
1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
421
static yyconst flex_int16_t yy_base[113] =
423
0, 0, 0, 0, 180, 179, 17, 0, 178, 177,
424
34, 0, 176, 175, 51, 0, 67, 70, 74, 0,
425
89, 91, 176, 183, 183, 94, 183, 172, 92, 171,
426
183, 0, 171, 183, 93, 0, 170, 183, 94, 0,
427
169, 183, 96, 0, 168, 183, 166, 183, 166, 183,
428
164, 152, 151, 151, 148, 183, 183, 159, 100, 158,
429
183, 103, 183, 104, 157, 183, 0, 157, 105, 183,
430
106, 0, 156, 107, 183, 108, 0, 155, 115, 183,
431
116, 0, 154, 183, 153, 183, 137, 136, 142, 139,
432
183, 117, 118, 119, 120, 183, 183, 183, 141, 183,
434
183, 131, 133, 135, 137, 147, 139, 146, 141, 145,
438
static yyconst flex_int16_t yy_def[113] =
440
102, 102, 101, 3, 102, 102, 101, 7, 102, 102,
441
101, 11, 102, 102, 101, 15, 102, 102, 101, 19,
442
103, 103, 101, 101, 101, 101, 101, 101, 104, 105,
443
101, 106, 101, 101, 107, 108, 101, 101, 109, 110,
444
101, 101, 111, 112, 101, 101, 101, 101, 101, 101,
445
101, 101, 101, 101, 101, 101, 101, 101, 101, 105,
446
101, 104, 101, 104, 105, 101, 106, 101, 107, 101,
447
107, 108, 101, 109, 101, 109, 110, 101, 111, 101,
448
111, 112, 101, 101, 101, 101, 101, 101, 101, 101,
449
101, 104, 107, 109, 111, 101, 101, 101, 101, 101,
451
0, 101, 101, 101, 101, 101, 101, 101, 101, 101,
455
static yyconst flex_int16_t yy_nxt[201] =
457
25, 26, 27, 28, 29, 30, 31, 32, 32, 32,
458
25, 32, 32, 32, 25, 25, 25, 34, 34, 24,
459
34, 35, 34, 34, 36, 36, 36, 34, 36, 36,
460
36, 34, 34, 34, 38, 38, 24, 38, 39, 38,
461
38, 40, 40, 40, 38, 40, 40, 40, 38, 38,
462
38, 42, 42, 24, 42, 43, 42, 42, 44, 44,
463
44, 42, 44, 44, 44, 42, 42, 42, 45, 46,
464
47, 45, 46, 47, 48, 49, 50, 51, 48, 48,
465
48, 48, 48, 48, 48, 52, 53, 48, 48, 54,
466
55, 57, 58, 57, 58, 59, 63, 70, 75, 60,
468
80, 59, 64, 71, 76, 60, 81, 63, 92, 70,
469
93, 75, 94, 64, 64, 71, 71, 76, 76, 80,
470
95, 63, 70, 75, 80, 81, 81, 64, 71, 76,
471
81, 24, 24, 56, 56, 62, 62, 65, 65, 69,
472
69, 74, 74, 79, 79, 82, 77, 72, 67, 100,
473
99, 98, 97, 96, 85, 83, 78, 73, 68, 66,
474
66, 91, 90, 89, 88, 87, 86, 85, 84, 83,
475
78, 73, 68, 66, 61, 101, 41, 41, 37, 37,
476
33, 33, 23, 101, 101, 101, 101, 101, 101, 101,
477
101, 101, 101, 101, 101, 101, 101, 101, 101, 101
481
static yyconst flex_int16_t yy_chk[201] =
483
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
484
3, 3, 3, 3, 3, 3, 3, 7, 7, 7,
485
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
486
7, 7, 7, 7, 11, 11, 11, 11, 11, 11,
487
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
488
11, 15, 15, 15, 15, 15, 15, 15, 15, 15,
489
15, 15, 15, 15, 15, 15, 15, 15, 17, 17,
490
17, 18, 18, 18, 19, 19, 19, 19, 19, 19,
491
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
492
19, 21, 21, 22, 22, 26, 29, 35, 39, 26,
494
43, 59, 29, 35, 39, 59, 43, 62, 64, 69,
495
71, 74, 76, 62, 64, 69, 71, 74, 76, 79,
496
81, 92, 93, 94, 95, 79, 81, 92, 93, 94,
497
95, 102, 102, 103, 103, 104, 104, 105, 105, 107,
498
107, 109, 109, 111, 111, 112, 110, 108, 106, 99,
499
90, 89, 88, 87, 85, 83, 78, 73, 68, 65,
500
60, 58, 55, 54, 53, 52, 51, 49, 47, 45,
501
41, 37, 33, 30, 28, 23, 14, 13, 10, 9,
502
6, 5, 101, 101, 101, 101, 101, 101, 101, 101,
503
101, 101, 101, 101, 101, 101, 101, 101, 101, 101
507
static yy_state_type yy_last_accepting_state;
508
static char *yy_last_accepting_cpos;
510
extern int Snmp_UE_file__flex_debug;
511
int Snmp_UE_file__flex_debug = 0;
513
/* The intent behind this definition is that it'll catch
514
* any uses of REJECT which flex missed.
516
#define REJECT reject_used_but_not_detected
517
#define yymore() yymore_used_but_not_detected
518
#define YY_MORE_ADJ 0
519
#define YY_RESTORE_YY_MORE_OFFSET
520
char *Snmp_UE_file_text;
521
#line 1 "./load_snmp_users_file.l"
522
#line 8 "./load_snmp_users_file.l"
524
* load_snmp_users_file.l
526
* User-based Security Model for SNMPv3
527
* SNMP user-engine association file parser
529
* Copyright 2007, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
531
* $Id: load_snmp_users_file.l 20393 2007-01-11 17:39:16Z lego $
533
* Wireshark - Network traffic analyzer
534
* By Gerald Combs <gerald@wireshark.org>
535
* Copyright 1998 Gerald Combs
537
* This program is free software; you can redistribute it and/or
538
* modify it under the terms of the GNU General Public License
539
* as published by the Free Software Foundation; either version 2
540
* of the License, or (at your option) any later version.
542
* This program is distributed in the hope that it will be useful,
543
* but WITHOUT ANY WARRANTY; without even the implied warranty of
544
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
545
* GNU General Public License for more details.
547
* You should have received a copy of the GNU General Public License
548
* along with this program; if not, write to the Free Software
549
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
562
#include <epan/tvbuff.h>
563
#include <epan/proto.h>
564
#include <epan/packet_info.h>
565
#include <epan/emem.h>
567
#include <epan/dissectors/packet-snmp.h>
574
static GString* error;
575
static GArray* assoc_arr = NULL;
577
static guint8* engine = NULL;
578
static guint engine_len = 0;
579
static guint8* user = NULL;
580
static guint user_len = 0;
581
static guint8* auth_password = NULL;
582
static guint auth_password_len = 0;
583
static guint8* priv_password = NULL;
584
static guint priv_password_len = 0;
585
static int auth = AUTH_MD5;
586
static int enc = PRIV_DES;
587
static guint linenum = 0;
588
static const gchar* filename = "";
589
static guint loaded = 0;
591
static void add_engine(void);
592
static guint8* unhexbytes(const char* s, guint len, guint* len_p);
593
static guint8* undquote(const char* s, guint in_len, guint* len_p);
595
static snmp_usm_auth_model_t model_md5 = {snmp_usm_password_to_key_md5, snmp_usm_auth_md5, 16};
596
static snmp_usm_auth_model_t model_sha1 = {snmp_usm_password_to_key_sha1, snmp_usm_auth_sha1, 20};
599
#define START_LINE() { \
605
auth_password = NULL;\
606
auth_password_len = 0;\
607
priv_password = NULL;\
608
priv_password_len = 0;\
620
#line 621 "load_snmp_users_file.c"
623
#define START_ENGINE 1
624
#define STOP_ENGINE 2
627
#define START_AUTHPASSWORD 5
628
#define STOP_AUTHPASSWORD 6
629
#define START_PRIVPASSWORD 7
630
#define STOP_PRIVPASSWORD 8
634
#ifndef YY_NO_UNISTD_H
635
/* Special case for "unistd.h", since it is non-ANSI. We include it way
636
* down here because we want the user's section 1 to have been scanned first.
637
* The user has a chance to override it with an option.
642
#ifndef YY_EXTRA_TYPE
643
#define YY_EXTRA_TYPE void *
646
/* Macros after this point can all be overridden by user definitions in
650
#ifndef YY_SKIP_YYWRAP
652
extern "C" int Snmp_UE_file_wrap (void );
654
extern int Snmp_UE_file_wrap (void );
659
static void yy_flex_strncpy (char *,yyconst char *,int );
662
#ifdef YY_NEED_STRLEN
663
static int yy_flex_strlen (yyconst char * );
669
static int yyinput (void );
671
static int input (void );
676
/* Amount of stuff to slurp up with each read. */
677
#ifndef YY_READ_BUF_SIZE
678
#define YY_READ_BUF_SIZE 8192
681
/* Copy whatever the last rule matched to the standard output. */
683
/* This used to be an fputs(), but since the string might contain NUL's,
684
* we now use fwrite().
686
#define ECHO (void) fwrite( Snmp_UE_file_text, Snmp_UE_file_leng, 1, Snmp_UE_file_out )
689
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
690
* is returned in "result".
693
#define YY_INPUT(buf,result,max_size) \
694
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
698
for ( n = 0; n < max_size && \
699
(c = getc( Snmp_UE_file_in )) != EOF && c != '\n'; ++n ) \
702
buf[n++] = (char) c; \
703
if ( c == EOF && ferror( Snmp_UE_file_in ) ) \
704
YY_FATAL_ERROR( "input in flex scanner failed" ); \
710
while ( (result = fread(buf, 1, max_size, Snmp_UE_file_in))==0 && ferror(Snmp_UE_file_in)) \
712
if( errno != EINTR) \
714
YY_FATAL_ERROR( "input in flex scanner failed" ); \
718
clearerr(Snmp_UE_file_in); \
725
/* No semi-colon after return; correct usage is to write "yyterminate();" -
726
* we don't want an extra ';' after the "return" because that will cause
727
* some compilers to complain about unreachable statements.
730
#define yyterminate() return YY_NULL
733
/* Number of entries by which start-condition stack grows. */
734
#ifndef YY_START_STACK_INCR
735
#define YY_START_STACK_INCR 25
738
/* Report a fatal error. */
739
#ifndef YY_FATAL_ERROR
740
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
743
/* end tables serialization structures and prototypes */
745
/* Default declaration of generated scanner - a define so the user can
746
* easily add parameters.
749
#define YY_DECL_IS_OURS 1
751
extern int Snmp_UE_file_lex (void);
753
#define YY_DECL int Snmp_UE_file_lex (void)
754
#endif /* !YY_DECL */
756
/* Code executed at the beginning of each rule, after Snmp_UE_file_text and Snmp_UE_file_leng
759
#ifndef YY_USER_ACTION
760
#define YY_USER_ACTION
763
/* Code executed at the end of each rule. */
765
#define YY_BREAK break;
768
#define YY_RULE_SETUP \
771
/** The main scanner function which does all the work.
775
register yy_state_type yy_current_state;
776
register char *yy_cp, *yy_bp;
779
#line 119 "./load_snmp_users_file.l"
782
#line 783 "load_snmp_users_file.c"
793
(yy_start) = 1; /* first start state */
795
if ( ! Snmp_UE_file_in )
796
Snmp_UE_file_in = stdin;
798
if ( ! Snmp_UE_file_out )
799
Snmp_UE_file_out = stdout;
801
if ( ! YY_CURRENT_BUFFER ) {
802
Snmp_UE_file_ensure_buffer_stack ();
803
YY_CURRENT_BUFFER_LVALUE =
804
Snmp_UE_file__create_buffer(Snmp_UE_file_in,YY_BUF_SIZE );
807
Snmp_UE_file__load_buffer_state( );
810
while ( 1 ) /* loops until end-of-file is reached */
812
yy_cp = (yy_c_buf_p);
814
/* Support of Snmp_UE_file_text. */
815
*yy_cp = (yy_hold_char);
817
/* yy_bp points to the position in yy_ch_buf of the start of
822
yy_current_state = (yy_start);
826
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
827
if ( yy_accept[yy_current_state] )
829
(yy_last_accepting_state) = yy_current_state;
830
(yy_last_accepting_cpos) = yy_cp;
832
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
834
yy_current_state = (int) yy_def[yy_current_state];
835
if ( yy_current_state >= 102 )
836
yy_c = yy_meta[(unsigned int) yy_c];
838
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
841
while ( yy_current_state != 101 );
842
yy_cp = (yy_last_accepting_cpos);
843
yy_current_state = (yy_last_accepting_state);
846
yy_act = yy_accept[yy_current_state];
850
do_action: /* This label is used only to access EOF actions. */
853
{ /* beginning of action switch */
854
case 0: /* must back up */
855
/* undo the effects of YY_DO_BEFORE_ACTION */
856
*yy_cp = (yy_hold_char);
857
yy_cp = (yy_last_accepting_cpos);
858
yy_current_state = (yy_last_accepting_state);
863
#line 121 "./load_snmp_users_file.l"
867
/* rule 2 can match eol */
869
#line 122 "./load_snmp_users_file.l"
873
/* rule 3 can match eol */
875
#line 124 "./load_snmp_users_file.l"
879
/* rule 4 can match eol */
881
#line 125 "./load_snmp_users_file.l"
885
/* rule 5 can match eol */
887
#line 127 "./load_snmp_users_file.l"
888
{ engine = undquote(Snmp_UE_file_text, Snmp_UE_file_leng, &engine_len); BEGIN STOP_ENGINE; }
892
#line 128 "./load_snmp_users_file.l"
893
{ engine = unhexbytes(Snmp_UE_file_text, Snmp_UE_file_leng, &engine_len); BEGIN STOP_ENGINE; }
897
#line 129 "./load_snmp_users_file.l"
898
{ engine = NULL; engine_len = 0; BEGIN STOP_ENGINE; }
902
#line 130 "./load_snmp_users_file.l"
903
{ ERR("Invalid engineId"); }
907
#line 132 "./load_snmp_users_file.l"
908
{ BEGIN START_USER; }
911
/* rule 10 can match eol */
913
#line 134 "./load_snmp_users_file.l"
914
{ user = undquote(Snmp_UE_file_text, Snmp_UE_file_leng,&user_len); BEGIN STOP_USER; }
918
#line 135 "./load_snmp_users_file.l"
919
{ user = unhexbytes(Snmp_UE_file_text, Snmp_UE_file_leng, &user_len); BEGIN STOP_USER; }
923
#line 136 "./load_snmp_users_file.l"
924
{ ERR("Invalid userName"); }
928
#line 138 "./load_snmp_users_file.l"
929
{ BEGIN START_AUTHPASSWORD; }
932
/* rule 14 can match eol */
934
#line 140 "./load_snmp_users_file.l"
935
{ auth_password = undquote(Snmp_UE_file_text, Snmp_UE_file_leng, &auth_password_len); BEGIN STOP_AUTHPASSWORD; }
939
#line 141 "./load_snmp_users_file.l"
940
{ auth_password = unhexbytes(Snmp_UE_file_text, Snmp_UE_file_leng, &auth_password_len); BEGIN STOP_AUTHPASSWORD; }
944
#line 142 "./load_snmp_users_file.l"
945
{ ERR("Invalid authPassword"); }
949
#line 144 "./load_snmp_users_file.l"
950
{ BEGIN START_PRIVPASSWORD; }
953
/* rule 18 can match eol */
955
#line 146 "./load_snmp_users_file.l"
956
{ priv_password = undquote(Snmp_UE_file_text, Snmp_UE_file_leng, &priv_password_len); BEGIN STOP_PRIVPASSWORD; }
960
#line 147 "./load_snmp_users_file.l"
961
{ priv_password = unhexbytes(Snmp_UE_file_text, Snmp_UE_file_leng, &priv_password_len); BEGIN STOP_PRIVPASSWORD; }
965
#line 148 "./load_snmp_users_file.l"
966
{ ERR("Invalid privPassword"); }
970
#line 150 "./load_snmp_users_file.l"
971
{ BEGIN ATTRIBUTES; }
974
/* rule 22 can match eol */
976
#line 151 "./load_snmp_users_file.l"
977
{ add_engine(); START_LINE(); }
981
#line 153 "./load_snmp_users_file.l"
986
#line 154 "./load_snmp_users_file.l"
991
#line 155 "./load_snmp_users_file.l"
996
#line 156 "./load_snmp_users_file.l"
1001
#line 157 "./load_snmp_users_file.l"
1005
/* rule 28 can match eol */
1007
#line 158 "./load_snmp_users_file.l"
1008
{ add_engine(); START_LINE(); }
1012
#line 159 "./load_snmp_users_file.l"
1013
{ ERR("Invalid char in attributes"); }
1017
#line 161 "./load_snmp_users_file.l"
1020
#line 1021 "load_snmp_users_file.c"
1021
case YY_STATE_EOF(INITIAL):
1022
case YY_STATE_EOF(START_ENGINE):
1023
case YY_STATE_EOF(STOP_ENGINE):
1024
case YY_STATE_EOF(START_USER):
1025
case YY_STATE_EOF(STOP_USER):
1026
case YY_STATE_EOF(START_AUTHPASSWORD):
1027
case YY_STATE_EOF(STOP_AUTHPASSWORD):
1028
case YY_STATE_EOF(START_PRIVPASSWORD):
1029
case YY_STATE_EOF(STOP_PRIVPASSWORD):
1030
case YY_STATE_EOF(ATTRIBUTES):
1031
case YY_STATE_EOF(ERRORED):
1034
case YY_END_OF_BUFFER:
1036
/* Amount of text matched not including the EOB char. */
1037
int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1039
/* Undo the effects of YY_DO_BEFORE_ACTION. */
1040
*yy_cp = (yy_hold_char);
1041
YY_RESTORE_YY_MORE_OFFSET
1043
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1045
/* We're scanning a new file or input source. It's
1046
* possible that this happened because the user
1047
* just pointed Snmp_UE_file_in at a new source and called
1048
* Snmp_UE_file_lex(). If so, then we have to assure
1049
* consistency between YY_CURRENT_BUFFER and our
1050
* globals. Here is the right place to do so, because
1051
* this is the first action (other than possibly a
1052
* back-up) that will match for the new input source.
1054
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1055
YY_CURRENT_BUFFER_LVALUE->yy_input_file = Snmp_UE_file_in;
1056
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1059
/* Note that here we test for yy_c_buf_p "<=" to the position
1060
* of the first EOB in the buffer, since yy_c_buf_p will
1061
* already have been incremented past the NUL character
1062
* (since all states make transitions on EOB to the
1063
* end-of-buffer state). Contrast this with the test
1066
if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1067
{ /* This was really a NUL. */
1068
yy_state_type yy_next_state;
1070
(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1072
yy_current_state = yy_get_previous_state( );
1074
/* Okay, we're now positioned to make the NUL
1075
* transition. We couldn't have
1076
* yy_get_previous_state() go ahead and do it
1077
* for us because it doesn't know how to deal
1078
* with the possibility of jamming (and we don't
1079
* want to build jamming into it because then it
1080
* will run more slowly).
1083
yy_next_state = yy_try_NUL_trans( yy_current_state );
1085
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1087
if ( yy_next_state )
1089
/* Consume the NUL. */
1090
yy_cp = ++(yy_c_buf_p);
1091
yy_current_state = yy_next_state;
1097
yy_cp = (yy_last_accepting_cpos);
1098
yy_current_state = (yy_last_accepting_state);
1099
goto yy_find_action;
1103
else switch ( yy_get_next_buffer( ) )
1105
case EOB_ACT_END_OF_FILE:
1107
(yy_did_buffer_switch_on_eof) = 0;
1109
if ( Snmp_UE_file_wrap( ) )
1111
/* Note: because we've taken care in
1112
* yy_get_next_buffer() to have set up
1113
* Snmp_UE_file_text, we can now set up
1114
* yy_c_buf_p so that if some total
1115
* hoser (like flex itself) wants to
1116
* call the scanner after we return the
1117
* YY_NULL, it'll still work - another
1118
* YY_NULL will get returned.
1120
(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1122
yy_act = YY_STATE_EOF(YY_START);
1128
if ( ! (yy_did_buffer_switch_on_eof) )
1134
case EOB_ACT_CONTINUE_SCAN:
1136
(yytext_ptr) + yy_amount_of_matched_text;
1138
yy_current_state = yy_get_previous_state( );
1140
yy_cp = (yy_c_buf_p);
1141
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1144
case EOB_ACT_LAST_MATCH:
1146
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1148
yy_current_state = yy_get_previous_state( );
1150
yy_cp = (yy_c_buf_p);
1151
yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1152
goto yy_find_action;
1159
"fatal flex scanner internal error--no action found" );
1160
} /* end of action switch */
1161
} /* end of scanning one token */
1162
} /* end of Snmp_UE_file_lex */
1164
/* yy_get_next_buffer - try to read in a new buffer
1166
* Returns a code representing an action:
1167
* EOB_ACT_LAST_MATCH -
1168
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1169
* EOB_ACT_END_OF_FILE - end of file
1171
static int yy_get_next_buffer (void)
1173
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1174
register char *source = (yytext_ptr);
1175
register int number_to_move, i;
1178
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1180
"fatal flex scanner internal error--end of buffer missed" );
1182
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1183
{ /* Don't try to fill the buffer, so this is an EOF. */
1184
if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1186
/* We matched a single character, the EOB, so
1187
* treat this as a final EOF.
1189
return EOB_ACT_END_OF_FILE;
1194
/* We matched some text prior to the EOB, first
1197
return EOB_ACT_LAST_MATCH;
1201
/* Try to read more data. */
1203
/* First move last chars to start of buffer. */
1204
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1206
for ( i = 0; i < number_to_move; ++i )
1207
*(dest++) = *(source++);
1209
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1210
/* don't do the read, it's not guaranteed to return an EOF,
1213
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1218
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1220
while ( num_to_read <= 0 )
1221
{ /* Not enough room in the buffer - grow it. */
1223
/* just a shorter name for the current buffer */
1224
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1226
int yy_c_buf_p_offset =
1227
(int) ((yy_c_buf_p) - b->yy_ch_buf);
1229
if ( b->yy_is_our_buffer )
1231
int new_size = b->yy_buf_size * 2;
1233
if ( new_size <= 0 )
1234
b->yy_buf_size += b->yy_buf_size / 8;
1236
b->yy_buf_size *= 2;
1238
b->yy_ch_buf = (char *)
1239
/* Include room in for 2 EOB chars. */
1240
Snmp_UE_file_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1243
/* Can't grow it, we don't own it. */
1246
if ( ! b->yy_ch_buf )
1248
"fatal error - scanner input buffer overflow" );
1250
(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1252
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1257
if ( num_to_read > YY_READ_BUF_SIZE )
1258
num_to_read = YY_READ_BUF_SIZE;
1260
/* Read in more data. */
1261
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1262
(yy_n_chars), num_to_read );
1264
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1267
if ( (yy_n_chars) == 0 )
1269
if ( number_to_move == YY_MORE_ADJ )
1271
ret_val = EOB_ACT_END_OF_FILE;
1272
Snmp_UE_file_restart(Snmp_UE_file_in );
1277
ret_val = EOB_ACT_LAST_MATCH;
1278
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1279
YY_BUFFER_EOF_PENDING;
1284
ret_val = EOB_ACT_CONTINUE_SCAN;
1286
(yy_n_chars) += number_to_move;
1287
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1288
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1290
(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1295
/* yy_get_previous_state - get the state just before the EOB char was reached */
1297
static yy_state_type yy_get_previous_state (void)
1299
register yy_state_type yy_current_state;
1300
register char *yy_cp;
1302
yy_current_state = (yy_start);
1304
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1306
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1307
if ( yy_accept[yy_current_state] )
1309
(yy_last_accepting_state) = yy_current_state;
1310
(yy_last_accepting_cpos) = yy_cp;
1312
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1314
yy_current_state = (int) yy_def[yy_current_state];
1315
if ( yy_current_state >= 102 )
1316
yy_c = yy_meta[(unsigned int) yy_c];
1318
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1321
return yy_current_state;
1324
/* yy_try_NUL_trans - try to make a transition on the NUL character
1327
* next_state = yy_try_NUL_trans( current_state );
1329
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1331
register int yy_is_jam;
1332
register char *yy_cp = (yy_c_buf_p);
1334
register YY_CHAR yy_c = 1;
1335
if ( yy_accept[yy_current_state] )
1337
(yy_last_accepting_state) = yy_current_state;
1338
(yy_last_accepting_cpos) = yy_cp;
1340
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1342
yy_current_state = (int) yy_def[yy_current_state];
1343
if ( yy_current_state >= 102 )
1344
yy_c = yy_meta[(unsigned int) yy_c];
1346
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1347
yy_is_jam = (yy_current_state == 101);
1349
return yy_is_jam ? 0 : yy_current_state;
1354
static int yyinput (void)
1356
static int input (void)
1362
*(yy_c_buf_p) = (yy_hold_char);
1364
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1366
/* yy_c_buf_p now points to the character we want to return.
1367
* If this occurs *before* the EOB characters, then it's a
1368
* valid NUL; if not, then we've hit the end of the buffer.
1370
if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1371
/* This was really a NUL. */
1372
*(yy_c_buf_p) = '\0';
1375
{ /* need more input */
1376
int offset = (yy_c_buf_p) - (yytext_ptr);
1379
switch ( yy_get_next_buffer( ) )
1381
case EOB_ACT_LAST_MATCH:
1382
/* This happens because yy_g_n_b()
1383
* sees that we've accumulated a
1384
* token and flags that we need to
1385
* try matching the token before
1386
* proceeding. But for input(),
1387
* there's no matching to consider.
1388
* So convert the EOB_ACT_LAST_MATCH
1389
* to EOB_ACT_END_OF_FILE.
1392
/* Reset buffer status. */
1393
Snmp_UE_file_restart(Snmp_UE_file_in );
1397
case EOB_ACT_END_OF_FILE:
1399
if ( Snmp_UE_file_wrap( ) )
1402
if ( ! (yy_did_buffer_switch_on_eof) )
1411
case EOB_ACT_CONTINUE_SCAN:
1412
(yy_c_buf_p) = (yytext_ptr) + offset;
1418
c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1419
*(yy_c_buf_p) = '\0'; /* preserve Snmp_UE_file_text */
1420
(yy_hold_char) = *++(yy_c_buf_p);
1424
#endif /* ifndef YY_NO_INPUT */
1426
/** Immediately switch to a different input stream.
1427
* @param input_file A readable stream.
1429
* @note This function does not reset the start condition to @c INITIAL .
1431
void Snmp_UE_file_restart (FILE * input_file )
1434
if ( ! YY_CURRENT_BUFFER ){
1435
Snmp_UE_file_ensure_buffer_stack ();
1436
YY_CURRENT_BUFFER_LVALUE =
1437
Snmp_UE_file__create_buffer(Snmp_UE_file_in,YY_BUF_SIZE );
1440
Snmp_UE_file__init_buffer(YY_CURRENT_BUFFER,input_file );
1441
Snmp_UE_file__load_buffer_state( );
1444
/** Switch to a different input buffer.
1445
* @param new_buffer The new input buffer.
1448
void Snmp_UE_file__switch_to_buffer (YY_BUFFER_STATE new_buffer )
1451
/* TODO. We should be able to replace this entire function body
1453
* Snmp_UE_file_pop_buffer_state();
1454
* Snmp_UE_file_push_buffer_state(new_buffer);
1456
Snmp_UE_file_ensure_buffer_stack ();
1457
if ( YY_CURRENT_BUFFER == new_buffer )
1460
if ( YY_CURRENT_BUFFER )
1462
/* Flush out information for old buffer. */
1463
*(yy_c_buf_p) = (yy_hold_char);
1464
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1465
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1468
YY_CURRENT_BUFFER_LVALUE = new_buffer;
1469
Snmp_UE_file__load_buffer_state( );
1471
/* We don't actually know whether we did this switch during
1472
* EOF (Snmp_UE_file_wrap()) processing, but the only time this flag
1473
* is looked at is after Snmp_UE_file_wrap() is called, so it's safe
1474
* to go ahead and always set it.
1476
(yy_did_buffer_switch_on_eof) = 1;
1479
static void Snmp_UE_file__load_buffer_state (void)
1481
(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1482
(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1483
Snmp_UE_file_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1484
(yy_hold_char) = *(yy_c_buf_p);
1487
/** Allocate and initialize an input buffer state.
1488
* @param file A readable stream.
1489
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1491
* @return the allocated buffer state.
1493
YY_BUFFER_STATE Snmp_UE_file__create_buffer (FILE * file, int size )
1497
b = (YY_BUFFER_STATE) Snmp_UE_file_alloc(sizeof( struct yy_buffer_state ) );
1499
YY_FATAL_ERROR( "out of dynamic memory in Snmp_UE_file__create_buffer()" );
1501
b->yy_buf_size = size;
1503
/* yy_ch_buf has to be 2 characters longer than the size given because
1504
* we need to put in 2 end-of-buffer characters.
1506
b->yy_ch_buf = (char *) Snmp_UE_file_alloc(b->yy_buf_size + 2 );
1507
if ( ! b->yy_ch_buf )
1508
YY_FATAL_ERROR( "out of dynamic memory in Snmp_UE_file__create_buffer()" );
1510
b->yy_is_our_buffer = 1;
1512
Snmp_UE_file__init_buffer(b,file );
1517
/** Destroy the buffer.
1518
* @param b a buffer created with Snmp_UE_file__create_buffer()
1521
void Snmp_UE_file__delete_buffer (YY_BUFFER_STATE b )
1527
if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1528
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1530
if ( b->yy_is_our_buffer )
1531
Snmp_UE_file_free((void *) b->yy_ch_buf );
1533
Snmp_UE_file_free((void *) b );
1536
/* Initializes or reinitializes a buffer.
1537
* This function is sometimes called more than once on the same buffer,
1538
* such as during a Snmp_UE_file_restart() or at EOF.
1540
static void Snmp_UE_file__init_buffer (YY_BUFFER_STATE b, FILE * file )
1545
Snmp_UE_file__flush_buffer(b );
1547
b->yy_input_file = file;
1548
b->yy_fill_buffer = 1;
1550
/* If b is the current buffer, then Snmp_UE_file__init_buffer was _probably_
1551
* called from Snmp_UE_file_restart() or through yy_get_next_buffer.
1552
* In that case, we don't want to reset the lineno or column.
1554
if (b != YY_CURRENT_BUFFER){
1555
b->yy_bs_lineno = 1;
1556
b->yy_bs_column = 0;
1559
b->yy_is_interactive = 0;
1564
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1565
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1568
void Snmp_UE_file__flush_buffer (YY_BUFFER_STATE b )
1575
/* We always need two end-of-buffer characters. The first causes
1576
* a transition to the end-of-buffer state. The second causes
1577
* a jam in that state.
1579
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1580
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1582
b->yy_buf_pos = &b->yy_ch_buf[0];
1585
b->yy_buffer_status = YY_BUFFER_NEW;
1587
if ( b == YY_CURRENT_BUFFER )
1588
Snmp_UE_file__load_buffer_state( );
1591
/** Pushes the new state onto the stack. The new state becomes
1592
* the current state. This function will allocate the stack
1594
* @param new_buffer The new state.
1597
void Snmp_UE_file_push_buffer_state (YY_BUFFER_STATE new_buffer )
1599
if (new_buffer == NULL)
1602
Snmp_UE_file_ensure_buffer_stack();
1604
/* This block is copied from Snmp_UE_file__switch_to_buffer. */
1605
if ( YY_CURRENT_BUFFER )
1607
/* Flush out information for old buffer. */
1608
*(yy_c_buf_p) = (yy_hold_char);
1609
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1610
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1613
/* Only push if top exists. Otherwise, replace top. */
1614
if (YY_CURRENT_BUFFER)
1615
(yy_buffer_stack_top)++;
1616
YY_CURRENT_BUFFER_LVALUE = new_buffer;
1618
/* copied from Snmp_UE_file__switch_to_buffer. */
1619
Snmp_UE_file__load_buffer_state( );
1620
(yy_did_buffer_switch_on_eof) = 1;
1623
/** Removes and deletes the top of the stack, if present.
1624
* The next element becomes the new top.
1627
void Snmp_UE_file_pop_buffer_state (void)
1629
if (!YY_CURRENT_BUFFER)
1632
Snmp_UE_file__delete_buffer(YY_CURRENT_BUFFER );
1633
YY_CURRENT_BUFFER_LVALUE = NULL;
1634
if ((yy_buffer_stack_top) > 0)
1635
--(yy_buffer_stack_top);
1637
if (YY_CURRENT_BUFFER) {
1638
Snmp_UE_file__load_buffer_state( );
1639
(yy_did_buffer_switch_on_eof) = 1;
1643
/* Allocates the stack if it does not exist.
1644
* Guarantees space for at least one push.
1646
static void Snmp_UE_file_ensure_buffer_stack (void)
1650
if (!(yy_buffer_stack)) {
1652
/* First allocation is just for 2 elements, since we don't know if this
1653
* scanner will even need a stack. We use 2 instead of 1 to avoid an
1654
* immediate realloc on the next call.
1657
(yy_buffer_stack) = (struct yy_buffer_state**)Snmp_UE_file_alloc
1658
(num_to_alloc * sizeof(struct yy_buffer_state*)
1661
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1663
(yy_buffer_stack_max) = num_to_alloc;
1664
(yy_buffer_stack_top) = 0;
1668
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1670
/* Increase the buffer to prepare for a possible push. */
1671
int grow_size = 8 /* arbitrary grow size */;
1673
num_to_alloc = (yy_buffer_stack_max) + grow_size;
1674
(yy_buffer_stack) = (struct yy_buffer_state**)Snmp_UE_file_realloc
1676
num_to_alloc * sizeof(struct yy_buffer_state*)
1679
/* zero only the new slots.*/
1680
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1681
(yy_buffer_stack_max) = num_to_alloc;
1685
/** Setup the input buffer state to scan directly from a user-specified character buffer.
1686
* @param base the character buffer
1687
* @param size the size in bytes of the character buffer
1689
* @return the newly allocated buffer state object.
1691
YY_BUFFER_STATE Snmp_UE_file__scan_buffer (char * base, yy_size_t size )
1696
base[size-2] != YY_END_OF_BUFFER_CHAR ||
1697
base[size-1] != YY_END_OF_BUFFER_CHAR )
1698
/* They forgot to leave room for the EOB's. */
1701
b = (YY_BUFFER_STATE) Snmp_UE_file_alloc(sizeof( struct yy_buffer_state ) );
1703
YY_FATAL_ERROR( "out of dynamic memory in Snmp_UE_file__scan_buffer()" );
1705
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1706
b->yy_buf_pos = b->yy_ch_buf = base;
1707
b->yy_is_our_buffer = 0;
1708
b->yy_input_file = 0;
1709
b->yy_n_chars = b->yy_buf_size;
1710
b->yy_is_interactive = 0;
1712
b->yy_fill_buffer = 0;
1713
b->yy_buffer_status = YY_BUFFER_NEW;
1715
Snmp_UE_file__switch_to_buffer(b );
1720
/** Setup the input buffer state to scan a string. The next call to Snmp_UE_file_lex() will
1721
* scan from a @e copy of @a str.
1722
* @param str a NUL-terminated string to scan
1724
* @return the newly allocated buffer state object.
1725
* @note If you want to scan bytes that may contain NUL values, then use
1726
* Snmp_UE_file__scan_bytes() instead.
1728
YY_BUFFER_STATE Snmp_UE_file__scan_string (yyconst char * yy_str )
1731
return Snmp_UE_file__scan_bytes(yy_str,strlen(yy_str) );
1734
/** Setup the input buffer state to scan the given bytes. The next call to Snmp_UE_file_lex() will
1735
* scan from a @e copy of @a bytes.
1736
* @param bytes the byte buffer to scan
1737
* @param len the number of bytes in the buffer pointed to by @a bytes.
1739
* @return the newly allocated buffer state object.
1741
YY_BUFFER_STATE Snmp_UE_file__scan_bytes (yyconst char * bytes, int len )
1748
/* Get memory for full buffer, including space for trailing EOB's. */
1750
buf = (char *) Snmp_UE_file_alloc(n );
1752
YY_FATAL_ERROR( "out of dynamic memory in Snmp_UE_file__scan_bytes()" );
1754
for ( i = 0; i < len; ++i )
1757
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1759
b = Snmp_UE_file__scan_buffer(buf,n );
1761
YY_FATAL_ERROR( "bad buffer in Snmp_UE_file__scan_bytes()" );
1763
/* It's okay to grow etc. this buffer, and we should throw it
1764
* away when we're done.
1766
b->yy_is_our_buffer = 1;
1771
#ifndef YY_EXIT_FAILURE
1772
#define YY_EXIT_FAILURE 2
1775
static void yy_fatal_error (yyconst char* msg )
1777
(void) fprintf( stderr, "%s\n", msg );
1778
exit( YY_EXIT_FAILURE );
1781
/* Redefine yyless() so it works in section 3 code. */
1787
/* Undo effects of setting up Snmp_UE_file_text. */ \
1788
int yyless_macro_arg = (n); \
1789
YY_LESS_LINENO(yyless_macro_arg);\
1790
Snmp_UE_file_text[Snmp_UE_file_leng] = (yy_hold_char); \
1791
(yy_c_buf_p) = Snmp_UE_file_text + yyless_macro_arg; \
1792
(yy_hold_char) = *(yy_c_buf_p); \
1793
*(yy_c_buf_p) = '\0'; \
1794
Snmp_UE_file_leng = yyless_macro_arg; \
1798
/* Accessor methods (get/set functions) to struct members. */
1800
/** Get the current line number.
1803
int Snmp_UE_file_get_lineno (void)
1806
return Snmp_UE_file_lineno;
1809
/** Get the input stream.
1812
FILE *Snmp_UE_file_get_in (void)
1814
return Snmp_UE_file_in;
1817
/** Get the output stream.
1820
FILE *Snmp_UE_file_get_out (void)
1822
return Snmp_UE_file_out;
1825
/** Get the length of the current token.
1828
int Snmp_UE_file_get_leng (void)
1830
return Snmp_UE_file_leng;
1833
/** Get the current token.
1837
char *Snmp_UE_file_get_text (void)
1839
return Snmp_UE_file_text;
1842
/** Set the current line number.
1843
* @param line_number
1846
void Snmp_UE_file_set_lineno (int line_number )
1849
Snmp_UE_file_lineno = line_number;
1852
/** Set the input stream. This does not discard the current
1854
* @param in_str A readable stream.
1856
* @see Snmp_UE_file__switch_to_buffer
1858
void Snmp_UE_file_set_in (FILE * in_str )
1860
Snmp_UE_file_in = in_str ;
1863
void Snmp_UE_file_set_out (FILE * out_str )
1865
Snmp_UE_file_out = out_str ;
1868
int Snmp_UE_file_get_debug (void)
1870
return Snmp_UE_file__flex_debug;
1873
void Snmp_UE_file_set_debug (int bdebug )
1875
Snmp_UE_file__flex_debug = bdebug ;
1878
/* Snmp_UE_file_lex_destroy is for both reentrant and non-reentrant scanners. */
1879
int Snmp_UE_file_lex_destroy (void)
1882
/* Pop the buffer stack, destroying each element. */
1883
while(YY_CURRENT_BUFFER){
1884
Snmp_UE_file__delete_buffer(YY_CURRENT_BUFFER );
1885
YY_CURRENT_BUFFER_LVALUE = NULL;
1886
Snmp_UE_file_pop_buffer_state();
1889
/* Destroy the stack itself. */
1890
Snmp_UE_file_free((yy_buffer_stack) );
1891
(yy_buffer_stack) = NULL;
1897
* Internal utility routines.
1901
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1904
for ( i = 0; i < n; ++i )
1909
#ifdef YY_NEED_STRLEN
1910
static int yy_flex_strlen (yyconst char * s )
1913
for ( n = 0; s[n]; ++n )
1920
void *Snmp_UE_file_alloc (yy_size_t size )
1922
return (void *) malloc( size );
1925
void *Snmp_UE_file_realloc (void * ptr, yy_size_t size )
1927
/* The cast to (char *) in the following accommodates both
1928
* implementations that use char* generic pointers, and those
1929
* that use void* generic pointers. It works with the latter
1930
* because both ANSI C and C++ allow castless assignment from
1931
* any pointer type to void*, and deal with argument conversions
1932
* as though doing an assignment.
1934
return (void *) realloc( (char *) ptr, size );
1937
void Snmp_UE_file_free (void * ptr )
1939
free( (char *) ptr ); /* see Snmp_UE_file_realloc() for (char *) cast */
1942
#define YYTABLES_NAME "yytables"
1945
#undef YY_FLUSH_BUFFER
1947
#undef yy_new_buffer
1948
#undef yy_set_interactive
1950
#undef YY_DO_BEFORE_ACTION
1952
#ifdef YY_DECL_IS_OURS
1953
#undef YY_DECL_IS_OURS
1956
#line 161 "./load_snmp_users_file.l"
1960
static guint8* unhexbytes(const char* si, guint len, guint* len_p) {
1963
const guint8* s = (void*)si;
1967
ERR("Uneven number of chars hex string");
1971
buf = g_malloc(len);
1974
for (i = 0; i<len ; i += 2) {
1978
if (hi >= '0' && hi <= '9') {
1980
} else if (hi >= 'a' && hi <= 'f') {
1983
} else if (hi >= 'A' && hi <= 'F') {
1990
if (lo >= '0' && lo <= '9') {
1992
} else if (lo >= 'a' && lo <= 'f') {
1995
} else if (lo >= 'A' && lo <= 'F') {
2002
*(p++) = (hi*0x10) + lo;
2007
if (len_p) *len_p = len;
2012
ERR("Error parsing hex string");
2017
static guint8* undquote(const char* si, guint in_len, guint* len_p) {
2018
guint8* buf = g_malloc(in_len); /* wastes one byte for every '\\' in text */
2021
guint8* end = buf+in_len;
2022
const guint8* s = (void*)si;
2024
for (s++; p < end; s++) {
2031
case 'a': *(p++) = '\a'; len++; break;
2032
case 'b': *(p++) = '\b'; len++; break;
2033
case 'e': *(p++) = '\e'; len++; break;
2034
case 'f': *(p++) = '\f'; len++; break;
2035
case 'n': *(p++) = '\n'; len++; break;
2036
case 'r': *(p++) = '\r'; len++; break;
2037
case 't': *(p++) = '\t'; len++; break;
2038
case 'v': *(p++) = '\v'; len++; break;
2055
if ( s[1] >= '0' && s[1] <= '7' ) {
2059
if ( s[1] >= '0' && s[1] <= '7' ) {
2065
c = (64 * c2) + (8 * c1) + c0;
2066
*(p++) = (char) (c > 255 ? 255 : c);
2085
while ( p < end ) *(p++) = '\0';
2088
if (len_p) *len_p = len;
2094
static void add_engine(void) {
2099
a.user.userName.data = user;
2100
a.user.userName.len = user_len;
2102
a.user.authPassword.data = auth_password;
2103
a.user.authPassword.len = auth_password_len;
2105
a.user.privPassword.data = priv_password;
2106
a.user.privPassword.len = priv_password_len;
2110
a.user.authModel = &model_md5;
2113
a.user.authModel = &model_sha1;
2116
g_assert_not_reached();
2122
a.user.privProtocol = snmp_usm_priv_des;
2125
a.user.privProtocol = snmp_usm_priv_aes;
2128
g_assert_not_reached();
2133
a.engine.data = engine;
2134
a.engine.len = engine_len;
2136
if (a.user.authModel) {
2137
a.user.authKey.data = g_malloc(a.user.authModel->key_size);
2138
a.user.authKey.len = a.user.authModel->key_size;
2139
a.user.privKey.data = g_malloc(a.user.authModel->key_size);
2140
a.user.privKey.len = a.user.authModel->key_size;
2141
a.user.authModel->pass2key( auth_password, auth_password_len, engine, engine_len, a.user.authKey.data);
2142
a.user.authModel->pass2key( priv_password, priv_password_len, engine, engine_len, a.user.privKey.data);
2144
a.user.authKey.data = NULL;
2145
a.user.authKey.len = 0;
2146
a.user.privKey.data = NULL;
2147
a.user.privKey.len = 0;
2151
a.engine.data = NULL;
2153
a.user.authKey.data = NULL;
2154
a.user.authKey.len = 0;
2155
a.user.privKey.data = NULL;
2156
a.user.privKey.len = 0;
2161
g_array_append_val(assoc_arr,a);
2167
gchar* load_snmp_users_file(const char* fname, snmp_ue_assoc_t** assocs) {
2168
gchar* err_str = NULL;
2172
assoc_arr = g_array_new(TRUE,FALSE,sizeof(snmp_ue_assoc_t));
2175
Snmp_UE_file_in = fopen(filename,"r");
2177
if (!Snmp_UE_file_in) {
2178
return ep_strdup_printf("Could not open file: '%s', error: %s",filename,strerror(errno));
2181
error = g_string_new("");
2188
fclose(Snmp_UE_file_in);
2190
Snmp_UE_file_restart(NULL);
2193
*assocs = (snmp_ue_assoc_t*)assoc_arr->data;
2194
g_array_free(assoc_arr,FALSE);
2197
g_array_free(assoc_arr,TRUE);
2202
err_str = error->str;