2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[4313] Added relay4[code].exists which was lost in merge

This commit is contained in:
Francis Dupont
2016-02-27 15:36:28 +01:00
parent 909987228c
commit 03c30d1252
12 changed files with 309 additions and 227 deletions

View File

@@ -32,10 +32,14 @@ nodist_libkea_eval_la_SOURCES = eval_messages.h eval_messages.cc
libkea_eval_la_CXXFLAGS = $(AM_CXXFLAGS) libkea_eval_la_CXXFLAGS = $(AM_CXXFLAGS)
libkea_eval_la_CPPFLAGS = $(AM_CPPFLAGS) libkea_eval_la_CPPFLAGS = $(AM_CPPFLAGS)
libkea_eval_la_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libkea_eval_la_LIBADD = $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la libkea_eval_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la libkea_eval_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la libkea_eval_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
libkea_eval_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libkea_eval_la_LIBADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) libkea_eval_la_LIBADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
libkea_eval_la_LDFLAGS = -no-undefined -version-info 3:0:0 libkea_eval_la_LDFLAGS = -no-undefined -version-info 3:0:0

View File

@@ -480,11 +480,11 @@ static yyconst flex_int16_t yy_acclist[128] =
26,16390, 25, 26,16390, 25, 26,16390, 1, 2, 26,16390, 25, 26,16390, 25, 26,16390, 1, 2,
3, 5, 7,16390, 8198,16390,16390,16390,16390,16390, 3, 5, 7,16390, 8198,16390,16390,16390,16390,16390,
16390,16390, 18,16390,16390,16390,16390, 4, 14,16390, 16390,16390, 18,16390,16390,16390,16390, 4, 14,16390,
17,16390,16390,16390, 10,16390, 16,16390,16390,16390, 17,16390,16390,16390, 11,16390, 16,16390,16390,16390,
16390,16390,16390,16390,16390,16390,16390, 9,16390,16390, 16390,16390,16390,16390,16390,16390,16390, 10,16390,16390,
16390,16390,16390,16390, 15,16390, 11,16390, 8,16390, 16390,16390,16390,16390, 15,16390, 12,16390, 8,16390,
12,16390,16390,16390,16390, 13,16390 9,16390,16390,16390,16390, 13,16390
} ; } ;
static yyconst flex_int16_t yy_accept[82] = static yyconst flex_int16_t yy_accept[82] =
@@ -1203,22 +1203,22 @@ return isc::eval::EvalParser::make_OPTION(loc);
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 127 "lexer.ll" #line 127 "lexer.ll"
return isc::eval::EvalParser::make_TEXT(loc); return isc::eval::EvalParser::make_RELAY4(loc);
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 128 "lexer.ll" #line 128 "lexer.ll"
return isc::eval::EvalParser::make_HEX(loc); return isc::eval::EvalParser::make_TEXT(loc);
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 129 "lexer.ll" #line 129 "lexer.ll"
return isc::eval::EvalParser::make_EXISTS(loc); return isc::eval::EvalParser::make_HEX(loc);
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 130 "lexer.ll" #line 130 "lexer.ll"
return isc::eval::EvalParser::make_RELAY4(loc); return isc::eval::EvalParser::make_EXISTS(loc);
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP

View File

@@ -124,10 +124,10 @@ blank [ \t]
"==" return isc::eval::EvalParser::make_EQUAL(loc); "==" return isc::eval::EvalParser::make_EQUAL(loc);
"option" return isc::eval::EvalParser::make_OPTION(loc); "option" return isc::eval::EvalParser::make_OPTION(loc);
"relay4" return isc::eval::EvalParser::make_RELAY4(loc);
"text" return isc::eval::EvalParser::make_TEXT(loc); "text" return isc::eval::EvalParser::make_TEXT(loc);
"hex" return isc::eval::EvalParser::make_HEX(loc); "hex" return isc::eval::EvalParser::make_HEX(loc);
"exists" return isc::eval::EvalParser::make_EXISTS(loc); "exists" return isc::eval::EvalParser::make_EXISTS(loc);
"relay4" return isc::eval::EvalParser::make_RELAY4(loc);
"substring" return isc::eval::EvalParser::make_SUBSTRING(loc); "substring" return isc::eval::EvalParser::make_SUBSTRING(loc);
"all" return isc::eval::EvalParser::make_ALL(loc); "all" return isc::eval::EvalParser::make_ALL(loc);
"concat" return isc::eval::EvalParser::make_CONCAT(loc); "concat" return isc::eval::EvalParser::make_CONCAT(loc);

View File

@@ -1,4 +1,4 @@
// Generated 20160219 // Generated 20160227
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.4.
// Locations for Bison parsers in C++ // Locations for Bison parsers in C++

View File

@@ -649,34 +649,58 @@ namespace isc { namespace eval {
break; break;
case 9: case 9:
#line 112 "parser.yy" // lalr1.cc:859 #line 110 "parser.yy" // lalr1.cc:859
{
switch (ctx.getUniverse()) {
case Option::V4:
{
TokenPtr opt(new TokenRelay4Option(yystack_[3].value.as< uint16_t > (), TokenOption::EXISTS));
ctx.expression.push_back(opt);
break;
}
case Option::V6:
// We will have relay6[123] for the DHCPv6.
// In a very distant future we'll possibly be able
// to mix both if we have DHCPv4-over-DHCPv6, so it
// has some sense to make it explicit whether we
// talk about DHCPv4 relay or DHCPv6 relay. However,
// for the time being relay4 can be used in DHCPv4
// only.
error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
}
}
#line 673 "parser.cc" // lalr1.cc:859
break;
case 10:
#line 132 "parser.yy" // lalr1.cc:859
{ {
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ())); TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str); ctx.expression.push_back(str);
} }
#line 658 "parser.cc" // lalr1.cc:859 #line 682 "parser.cc" // lalr1.cc:859
break; break;
case 10: case 11:
#line 117 "parser.yy" // lalr1.cc:859 #line 137 "parser.yy" // lalr1.cc:859
{ {
TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ())); TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(hex); ctx.expression.push_back(hex);
} }
#line 667 "parser.cc" // lalr1.cc:859 #line 691 "parser.cc" // lalr1.cc:859
break; break;
case 11: case 12:
#line 122 "parser.yy" // lalr1.cc:859 #line 142 "parser.yy" // lalr1.cc:859
{ {
TokenPtr opt(new TokenOption(yystack_[3].value.as< uint16_t > (), yystack_[0].value.as< TokenOption::RepresentationType > ())); TokenPtr opt(new TokenOption(yystack_[3].value.as< uint16_t > (), yystack_[0].value.as< TokenOption::RepresentationType > ()));
ctx.expression.push_back(opt); ctx.expression.push_back(opt);
} }
#line 676 "parser.cc" // lalr1.cc:859 #line 700 "parser.cc" // lalr1.cc:859
break; break;
case 12: case 13:
#line 127 "parser.yy" // lalr1.cc:859 #line 147 "parser.yy" // lalr1.cc:859
{ {
switch (ctx.getUniverse()) { switch (ctx.getUniverse()) {
case Option::V4: case Option::V4:
@@ -696,88 +720,88 @@ namespace isc { namespace eval {
error(yystack_[5].location, "relay4 can only be used in DHCPv4."); error(yystack_[5].location, "relay4 can only be used in DHCPv4.");
} }
} }
#line 700 "parser.cc" // lalr1.cc:859 #line 724 "parser.cc" // lalr1.cc:859
break; break;
case 13: case 14:
#line 147 "parser.yy" // lalr1.cc:859 #line 167 "parser.yy" // lalr1.cc:859
{ {
TokenPtr sub(new TokenSubstring()); TokenPtr sub(new TokenSubstring());
ctx.expression.push_back(sub); ctx.expression.push_back(sub);
} }
#line 709 "parser.cc" // lalr1.cc:859 #line 733 "parser.cc" // lalr1.cc:859
break; break;
case 14: case 15:
#line 152 "parser.yy" // lalr1.cc:859 #line 172 "parser.yy" // lalr1.cc:859
{ {
TokenPtr conc(new TokenConcat()); TokenPtr conc(new TokenConcat());
ctx.expression.push_back(conc); ctx.expression.push_back(conc);
} }
#line 718 "parser.cc" // lalr1.cc:859
break;
case 15:
#line 159 "parser.yy" // lalr1.cc:859
{
yylhs.value.as< uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as< std::string > (), yystack_[0].location);
}
#line 726 "parser.cc" // lalr1.cc:859
break;
case 16:
#line 163 "parser.yy" // lalr1.cc:859
{
yylhs.value.as< uint16_t > () = ctx.convertOptionName(yystack_[0].value.as< std::string > (), yystack_[0].location);
}
#line 734 "parser.cc" // lalr1.cc:859
break;
case 17:
#line 169 "parser.yy" // lalr1.cc:859
{
yylhs.value.as< TokenOption::RepresentationType > () = TokenOption::TEXTUAL;
}
#line 742 "parser.cc" // lalr1.cc:859 #line 742 "parser.cc" // lalr1.cc:859
break; break;
case 18: case 16:
#line 173 "parser.yy" // lalr1.cc:859 #line 179 "parser.yy" // lalr1.cc:859
{ {
yylhs.value.as< TokenOption::RepresentationType > () = TokenOption::HEXADECIMAL; yylhs.value.as< uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as< std::string > (), yystack_[0].location);
} }
#line 750 "parser.cc" // lalr1.cc:859 #line 750 "parser.cc" // lalr1.cc:859
break; break;
case 17:
#line 183 "parser.yy" // lalr1.cc:859
{
yylhs.value.as< uint16_t > () = ctx.convertOptionName(yystack_[0].value.as< std::string > (), yystack_[0].location);
}
#line 758 "parser.cc" // lalr1.cc:859
break;
case 18:
#line 189 "parser.yy" // lalr1.cc:859
{
yylhs.value.as< TokenOption::RepresentationType > () = TokenOption::TEXTUAL;
}
#line 766 "parser.cc" // lalr1.cc:859
break;
case 19: case 19:
#line 179 "parser.yy" // lalr1.cc:859 #line 193 "parser.yy" // lalr1.cc:859
{
yylhs.value.as< TokenOption::RepresentationType > () = TokenOption::HEXADECIMAL;
}
#line 774 "parser.cc" // lalr1.cc:859
break;
case 20:
#line 199 "parser.yy" // lalr1.cc:859
{ {
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ())); TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str); ctx.expression.push_back(str);
} }
#line 759 "parser.cc" // lalr1.cc:859 #line 783 "parser.cc" // lalr1.cc:859
break; break;
case 20: case 21:
#line 186 "parser.yy" // lalr1.cc:859 #line 206 "parser.yy" // lalr1.cc:859
{ {
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ())); TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
ctx.expression.push_back(str); ctx.expression.push_back(str);
} }
#line 768 "parser.cc" // lalr1.cc:859 #line 792 "parser.cc" // lalr1.cc:859
break; break;
case 21: case 22:
#line 191 "parser.yy" // lalr1.cc:859 #line 211 "parser.yy" // lalr1.cc:859
{ {
TokenPtr str(new TokenString("all")); TokenPtr str(new TokenString("all"));
ctx.expression.push_back(str); ctx.expression.push_back(str);
} }
#line 777 "parser.cc" // lalr1.cc:859 #line 801 "parser.cc" // lalr1.cc:859
break; break;
#line 781 "parser.cc" // lalr1.cc:859 #line 805 "parser.cc" // lalr1.cc:859
default: default:
break; break;
} }
@@ -1032,93 +1056,98 @@ namespace isc { namespace eval {
} }
const signed char EvalParser::yypact_ninf_ = -14; const signed char EvalParser::yypact_ninf_ = -29;
const signed char EvalParser::yytable_ninf_ = -1; const signed char EvalParser::yytable_ninf_ = -1;
const signed char const signed char
EvalParser::yypact_[] = EvalParser::yypact_[] =
{ {
-2, -12, -4, 3, -2, 14, -2, -14, -14, 39, -1, -1, -1, 1, 10, 28, 36, -29, -29, 32,
33, 40, 16, 6, 6, -14, 16, 17, -14, -2, 0, 41, 29, -29, -7, -7, 17, 17, -29, -1,
-2, 6, -14, -14, 25, 27, 28, 31, 29, -14, -1, 17, -29, -29, -29, 38, 39, 42, 43, 37,
-14, 42, -14, 36, 16, 26, 6, 37, 24, 34, 40, -29, 46, -29, 44, 45, -7, -7, 47, 17,
-14, 41, 35, 18, -14, -14, -14, -14, 43, 0, 27, 30, 48, 49, -29, 51, 58, -29, -29, -29,
-14, -14, 18, -14, -14, 38, -14 -29, -29, -29, 50, 52, -4, -29, 33, 33, -29,
-29, 60, -29
}; };
const unsigned char const unsigned char
EvalParser::yydefact_[] = EvalParser::yydefact_[] =
{ {
0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 0,
2, 0, 0, 0, 0, 4, 0, 0, 1, 0, 2, 0, 0, 4, 0, 0, 0, 0, 1, 0,
0, 0, 15, 16, 0, 0, 0, 0, 0, 3, 0, 0, 3, 16, 17, 0, 0, 0, 0, 0,
5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 0, 0, 0, 0, 0, 0,
19, 0, 0, 0, 17, 18, 8, 11, 0, 0, 0, 0, 0, 0, 20, 0, 0, 18, 19, 8,
14, 12, 0, 21, 20, 0, 13 12, 9, 13, 0, 0, 0, 15, 0, 0, 22,
21, 0, 14
}; };
const signed char const signed char
EvalParser::yypgoto_[] = EvalParser::yypgoto_[] =
{ {
-14, -14, 12, -13, -10, 19, -14, -14 -29, -29, 9, -16, -12, -28, -29, -29
}; };
const signed char const signed char
EvalParser::yydefgoto_[] = EvalParser::yydefgoto_[] =
{ {
-1, 9, 10, 11, 24, 47, 41, 55 -1, 9, 10, 11, 25, 50, 45, 61
}; };
const unsigned char const unsigned char
EvalParser::yytable_[] = EvalParser::yytable_[] =
{ {
26, 27, 1, 2, 3, 4, 28, 12, 32, 5, 29, 30, 1, 26, 2, 33, 19, 20, 3, 4,
25, 2, 3, 13, 53, 6, 15, 5, 17, 7, 12, 13, 14, 52, 59, 23, 5, 24, 60, 6,
14, 8, 54, 42, 39, 19, 20, 7, 44, 8, 7, 15, 8, 46, 42, 43, 27, 28, 31, 32,
45, 30, 31, 16, 44, 29, 45, 46, 22, 18, 52, 16, 18, 22, 5, 19, 20, 6, 7, 17,
23, 19, 20, 21, 35, 33, 34, 36, 40, 37, 8, 47, 48, 49, 47, 48, 51, 47, 48, 21,
19, 38, 43, 50, 48, 0, 56, 49, 52, 0, 34, 35, 19, 36, 37, 0, 38, 40, 41, 39,
0, 0, 51 53, 54, 56, 57, 62, 58, 0, 0, 0, 44,
55
}; };
const signed char const signed char
EvalParser::yycheck_[] = EvalParser::yycheck_[] =
{ {
13, 14, 4, 5, 6, 7, 16, 19, 21, 11, 16, 17, 3, 15, 5, 21, 6, 7, 9, 10,
4, 5, 6, 17, 14, 17, 4, 11, 6, 21, 1, 2, 11, 41, 18, 22, 17, 24, 22, 20,
17, 23, 22, 36, 34, 8, 9, 21, 10, 23, 21, 11, 23, 39, 36, 37, 9, 10, 19, 20,
12, 19, 20, 19, 10, 18, 12, 13, 22, 0, 58, 3, 0, 4, 17, 6, 7, 20, 21, 3,
24, 8, 9, 3, 16, 20, 19, 16, 22, 20, 23, 14, 15, 16, 14, 15, 16, 14, 15, 8,
8, 15, 15, 18, 20, -1, 18, 16, 15, -1, 12, 12, 6, 11, 11, -1, 19, 13, 13, 19,
-1, -1, 43 12, 12, 4, 13, 4, 13, -1, -1, -1, 22,
19
}; };
const unsigned char const unsigned char
EvalParser::yystos_[] = EvalParser::yystos_[] =
{ {
0, 4, 5, 6, 7, 11, 17, 21, 23, 26, 0, 3, 5, 9, 10, 17, 20, 21, 23, 26,
27, 28, 19, 17, 17, 27, 19, 27, 0, 8, 27, 28, 27, 27, 11, 11, 3, 3, 0, 6,
9, 3, 22, 24, 29, 4, 28, 28, 29, 18, 7, 8, 4, 22, 24, 29, 29, 9, 10, 28,
27, 27, 28, 20, 19, 16, 16, 20, 15, 29, 28, 27, 27, 28, 12, 12, 11, 11, 19, 19,
22, 31, 28, 15, 10, 12, 13, 30, 20, 16, 13, 13, 29, 29, 22, 31, 28, 14, 15, 16,
18, 30, 15, 14, 22, 32, 18 30, 16, 30, 12, 12, 19, 4, 13, 13, 18,
22, 32, 4
}; };
const unsigned char const unsigned char
EvalParser::yyr1_[] = EvalParser::yyr1_[] =
{ {
0, 25, 26, 27, 27, 27, 27, 27, 27, 28, 0, 25, 26, 27, 27, 27, 27, 27, 27, 27,
28, 28, 28, 28, 28, 29, 29, 30, 30, 31, 28, 28, 28, 28, 28, 28, 29, 29, 30, 30,
32, 32 31, 32, 32
}; };
const unsigned char const unsigned char
EvalParser::yyr2_[] = EvalParser::yyr2_[] =
{ {
0, 2, 1, 3, 2, 3, 3, 3, 6, 1, 0, 2, 1, 3, 2, 3, 3, 3, 6, 6,
1, 6, 6, 8, 6, 1, 1, 1, 1, 1, 1, 1, 6, 6, 8, 6, 1, 1, 1, 1,
1, 1 1, 1, 1
}; };
@@ -1128,22 +1157,22 @@ namespace isc { namespace eval {
const char* const char*
const EvalParser::yytname_[] = const EvalParser::yytname_[] =
{ {
"\"end of file\"", "error", "$undefined", "\"==\"", "\"option\"", "\"end of file\"", "error", "$undefined", "\"(\"", "\")\"", "\"not\"",
"\"substring\"", "\"concat\"", "\"not\"", "\"and\"", "\"or\"", "\"and\"", "\"or\"", "\"==\"", "\"option\"", "\"relay4\"", "\"[\"",
"\"text\"", "\"relay4\"", "\"hex\"", "\"exists\"", "\"all\"", "\".\"", "\"]\"", "\".\"", "\"text\"", "\"hex\"", "\"exists\"", "\"substring\"",
"\",\"", "\"(\"", "\")\"", "\"[\"", "\"]\"", "\"constant string\"", "\"all\"", "\",\"", "\"concat\"", "\"constant string\"", "\"integer\"",
"\"integer\"", "\"constant hexstring\"", "\"option name\"", "$accept", "\"constant hexstring\"", "\"option name\"", "$accept", "expression",
"expression", "bool_expr", "string_expr", "option_code", "bool_expr", "string_expr", "option_code", "option_repr_type",
"option_repr_type", "start_expr", "length_expr", YY_NULLPTR "start_expr", "length_expr", YY_NULLPTR
}; };
#if YYDEBUG #if YYDEBUG
const unsigned char const unsigned char
EvalParser::yyrline_[] = EvalParser::yyrline_[] =
{ {
0, 80, 80, 83, 84, 89, 94, 99, 104, 111, 0, 80, 80, 83, 84, 89, 94, 99, 104, 109,
116, 121, 126, 146, 151, 158, 162, 168, 172, 178, 131, 136, 141, 146, 166, 171, 178, 182, 188, 192,
185, 190 198, 205, 210
}; };
// Print the state stack on the debug stream. // Print the state stack on the debug stream.
@@ -1178,8 +1207,8 @@ namespace isc { namespace eval {
#line 13 "parser.yy" // lalr1.cc:1167 #line 13 "parser.yy" // lalr1.cc:1167
} } // isc::eval } } // isc::eval
#line 1182 "parser.cc" // lalr1.cc:1167 #line 1211 "parser.cc" // lalr1.cc:1167
#line 197 "parser.yy" // lalr1.cc:1168 #line 217 "parser.yy" // lalr1.cc:1168
void void
isc::eval::EvalParser::error(const location_type& loc, isc::eval::EvalParser::error(const location_type& loc,

View File

@@ -329,24 +329,24 @@ namespace isc { namespace eval {
enum yytokentype enum yytokentype
{ {
TOKEN_END = 0, TOKEN_END = 0,
TOKEN_EQUAL = 258, TOKEN_LPAREN = 258,
TOKEN_OPTION = 259, TOKEN_RPAREN = 259,
TOKEN_SUBSTRING = 260, TOKEN_NOT = 260,
TOKEN_CONCAT = 261, TOKEN_AND = 261,
TOKEN_NOT = 262, TOKEN_OR = 262,
TOKEN_AND = 263, TOKEN_EQUAL = 263,
TOKEN_OR = 264, TOKEN_OPTION = 264,
TOKEN_TEXT = 265, TOKEN_RELAY4 = 265,
TOKEN_RELAY4 = 266, TOKEN_LBRACKET = 266,
TOKEN_HEX = 267, TOKEN_RBRACKET = 267,
TOKEN_EXISTS = 268, TOKEN_DOT = 268,
TOKEN_ALL = 269, TOKEN_TEXT = 269,
TOKEN_DOT = 270, TOKEN_HEX = 270,
TOKEN_COMA = 271, TOKEN_EXISTS = 271,
TOKEN_LPAREN = 272, TOKEN_SUBSTRING = 272,
TOKEN_RPAREN = 273, TOKEN_ALL = 273,
TOKEN_LBRACKET = 274, TOKEN_COMA = 274,
TOKEN_RBRACKET = 275, TOKEN_CONCAT = 275,
TOKEN_STRING = 276, TOKEN_STRING = 276,
TOKEN_INTEGER = 277, TOKEN_INTEGER = 277,
TOKEN_HEXSTRING = 278, TOKEN_HEXSTRING = 278,
@@ -467,19 +467,11 @@ namespace isc { namespace eval {
static inline static inline
symbol_type symbol_type
make_EQUAL (const location_type& l); make_LPAREN (const location_type& l);
static inline static inline
symbol_type symbol_type
make_OPTION (const location_type& l); make_RPAREN (const location_type& l);
static inline
symbol_type
make_SUBSTRING (const location_type& l);
static inline
symbol_type
make_CONCAT (const location_type& l);
static inline static inline
symbol_type symbol_type
@@ -495,12 +487,32 @@ namespace isc { namespace eval {
static inline static inline
symbol_type symbol_type
make_TEXT (const location_type& l); make_EQUAL (const location_type& l);
static inline
symbol_type
make_OPTION (const location_type& l);
static inline static inline
symbol_type symbol_type
make_RELAY4 (const location_type& l); make_RELAY4 (const location_type& l);
static inline
symbol_type
make_LBRACKET (const location_type& l);
static inline
symbol_type
make_RBRACKET (const location_type& l);
static inline
symbol_type
make_DOT (const location_type& l);
static inline
symbol_type
make_TEXT (const location_type& l);
static inline static inline
symbol_type symbol_type
make_HEX (const location_type& l); make_HEX (const location_type& l);
@@ -511,11 +523,11 @@ namespace isc { namespace eval {
static inline static inline
symbol_type symbol_type
make_ALL (const location_type& l); make_SUBSTRING (const location_type& l);
static inline static inline
symbol_type symbol_type
make_DOT (const location_type& l); make_ALL (const location_type& l);
static inline static inline
symbol_type symbol_type
@@ -523,19 +535,7 @@ namespace isc { namespace eval {
static inline static inline
symbol_type symbol_type
make_LPAREN (const location_type& l); make_CONCAT (const location_type& l);
static inline
symbol_type
make_RPAREN (const location_type& l);
static inline
symbol_type
make_LBRACKET (const location_type& l);
static inline
symbol_type
make_RBRACKET (const location_type& l);
static inline static inline
symbol_type symbol_type
@@ -758,7 +758,7 @@ namespace isc { namespace eval {
enum enum
{ {
yyeof_ = 0, yyeof_ = 0,
yylast_ = 62, ///< Last index in yytable_. yylast_ = 70, ///< Last index in yytable_.
yynnts_ = 8, ///< Number of nonterminal symbols. yynnts_ = 8, ///< Number of nonterminal symbols.
yyfinal_ = 18, ///< Termination state number. yyfinal_ = 18, ///< Termination state number.
yyterror_ = 1, yyterror_ = 1,
@@ -1073,27 +1073,15 @@ namespace isc { namespace eval {
} }
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_EQUAL (const location_type& l) EvalParser::make_LPAREN (const location_type& l)
{ {
return symbol_type (token::TOKEN_EQUAL, l); return symbol_type (token::TOKEN_LPAREN, l);
} }
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_OPTION (const location_type& l) EvalParser::make_RPAREN (const location_type& l)
{ {
return symbol_type (token::TOKEN_OPTION, l); return symbol_type (token::TOKEN_RPAREN, l);
}
EvalParser::symbol_type
EvalParser::make_SUBSTRING (const location_type& l)
{
return symbol_type (token::TOKEN_SUBSTRING, l);
}
EvalParser::symbol_type
EvalParser::make_CONCAT (const location_type& l)
{
return symbol_type (token::TOKEN_CONCAT, l);
} }
EvalParser::symbol_type EvalParser::symbol_type
@@ -1115,9 +1103,15 @@ namespace isc { namespace eval {
} }
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_TEXT (const location_type& l) EvalParser::make_EQUAL (const location_type& l)
{ {
return symbol_type (token::TOKEN_TEXT, l); return symbol_type (token::TOKEN_EQUAL, l);
}
EvalParser::symbol_type
EvalParser::make_OPTION (const location_type& l)
{
return symbol_type (token::TOKEN_OPTION, l);
} }
EvalParser::symbol_type EvalParser::symbol_type
@@ -1126,6 +1120,30 @@ namespace isc { namespace eval {
return symbol_type (token::TOKEN_RELAY4, l); return symbol_type (token::TOKEN_RELAY4, l);
} }
EvalParser::symbol_type
EvalParser::make_LBRACKET (const location_type& l)
{
return symbol_type (token::TOKEN_LBRACKET, l);
}
EvalParser::symbol_type
EvalParser::make_RBRACKET (const location_type& l)
{
return symbol_type (token::TOKEN_RBRACKET, l);
}
EvalParser::symbol_type
EvalParser::make_DOT (const location_type& l)
{
return symbol_type (token::TOKEN_DOT, l);
}
EvalParser::symbol_type
EvalParser::make_TEXT (const location_type& l)
{
return symbol_type (token::TOKEN_TEXT, l);
}
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_HEX (const location_type& l) EvalParser::make_HEX (const location_type& l)
{ {
@@ -1139,15 +1157,15 @@ namespace isc { namespace eval {
} }
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_ALL (const location_type& l) EvalParser::make_SUBSTRING (const location_type& l)
{ {
return symbol_type (token::TOKEN_ALL, l); return symbol_type (token::TOKEN_SUBSTRING, l);
} }
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_DOT (const location_type& l) EvalParser::make_ALL (const location_type& l)
{ {
return symbol_type (token::TOKEN_DOT, l); return symbol_type (token::TOKEN_ALL, l);
} }
EvalParser::symbol_type EvalParser::symbol_type
@@ -1157,27 +1175,9 @@ namespace isc { namespace eval {
} }
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_LPAREN (const location_type& l) EvalParser::make_CONCAT (const location_type& l)
{ {
return symbol_type (token::TOKEN_LPAREN, l); return symbol_type (token::TOKEN_CONCAT, l);
}
EvalParser::symbol_type
EvalParser::make_RPAREN (const location_type& l)
{
return symbol_type (token::TOKEN_RPAREN, l);
}
EvalParser::symbol_type
EvalParser::make_LBRACKET (const location_type& l)
{
return symbol_type (token::TOKEN_LBRACKET, l);
}
EvalParser::symbol_type
EvalParser::make_RBRACKET (const location_type& l)
{
return symbol_type (token::TOKEN_RBRACKET, l);
} }
EvalParser::symbol_type EvalParser::symbol_type

View File

@@ -36,24 +36,24 @@ using namespace isc::eval;
%define api.token.prefix {TOKEN_} %define api.token.prefix {TOKEN_}
%token %token
END 0 "end of file" END 0 "end of file"
EQUAL "==" LPAREN "("
OPTION "option" RPAREN ")"
SUBSTRING "substring"
CONCAT "concat"
NOT "not" NOT "not"
AND "and" AND "and"
OR "or" OR "or"
TEXT "text" EQUAL "=="
OPTION "option"
RELAY4 "relay4" RELAY4 "relay4"
HEX "hex"
EXISTS "exists"
ALL "all"
DOT "."
COMA ","
LPAREN "("
RPAREN ")"
LBRACKET "[" LBRACKET "["
RBRACKET "]" RBRACKET "]"
DOT "."
TEXT "text"
HEX "hex"
EXISTS "exists"
SUBSTRING "substring"
ALL "all"
COMA ","
CONCAT "concat"
; ;
%token <std::string> STRING "constant string" %token <std::string> STRING "constant string"
@@ -106,6 +106,26 @@ bool_expr : "(" bool_expr ")"
TokenPtr opt(new TokenOption($3, TokenOption::EXISTS)); TokenPtr opt(new TokenOption($3, TokenOption::EXISTS));
ctx.expression.push_back(opt); ctx.expression.push_back(opt);
} }
| RELAY4 "[" option_code "]" "." EXISTS
{
switch (ctx.getUniverse()) {
case Option::V4:
{
TokenPtr opt(new TokenRelay4Option($3, TokenOption::EXISTS));
ctx.expression.push_back(opt);
break;
}
case Option::V6:
// We will have relay6[123] for the DHCPv6.
// In a very distant future we'll possibly be able
// to mix both if we have DHCPv4-over-DHCPv6, so it
// has some sense to make it explicit whether we
// talk about DHCPv4 relay or DHCPv6 relay. However,
// for the time being relay4 can be used in DHCPv4
// only.
error(@1, "relay4 can only be used in DHCPv4.");
}
}
; ;
string_expr : STRING string_expr : STRING

View File

@@ -1,4 +1,4 @@
// Generated 20160219 // Generated 20160227
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.4.
// Positions for Bison parsers in C++ // Positions for Bison parsers in C++

View File

@@ -1,4 +1,4 @@
// Generated 20160219 // Generated 20160227
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.4.
// Stack handling for Bison parsers in C++ // Stack handling for Bison parsers in C++

View File

@@ -36,7 +36,12 @@ libeval_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
libeval_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) libeval_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
libeval_unittests_LDADD = $(top_builddir)/src/lib/eval/libkea-eval.la libeval_unittests_LDADD = $(top_builddir)/src/lib/eval/libkea-eval.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la libeval_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la libeval_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
libeval_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la libeval_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libeval_unittests_LDADD += $(CRYPTO_LIBS) $(LOG4CPLUS_LIBS) libeval_unittests_LDADD += $(CRYPTO_LIBS) $(LOG4CPLUS_LIBS)
libeval_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD) libeval_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)

View File

@@ -283,7 +283,7 @@ TEST_F(EvalContextTest, optionHex) {
checkTokenOption(eval.expression.at(0), 123); checkTokenOption(eval.expression.at(0), 123);
} }
// This test checks that the relay[code].hex can be used in expressions. // This test checks that the relay4[code].hex can be used in expressions.
TEST_F(EvalContextTest, relay4Option) { TEST_F(EvalContextTest, relay4Option) {
EvalContext eval(Option::V4); EvalContext eval(Option::V4);
@@ -301,6 +301,16 @@ TEST_F(EvalContextTest, relay4Option) {
checkTokenEq(tmp3); checkTokenEq(tmp3);
} }
// This test check the relay4[code].exists is supported.
TEST_F(EvalContextTest, relay4Exists) {
EvalContext eval(Option::V4);
EXPECT_NO_THROW(parsed_ = eval.parseString("relay4[13].exists"));
EXPECT_TRUE(parsed_);
ASSERT_EQ(1, eval.expression.size());
checkTokenRelay4(eval.expression.at(0), 13);
}
// Verify that relay4[13] is not usable in v6 // Verify that relay4[13] is not usable in v6
// There will be a separate relay accessor for v6. // There will be a separate relay accessor for v6.
TEST_F(EvalContextTest, relay4Error) { TEST_F(EvalContextTest, relay4Error) {
@@ -520,7 +530,7 @@ TEST_F(EvalContextTest, parseErrors) {
"<string>:1.9: syntax error, unexpected end of file"); "<string>:1.9: syntax error, unexpected end of file");
checkError("('foo' == 'bar'", checkError("('foo' == 'bar'",
"<string>:1.16: syntax error, unexpected end of file, " "<string>:1.16: syntax error, unexpected end of file, "
"expecting and or or or )"); "expecting ) or and or or");
checkError("('foo' == 'bar') ''", checkError("('foo' == 'bar') ''",
"<string>:1.18-19: syntax error, unexpected constant string, " "<string>:1.18-19: syntax error, unexpected constant string, "
"expecting end of file"); "expecting end of file");

View File

@@ -441,8 +441,8 @@ TEST_F(TokenTest, optionExistsString6) {
EXPECT_EQ("true", values_.top()); EXPECT_EQ("true", values_.top());
} }
// This test checks that the existing relay option can be found. // This test checks that the existing relay4 option can be found.
TEST_F(TokenTest, relayOption) { TEST_F(TokenTest, relay4Option) {
// Insert relay option with sub-options 1 and 13 // Insert relay option with sub-options 1 and 13
insertRelay4Option(); insertRelay4Option();
@@ -456,14 +456,14 @@ TEST_F(TokenTest, relayOption) {
// we should have one value on the stack // we should have one value on the stack
ASSERT_EQ(1, values_.size()); ASSERT_EQ(1, values_.size());
// The option should be found and relay[13] should evaluate to the // The option should be found and relay4[13] should evaluate to the
// content of that sub-option, i.e. "thirteen" // content of that sub-option, i.e. "thirteen"
EXPECT_EQ("thirteen", values_.top()); EXPECT_EQ("thirteen", values_.top());
} }
// This test checks that the code properly handles cases when // This test checks that the code properly handles cases when
// there is a RAI option, but there's no requested sub-option. // there is a RAI option, but there's no requested sub-option.
TEST_F(TokenTest, relayOptionNoSuboption) { TEST_F(TokenTest, relay4OptionNoSuboption) {
// Insert relay option with sub-options 1 and 13 // Insert relay option with sub-options 1 and 13
insertRelay4Option(); insertRelay4Option();
@@ -484,7 +484,7 @@ TEST_F(TokenTest, relayOptionNoSuboption) {
// This test checks that the code properly handles cases when // This test checks that the code properly handles cases when
// there's no RAI option at all. // there's no RAI option at all.
TEST_F(TokenTest, relayOptionNoRai) { TEST_F(TokenTest, relay4OptionNoRai) {
// We didn't call insertRelay4Option(), so there's no RAI option. // We didn't call insertRelay4Option(), so there's no RAI option.
@@ -504,7 +504,7 @@ TEST_F(TokenTest, relayOptionNoRai) {
// This test checks that only the RAI is searched for the requested // This test checks that only the RAI is searched for the requested
// sub-option. // sub-option.
TEST_F(TokenTest, relayRAIOnly) { TEST_F(TokenTest, relay4RAIOnly) {
// Insert relay option with sub-options 1 and 13 // Insert relay option with sub-options 1 and 13
insertRelay4Option(); insertRelay4Option();
@@ -542,6 +542,20 @@ TEST_F(TokenTest, relayRAIOnly) {
EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_)); EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_));
ASSERT_EQ(1, values_.size()); ASSERT_EQ(1, values_.size());
EXPECT_EQ("", values_.top()); EXPECT_EQ("", values_.top());
// Try to check option 1. It should return "true"
clearStack();
ASSERT_NO_THROW(t_.reset(new TokenRelay4Option(1, TokenOption::EXISTS)));
EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_));
ASSERT_EQ(1, values_.size());
EXPECT_EQ("true", values_.top());
// Try to check option 70. It should return "false"
clearStack();
ASSERT_NO_THROW(t_.reset(new TokenRelay4Option(70, TokenOption::EXISTS)));
EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_));
ASSERT_EQ(1, values_.size());
EXPECT_EQ("false", values_.top());
} }
// This test checks if a token representing an == operator is able to // This test checks if a token representing an == operator is able to