mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 04:57:52 +00:00
[master] Merged trac4313 (relay4[xxx].exists)
This commit is contained in:
commit
1de28b24e5
@ -204,6 +204,11 @@ sub-option with code "code" from the DHCPv4 Relay Agent Information option
|
||||
expression is allowed in DHCPv4 only.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
"relay4" shares the same representation types than "option", for
|
||||
instance "relay4[code].exists" is supported.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<table frame="all" id="classification-expressions-list">
|
||||
<title>List of Classification Expressions</title>
|
||||
|
@ -32,10 +32,14 @@ nodist_libkea_eval_la_SOURCES = eval_messages.h eval_messages.cc
|
||||
|
||||
libkea_eval_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||
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/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/exceptions/libkea-exceptions.la
|
||||
libkea_eval_la_LIBADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS)
|
||||
|
||||
libkea_eval_la_LDFLAGS = -no-undefined -version-info 3:0:0
|
||||
|
@ -480,11 +480,11 @@ static yyconst flex_int16_t yy_acclist[128] =
|
||||
26,16390, 25, 26,16390, 25, 26,16390, 1, 2,
|
||||
3, 5, 7,16390, 8198,16390,16390,16390,16390,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, 15,16390, 11,16390, 8,16390,
|
||||
12,16390,16390,16390,16390, 13,16390
|
||||
16390,16390,16390,16390,16390,16390,16390, 10,16390,16390,
|
||||
16390,16390,16390,16390, 15,16390, 12,16390, 8,16390,
|
||||
9,16390,16390,16390,16390, 13,16390
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_accept[82] =
|
||||
@ -1203,22 +1203,22 @@ return isc::eval::EvalParser::make_OPTION(loc);
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 127 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_TEXT(loc);
|
||||
return isc::eval::EvalParser::make_RELAY4(loc);
|
||||
YY_BREAK
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
#line 128 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_HEX(loc);
|
||||
return isc::eval::EvalParser::make_TEXT(loc);
|
||||
YY_BREAK
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 129 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_EXISTS(loc);
|
||||
return isc::eval::EvalParser::make_HEX(loc);
|
||||
YY_BREAK
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 130 "lexer.ll"
|
||||
return isc::eval::EvalParser::make_RELAY4(loc);
|
||||
return isc::eval::EvalParser::make_EXISTS(loc);
|
||||
YY_BREAK
|
||||
case 13:
|
||||
YY_RULE_SETUP
|
||||
|
@ -124,10 +124,10 @@ blank [ \t]
|
||||
|
||||
"==" return isc::eval::EvalParser::make_EQUAL(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);
|
||||
"hex" return isc::eval::EvalParser::make_HEX(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);
|
||||
"all" return isc::eval::EvalParser::make_ALL(loc);
|
||||
"concat" return isc::eval::EvalParser::make_CONCAT(loc);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated 20160219
|
||||
// Generated 20160227
|
||||
// A Bison parser, made by GNU Bison 3.0.4.
|
||||
|
||||
// Locations for Bison parsers in C++
|
||||
|
@ -649,34 +649,58 @@ namespace isc { namespace eval {
|
||||
break;
|
||||
|
||||
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 > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 658 "parser.cc" // lalr1.cc:859
|
||||
#line 682 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 10:
|
||||
#line 117 "parser.yy" // lalr1.cc:859
|
||||
case 11:
|
||||
#line 137 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr hex(new TokenHexString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(hex);
|
||||
}
|
||||
#line 667 "parser.cc" // lalr1.cc:859
|
||||
#line 691 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 11:
|
||||
#line 122 "parser.yy" // lalr1.cc:859
|
||||
case 12:
|
||||
#line 142 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr opt(new TokenOption(yystack_[3].value.as< uint16_t > (), yystack_[0].value.as< TokenOption::RepresentationType > ()));
|
||||
ctx.expression.push_back(opt);
|
||||
}
|
||||
#line 676 "parser.cc" // lalr1.cc:859
|
||||
#line 700 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 12:
|
||||
#line 127 "parser.yy" // lalr1.cc:859
|
||||
case 13:
|
||||
#line 147 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
switch (ctx.getUniverse()) {
|
||||
case Option::V4:
|
||||
@ -696,88 +720,88 @@ namespace isc { namespace eval {
|
||||
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;
|
||||
|
||||
case 13:
|
||||
#line 147 "parser.yy" // lalr1.cc:859
|
||||
case 14:
|
||||
#line 167 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr sub(new TokenSubstring());
|
||||
ctx.expression.push_back(sub);
|
||||
}
|
||||
#line 709 "parser.cc" // lalr1.cc:859
|
||||
#line 733 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 14:
|
||||
#line 152 "parser.yy" // lalr1.cc:859
|
||||
case 15:
|
||||
#line 172 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr conc(new TokenConcat());
|
||||
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
|
||||
break;
|
||||
|
||||
case 18:
|
||||
#line 173 "parser.yy" // lalr1.cc:859
|
||||
case 16:
|
||||
#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
|
||||
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:
|
||||
#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 > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 759 "parser.cc" // lalr1.cc:859
|
||||
#line 783 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 20:
|
||||
#line 186 "parser.yy" // lalr1.cc:859
|
||||
case 21:
|
||||
#line 206 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString(yystack_[0].value.as< std::string > ()));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 768 "parser.cc" // lalr1.cc:859
|
||||
#line 792 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
case 21:
|
||||
#line 191 "parser.yy" // lalr1.cc:859
|
||||
case 22:
|
||||
#line 211 "parser.yy" // lalr1.cc:859
|
||||
{
|
||||
TokenPtr str(new TokenString("all"));
|
||||
ctx.expression.push_back(str);
|
||||
}
|
||||
#line 777 "parser.cc" // lalr1.cc:859
|
||||
#line 801 "parser.cc" // lalr1.cc:859
|
||||
break;
|
||||
|
||||
|
||||
#line 781 "parser.cc" // lalr1.cc:859
|
||||
#line 805 "parser.cc" // lalr1.cc:859
|
||||
default:
|
||||
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::yypact_[] =
|
||||
{
|
||||
-2, -12, -4, 3, -2, 14, -2, -14, -14, 39,
|
||||
33, 40, 16, 6, 6, -14, 16, 17, -14, -2,
|
||||
-2, 6, -14, -14, 25, 27, 28, 31, 29, -14,
|
||||
-14, 42, -14, 36, 16, 26, 6, 37, 24, 34,
|
||||
-14, 41, 35, 18, -14, -14, -14, -14, 43, 0,
|
||||
-14, -14, 18, -14, -14, 38, -14
|
||||
-1, -1, -1, 1, 10, 28, 36, -29, -29, 32,
|
||||
0, 41, 29, -29, -7, -7, 17, 17, -29, -1,
|
||||
-1, 17, -29, -29, -29, 38, 39, 42, 43, 37,
|
||||
40, -29, 46, -29, 44, 45, -7, -7, 47, 17,
|
||||
27, 30, 48, 49, -29, 51, 58, -29, -29, -29,
|
||||
-29, -29, -29, 50, 52, -4, -29, 33, 33, -29,
|
||||
-29, 60, -29
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yydefact_[] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 9, 10, 0,
|
||||
2, 0, 0, 0, 0, 4, 0, 0, 1, 0,
|
||||
0, 0, 15, 16, 0, 0, 0, 0, 0, 3,
|
||||
5, 6, 7, 0, 0, 0, 0, 0, 0, 0,
|
||||
19, 0, 0, 0, 17, 18, 8, 11, 0, 0,
|
||||
14, 12, 0, 21, 20, 0, 13
|
||||
0, 0, 0, 0, 0, 0, 0, 10, 11, 0,
|
||||
2, 0, 0, 4, 0, 0, 0, 0, 1, 0,
|
||||
0, 0, 3, 16, 17, 0, 0, 0, 0, 0,
|
||||
0, 5, 6, 7, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 20, 0, 0, 18, 19, 8,
|
||||
12, 9, 13, 0, 0, 0, 15, 0, 0, 22,
|
||||
21, 0, 14
|
||||
};
|
||||
|
||||
const signed char
|
||||
EvalParser::yypgoto_[] =
|
||||
{
|
||||
-14, -14, 12, -13, -10, 19, -14, -14
|
||||
-29, -29, 9, -16, -12, -28, -29, -29
|
||||
};
|
||||
|
||||
const signed char
|
||||
EvalParser::yydefgoto_[] =
|
||||
{
|
||||
-1, 9, 10, 11, 24, 47, 41, 55
|
||||
-1, 9, 10, 11, 25, 50, 45, 61
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yytable_[] =
|
||||
{
|
||||
26, 27, 1, 2, 3, 4, 28, 12, 32, 5,
|
||||
25, 2, 3, 13, 53, 6, 15, 5, 17, 7,
|
||||
14, 8, 54, 42, 39, 19, 20, 7, 44, 8,
|
||||
45, 30, 31, 16, 44, 29, 45, 46, 22, 18,
|
||||
23, 19, 20, 21, 35, 33, 34, 36, 40, 37,
|
||||
19, 38, 43, 50, 48, 0, 56, 49, 52, 0,
|
||||
0, 0, 51
|
||||
29, 30, 1, 26, 2, 33, 19, 20, 3, 4,
|
||||
12, 13, 14, 52, 59, 23, 5, 24, 60, 6,
|
||||
7, 15, 8, 46, 42, 43, 27, 28, 31, 32,
|
||||
52, 16, 18, 22, 5, 19, 20, 6, 7, 17,
|
||||
8, 47, 48, 49, 47, 48, 51, 47, 48, 21,
|
||||
34, 35, 19, 36, 37, 0, 38, 40, 41, 39,
|
||||
53, 54, 56, 57, 62, 58, 0, 0, 0, 44,
|
||||
55
|
||||
};
|
||||
|
||||
const signed char
|
||||
EvalParser::yycheck_[] =
|
||||
{
|
||||
13, 14, 4, 5, 6, 7, 16, 19, 21, 11,
|
||||
4, 5, 6, 17, 14, 17, 4, 11, 6, 21,
|
||||
17, 23, 22, 36, 34, 8, 9, 21, 10, 23,
|
||||
12, 19, 20, 19, 10, 18, 12, 13, 22, 0,
|
||||
24, 8, 9, 3, 16, 20, 19, 16, 22, 20,
|
||||
8, 15, 15, 18, 20, -1, 18, 16, 15, -1,
|
||||
-1, -1, 43
|
||||
16, 17, 3, 15, 5, 21, 6, 7, 9, 10,
|
||||
1, 2, 11, 41, 18, 22, 17, 24, 22, 20,
|
||||
21, 11, 23, 39, 36, 37, 9, 10, 19, 20,
|
||||
58, 3, 0, 4, 17, 6, 7, 20, 21, 3,
|
||||
23, 14, 15, 16, 14, 15, 16, 14, 15, 8,
|
||||
12, 12, 6, 11, 11, -1, 19, 13, 13, 19,
|
||||
12, 12, 4, 13, 4, 13, -1, -1, -1, 22,
|
||||
19
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yystos_[] =
|
||||
{
|
||||
0, 4, 5, 6, 7, 11, 17, 21, 23, 26,
|
||||
27, 28, 19, 17, 17, 27, 19, 27, 0, 8,
|
||||
9, 3, 22, 24, 29, 4, 28, 28, 29, 18,
|
||||
27, 27, 28, 20, 19, 16, 16, 20, 15, 29,
|
||||
22, 31, 28, 15, 10, 12, 13, 30, 20, 16,
|
||||
18, 30, 15, 14, 22, 32, 18
|
||||
0, 3, 5, 9, 10, 17, 20, 21, 23, 26,
|
||||
27, 28, 27, 27, 11, 11, 3, 3, 0, 6,
|
||||
7, 8, 4, 22, 24, 29, 29, 9, 10, 28,
|
||||
28, 27, 27, 28, 12, 12, 11, 11, 19, 19,
|
||||
13, 13, 29, 29, 22, 31, 28, 14, 15, 16,
|
||||
30, 16, 30, 12, 12, 19, 4, 13, 13, 18,
|
||||
22, 32, 4
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yyr1_[] =
|
||||
{
|
||||
0, 25, 26, 27, 27, 27, 27, 27, 27, 28,
|
||||
28, 28, 28, 28, 28, 29, 29, 30, 30, 31,
|
||||
32, 32
|
||||
0, 25, 26, 27, 27, 27, 27, 27, 27, 27,
|
||||
28, 28, 28, 28, 28, 28, 29, 29, 30, 30,
|
||||
31, 32, 32
|
||||
};
|
||||
|
||||
const unsigned char
|
||||
EvalParser::yyr2_[] =
|
||||
{
|
||||
0, 2, 1, 3, 2, 3, 3, 3, 6, 1,
|
||||
1, 6, 6, 8, 6, 1, 1, 1, 1, 1,
|
||||
1, 1
|
||||
0, 2, 1, 3, 2, 3, 3, 3, 6, 6,
|
||||
1, 1, 6, 6, 8, 6, 1, 1, 1, 1,
|
||||
1, 1, 1
|
||||
};
|
||||
|
||||
|
||||
@ -1128,22 +1157,22 @@ namespace isc { namespace eval {
|
||||
const char*
|
||||
const EvalParser::yytname_[] =
|
||||
{
|
||||
"\"end of file\"", "error", "$undefined", "\"==\"", "\"option\"",
|
||||
"\"substring\"", "\"concat\"", "\"not\"", "\"and\"", "\"or\"",
|
||||
"\"text\"", "\"relay4\"", "\"hex\"", "\"exists\"", "\"all\"", "\".\"",
|
||||
"\",\"", "\"(\"", "\")\"", "\"[\"", "\"]\"", "\"constant string\"",
|
||||
"\"integer\"", "\"constant hexstring\"", "\"option name\"", "$accept",
|
||||
"expression", "bool_expr", "string_expr", "option_code",
|
||||
"option_repr_type", "start_expr", "length_expr", YY_NULLPTR
|
||||
"\"end of file\"", "error", "$undefined", "\"(\"", "\")\"", "\"not\"",
|
||||
"\"and\"", "\"or\"", "\"==\"", "\"option\"", "\"relay4\"", "\"[\"",
|
||||
"\"]\"", "\".\"", "\"text\"", "\"hex\"", "\"exists\"", "\"substring\"",
|
||||
"\"all\"", "\",\"", "\"concat\"", "\"constant string\"", "\"integer\"",
|
||||
"\"constant hexstring\"", "\"option name\"", "$accept", "expression",
|
||||
"bool_expr", "string_expr", "option_code", "option_repr_type",
|
||||
"start_expr", "length_expr", YY_NULLPTR
|
||||
};
|
||||
|
||||
#if YYDEBUG
|
||||
const unsigned char
|
||||
EvalParser::yyrline_[] =
|
||||
{
|
||||
0, 80, 80, 83, 84, 89, 94, 99, 104, 111,
|
||||
116, 121, 126, 146, 151, 158, 162, 168, 172, 178,
|
||||
185, 190
|
||||
0, 80, 80, 83, 84, 89, 94, 99, 104, 109,
|
||||
131, 136, 141, 146, 166, 171, 178, 182, 188, 192,
|
||||
198, 205, 210
|
||||
};
|
||||
|
||||
// Print the state stack on the debug stream.
|
||||
@ -1178,8 +1207,8 @@ namespace isc { namespace eval {
|
||||
|
||||
#line 13 "parser.yy" // lalr1.cc:1167
|
||||
} } // isc::eval
|
||||
#line 1182 "parser.cc" // lalr1.cc:1167
|
||||
#line 197 "parser.yy" // lalr1.cc:1168
|
||||
#line 1211 "parser.cc" // lalr1.cc:1167
|
||||
#line 217 "parser.yy" // lalr1.cc:1168
|
||||
|
||||
void
|
||||
isc::eval::EvalParser::error(const location_type& loc,
|
||||
|
@ -329,24 +329,24 @@ namespace isc { namespace eval {
|
||||
enum yytokentype
|
||||
{
|
||||
TOKEN_END = 0,
|
||||
TOKEN_EQUAL = 258,
|
||||
TOKEN_OPTION = 259,
|
||||
TOKEN_SUBSTRING = 260,
|
||||
TOKEN_CONCAT = 261,
|
||||
TOKEN_NOT = 262,
|
||||
TOKEN_AND = 263,
|
||||
TOKEN_OR = 264,
|
||||
TOKEN_TEXT = 265,
|
||||
TOKEN_RELAY4 = 266,
|
||||
TOKEN_HEX = 267,
|
||||
TOKEN_EXISTS = 268,
|
||||
TOKEN_ALL = 269,
|
||||
TOKEN_DOT = 270,
|
||||
TOKEN_COMA = 271,
|
||||
TOKEN_LPAREN = 272,
|
||||
TOKEN_RPAREN = 273,
|
||||
TOKEN_LBRACKET = 274,
|
||||
TOKEN_RBRACKET = 275,
|
||||
TOKEN_LPAREN = 258,
|
||||
TOKEN_RPAREN = 259,
|
||||
TOKEN_NOT = 260,
|
||||
TOKEN_AND = 261,
|
||||
TOKEN_OR = 262,
|
||||
TOKEN_EQUAL = 263,
|
||||
TOKEN_OPTION = 264,
|
||||
TOKEN_RELAY4 = 265,
|
||||
TOKEN_LBRACKET = 266,
|
||||
TOKEN_RBRACKET = 267,
|
||||
TOKEN_DOT = 268,
|
||||
TOKEN_TEXT = 269,
|
||||
TOKEN_HEX = 270,
|
||||
TOKEN_EXISTS = 271,
|
||||
TOKEN_SUBSTRING = 272,
|
||||
TOKEN_ALL = 273,
|
||||
TOKEN_COMA = 274,
|
||||
TOKEN_CONCAT = 275,
|
||||
TOKEN_STRING = 276,
|
||||
TOKEN_INTEGER = 277,
|
||||
TOKEN_HEXSTRING = 278,
|
||||
@ -467,19 +467,11 @@ namespace isc { namespace eval {
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_EQUAL (const location_type& l);
|
||||
make_LPAREN (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_OPTION (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_SUBSTRING (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_CONCAT (const location_type& l);
|
||||
make_RPAREN (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
@ -495,12 +487,32 @@ namespace isc { namespace eval {
|
||||
|
||||
static inline
|
||||
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
|
||||
symbol_type
|
||||
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
|
||||
symbol_type
|
||||
make_HEX (const location_type& l);
|
||||
@ -511,11 +523,11 @@ namespace isc { namespace eval {
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_ALL (const location_type& l);
|
||||
make_SUBSTRING (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_DOT (const location_type& l);
|
||||
make_ALL (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
@ -523,19 +535,7 @@ namespace isc { namespace eval {
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_LPAREN (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);
|
||||
make_CONCAT (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
@ -758,7 +758,7 @@ namespace isc { namespace eval {
|
||||
enum
|
||||
{
|
||||
yyeof_ = 0,
|
||||
yylast_ = 62, ///< Last index in yytable_.
|
||||
yylast_ = 70, ///< Last index in yytable_.
|
||||
yynnts_ = 8, ///< Number of nonterminal symbols.
|
||||
yyfinal_ = 18, ///< Termination state number.
|
||||
yyterror_ = 1,
|
||||
@ -1073,27 +1073,15 @@ namespace isc { namespace eval {
|
||||
}
|
||||
|
||||
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::make_OPTION (const location_type& l)
|
||||
EvalParser::make_RPAREN (const location_type& l)
|
||||
{
|
||||
return symbol_type (token::TOKEN_OPTION, 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);
|
||||
return symbol_type (token::TOKEN_RPAREN, l);
|
||||
}
|
||||
|
||||
EvalParser::symbol_type
|
||||
@ -1115,9 +1103,15 @@ namespace isc { namespace eval {
|
||||
}
|
||||
|
||||
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
|
||||
@ -1126,6 +1120,30 @@ namespace isc { namespace eval {
|
||||
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::make_HEX (const location_type& l)
|
||||
{
|
||||
@ -1139,15 +1157,15 @@ namespace isc { namespace eval {
|
||||
}
|
||||
|
||||
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::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
|
||||
@ -1157,27 +1175,9 @@ namespace isc { namespace eval {
|
||||
}
|
||||
|
||||
EvalParser::symbol_type
|
||||
EvalParser::make_LPAREN (const location_type& l)
|
||||
EvalParser::make_CONCAT (const location_type& l)
|
||||
{
|
||||
return symbol_type (token::TOKEN_LPAREN, 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);
|
||||
return symbol_type (token::TOKEN_CONCAT, l);
|
||||
}
|
||||
|
||||
EvalParser::symbol_type
|
||||
|
@ -34,26 +34,27 @@ using namespace isc::eval;
|
||||
}
|
||||
|
||||
%define api.token.prefix {TOKEN_}
|
||||
// Tokens in an order which makes sense and related to the intented use.
|
||||
%token
|
||||
END 0 "end of file"
|
||||
EQUAL "=="
|
||||
OPTION "option"
|
||||
SUBSTRING "substring"
|
||||
CONCAT "concat"
|
||||
LPAREN "("
|
||||
RPAREN ")"
|
||||
NOT "not"
|
||||
AND "and"
|
||||
OR "or"
|
||||
TEXT "text"
|
||||
EQUAL "=="
|
||||
OPTION "option"
|
||||
RELAY4 "relay4"
|
||||
HEX "hex"
|
||||
EXISTS "exists"
|
||||
ALL "all"
|
||||
DOT "."
|
||||
COMA ","
|
||||
LPAREN "("
|
||||
RPAREN ")"
|
||||
LBRACKET "["
|
||||
RBRACKET "]"
|
||||
DOT "."
|
||||
TEXT "text"
|
||||
HEX "hex"
|
||||
EXISTS "exists"
|
||||
SUBSTRING "substring"
|
||||
ALL "all"
|
||||
COMA ","
|
||||
CONCAT "concat"
|
||||
;
|
||||
|
||||
%token <std::string> STRING "constant string"
|
||||
@ -106,6 +107,26 @@ bool_expr : "(" bool_expr ")"
|
||||
TokenPtr opt(new TokenOption($3, TokenOption::EXISTS));
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated 20160219
|
||||
// Generated 20160227
|
||||
// A Bison parser, made by GNU Bison 3.0.4.
|
||||
|
||||
// Positions for Bison parsers in C++
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated 20160219
|
||||
// Generated 20160227
|
||||
// A Bison parser, made by GNU Bison 3.0.4.
|
||||
|
||||
// Stack handling for Bison parsers in C++
|
||||
|
@ -36,7 +36,12 @@ libeval_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
|
||||
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/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/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 += $(CRYPTO_LIBS) $(LOG4CPLUS_LIBS)
|
||||
libeval_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD)
|
||||
|
@ -72,24 +72,38 @@ public:
|
||||
}
|
||||
|
||||
/// @brief checks if the given token is an option with the expected code
|
||||
void checkTokenOption(const TokenPtr& token, uint16_t expected_code) {
|
||||
/// and representation type
|
||||
/// @param token token to be checked
|
||||
/// @param expected_code expected option code
|
||||
/// @param expected_repr expected representation (text, hex, exists)
|
||||
void checkTokenOption(const TokenPtr& token,
|
||||
uint16_t expected_code,
|
||||
TokenOption::RepresentationType expected_repr) {
|
||||
ASSERT_TRUE(token);
|
||||
boost::shared_ptr<TokenOption> opt =
|
||||
boost::dynamic_pointer_cast<TokenOption>(token);
|
||||
ASSERT_TRUE(opt);
|
||||
|
||||
EXPECT_EQ(expected_code, opt->getCode());
|
||||
EXPECT_EQ(expected_repr, opt->getRepresentation());
|
||||
}
|
||||
|
||||
/// @brief check if the given token is relay4 with the expected code
|
||||
void checkTokenRelay4(const TokenPtr& token, uint16_t code) {
|
||||
/// and representation type
|
||||
/// @param token token to be checked
|
||||
/// @param expected_code expected option code
|
||||
/// @param expected_repr expected representation (text, hex, exists)
|
||||
void checkTokenRelay4(const TokenPtr& token,
|
||||
uint16_t expected_code,
|
||||
TokenOption::RepresentationType expected_repr) {
|
||||
ASSERT_TRUE(token);
|
||||
boost::shared_ptr<TokenRelay4Option> relay4 =
|
||||
boost::dynamic_pointer_cast<TokenRelay4Option>(token);
|
||||
EXPECT_TRUE(relay4);
|
||||
|
||||
if (relay4) {
|
||||
EXPECT_EQ(code, relay4->getCode());
|
||||
EXPECT_EQ(expected_code, relay4->getCode());
|
||||
EXPECT_EQ(expected_repr, relay4->getRepresentation());
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +240,7 @@ TEST_F(EvalContextTest, option) {
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("option[123].text == 'foo'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
checkTokenOption(eval.expression.at(0), 123);
|
||||
checkTokenOption(eval.expression.at(0), 123, TokenOption::TEXTUAL);
|
||||
}
|
||||
|
||||
// Test parsing of an option identified by name.
|
||||
@ -237,7 +251,7 @@ TEST_F(EvalContextTest, optionWithName) {
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("option[host-name].text == 'foo'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
checkTokenOption(eval.expression.at(0), 12);
|
||||
checkTokenOption(eval.expression.at(0), 12, TokenOption::TEXTUAL);
|
||||
}
|
||||
|
||||
// Test parsing of an option existence
|
||||
@ -247,7 +261,7 @@ TEST_F(EvalContextTest, optionExists) {
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("option[100].exists"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
ASSERT_EQ(1, eval.expression.size());
|
||||
checkTokenOption(eval.expression.at(0), 100);
|
||||
checkTokenOption(eval.expression.at(0), 100, TokenOption::EXISTS);
|
||||
}
|
||||
|
||||
// Test checking that whitespace can surround option name.
|
||||
@ -258,7 +272,7 @@ TEST_F(EvalContextTest, optionWithNameAndWhitespace) {
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("option[ host-name ].text == 'foo'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
checkTokenOption(eval.expression.at(0), 12);
|
||||
checkTokenOption(eval.expression.at(0), 12, TokenOption::TEXTUAL);
|
||||
}
|
||||
|
||||
// Test checking that newlines can surround option name.
|
||||
@ -270,7 +284,7 @@ TEST_F(EvalContextTest, optionWithNameAndNewline) {
|
||||
eval.parseString("option[\n host-name \n ].text == \n'foo'"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
checkTokenOption(eval.expression.at(0), 12);
|
||||
checkTokenOption(eval.expression.at(0), 12, TokenOption::TEXTUAL);
|
||||
}
|
||||
|
||||
// Test parsing of an option represented as hexadecimal string.
|
||||
@ -280,10 +294,10 @@ TEST_F(EvalContextTest, optionHex) {
|
||||
EXPECT_NO_THROW(parsed_ = eval.parseString("option[123].hex == 0x666F6F"));
|
||||
EXPECT_TRUE(parsed_);
|
||||
ASSERT_EQ(3, eval.expression.size());
|
||||
checkTokenOption(eval.expression.at(0), 123);
|
||||
checkTokenOption(eval.expression.at(0), 123, TokenOption::HEXADECIMAL);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
||||
EvalContext eval(Option::V4);
|
||||
@ -296,11 +310,21 @@ TEST_F(EvalContextTest, relay4Option) {
|
||||
TokenPtr tmp2 = eval.expression.at(1);
|
||||
TokenPtr tmp3 = eval.expression.at(2);
|
||||
|
||||
checkTokenRelay4(tmp1, 13);
|
||||
checkTokenRelay4(tmp1, 13, TokenOption::HEXADECIMAL);
|
||||
checkTokenString(tmp2, "thirteen");
|
||||
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, TokenOption::EXISTS);
|
||||
}
|
||||
|
||||
// Verify that relay4[13] is not usable in v6
|
||||
// There will be a separate relay accessor for v6.
|
||||
TEST_F(EvalContextTest, relay4Error) {
|
||||
@ -520,7 +544,7 @@ TEST_F(EvalContextTest, parseErrors) {
|
||||
"<string>:1.9: syntax error, unexpected end of file");
|
||||
checkError("('foo' == 'bar'",
|
||||
"<string>:1.16: syntax error, unexpected end of file, "
|
||||
"expecting and or or or )");
|
||||
"expecting ) or and or or");
|
||||
checkError("('foo' == 'bar') ''",
|
||||
"<string>:1.18-19: syntax error, unexpected constant string, "
|
||||
"expecting end of file");
|
||||
|
@ -441,8 +441,8 @@ TEST_F(TokenTest, optionExistsString6) {
|
||||
EXPECT_EQ("true", values_.top());
|
||||
}
|
||||
|
||||
// This test checks that the existing relay option can be found.
|
||||
TEST_F(TokenTest, relayOption) {
|
||||
// This test checks that the existing relay4 option can be found.
|
||||
TEST_F(TokenTest, relay4Option) {
|
||||
|
||||
// Insert relay option with sub-options 1 and 13
|
||||
insertRelay4Option();
|
||||
@ -456,14 +456,14 @@ TEST_F(TokenTest, relayOption) {
|
||||
// we should have one value on the stack
|
||||
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"
|
||||
EXPECT_EQ("thirteen", values_.top());
|
||||
}
|
||||
|
||||
// This test checks that the code properly handles cases when
|
||||
// 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
|
||||
insertRelay4Option();
|
||||
@ -484,7 +484,7 @@ TEST_F(TokenTest, relayOptionNoSuboption) {
|
||||
|
||||
// This test checks that the code properly handles cases when
|
||||
// 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.
|
||||
|
||||
@ -504,7 +504,7 @@ TEST_F(TokenTest, relayOptionNoRai) {
|
||||
|
||||
// This test checks that only the RAI is searched for the requested
|
||||
// sub-option.
|
||||
TEST_F(TokenTest, relayRAIOnly) {
|
||||
TEST_F(TokenTest, relay4RAIOnly) {
|
||||
|
||||
// Insert relay option with sub-options 1 and 13
|
||||
insertRelay4Option();
|
||||
@ -542,6 +542,20 @@ TEST_F(TokenTest, relayRAIOnly) {
|
||||
EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_));
|
||||
ASSERT_EQ(1, values_.size());
|
||||
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
|
||||
|
@ -224,9 +224,9 @@ TokenNot::evaluate(const Pkt& /*pkt*/, ValueStack& values) {
|
||||
bool val = toBool(op);
|
||||
|
||||
if (!val) {
|
||||
values.push("true");
|
||||
values.push("true");
|
||||
} else {
|
||||
values.push("false");
|
||||
values.push("false");
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,9 +246,9 @@ TokenAnd::evaluate(const Pkt& /*pkt*/, ValueStack& values) {
|
||||
bool val2 = toBool(op2);
|
||||
|
||||
if (val1 && val2) {
|
||||
values.push("true");
|
||||
values.push("true");
|
||||
} else {
|
||||
values.push("false");
|
||||
values.push("false");
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,8 +268,8 @@ TokenOr::evaluate(const Pkt& /*pkt*/, ValueStack& values) {
|
||||
bool val2 = toBool(op2);
|
||||
|
||||
if (val1 || val2) {
|
||||
values.push("true");
|
||||
values.push("true");
|
||||
} else {
|
||||
values.push("false");
|
||||
values.push("false");
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// The order where Token subtypes are declared should be:
|
||||
/// - literal terminals
|
||||
/// - option & co
|
||||
/// - pkt & co
|
||||
/// - ==
|
||||
/// - substring & co
|
||||
/// - not, and, or
|
||||
|
||||
/// @brief Token representing a constant string
|
||||
///
|
||||
/// This token holds value of a constant string, e.g. it represents
|
||||
@ -203,6 +211,16 @@ public:
|
||||
return (option_code_);
|
||||
}
|
||||
|
||||
/// @brief Returns representation-type
|
||||
///
|
||||
/// This method is used in testing to determine if the parser had
|
||||
/// instantiated TokenOption with correct parameters.
|
||||
///
|
||||
/// @return representation-type of the option this token expects to use.
|
||||
RepresentationType getRepresentation() const {
|
||||
return (representation_type_);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// @brief Attempts to retrieve an option
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user