Commit 97aaee6e authored by Francis Dupont's avatar Francis Dupont
Browse files

[4204fd] Reverted hex->bin change

parent c4cd450f
......@@ -161,7 +161,7 @@
<row><entry>Hex String</entry><entry>0XABCD</entry><entry>A hexadecimal string</entry></row>
<row><entry>Integer</entry><entry>123</entry><entry>An integer value</entry></row>
<row><entry>Option Text</entry><entry>option[code].text</entry><entry>The value of the option with code "code" from the packet as text</entry></row>
<row><entry>Option Bin</entry><entry>option[code].bin</entry><entry>The value of the option with code "code" from the packet as binary</entry></row>
<row><entry>Option Hex</entry><entry>option[code].hex</entry><entry>The value of the option with code "code" from the packet as hex</entry></row>
</tbody>
</tgroup>
</table>
......@@ -178,8 +178,8 @@
<para>
"option[code]" extracts the value of the option with the given code
from the incoming packet. If the packet doesn't contain the option, it
returns the empty string. The string can be presented as text or binary
with the ".text" or ".bin" modifiers. In both cases only the payload
returns the empty string. The string can be presented as text or hex
with the ".text" or ".hex" modifiers. In both cases only the payload
is presented; the type code and length fields are not included.
</para>
......@@ -297,7 +297,7 @@
"client-classes": [<userinput>
{
"name": "Client_enterprise",
"test": "substring(option[2].bin,0,6) == 0x0002AABBCCDD'",
"test": "substring(option[2].hex,0,6) == 0x0002AABBCCDD'",
"option-data": [
{
"name": "dns-servers",
......@@ -370,7 +370,7 @@
"client-classes": [
{
"name": "Client_enterprise",
"test": "substring(option[2].bin,0,6) == 0x0002AABBCCDD'",
"test": "substring(option[2].hex,0,6) == 0x0002AABBCCDD'",
"option-data": [
{
"name": "dns-servers",
......
......@@ -1615,7 +1615,7 @@ should include options from the isc option space:
"client-classes": [
{<userinput>
"name": "Client_enterprise",
"test": "substring(option[2].bin,0,6) == 0x0002AABBCCDD'",
"test": "substring(option[2].hex,0,6) == 0x0002AABBCCDD'",
"option-data": [
{
"name": "dns-servers",
......
......@@ -85,9 +85,9 @@
19. TokenPtr opt(new TokenOption($3, TokenOption::TEXTUAL));
20. ctx.expression.push_back(opt);
21. }
22. | OPTION '[' INTEGER ']' DOT BIN
22. | OPTION '[' INTEGER ']' DOT HEX
23. {
24. TokenPtr opt(new TokenOption($3, TokenOption::BINARY));
24. TokenPtr opt(new TokenOption($3, TokenOption::HEXADECIMAL));
25. ctx.expression.push_back(opt);
26. }
27. ;
......@@ -99,7 +99,7 @@ single token or an expression "token == token" (EQUAL has been defined as
"==" elsewhere). Token is further
defined in lines 7-22: it may either be a string (lines 7-11),
a hex string (lines 12-16), option in the textual format (lines 17-21)
or option in the binary format (lines 22-26).
or option in a hexadecimal format (lines 22-26).
When the actual case is determined, the respective C++ action
is executed. For example, if the token is a string, the TokenString class is
instantiated with the appropriate value and put onto the expression vector.
......
......@@ -514,8 +514,8 @@ static yyconst flex_int32_t yy_ec[256] =
14, 14, 14, 14, 14, 14, 14, 15, 14, 14,
16, 1, 17, 1, 18, 1, 19, 20, 13, 13,
21, 13, 22, 14, 23, 14, 14, 24, 14, 25,
26, 27, 14, 28, 29, 30, 31, 14, 14, 32,
21, 13, 22, 23, 24, 14, 14, 25, 14, 26,
27, 28, 14, 29, 30, 31, 32, 14, 14, 33,
14, 14, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
......@@ -533,22 +533,22 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[33] =
static yyconst flex_int32_t yy_meta[34] =
{ 0,
1, 2, 3, 1, 1, 1, 1, 2, 1, 4,
4, 1, 4, 2, 2, 1, 2, 2, 4, 4,
4, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2
2, 2, 2
} ;
static yyconst flex_int16_t yy_base[60] =
{ 0,
0, 0, 113, 114, 110, 108, 106, 114, 114, 114,
23, 114, 25, 27, 97, 37, 114, 114, 56, 18,
19, 20, 26, 106, 104, 102, 114, 38, 0, 114,
50, 51, 81, 114, 80, 35, 32, 41, 39, 0,
79, 78, 46, 48, 52, 55, 54, 76, 61, 59,
73, 65, 66, 70, 69, 114, 94, 97, 62
0, 0, 114, 115, 111, 109, 107, 115, 115, 115,
24, 115, 26, 28, 98, 38, 115, 115, 58, 22,
17, 19, 27, 107, 105, 103, 115, 39, 0, 115,
51, 52, 81, 115, 79, 32, 33, 42, 38, 0,
76, 72, 48, 49, 53, 55, 56, 71, 60, 63,
66, 65, 68, 73, 45, 115, 98, 101, 57
} ;
static yyconst flex_int16_t yy_def[60] =
......@@ -561,44 +561,44 @@ static yyconst flex_int16_t yy_def[60] =
19, 19, 19, 19, 19, 0, 56, 56, 56
} ;
static yyconst flex_int16_t yy_nxt[147] =
static yyconst flex_int16_t yy_nxt[149] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 16, 16, 17, 18, 4, 19, 20,
16, 16, 16, 16, 16, 21, 16, 16, 22, 23,
16, 16, 28, 28, 28, 28, 28, 28, 31, 29,
36, 33, 33, 33, 32, 37, 39, 28, 28, 33,
38, 31, 56, 34, 32, 33, 29, 31, 33, 42,
44, 43, 33, 32, 33, 40, 34, 56, 46, 33,
45, 33, 34, 32, 33, 33, 47, 33, 33, 35,
49, 48, 33, 50, 33, 51, 52, 53, 33, 33,
54, 55, 33, 33, 26, 26, 33, 26, 33, 33,
33, 33, 33, 41, 33, 27, 25, 24, 30, 27,
25, 24, 56, 3, 56, 56, 56, 56, 56, 56,
14, 15, 16, 16, 16, 17, 18, 4, 19, 16,
16, 16, 20, 16, 16, 16, 21, 16, 16, 22,
23, 16, 16, 28, 28, 28, 28, 28, 28, 31,
29, 33, 36, 33, 37, 32, 33, 39, 28, 28,
38, 33, 31, 56, 34, 32, 33, 33, 29, 31,
40, 44, 33, 43, 42, 32, 33, 34, 56, 33,
45, 46, 33, 33, 34, 32, 33, 33, 47, 33,
33, 49, 35, 48, 33, 51, 50, 33, 53, 33,
33, 52, 33, 54, 55, 33, 33, 33, 26, 26,
33, 26, 33, 41, 33, 33, 27, 25, 24, 30,
27, 25, 24, 56, 3, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56
56, 56, 56, 56, 56, 56, 56, 56
} ;
static yyconst flex_int16_t yy_chk[147] =
static yyconst flex_int16_t yy_chk[149] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 11, 11, 13, 13, 14, 14, 16, 13,
20, 20, 21, 22, 16, 21, 23, 28, 28, 23,
22, 31, 32, 16, 16, 37, 13, 19, 36, 36,
38, 37, 39, 19, 38, 59, 31, 32, 43, 43,
39, 44, 19, 19, 32, 45, 44, 47, 46, 19,
46, 45, 50, 47, 49, 49, 50, 52, 52, 53,
53, 54, 55, 54, 57, 57, 51, 57, 58, 48,
58, 42, 41, 35, 33, 26, 25, 24, 15, 7,
6, 5, 3, 56, 56, 56, 56, 56, 56, 56,
1, 1, 1, 11, 11, 13, 13, 14, 14, 16,
13, 21, 20, 22, 21, 16, 20, 23, 28, 28,
22, 23, 31, 32, 16, 16, 36, 37, 13, 19,
59, 38, 39, 37, 36, 19, 38, 31, 32, 55,
39, 43, 43, 44, 19, 19, 32, 45, 44, 46,
47, 46, 19, 45, 49, 49, 47, 50, 52, 52,
51, 50, 53, 53, 54, 48, 42, 54, 57, 57,
41, 57, 58, 35, 58, 33, 26, 25, 24, 15,
7, 6, 5, 3, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
56, 56, 56, 56, 56, 56
56, 56, 56, 56, 56, 56, 56, 56
} ;
/* Table of booleans, true if rule could match eol. */
......@@ -1182,7 +1182,7 @@ return isc::eval::EvalParser::make_TEXT(loc);
case 10:
YY_RULE_SETUP
#line 133 "lexer.ll"
return isc::eval::EvalParser::make_BIN(loc);
return isc::eval::EvalParser::make_HEX(loc);
YY_BREAK
case 11:
YY_RULE_SETUP
......
......@@ -130,7 +130,7 @@ blank [ \t]
"==" return isc::eval::EvalParser::make_EQUAL(loc);
"option" return isc::eval::EvalParser::make_OPTION(loc);
"text" return isc::eval::EvalParser::make_TEXT(loc);
"bin" return isc::eval::EvalParser::make_BIN(loc);
"hex" return isc::eval::EvalParser::make_HEX(loc);
"substring" return isc::eval::EvalParser::make_SUBSTRING(loc);
"all" return isc::eval::EvalParser::make_ALL(loc);
"." return isc::eval::EvalParser::make_DOT(loc);
......
......@@ -643,7 +643,7 @@ namespace isc { namespace eval {
#line 134 "parser.yy" // lalr1.cc:859
{
uint16_t numeric_code = convert_option_code(yystack_[3].value.as< std::string > (), yystack_[3].location, ctx);
TokenPtr opt(new TokenOption(numeric_code, TokenOption::BINARY));
TokenPtr opt(new TokenOption(numeric_code, TokenOption::HEXADECIMAL));
ctx.expression.push_back(opt);
}
#line 650 "parser.cc" // lalr1.cc:859
......@@ -673,7 +673,7 @@ namespace isc { namespace eval {
// This may result in exception if the specified
// name is unknown.
TokenPtr opt(new TokenOption(yystack_[3].value.as< std::string > (), option_universe,
TokenOption::BINARY));
TokenOption::HEXADECIMAL));
ctx.expression.push_back(opt);
} catch (const isc::BadValue& ex) {
......@@ -1058,7 +1058,7 @@ namespace isc { namespace eval {
const EvalParser::yytname_[] =
{
"\"end of file\"", "error", "$undefined", "\"==\"", "\"option\"",
"\"substring\"", "\"text\"", "\"bin\"", "\"all\"", "\".\"", "\",\"",
"\"substring\"", "\"text\"", "\"hex\"", "\"all\"", "\".\"", "\",\"",
"\"(\"", "\")\"", "\"[\"", "\"]\"", "\"constant string\"", "\"integer\"",
"\"constant hexstring\"", "\"option name\"", "TOKEN", "$accept",
"expression", "bool_expr", "string_expr", "start_expr", "length_expr", YY_NULLPTR
......
......@@ -328,7 +328,7 @@ namespace isc { namespace eval {
TOKEN_OPTION = 259,
TOKEN_SUBSTRING = 260,
TOKEN_TEXT = 261,
TOKEN_BIN = 262,
TOKEN_HEX = 262,
TOKEN_ALL = 263,
TOKEN_DOT = 264,
TOKEN_COMA = 265,
......@@ -469,7 +469,7 @@ namespace isc { namespace eval {
static inline
symbol_type
make_BIN (const location_type& l);
make_HEX (const location_type& l);
static inline
symbol_type
......@@ -1021,9 +1021,9 @@ namespace isc { namespace eval {
}
EvalParser::symbol_type
EvalParser::make_BIN (const location_type& l)
EvalParser::make_HEX (const location_type& l)
{
return symbol_type (token::TOKEN_BIN, l);
return symbol_type (token::TOKEN_HEX, l);
}
EvalParser::symbol_type
......
......@@ -51,7 +51,7 @@ using namespace isc::eval;
OPTION "option"
SUBSTRING "substring"
TEXT "text"
BIN "bin"
HEX "hex"
ALL "all"
DOT "."
COMA ","
......@@ -130,10 +130,10 @@ string_expr : STRING
TokenPtr opt(new TokenOption(numeric_code, TokenOption::TEXTUAL));
ctx.expression.push_back(opt);
}
| OPTION "[" INTEGER "]" DOT BIN
| OPTION "[" INTEGER "]" DOT HEX
{
uint16_t numeric_code = convert_option_code($3, @3, ctx);
TokenPtr opt(new TokenOption(numeric_code, TokenOption::BINARY));
TokenPtr opt(new TokenOption(numeric_code, TokenOption::HEXADECIMAL));
ctx.expression.push_back(opt);
}
| OPTION "[" OPTION_NAME "]" DOT TEXT
......@@ -149,13 +149,13 @@ string_expr : STRING
ctx.error(@3, ex.what());
}
}
| OPTION "[" OPTION_NAME "]" DOT BIN
| OPTION "[" OPTION_NAME "]" DOT HEX
{
try {
// This may result in exception if the specified
// name is unknown.
TokenPtr opt(new TokenOption($3, option_universe,
TokenOption::BINARY));
TokenOption::HEXADECIMAL));
ctx.expression.push_back(opt);
} catch (const isc::BadValue& ex) {
......
......@@ -227,11 +227,11 @@ TEST_F(EvalContextTest, optionWithNameAndWhitespace) {
checkTokenOption(eval.expression.at(0), 12);
}
// Test parsing of an option represented as binary string.
TEST_F(EvalContextTest, optionBin) {
// Test parsing of an option represented as hexadecimal string.
TEST_F(EvalContextTest, optionHex) {
EvalContext eval(Option::V4);
EXPECT_NO_THROW(parsed_ = eval.parseString("option[123].bin == 0x666F6F"));
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);
......@@ -296,7 +296,7 @@ TEST_F(EvalContextTest, scanParseErrors) {
checkError("option[0ab].text",
"<string>:1.9-10: syntax error, unexpected option name, "
"expecting ]");
checkError("option[ab_].bin", "<string>:1.8: Invalid character: a");
checkError("option[ab_].hex", "<string>:1.8: Invalid character: a");
checkError("substring('foo',12345678901234567890,1)",
"<string>:1.17-36: Failed to convert 12345678901234567890 "
"to an integer.");
......
......@@ -209,13 +209,13 @@ TEST_F(EvaluateTest, packet) {
EXPECT_FALSE(result_);
}
// A test which compares option value represented in binary format.
// A test which compares option value represented in hexadecimal format.
TEST_F(EvaluateTest, optionHex) {
TokenPtr toption;
TokenPtr tstring;
TokenPtr tequal;
ASSERT_NO_THROW(toption.reset(new TokenOption(100, TokenOption::BINARY)));
ASSERT_NO_THROW(toption.reset(new TokenOption(100, TokenOption::HEXADECIMAL)));
e_.push_back(toption);
ASSERT_NO_THROW(tstring.reset(new TokenString("hundred4")));
e_.push_back(tstring);
......
......@@ -325,14 +325,14 @@ TEST_F(TokenTest, optionWithNameString4) {
// This test checks if a token representing option value is able to extract
// the option from an IPv4 packet and properly store its value in a
// binary format.
TEST_F(TokenTest, optionBinString4) {
// hexadecimal format.
TEST_F(TokenTest, optionHexString4) {
TokenPtr found;
TokenPtr not_found;
// The packets we use have option 100 with a string in them.
ASSERT_NO_THROW(found.reset(new TokenOption(100, TokenOption::BINARY)));
ASSERT_NO_THROW(not_found.reset(new TokenOption(101, TokenOption::BINARY)));
ASSERT_NO_THROW(found.reset(new TokenOption(100, TokenOption::HEXADECIMAL)));
ASSERT_NO_THROW(not_found.reset(new TokenOption(101, TokenOption::HEXADECIMAL)));
// This should evaluate to the content of the option 100 (i.e. "hundred4")
ASSERT_NO_THROW(found->evaluate(*pkt4_, values_));
......@@ -354,8 +354,8 @@ TEST_F(TokenTest, optionBinString4) {
// This test checks if a token representing an option identified by name is
// able to extract this option from an IPv4 packet and properly store its
// value in the binary format.
TEST_F(TokenTest, optionWithNameBinString4) {
// value in the hexadecimal format.
TEST_F(TokenTest, optionWithNameHexString4) {
// Create definition of option 100 to provide a mapping between option
// code and option name.
ASSERT_NO_THROW(createOptionDefinitions4());
......@@ -364,7 +364,7 @@ TEST_F(TokenTest, optionWithNameBinString4) {
// map the option name to its code.
TokenPtr token;
ASSERT_NO_THROW(token.reset(new TokenOption("name-hundred4", Option::V4,
TokenOption::BINARY)));
TokenOption::HEXADECIMAL)));
// Evaluate option in the packet.
ASSERT_NO_THROW(token->evaluate(*pkt4_, values_));
......@@ -426,15 +426,15 @@ TEST_F(TokenTest, optionWithNameString6) {
// This test checks if a token representing an option value is able to extract
// the option from an IPv6 packet and properly store its value in binary
// the option from an IPv6 packet and properly store its value in hexadecimal
// format.
TEST_F(TokenTest, optionBinString6) {
TEST_F(TokenTest, optionHexString6) {
TokenPtr found;
TokenPtr not_found;
// The packets we use have option 100 with a string in them.
ASSERT_NO_THROW(found.reset(new TokenOption(100, TokenOption::BINARY)));
ASSERT_NO_THROW(not_found.reset(new TokenOption(101, TokenOption::BINARY)));
ASSERT_NO_THROW(found.reset(new TokenOption(100, TokenOption::HEXADECIMAL)));
ASSERT_NO_THROW(not_found.reset(new TokenOption(101, TokenOption::HEXADECIMAL)));
// This should evaluate to the content of the option 100 (i.e. "hundred6")
ASSERT_NO_THROW(found->evaluate(*pkt6_, values_));
......@@ -456,8 +456,8 @@ TEST_F(TokenTest, optionBinString6) {
// This test checks if a token representing an option identified by name is
// able to extract this option from an IPv6 packet and properly store its
// value in the binary format.
TEST_F(TokenTest, optionWithNameBinString6) {
// value in the hexadecimal format.
TEST_F(TokenTest, optionWithNameHexString6) {
// Create definition of option 100 to provide a mapping between option
// code and option name.
ASSERT_NO_THROW(createOptionDefinitions6());
......@@ -466,7 +466,7 @@ TEST_F(TokenTest, optionWithNameBinString6) {
// map the option name to its code.
TokenPtr token;
ASSERT_NO_THROW(token.reset(new TokenOption("name-hundred6", Option::V6,
TokenOption::BINARY)));
TokenOption::HEXADECIMAL)));
// Evaluate option in the packet.
ASSERT_NO_THROW(token->evaluate(*pkt6_, values_));
......
......@@ -153,13 +153,13 @@ public:
/// @brief Token representation type.
///
/// There are many possible ways in which option can be presented.
/// Currently the textual and binary representations are
/// Currently the textual and hexadecimal representations are
/// supported. The type of representation is specified in the
/// constructor and it affects the value generated by the
/// @c TokenOption::evaluate function.
enum RepresentationType {
TEXTUAL,
BINARY
HEXADECIMAL
};
/// @brief Constructor that takes an option code as a parameter
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment