From: Marcin Siodelski Date: Tue, 1 Dec 2015 10:26:18 +0000 (+0100) Subject: [master] Merge branch 'trac4204fd' X-Git-Tag: trac4231_base~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38aebe9566e09daa30796df686cfdd6d0c43fa4d;p=thirdparty%2Fkea.git [master] Merge branch 'trac4204fd' --- 38aebe9566e09daa30796df686cfdd6d0c43fa4d diff --cc src/lib/dhcpsrv/Makefile.am index 0b7985cfe7,b140c7e48f..e2be804e17 mode 100755,100644..100755 --- a/src/lib/dhcpsrv/Makefile.am +++ b/src/lib/dhcpsrv/Makefile.am diff --cc src/lib/eval/eval_context.cc index 99cc4e085c,6e27c88d89..4fae02f208 --- a/src/lib/eval/eval_context.cc +++ b/src/lib/eval/eval_context.cc @@@ -51,8 -56,46 +56,52 @@@ EvalContext::error (const std::string& isc_throw(EvalParseError, what); } + uint16_t + EvalContext::convertOptionCode(const std::string& option_code, + const isc::eval::location& loc) + { + int n = 0; + try { + n = boost::lexical_cast(option_code); + } catch (const boost::bad_lexical_cast &) { + // This can't happen... + error(loc, "Option code has invalid value in " + option_code); + } + if (option_universe_ == Option::V6) { + if (n < 0 || n > 65535) { + error(loc, "Option code has invalid value in " + + option_code + ". Allowed range: 0..65535"); + } + } else { + if (n < 0 || n > 255) { + error(loc, "Option code has invalid value in " + + option_code + ". Allowed range: 0..255"); + } + } + return (static_cast(n)); + } + + uint16_t + EvalContext::convertOptionName(const std::string& option_name, + const isc::eval::location& loc) + { + OptionDefinitionPtr option_def = LibDHCP::getOptionDef(option_universe_, + option_name); + if (!option_def) { + const std::string global_space = + (option_universe_ == Option::V4) ? "dhcp4" : "dhcp6"; + option_def = LibDHCP::getRuntimeOptionDef(global_space, option_name); + } + + if (!option_def) { + error(loc, "option '" + option_name + "' is not defined"); + } + + return (option_def->getCode()); + } ++ +void +EvalContext::fatal (const std::string& what) +{ + isc_throw(Unexpected, what); +} diff --cc src/lib/eval/eval_context.h index e1721baf19,b3ece5d672..bc0900621f --- a/src/lib/eval/eval_context.h +++ b/src/lib/eval/eval_context.h @@@ -81,11 -85,25 +85,30 @@@ public /// cases when the EvalParser is not able to handle the packet. void error(const std::string& what); + /// @brief Fatal error handler + /// + /// This is for should not happen but fatal errors + static void fatal(const std::string& what); + + /// @brief Option code convertion + /// + /// @param option_code a string representing the integer code + /// @param loc the location of the token + /// @result the option code + /// @throw calls the syntax error function if the value is no in + /// the range 0..255 or 0..65535 + uint16_t convertOptionCode(const std::string& option_code, + const isc::eval::location& loc); + + /// @brief Option name convertion + /// + /// @param option_name the option name + /// @param loc the location of the token + /// @result the option code + /// @throw calls the syntax error function if the name cannot be resolved + uint16_t convertOptionName(const std::string& option_name, + const isc::eval::location& loc); + private: /// @brief Flag determining scanner debugging. bool trace_scanning_; diff --cc src/lib/eval/lexer.cc index 3d81bf6c29,8d8660a37b..2122b1d39a --- a/src/lib/eval/lexer.cc +++ b/src/lib/eval/lexer.cc @@@ -18,7 -18,7 +18,7 @@@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 --#define YY_FLEX_SUBMINOR_VERSION 39 ++#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@@ -72,6 -72,6 +72,7 @@@ typedef int16_t flex_int16_t typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; ++typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@@ -79,6 -79,6 +80,7 @@@ typedef int flex_int32_t typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; ++#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@@ -109,8 -109,8 +111,6 @@@ #define UINT32_MAX (4294967295U) #endif --#endif /* ! C99 */ -- #endif /* ! FLEXINT_H */ /* %endif */ @@@ -225,18 -225,18 +225,11 @@@ extern FILE *yyin, *yyout */ #define YY_LESS_LINENO(n) \ do { \ -- int yyl;\ ++ yy_size_t yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ }while(0) -- #define YY_LINENO_REWIND_TO(dst) \ -- do {\ -- const char *p;\ -- for ( p = yy_cp-1; p >= (dst); --p)\ -- if ( *p == '\n' )\ -- --yylineno;\ -- }while(0) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ @@@ -427,7 -427,7 +420,7 @@@ void yyfree (void * ) /* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ /* Begin user sect3 */ --#define yywrap() 1 ++#define yywrap(n) 1 #define YY_SKIP_YYWRAP #define FLEX_DEBUG @@@ -445,8 -445,8 +438,6 @@@ int yylineno = 1 extern char *yytext; #define yytext_ptr yytext --/* %% [1.5] DFA */ -- /* %if-c-only Standard (non-C++) definition */ static yy_state_type yy_get_previous_state (void ); @@@ -462,7 -462,7 +453,7 @@@ static void yy_fatal_error (yyconst cha #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ /* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ -- yyleng = (size_t) (yy_cp - yy_bp); \ ++ yyleng = (yy_size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ /* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ @@@ -592,16 -612,31 +603,31 @@@ static yyconst flex_int32_t yy_rule_can extern int yy_flex_debug; int yy_flex_debug = 1; - static yyconst flex_int16_t yy_rule_linenum[19] = + static yyconst flex_int16_t yy_rule_linenum[20] = { 0, - 86, 90, 96, 106, 112, 126, 127, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 137, 139 - 83, 87, 93, 103, 109, 123, 130, 131, 132, 133, - 134, 135, 136, 137, 138, 139, 140, 141, 143 ++ 86, 90, 96, 106, 112, 126, 133, 134, 135, 136, ++ 137, 138, 139, 140, 141, 142, 143, 144, 146 } ; - /* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ - #define REJECT reject_used_but_not_detected + static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; + static char *yy_full_match; + static int yy_lp; + static int yy_looking_for_trail_begin = 0; + static int yy_full_lp; + static int *yy_full_state; + #define YY_TRAILING_MASK 0x2000 + #define YY_TRAILING_HEAD_MASK 0x4000 + #define REJECT \ + { \ + *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */ \ + yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ + (yy_lp) = (yy_full_lp); /* restore orig. accepting pos. */ \ + (yy_state_ptr) = (yy_full_state); /* restore orig. state */ \ + yy_current_state = *(yy_state_ptr); /* restore curr. state */ \ + ++(yy_lp); \ + goto find_rule; \ + } + #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET @@@ -665,7 -697,7 +691,7 @@@ static isc::eval::location loc // by moving it ahead by yyleng bytes. yyleng specifies the length of the // currently matched token. #define YY_USER_ACTION loc.columns(yyleng); - #line 669 "lexer.cc" -#line 701 "lexer.cc" ++#line 695 "lexer.cc" #define INITIAL 0 @@@ -783,7 -815,7 +809,7 @@@ static int input (void ) /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ --#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) ++#define ECHO fwrite( yytext, yyleng, 1, yyout ) /* %endif */ /* %if-c++-only C++ definition */ /* %endif */ @@@ -798,7 -830,7 +824,7 @@@ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ -- size_t n; \ ++ yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@@ -904,6 -936,6 +930,17 @@@ YY_DEC register char *yy_cp, *yy_bp; register int yy_act; ++/* %% [7.0] user's declarations go here */ ++#line 79 "lexer.ll" ++ ++ ++ ++ // Code run each time yylex is called. ++ loc.step(); ++ ++ ++#line 943 "lexer.cc" ++ if ( !(yy_init) ) { (yy_init) = 1; @@@ -938,18 -976,18 +981,6 @@@ yy_load_buffer_state( ); } -- { --/* %% [7.0] user's declarations go here */ - #line 79 "lexer.ll" -#line 76 "lexer.ll" -- -- -- -- // Code run each time yylex is called. -- loc.step(); -- -- - #line 952 "lexer.cc" -#line 990 "lexer.cc" -- while ( 1 ) /* loops until end-of-file is reached */ { /* %% [8.0] yymore()-related code goes here */ @@@ -968,12 -1010,7 +1003,7 @@@ yy_match: do { -- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; - if ( yy_accept[yy_current_state] ) - { - (yy_last_accepting_state) = yy_current_state; - (yy_last_accepting_cpos) = yy_cp; - } ++ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; @@@ -989,7 -1025,43 +1018,44 @@@ yy_find_action: /* %% [10.0] code to find the action number goes here */ - yy_act = yy_accept[yy_current_state]; + yy_current_state = *--(yy_state_ptr); + (yy_lp) = yy_accept[yy_current_state]; ++goto find_rule; /* Shut up GCC warning -Wall */ + find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[(yy_lp)]; + if ( yy_act & YY_TRAILING_HEAD_MASK || + (yy_looking_for_trail_begin) ) + { + if ( yy_act == (yy_looking_for_trail_begin) ) + { + (yy_looking_for_trail_begin) = 0; + yy_act &= ~YY_TRAILING_HEAD_MASK; + break; + } + } + else if ( yy_act & YY_TRAILING_MASK ) + { + (yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; + (yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; + } + else + { + (yy_full_match) = yy_cp; + (yy_full_state) = (yy_state_ptr); + (yy_full_lp) = (yy_lp); + break; + } + ++(yy_lp); + goto find_rule; + } + --yy_cp; + yy_current_state = *--(yy_state_ptr); + (yy_lp) = yy_accept[yy_current_state]; + } YY_DO_BEFORE_ACTION; @@@ -1027,16 -1099,9 +1093,9 @@@ do_action: /* This label is used only t switch ( yy_act ) { /* beginning of action switch */ /* %% [13.0] actions go here */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = (yy_hold_char); - yy_cp = (yy_last_accepting_cpos); - yy_current_state = (yy_last_accepting_state); - goto yy_find_action; - case 1: YY_RULE_SETUP -#line 83 "lexer.ll" +#line 86 "lexer.ll" { // Ok, we found a with space. Let's ignore it and update loc variable. loc.step(); @@@ -1092,80 -1157,91 +1151,91 @@@ YY_RULE_SETU } YY_BREAK case 6: + /* rule 6 can match eol */ YY_RULE_SETUP -#line 123 "lexer.ll" +#line 126 "lexer.ll" - return isc::eval::EvalParser::make_EQUAL(loc); + { + // This string specifies option name starting with a letter + // and further containing letters, digits, hyphens and + // underscores and finishing by letters or digits. + return isc::eval::EvalParser::make_OPTION_NAME(yytext, loc); + } YY_BREAK case 7: YY_RULE_SETUP - #line 127 "lexer.ll" - return isc::eval::EvalParser::make_OPTION(loc); -#line 130 "lexer.ll" ++#line 133 "lexer.ll" + return isc::eval::EvalParser::make_EQUAL(loc); YY_BREAK case 8: YY_RULE_SETUP - #line 128 "lexer.ll" - return isc::eval::EvalParser::make_TEXT(loc); -#line 131 "lexer.ll" ++#line 134 "lexer.ll" + return isc::eval::EvalParser::make_OPTION(loc); YY_BREAK case 9: YY_RULE_SETUP - #line 129 "lexer.ll" - return isc::eval::EvalParser::make_HEX(loc); -#line 132 "lexer.ll" ++#line 135 "lexer.ll" + return isc::eval::EvalParser::make_TEXT(loc); YY_BREAK case 10: YY_RULE_SETUP - #line 130 "lexer.ll" - return isc::eval::EvalParser::make_SUBSTRING(loc); -#line 133 "lexer.ll" ++#line 136 "lexer.ll" + return isc::eval::EvalParser::make_HEX(loc); YY_BREAK case 11: YY_RULE_SETUP - #line 131 "lexer.ll" - return isc::eval::EvalParser::make_ALL(loc); -#line 134 "lexer.ll" ++#line 137 "lexer.ll" + return isc::eval::EvalParser::make_SUBSTRING(loc); YY_BREAK case 12: YY_RULE_SETUP - #line 132 "lexer.ll" - return isc::eval::EvalParser::make_DOT(loc); -#line 135 "lexer.ll" ++#line 138 "lexer.ll" + return isc::eval::EvalParser::make_ALL(loc); YY_BREAK case 13: YY_RULE_SETUP - #line 133 "lexer.ll" - return isc::eval::EvalParser::make_LPAREN(loc); -#line 136 "lexer.ll" ++#line 139 "lexer.ll" + return isc::eval::EvalParser::make_DOT(loc); YY_BREAK case 14: YY_RULE_SETUP - #line 134 "lexer.ll" - return isc::eval::EvalParser::make_RPAREN(loc); -#line 137 "lexer.ll" ++#line 140 "lexer.ll" + return isc::eval::EvalParser::make_LPAREN(loc); YY_BREAK case 15: YY_RULE_SETUP - #line 135 "lexer.ll" - return isc::eval::EvalParser::make_LBRACKET(loc); -#line 138 "lexer.ll" ++#line 141 "lexer.ll" + return isc::eval::EvalParser::make_RPAREN(loc); YY_BREAK case 16: YY_RULE_SETUP - #line 136 "lexer.ll" - return isc::eval::EvalParser::make_RBRACKET(loc); -#line 139 "lexer.ll" ++#line 142 "lexer.ll" + return isc::eval::EvalParser::make_LBRACKET(loc); YY_BREAK case 17: YY_RULE_SETUP - #line 137 "lexer.ll" - return isc::eval::EvalParser::make_COMA(loc); -#line 140 "lexer.ll" ++#line 143 "lexer.ll" + return isc::eval::EvalParser::make_RBRACKET(loc); YY_BREAK case 18: YY_RULE_SETUP - #line 139 "lexer.ll" -#line 141 "lexer.ll" ++#line 144 "lexer.ll" + return isc::eval::EvalParser::make_COMA(loc); + YY_BREAK + case 19: + YY_RULE_SETUP -#line 143 "lexer.ll" ++#line 146 "lexer.ll" driver.error (loc, "Invalid character: " + std::string(yytext)); YY_BREAK case YY_STATE_EOF(INITIAL): - #line 140 "lexer.ll" -#line 144 "lexer.ll" ++#line 147 "lexer.ll" return isc::eval::EvalParser::make_END(loc); YY_BREAK - case 19: + case 20: YY_RULE_SETUP - #line 141 "lexer.ll" -#line 145 "lexer.ll" ++#line 148 "lexer.ll" ECHO; YY_BREAK - #line 1169 "lexer.cc" -#line 1245 "lexer.cc" ++#line 1239 "lexer.cc" case YY_END_OF_BUFFER: { @@@ -1296,7 -1371,7 +1365,6 @@@ "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ -- } /* end of user's declarations */ } /* end of yylex */ /* %ok-for-header */ @@@ -1515,9 -1554,11 +1547,11 @@@ static int yy_get_next_buffer (void yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 51); + yy_is_jam = (yy_current_state == 56); + if ( ! yy_is_jam ) + *(yy_state_ptr)++ = yy_current_state; -- return yy_is_jam ? 0 : yy_current_state; ++ return yy_is_jam ? 0 : yy_current_state; } /* %if-c-only */ @@@ -1576,7 -1617,7 +1610,7 @@@ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) -- return EOF; ++ return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@@ -1740,6 -1781,6 +1774,17 @@@ static void yy_load_buffer_state (void yyfree((void *) b ); } ++/* %if-c-only */ ++ ++#ifndef __cplusplus ++extern int isatty (int ); ++#endif /* __cplusplus */ ++ ++/* %endif */ ++ ++/* %if-c++-only */ ++/* %endif */ ++ /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. @@@ -1980,8 -2021,8 +2025,8 @@@ YY_BUFFER_STATE yy_scan_string (yycons /* %if-c-only */ /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. -- * @param yybytes the byte buffer to scan -- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. ++ * @param bytes the byte buffer to scan ++ * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ @@@ -1989,8 -2030,8 +2034,7 @@@ YY_BUFFER_STATE yy_scan_bytes (yycons { YY_BUFFER_STATE b; char *buf; -- yy_size_t n; -- yy_size_t i; ++ yy_size_t n, i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; @@@ -2253,7 -2302,7 +2305,7 @@@ void yyfree (void * ptr /* %ok-for-header */ - #line 141 "lexer.ll" -#line 145 "lexer.ll" ++#line 148 "lexer.ll"