diff options
Diffstat (limited to 'src/lib/eval')
-rw-r--r-- | src/lib/eval/eval_messages.cc | 12 | ||||
-rw-r--r-- | src/lib/eval/eval_messages.h | 6 | ||||
-rw-r--r-- | src/lib/eval/eval_messages.mes | 36 | ||||
-rw-r--r-- | src/lib/eval/lexer.cc | 444 | ||||
-rw-r--r-- | src/lib/eval/lexer.ll | 6 | ||||
-rw-r--r-- | src/lib/eval/parser.cc | 816 | ||||
-rw-r--r-- | src/lib/eval/parser.h | 264 | ||||
-rw-r--r-- | src/lib/eval/parser.yy | 36 | ||||
-rw-r--r-- | src/lib/eval/tests/context_unittest.cc | 218 | ||||
-rw-r--r-- | src/lib/eval/tests/token_unittest.cc | 130 | ||||
-rw-r--r-- | src/lib/eval/token.cc | 138 | ||||
-rw-r--r-- | src/lib/eval/token.h | 108 |
12 files changed, 1564 insertions, 650 deletions
diff --git a/src/lib/eval/eval_messages.cc b/src/lib/eval/eval_messages.cc index 5b926dc316..d70cd2e8c0 100644 --- a/src/lib/eval/eval_messages.cc +++ b/src/lib/eval/eval_messages.cc @@ -13,6 +13,9 @@ extern const isc::log::MessageID EVAL_DEBUG_EQUAL = "EVAL_DEBUG_EQUAL"; extern const isc::log::MessageID EVAL_DEBUG_HEXSTRING = "EVAL_DEBUG_HEXSTRING"; extern const isc::log::MessageID EVAL_DEBUG_IFELSE_FALSE = "EVAL_DEBUG_IFELSE_FALSE"; extern const isc::log::MessageID EVAL_DEBUG_IFELSE_TRUE = "EVAL_DEBUG_IFELSE_TRUE"; +extern const isc::log::MessageID EVAL_DEBUG_INT16TOTEXT = "EVAL_DEBUG_INT16TOTEXT"; +extern const isc::log::MessageID EVAL_DEBUG_INT32TOTEXT = "EVAL_DEBUG_INT32TOTEXT"; +extern const isc::log::MessageID EVAL_DEBUG_INT8TOTEXT = "EVAL_DEBUG_INT8TOTEXT"; extern const isc::log::MessageID EVAL_DEBUG_IPADDRESS = "EVAL_DEBUG_IPADDRESS"; extern const isc::log::MessageID EVAL_DEBUG_IPADDRESSTOTEXT = "EVAL_DEBUG_IPADDRESSTOTEXT"; extern const isc::log::MessageID EVAL_DEBUG_MEMBER = "EVAL_DEBUG_MEMBER"; @@ -31,6 +34,9 @@ extern const isc::log::MessageID EVAL_DEBUG_SUBSTRING_RANGE = "EVAL_DEBUG_SUBSTR extern const isc::log::MessageID EVAL_DEBUG_SUB_OPTION = "EVAL_DEBUG_SUB_OPTION"; extern const isc::log::MessageID EVAL_DEBUG_SUB_OPTION_NO_OPTION = "EVAL_DEBUG_SUB_OPTION_NO_OPTION"; extern const isc::log::MessageID EVAL_DEBUG_TOHEXSTRING = "EVAL_DEBUG_TOHEXSTRING"; +extern const isc::log::MessageID EVAL_DEBUG_UINT16TOTEXT = "EVAL_DEBUG_UINT16TOTEXT"; +extern const isc::log::MessageID EVAL_DEBUG_UINT32TOTEXT = "EVAL_DEBUG_UINT32TOTEXT"; +extern const isc::log::MessageID EVAL_DEBUG_UINT8TOTEXT = "EVAL_DEBUG_UINT8TOTEXT"; extern const isc::log::MessageID EVAL_DEBUG_VENDOR_CLASS_DATA = "EVAL_DEBUG_VENDOR_CLASS_DATA"; extern const isc::log::MessageID EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND = "EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND"; extern const isc::log::MessageID EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID = "EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID"; @@ -55,6 +61,9 @@ const char* values[] = { "EVAL_DEBUG_HEXSTRING", "Pushing hex string %1", "EVAL_DEBUG_IFELSE_FALSE", "Popping %1 (false) and %2, leaving %3", "EVAL_DEBUG_IFELSE_TRUE", "Popping %1 (true) and %2, leaving %3", + "EVAL_DEBUG_INT16TOTEXT", "Pushing Int16 %1", + "EVAL_DEBUG_INT32TOTEXT", "Pushing Int32 %1", + "EVAL_DEBUG_INT8TOTEXT", "Pushing Int8 %1", "EVAL_DEBUG_IPADDRESS", "Pushing IPAddress %1", "EVAL_DEBUG_IPADDRESSTOTEXT", "Pushing IPAddress %1", "EVAL_DEBUG_MEMBER", "Checking membership of '%1', pushing result %2", @@ -73,6 +82,9 @@ const char* values[] = { "EVAL_DEBUG_SUB_OPTION", "Pushing option %1 sub-option %2 with value %3", "EVAL_DEBUG_SUB_OPTION_NO_OPTION", "Requested option %1 sub-option %2, but the parent option is not present, pushing result %3", "EVAL_DEBUG_TOHEXSTRING", "Popping binary value %1 and separator %2, pushing result %3", + "EVAL_DEBUG_UINT16TOTEXT", "Pushing UInt16 %1", + "EVAL_DEBUG_UINT32TOTEXT", "Pushing UInt32 %1", + "EVAL_DEBUG_UINT8TOTEXT", "Pushing UInt8 %1", "EVAL_DEBUG_VENDOR_CLASS_DATA", "Data %1 (out of %2 received) in vendor class found, pushing result '%3'", "EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND", "Requested data index %1, but option with enterprise-id %2 has only %3 data tuple(s), pushing result '%4'", "EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID", "Pushing enterprise-id %1 as result 0x%2", diff --git a/src/lib/eval/eval_messages.h b/src/lib/eval/eval_messages.h index 5d3d1cc062..5b7173423b 100644 --- a/src/lib/eval/eval_messages.h +++ b/src/lib/eval/eval_messages.h @@ -14,6 +14,9 @@ extern const isc::log::MessageID EVAL_DEBUG_EQUAL; extern const isc::log::MessageID EVAL_DEBUG_HEXSTRING; extern const isc::log::MessageID EVAL_DEBUG_IFELSE_FALSE; extern const isc::log::MessageID EVAL_DEBUG_IFELSE_TRUE; +extern const isc::log::MessageID EVAL_DEBUG_INT16TOTEXT; +extern const isc::log::MessageID EVAL_DEBUG_INT32TOTEXT; +extern const isc::log::MessageID EVAL_DEBUG_INT8TOTEXT; extern const isc::log::MessageID EVAL_DEBUG_IPADDRESS; extern const isc::log::MessageID EVAL_DEBUG_IPADDRESSTOTEXT; extern const isc::log::MessageID EVAL_DEBUG_MEMBER; @@ -32,6 +35,9 @@ extern const isc::log::MessageID EVAL_DEBUG_SUBSTRING_RANGE; extern const isc::log::MessageID EVAL_DEBUG_SUB_OPTION; extern const isc::log::MessageID EVAL_DEBUG_SUB_OPTION_NO_OPTION; extern const isc::log::MessageID EVAL_DEBUG_TOHEXSTRING; +extern const isc::log::MessageID EVAL_DEBUG_UINT16TOTEXT; +extern const isc::log::MessageID EVAL_DEBUG_UINT32TOTEXT; +extern const isc::log::MessageID EVAL_DEBUG_UINT8TOTEXT; extern const isc::log::MessageID EVAL_DEBUG_VENDOR_CLASS_DATA; extern const isc::log::MessageID EVAL_DEBUG_VENDOR_CLASS_DATA_NOT_FOUND; extern const isc::log::MessageID EVAL_DEBUG_VENDOR_CLASS_ENTERPRISE_ID; diff --git a/src/lib/eval/eval_messages.mes b/src/lib/eval/eval_messages.mes index 0c6006bf21..f65f933c2a 100644 --- a/src/lib/eval/eval_messages.mes +++ b/src/lib/eval/eval_messages.mes @@ -60,6 +60,42 @@ This debug message indicates that the given address string representation is being pushed onto the value stack. This represents either an IPv4 or IPv6 address. +# For use with TokenInt8ToText + +% EVAL_DEBUG_INT8TOTEXT Pushing Int8 %1 +This debug message indicates that the given address string representation is +being pushed onto the value stack. This represents an 8 bits integer. + +# For use with TokenInt16ToText + +% EVAL_DEBUG_INT16TOTEXT Pushing Int16 %1 +This debug message indicates that the given address string representation is +being pushed onto the value stack. This represents a 16 bits integer. + +# For use with TokenInt32ToText + +% EVAL_DEBUG_INT32TOTEXT Pushing Int32 %1 +This debug message indicates that the given address string representation is +being pushed onto the value stack. This represents a 32 bits integer. + +# For use with TokenUInt8ToText + +% EVAL_DEBUG_UINT8TOTEXT Pushing UInt8 %1 +This debug message indicates that the given address string representation is +being pushed onto the value stack. This represents an 8 bits unsigned integer. + +# For use with TokenUInt16ToText + +% EVAL_DEBUG_UINT16TOTEXT Pushing UInt16 %1 +This debug message indicates that the given address string representation is +being pushed onto the value stack. This represents a 16 bits unsigned integer. + +# For use with TokenUInt32ToText + +% EVAL_DEBUG_UINT32TOTEXT Pushing UInt32 %1 +This debug message indicates that the given address string representation is +being pushed onto the value stack. This represents a 32 bits unsigned integer. + # For use with TokenMember % EVAL_DEBUG_MEMBER Checking membership of '%1', pushing result %2 diff --git a/src/lib/eval/lexer.cc b/src/lib/eval/lexer.cc index 5c752033c4..1dbeed694b 100644 --- a/src/lib/eval/lexer.cc +++ b/src/lib/eval/lexer.cc @@ -710,8 +710,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); /* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ (yy_c_buf_p) = yy_cp; /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ -#define YY_NUM_RULES 55 -#define YY_END_OF_BUFFER 56 +#define YY_NUM_RULES 61 +#define YY_END_OF_BUFFER 62 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -719,33 +719,38 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[222] = +static const flex_int16_t yy_accept[274] = { 0, - 0, 0, 56, 54, 1, 2, 54, 48, 49, 53, - 52, 54, 47, 5, 5, 54, 54, 54, 54, 50, - 51, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 1, 2, - 0, 3, 5, 0, 5, 0, 0, 0, 0, 7, - 8, 0, 0, 0, 0, 6, 0, 0, 0, 0, + 0, 0, 62, 60, 1, 2, 60, 54, 55, 59, + 58, 60, 53, 5, 5, 60, 60, 60, 60, 56, + 57, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 1, + 2, 0, 3, 5, 0, 5, 0, 0, 0, 0, + 7, 8, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, - 7, 0, 38, 44, 0, 0, 0, 20, 0, 0, - - 0, 15, 0, 0, 0, 0, 21, 0, 23, 0, - 0, 43, 0, 0, 17, 0, 0, 19, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, - 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, - 0, 22, 30, 0, 0, 0, 14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 25, 18, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 26, 39, 0, 16, 27, 0, - 40, 0, 46, 0, 9, 0, 10, 11, 29, 0, - 0, 33, 28, 7, 0, 0, 0, 0, 31, 0, - - 0, 32, 0, 0, 0, 0, 13, 12, 0, 0, - 0, 0, 41, 37, 0, 42, 36, 0, 0, 34, - 0 + 0, 0, 4, 7, 0, 38, 50, 0, 0, 0, + + 20, 0, 0, 0, 15, 0, 0, 0, 0, 0, + 21, 0, 23, 0, 0, 49, 0, 0, 17, 0, + 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 35, 0, 0, 0, 0, 24, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, + 30, 0, 0, 0, 14, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 25, 18, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, + 39, 0, 16, 27, 0, 40, 0, 0, 0, 0, + + 52, 0, 9, 0, 10, 11, 29, 0, 0, 0, + 0, 0, 33, 28, 7, 0, 0, 0, 0, 0, + 0, 0, 31, 0, 0, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 13, 12, 0, 0, + 0, 0, 0, 0, 0, 41, 0, 0, 0, 37, + 0, 0, 0, 0, 42, 36, 0, 0, 43, 0, + 0, 0, 0, 44, 45, 0, 0, 46, 0, 47, + 48, 34, 0 } ; static const YY_CHAR yy_ec[256] = @@ -754,16 +759,16 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 4, 5, - 6, 7, 1, 8, 9, 10, 1, 11, 12, 12, - 12, 13, 12, 14, 12, 12, 12, 15, 1, 1, - 16, 1, 1, 1, 17, 17, 17, 17, 17, 17, - 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 18, 19, 18, 18, - 20, 1, 21, 1, 22, 1, 23, 24, 25, 26, - - 27, 28, 29, 30, 31, 18, 32, 33, 34, 35, - 36, 37, 18, 38, 39, 40, 41, 42, 18, 43, - 44, 18, 1, 1, 1, 1, 1, 1, 1, 1, + 6, 7, 1, 8, 9, 10, 1, 11, 12, 13, + 14, 15, 16, 17, 16, 18, 16, 19, 1, 1, + 20, 1, 1, 1, 21, 21, 21, 21, 21, 21, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 23, 22, 22, + 24, 1, 25, 1, 26, 1, 27, 28, 29, 30, + + 31, 32, 33, 34, 35, 22, 36, 37, 38, 39, + 40, 41, 22, 42, 43, 44, 45, 46, 22, 47, + 48, 22, 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, 1, 1, 1, 1, 1, 1, @@ -780,169 +785,194 @@ static const YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static const YY_CHAR yy_meta[45] = +static const YY_CHAR yy_meta[49] = { 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, - 4, 4, 4, 4, 5, 1, 4, 1, 1, 1, - 1, 1, 4, 4, 4, 4, 4, 4, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1 + 4, 4, 4, 4, 4, 4, 4, 4, 5, 1, + 6, 1, 1, 1, 1, 1, 6, 6, 6, 6, + 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1 } ; -static const flex_int16_t yy_base[227] = +static const flex_int16_t yy_base[283] = { 0, - 0, 0, 334, 335, 331, 329, 327, 335, 335, 335, - 335, 34, 335, 39, 36, 315, 313, 81, 115, 335, - 335, 35, 38, 34, 37, 297, 48, 299, 58, 108, - 290, 22, 44, 298, 113, 59, 297, 292, 320, 318, - 316, 335, 144, 148, 58, 304, 303, 0, 302, 0, - 335, 131, 143, 0, 0, 335, 290, 282, 288, 290, - 277, 271, 270, 269, 277, 284, 263, 278, 260, 64, - 268, 267, 276, 266, 270, 258, 257, 0, 269, 255, - 261, 270, 267, 267, 247, 266, 253, 264, 155, 0, - 0, 248, 0, 0, 259, 259, 260, 0, 255, 242, - - 254, 240, 243, 240, 251, 242, 0, 242, 0, 249, - 232, 0, 240, 232, 123, 246, 242, 0, 228, 226, - 230, 238, 237, 159, 222, 235, 237, 0, 221, 218, - 231, 216, 0, 228, 227, 214, 229, 224, 206, 213, - 225, 0, 0, 203, 220, 205, 0, 205, 207, 216, - 164, 205, 202, 199, 201, 198, 198, 197, 0, 0, - 207, 207, 194, 194, 195, 203, 135, 190, 189, 195, - 187, 186, 168, 183, 0, 0, 174, 0, 0, 178, - 0, 182, 0, 180, 0, 179, 0, 0, 0, 173, - 177, 193, 0, 172, 174, 169, 164, 160, 0, 159, - - 161, 0, 185, 152, 155, 164, 0, 0, 163, 158, - 150, 162, 0, 0, 140, 0, 0, 114, 111, 0, - 335, 210, 212, 214, 74, 217 + 0, 0, 378, 379, 375, 373, 371, 379, 379, 379, + 379, 0, 379, 39, 36, 355, 353, 85, 123, 379, + 379, 35, 38, 34, 37, 337, 48, 43, 58, 116, + 331, 22, 59, 339, 121, 49, 334, 337, 332, 364, + 362, 360, 379, 0, 0, 58, 344, 343, 0, 342, + 0, 379, 143, 146, 0, 0, 379, 330, 322, 328, + 330, 317, 311, 310, 309, 317, 324, 303, 318, 300, + 130, 303, 307, 306, 315, 305, 309, 297, 296, 0, + 308, 294, 300, 309, 306, 306, 286, 305, 292, 291, + 302, 318, 0, 0, 285, 0, 0, 296, 296, 297, + + 0, 292, 279, 291, 277, 280, 277, 288, 279, 146, + 0, 279, 0, 286, 269, 0, 277, 269, 150, 283, + 279, 0, 265, 263, 267, 261, 274, 273, 0, 258, + 271, 273, 0, 257, 254, 267, 252, 0, 264, 263, + 250, 275, 278, 246, 262, 257, 239, 246, 258, 0, + 0, 236, 253, 238, 0, 238, 158, 240, 249, 268, + 237, 234, 231, 233, 230, 230, 229, 0, 0, 239, + 225, 224, 227, 236, 223, 223, 224, 232, 158, 219, + 218, 224, 241, 244, 212, 213, 212, 0, 209, 0, + 0, 210, 0, 0, 216, 0, 210, 209, 204, 217, + + 0, 215, 0, 215, 0, 0, 0, 209, 213, 198, + 197, 200, 230, 0, 0, 207, 202, 197, 191, 190, + 202, 190, 0, 189, 191, 0, 189, 188, 183, 175, + 179, 182, 191, 187, 175, 156, 0, 0, 169, 157, + 155, 167, 160, 152, 164, 0, 147, 146, 148, 0, + 160, 159, 142, 161, 0, 0, 143, 142, 0, 138, + 137, 139, 139, 0, 0, 137, 136, 0, 136, 0, + 0, 0, 379, 204, 170, 207, 165, 210, 213, 217, + 158, 105 } ; -static const flex_int16_t yy_def[227] = +static const flex_int16_t yy_def[283] = { 0, - 221, 1, 221, 221, 221, 221, 222, 221, 221, 221, - 221, 221, 221, 221, 14, 223, 221, 221, 18, 221, - 221, 18, 18, 18, 18, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 221, 221, - 222, 221, 221, 221, 14, 223, 224, 225, 223, 226, - 221, 221, 19, 18, 19, 221, 18, 19, 19, 19, - 19, 18, 19, 19, 19, 19, 19, 19, 19, 19, + 273, 1, 273, 273, 273, 273, 274, 273, 273, 273, + 273, 275, 273, 273, 14, 276, 273, 273, 18, 273, + 273, 18, 18, 18, 18, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 273, + 273, 274, 273, 275, 277, 14, 276, 278, 279, 276, + 280, 273, 273, 19, 18, 19, 273, 18, 19, 19, + 19, 19, 18, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 221, 225, - 226, 18, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 277, 279, 280, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 221, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 281, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 281, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 221, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 221, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 282, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 221, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 282, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 0, 221, 221, 221, 221, 221 + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 0, 273, 273, 273, 273, 273, 273, 273, + 273, 273 } ; -static const flex_int16_t yy_nxt[380] = +static const flex_int16_t yy_nxt[428] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 15, 15, 16, 17, 18, 19, 19, 20, - 21, 4, 22, 18, 23, 24, 25, 18, 26, 27, - 28, 19, 29, 30, 31, 32, 33, 34, 35, 36, - 19, 37, 19, 38, 43, 43, 43, 43, 44, 45, - 45, 45, 45, 46, 221, 47, 62, 48, 77, 78, - 57, 47, 47, 47, 47, 47, 47, 58, 60, 59, - 79, 64, 63, 61, 67, 80, 221, 90, 221, 65, - 68, 48, 52, 52, 71, 85, 105, 69, 72, 53, - 106, 54, 54, 54, 54, 46, 86, 54, 55, 55, - - 221, 56, 53, 54, 54, 54, 54, 54, 54, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 221, - 73, 55, 52, 52, 74, 142, 143, 55, 55, 55, - 55, 55, 55, 82, 221, 221, 75, 187, 188, 220, - 83, 56, 219, 84, 43, 43, 43, 43, 89, 89, - 89, 89, 218, 221, 124, 89, 89, 89, 89, 151, - 151, 151, 151, 173, 151, 151, 151, 151, 194, 194, - 194, 194, 194, 194, 194, 194, 221, 221, 217, 216, - 215, 214, 213, 212, 211, 209, 208, 207, 206, 205, - - 204, 203, 202, 201, 200, 221, 199, 198, 197, 210, - 41, 196, 41, 41, 41, 49, 49, 47, 47, 91, - 91, 91, 195, 193, 192, 191, 190, 189, 186, 185, - 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, - 174, 172, 171, 170, 169, 168, 167, 166, 165, 164, - 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, - 153, 152, 150, 149, 148, 147, 146, 145, 144, 141, - 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, - 130, 129, 128, 127, 126, 125, 123, 122, 121, 120, - 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, - - 109, 108, 107, 104, 103, 102, 101, 100, 99, 98, - 97, 96, 95, 94, 93, 92, 50, 46, 50, 42, - 40, 39, 88, 87, 81, 76, 70, 66, 51, 50, - 42, 40, 39, 221, 3, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221 + 14, 15, 15, 15, 15, 15, 15, 15, 16, 17, + 18, 19, 19, 20, 21, 4, 22, 18, 23, 24, + 25, 18, 26, 27, 28, 19, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 19, 39, 45, 46, + 46, 46, 46, 46, 46, 46, 46, 47, 273, 48, + 63, 49, 79, 80, 58, 48, 48, 48, 48, 48, + 48, 59, 61, 60, 71, 65, 64, 62, 68, 87, + 273, 72, 273, 66, 69, 49, 53, 53, 73, 81, + 88, 70, 74, 54, 82, 55, 55, 55, 55, 55, + + 55, 55, 55, 47, 273, 55, 56, 56, 215, 57, + 54, 55, 55, 55, 55, 55, 55, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 273, 75, 56, 53, 53, 76, 273, 273, 56, + 56, 56, 56, 56, 56, 84, 108, 142, 77, 143, + 109, 160, 85, 144, 150, 86, 151, 57, 92, 183, + 273, 184, 205, 44, 206, 185, 273, 273, 272, 271, + 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, + 260, 259, 258, 257, 256, 255, 254, 253, 252, 273, + + 251, 250, 249, 243, 42, 248, 42, 42, 42, 42, + 50, 50, 50, 48, 48, 48, 93, 247, 93, 94, + 94, 94, 94, 246, 245, 244, 242, 241, 240, 239, + 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, + 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, + 218, 217, 216, 214, 213, 212, 211, 210, 209, 208, + 207, 204, 203, 202, 201, 200, 199, 198, 197, 196, + 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, + 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, + 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, + + 162, 161, 159, 158, 157, 156, 155, 154, 153, 152, + 149, 148, 147, 146, 145, 141, 140, 139, 138, 137, + 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, + 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, + 116, 115, 114, 113, 112, 111, 110, 107, 106, 105, + 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, + 51, 47, 51, 43, 41, 40, 91, 90, 89, 83, + 78, 67, 52, 51, 43, 41, 40, 273, 3, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273 } ; -static const flex_int16_t yy_chk[380] = +static const flex_int16_t yy_chk[428] = { 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, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 12, 12, 12, 12, 14, 14, - 14, 14, 14, 14, 15, 14, 24, 14, 32, 32, - 22, 14, 14, 14, 14, 14, 14, 22, 23, 22, - 33, 25, 24, 23, 27, 33, 45, 225, 15, 25, - 27, 14, 18, 18, 29, 36, 70, 27, 29, 18, - 70, 18, 18, 18, 18, 18, 36, 18, 18, 18, - - 45, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 1, 1, 1, 1, 1, 1, 1, 1, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 15, 14, + 24, 14, 32, 32, 22, 14, 14, 14, 14, 14, + 14, 22, 23, 22, 28, 25, 24, 23, 27, 36, + 46, 28, 15, 25, 27, 14, 18, 18, 29, 33, + 36, 27, 29, 18, 33, 18, 18, 18, 18, 18, + + 18, 18, 18, 18, 46, 18, 18, 18, 282, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, - 30, 19, 52, 52, 30, 115, 115, 19, 19, 19, - 19, 19, 19, 35, 53, 53, 30, 167, 167, 219, - 35, 52, 218, 35, 43, 43, 43, 43, 44, 44, - 44, 44, 215, 53, 89, 89, 89, 89, 89, 124, - 124, 124, 124, 151, 151, 151, 151, 151, 173, 173, - 173, 173, 194, 194, 194, 194, 203, 203, 212, 211, - 210, 209, 206, 205, 204, 201, 200, 198, 197, 196, - - 195, 192, 191, 190, 186, 203, 184, 182, 180, 203, - 222, 177, 222, 222, 222, 223, 223, 224, 224, 226, - 226, 226, 174, 172, 171, 170, 169, 168, 166, 165, - 164, 163, 162, 161, 158, 157, 156, 155, 154, 153, - 152, 150, 149, 148, 146, 145, 144, 141, 140, 139, - 138, 137, 136, 135, 134, 132, 131, 130, 129, 127, - 126, 125, 123, 122, 121, 120, 119, 117, 116, 114, - 113, 111, 110, 108, 106, 105, 104, 103, 102, 101, - 100, 99, 97, 96, 95, 92, 88, 87, 86, 85, - 84, 83, 82, 81, 80, 79, 77, 76, 75, 74, - - 73, 72, 71, 69, 68, 67, 66, 65, 64, 63, - 62, 61, 60, 59, 58, 57, 49, 47, 46, 41, - 40, 39, 38, 37, 34, 31, 28, 26, 17, 16, - 7, 6, 5, 3, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221 + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 30, 19, 53, 53, 30, 54, 54, 19, + 19, 19, 19, 19, 19, 35, 71, 110, 30, 110, + 71, 281, 35, 110, 119, 35, 119, 53, 277, 157, + 54, 157, 179, 275, 179, 157, 230, 230, 269, 267, + 266, 263, 262, 261, 260, 258, 257, 254, 253, 252, + 251, 249, 248, 247, 245, 244, 243, 242, 241, 230, + + 240, 239, 236, 230, 274, 235, 274, 274, 274, 274, + 276, 276, 276, 278, 278, 278, 279, 234, 279, 280, + 280, 280, 280, 233, 232, 231, 229, 228, 227, 225, + 224, 222, 221, 220, 219, 218, 217, 216, 213, 212, + 211, 210, 209, 208, 204, 202, 200, 199, 198, 197, + 195, 192, 189, 187, 186, 185, 184, 183, 182, 181, + 180, 178, 177, 176, 175, 174, 173, 172, 171, 170, + 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, + 156, 154, 153, 152, 149, 148, 147, 146, 145, 144, + 143, 142, 141, 140, 139, 137, 136, 135, 134, 132, + + 131, 130, 128, 127, 126, 125, 124, 123, 121, 120, + 118, 117, 115, 114, 112, 109, 108, 107, 106, 105, + 104, 103, 102, 100, 99, 98, 95, 92, 91, 90, + 89, 88, 87, 86, 85, 84, 83, 82, 81, 79, + 78, 77, 76, 75, 74, 73, 72, 70, 69, 68, + 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, + 50, 48, 47, 42, 41, 40, 39, 38, 37, 34, + 31, 26, 17, 16, 7, 6, 5, 3, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273 } ; /* Table of booleans, true if rule could match eol. */ -static const flex_int32_t yy_rule_can_match_eol[56] = +static const flex_int32_t yy_rule_can_match_eol[62] = { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, }; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; @@ -950,14 +980,14 @@ static char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 1; -static const flex_int16_t yy_rule_linenum[55] = +static const flex_int16_t yy_rule_linenum[61] = { 0, 106, 111, 117, 127, 133, 151, 175, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, - 232, 233, 234, 235 + 232, 233, 234, 235, 236, 237, 238, 239, 240, 241 } ; /* The intent behind this definition is that it'll catch @@ -1008,7 +1038,7 @@ namespace { /* To avoid the call to exit... oops! */ #define YY_FATAL_ERROR(msg) isc::eval::EvalContext::fatal(msg) -#line 1012 "lexer.cc" +#line 1042 "lexer.cc" /* noyywrap disables automatic rewinding for the next file to parse. Since we always parse only a single string, there's no need to do any wraps. And using yywrap requires linking with -lfl, which provides the default yywrap @@ -1033,8 +1063,8 @@ namespace { by moving it ahead by yyleng bytes. yyleng specifies the length of the currently matched token. */ #define YY_USER_ACTION loc.columns(evalleng); -#line 1037 "lexer.cc" -#line 1038 "lexer.cc" +#line 1067 "lexer.cc" +#line 1068 "lexer.cc" #define INITIAL 0 @@ -1333,7 +1363,7 @@ YY_DECL -#line 1337 "lexer.cc" +#line 1367 "lexer.cc" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1362,13 +1392,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) + if ( yy_current_state >= 274 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 221 ); + while ( yy_current_state != 273 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1397,13 +1427,13 @@ do_action: /* This label is used only to access EOF actions. */ { if ( yy_act == 0 ) fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 55 ) + else if ( yy_act < 61 ) fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 55 ) + else if ( yy_act == 61 ) fprintf( stderr, "--accepting default rule (\"%s\")\n", yytext ); - else if ( yy_act == 56 ) + else if ( yy_act == 62 ) fprintf( stderr, "--(end of buffer or a NUL)\n" ); else fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); @@ -1707,73 +1737,103 @@ return isc::eval::EvalParser::make_ADDRTOTEXT(loc); case 43: YY_RULE_SETUP #line 224 "lexer.ll" -return isc::eval::EvalParser::make_NOT(loc); +return isc::eval::EvalParser::make_INT8TOTEXT(loc); YY_BREAK case 44: YY_RULE_SETUP #line 225 "lexer.ll" -return isc::eval::EvalParser::make_AND(loc); +return isc::eval::EvalParser::make_INT16TOTEXT(loc); YY_BREAK case 45: YY_RULE_SETUP #line 226 "lexer.ll" -return isc::eval::EvalParser::make_OR(loc); +return isc::eval::EvalParser::make_INT32TOTEXT(loc); YY_BREAK case 46: YY_RULE_SETUP #line 227 "lexer.ll" -return isc::eval::EvalParser::make_MEMBER(loc); +return isc::eval::EvalParser::make_UINT8TOTEXT(loc); YY_BREAK case 47: YY_RULE_SETUP #line 228 "lexer.ll" -return isc::eval::EvalParser::make_DOT(loc); +return isc::eval::EvalParser::make_UINT16TOTEXT(loc); YY_BREAK case 48: YY_RULE_SETUP #line 229 "lexer.ll" -return isc::eval::EvalParser::make_LPAREN(loc); +return isc::eval::EvalParser::make_UINT32TOTEXT(loc); YY_BREAK case 49: YY_RULE_SETUP #line 230 "lexer.ll" -return isc::eval::EvalParser::make_RPAREN(loc); +return isc::eval::EvalParser::make_NOT(loc); YY_BREAK case 50: YY_RULE_SETUP #line 231 "lexer.ll" -return isc::eval::EvalParser::make_LBRACKET(loc); +return isc::eval::EvalParser::make_AND(loc); YY_BREAK case 51: YY_RULE_SETUP #line 232 "lexer.ll" -return isc::eval::EvalParser::make_RBRACKET(loc); +return isc::eval::EvalParser::make_OR(loc); YY_BREAK case 52: YY_RULE_SETUP #line 233 "lexer.ll" -return isc::eval::EvalParser::make_COMA(loc); +return isc::eval::EvalParser::make_MEMBER(loc); YY_BREAK case 53: YY_RULE_SETUP #line 234 "lexer.ll" -return isc::eval::EvalParser::make_ANY(loc); +return isc::eval::EvalParser::make_DOT(loc); YY_BREAK case 54: YY_RULE_SETUP #line 235 "lexer.ll" +return isc::eval::EvalParser::make_LPAREN(loc); + YY_BREAK +case 55: +YY_RULE_SETUP +#line 236 "lexer.ll" +return isc::eval::EvalParser::make_RPAREN(loc); + YY_BREAK +case 56: +YY_RULE_SETUP +#line 237 "lexer.ll" +return isc::eval::EvalParser::make_LBRACKET(loc); + YY_BREAK +case 57: +YY_RULE_SETUP +#line 238 "lexer.ll" +return isc::eval::EvalParser::make_RBRACKET(loc); + YY_BREAK +case 58: +YY_RULE_SETUP +#line 239 "lexer.ll" +return isc::eval::EvalParser::make_COMA(loc); + YY_BREAK +case 59: +YY_RULE_SETUP +#line 240 "lexer.ll" +return isc::eval::EvalParser::make_ANY(loc); + YY_BREAK +case 60: +YY_RULE_SETUP +#line 241 "lexer.ll" driver.error (loc, "Invalid character: " + std::string(evaltext)); YY_BREAK case YY_STATE_EOF(INITIAL): -#line 236 "lexer.ll" +#line 242 "lexer.ll" return isc::eval::EvalParser::make_END(loc); YY_BREAK -case 55: +case 61: YY_RULE_SETUP -#line 237 "lexer.ll" +#line 243 "lexer.ll" ECHO; YY_BREAK -#line 1777 "lexer.cc" +#line 1837 "lexer.cc" case YY_END_OF_BUFFER: { @@ -2092,7 +2152,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) + if ( yy_current_state >= 274 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -2125,11 +2185,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) + if ( yy_current_state >= 274 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 221); + yy_is_jam = (yy_current_state == 273); return yy_is_jam ? 0 : yy_current_state; } @@ -2885,7 +2945,7 @@ void yyfree (void * ptr ) /* %ok-for-header */ -#line 237 "lexer.ll" +#line 243 "lexer.ll" using namespace isc::eval; diff --git a/src/lib/eval/lexer.ll b/src/lib/eval/lexer.ll index 4ee72afb07..12a0bf8655 100644 --- a/src/lib/eval/lexer.ll +++ b/src/lib/eval/lexer.ll @@ -220,6 +220,12 @@ addr6 [0-9a-fA-F]*\:[0-9a-fA-F]*\:[0-9a-fA-F:.]* "ifelse" return isc::eval::EvalParser::make_IFELSE(loc); "hexstring" return isc::eval::EvalParser::make_TOHEXSTRING(loc); "addrtotext" return isc::eval::EvalParser::make_ADDRTOTEXT(loc); +"int8totext" return isc::eval::EvalParser::make_INT8TOTEXT(loc); +"int16totext" return isc::eval::EvalParser::make_INT16TOTEXT(loc); +"int32totext" return isc::eval::EvalParser::make_INT32TOTEXT(loc); +"uint8totext" return isc::eval::EvalParser::make_UINT8TOTEXT(loc); +"uint16totext" return isc::eval::EvalParser::make_UINT16TOTEXT(loc); +"uint32totext" return isc::eval::EvalParser::make_UINT32TOTEXT(loc); "not" return isc::eval::EvalParser::make_NOT(loc); "and" return isc::eval::EvalParser::make_AND(loc); "or" return isc::eval::EvalParser::make_OR(loc); diff --git a/src/lib/eval/parser.cc b/src/lib/eval/parser.cc index 29abc51ba4..7ed3d6eddd 100644 --- a/src/lib/eval/parser.cc +++ b/src/lib/eval/parser.cc @@ -249,45 +249,45 @@ namespace isc { namespace eval { { switch (that.type_get ()) { - case 64: // option_repr_type + case 70: // option_repr_type value.YY_MOVE_OR_COPY< TokenOption::RepresentationType > (YY_MOVE (that.value)); break; - case 68: // pkt4_field + case 74: // pkt4_field value.YY_MOVE_OR_COPY< TokenPkt4::FieldType > (YY_MOVE (that.value)); break; - case 69: // pkt6_field + case 75: // pkt6_field value.YY_MOVE_OR_COPY< TokenPkt6::FieldType > (YY_MOVE (that.value)); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.YY_MOVE_OR_COPY< TokenPkt::MetadataType > (YY_MOVE (that.value)); break; - case 70: // relay6_field + case 76: // relay6_field value.YY_MOVE_OR_COPY< TokenRelay6Field::FieldType > (YY_MOVE (that.value)); break; - case 65: // nest_level + case 71: // nest_level value.YY_MOVE_OR_COPY< int8_t > (YY_MOVE (that.value)); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value)); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.YY_MOVE_OR_COPY< uint16_t > (YY_MOVE (that.value)); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.YY_MOVE_OR_COPY< uint32_t > (YY_MOVE (that.value)); break; @@ -306,45 +306,45 @@ namespace isc { namespace eval { { switch (that.type_get ()) { - case 64: // option_repr_type + case 70: // option_repr_type value.move< TokenOption::RepresentationType > (YY_MOVE (that.value)); break; - case 68: // pkt4_field + case 74: // pkt4_field value.move< TokenPkt4::FieldType > (YY_MOVE (that.value)); break; - case 69: // pkt6_field + case 75: // pkt6_field value.move< TokenPkt6::FieldType > (YY_MOVE (that.value)); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.move< TokenPkt::MetadataType > (YY_MOVE (that.value)); break; - case 70: // relay6_field + case 76: // relay6_field value.move< TokenRelay6Field::FieldType > (YY_MOVE (that.value)); break; - case 65: // nest_level + case 71: // nest_level value.move< int8_t > (YY_MOVE (that.value)); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.move< std::string > (YY_MOVE (that.value)); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.move< uint16_t > (YY_MOVE (that.value)); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.move< uint32_t > (YY_MOVE (that.value)); break; @@ -363,45 +363,45 @@ namespace isc { namespace eval { state = that.state; switch (that.type_get ()) { - case 64: // option_repr_type + case 70: // option_repr_type value.copy< TokenOption::RepresentationType > (that.value); break; - case 68: // pkt4_field + case 74: // pkt4_field value.copy< TokenPkt4::FieldType > (that.value); break; - case 69: // pkt6_field + case 75: // pkt6_field value.copy< TokenPkt6::FieldType > (that.value); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.copy< TokenPkt::MetadataType > (that.value); break; - case 70: // relay6_field + case 76: // relay6_field value.copy< TokenRelay6Field::FieldType > (that.value); break; - case 65: // nest_level + case 71: // nest_level value.copy< int8_t > (that.value); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.copy< std::string > (that.value); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.copy< uint16_t > (that.value); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.copy< uint32_t > (that.value); break; @@ -419,45 +419,45 @@ namespace isc { namespace eval { state = that.state; switch (that.type_get ()) { - case 64: // option_repr_type + case 70: // option_repr_type value.move< TokenOption::RepresentationType > (that.value); break; - case 68: // pkt4_field + case 74: // pkt4_field value.move< TokenPkt4::FieldType > (that.value); break; - case 69: // pkt6_field + case 75: // pkt6_field value.move< TokenPkt6::FieldType > (that.value); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.move< TokenPkt::MetadataType > (that.value); break; - case 70: // relay6_field + case 76: // relay6_field value.move< TokenRelay6Field::FieldType > (that.value); break; - case 65: // nest_level + case 71: // nest_level value.move< int8_t > (that.value); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.move< std::string > (that.value); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.move< uint16_t > (that.value); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.move< uint32_t > (that.value); break; @@ -500,92 +500,92 @@ namespace isc { namespace eval { << yysym.location << ": "; switch (yytype) { - case 51: // "constant string" -#line 113 "parser.yy" + case 57: // "constant string" +#line 119 "parser.yy" { yyoutput << yysym.value.template as < std::string > (); } #line 507 "parser.cc" break; - case 52: // "integer" -#line 113 "parser.yy" + case 58: // "integer" +#line 119 "parser.yy" { yyoutput << yysym.value.template as < std::string > (); } #line 513 "parser.cc" break; - case 53: // "constant hexstring" -#line 113 "parser.yy" + case 59: // "constant hexstring" +#line 119 "parser.yy" { yyoutput << yysym.value.template as < std::string > (); } #line 519 "parser.cc" break; - case 54: // "option name" -#line 113 "parser.yy" + case 60: // "option name" +#line 119 "parser.yy" { yyoutput << yysym.value.template as < std::string > (); } #line 525 "parser.cc" break; - case 55: // "ip address" -#line 113 "parser.yy" + case 61: // "ip address" +#line 119 "parser.yy" { yyoutput << yysym.value.template as < std::string > (); } #line 531 "parser.cc" break; - case 61: // integer_expr -#line 113 "parser.yy" + case 67: // integer_expr +#line 119 "parser.yy" { yyoutput << yysym.value.template as < uint32_t > (); } #line 537 "parser.cc" break; - case 62: // option_code -#line 113 "parser.yy" + case 68: // option_code +#line 119 "parser.yy" { yyoutput << yysym.value.template as < uint16_t > (); } #line 543 "parser.cc" break; - case 63: // sub_option_code -#line 113 "parser.yy" + case 69: // sub_option_code +#line 119 "parser.yy" { yyoutput << yysym.value.template as < uint16_t > (); } #line 549 "parser.cc" break; - case 64: // option_repr_type -#line 113 "parser.yy" + case 70: // option_repr_type +#line 119 "parser.yy" { yyoutput << yysym.value.template as < TokenOption::RepresentationType > (); } #line 555 "parser.cc" break; - case 65: // nest_level -#line 113 "parser.yy" + case 71: // nest_level +#line 119 "parser.yy" { yyoutput << yysym.value.template as < int8_t > (); } #line 561 "parser.cc" break; - case 66: // pkt_metadata -#line 113 "parser.yy" + case 72: // pkt_metadata +#line 119 "parser.yy" { yyoutput << yysym.value.template as < TokenPkt::MetadataType > (); } #line 567 "parser.cc" break; - case 67: // enterprise_id -#line 113 "parser.yy" + case 73: // enterprise_id +#line 119 "parser.yy" { yyoutput << yysym.value.template as < uint32_t > (); } #line 573 "parser.cc" break; - case 68: // pkt4_field -#line 113 "parser.yy" + case 74: // pkt4_field +#line 119 "parser.yy" { yyoutput << yysym.value.template as < TokenPkt4::FieldType > (); } #line 579 "parser.cc" break; - case 69: // pkt6_field -#line 113 "parser.yy" + case 75: // pkt6_field +#line 119 "parser.yy" { yyoutput << yysym.value.template as < TokenPkt6::FieldType > (); } #line 585 "parser.cc" break; - case 70: // relay6_field -#line 113 "parser.yy" + case 76: // relay6_field +#line 119 "parser.yy" { yyoutput << yysym.value.template as < TokenRelay6Field::FieldType > (); } #line 591 "parser.cc" break; @@ -805,45 +805,45 @@ namespace isc { namespace eval { when using variants. */ switch (yyr1_[yyn]) { - case 64: // option_repr_type + case 70: // option_repr_type yylhs.value.emplace< TokenOption::RepresentationType > (); break; - case 68: // pkt4_field + case 74: // pkt4_field yylhs.value.emplace< TokenPkt4::FieldType > (); break; - case 69: // pkt6_field + case 75: // pkt6_field yylhs.value.emplace< TokenPkt6::FieldType > (); break; - case 66: // pkt_metadata + case 72: // pkt_metadata yylhs.value.emplace< TokenPkt::MetadataType > (); break; - case 70: // relay6_field + case 76: // relay6_field yylhs.value.emplace< TokenRelay6Field::FieldType > (); break; - case 65: // nest_level + case 71: // nest_level yylhs.value.emplace< int8_t > (); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" yylhs.value.emplace< std::string > (); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code yylhs.value.emplace< uint16_t > (); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id yylhs.value.emplace< uint32_t > (); break; @@ -868,7 +868,7 @@ namespace isc { namespace eval { switch (yyn) { case 6: -#line 133 "parser.yy" +#line 139 "parser.yy" { TokenPtr neg(new TokenNot()); ctx.expression.push_back(neg); @@ -877,7 +877,7 @@ namespace isc { namespace eval { break; case 7: -#line 138 "parser.yy" +#line 144 "parser.yy" { TokenPtr neg(new TokenAnd()); ctx.expression.push_back(neg); @@ -886,7 +886,7 @@ namespace isc { namespace eval { break; case 8: -#line 143 "parser.yy" +#line 149 "parser.yy" { TokenPtr neg(new TokenOr()); ctx.expression.push_back(neg); @@ -895,7 +895,7 @@ namespace isc { namespace eval { break; case 9: -#line 148 "parser.yy" +#line 154 "parser.yy" { TokenPtr eq(new TokenEqual()); ctx.expression.push_back(eq); @@ -904,7 +904,7 @@ namespace isc { namespace eval { break; case 10: -#line 153 "parser.yy" +#line 159 "parser.yy" { TokenPtr opt(new TokenOption(yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS)); ctx.expression.push_back(opt); @@ -913,7 +913,7 @@ namespace isc { namespace eval { break; case 11: -#line 158 "parser.yy" +#line 164 "parser.yy" { TokenPtr opt(new TokenSubOption(yystack_[8].value.as < uint16_t > (), yystack_[3].value.as < uint16_t > (), TokenOption::EXISTS)); ctx.expression.push_back(opt); @@ -922,7 +922,7 @@ namespace isc { namespace eval { break; case 12: -#line 163 "parser.yy" +#line 169 "parser.yy" { switch (ctx.getUniverse()) { case Option::V4: @@ -946,7 +946,7 @@ namespace isc { namespace eval { break; case 13: -#line 183 "parser.yy" +#line 189 "parser.yy" { switch (ctx.getUniverse()) { case Option::V6: @@ -964,7 +964,7 @@ namespace isc { namespace eval { break; case 14: -#line 197 "parser.yy" +#line 203 "parser.yy" { // Expression: vendor-class[1234].exists // @@ -977,7 +977,7 @@ namespace isc { namespace eval { break; case 15: -#line 206 "parser.yy" +#line 212 "parser.yy" { // Expression: vendor[1234].exists // @@ -990,7 +990,7 @@ namespace isc { namespace eval { break; case 16: -#line 215 "parser.yy" +#line 221 "parser.yy" { // Expression vendor[1234].option[123].exists // @@ -1004,7 +1004,7 @@ namespace isc { namespace eval { break; case 17: -#line 225 "parser.yy" +#line 231 "parser.yy" { // Expression member('foo') // @@ -1023,7 +1023,7 @@ namespace isc { namespace eval { break; case 18: -#line 242 "parser.yy" +#line 248 "parser.yy" { TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ())); ctx.expression.push_back(str); @@ -1032,7 +1032,7 @@ namespace isc { namespace eval { break; case 19: -#line 247 "parser.yy" +#line 253 "parser.yy" { TokenPtr hex(new TokenHexString(yystack_[0].value.as < std::string > ())); ctx.expression.push_back(hex); @@ -1041,7 +1041,7 @@ namespace isc { namespace eval { break; case 20: -#line 252 "parser.yy" +#line 258 "parser.yy" { TokenPtr ip(new TokenIpAddress(yystack_[0].value.as < std::string > ())); ctx.expression.push_back(ip); @@ -1050,7 +1050,7 @@ namespace isc { namespace eval { break; case 21: -#line 257 "parser.yy" +#line 263 "parser.yy" { TokenPtr opt(new TokenOption(yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ())); ctx.expression.push_back(opt); @@ -1059,7 +1059,7 @@ namespace isc { namespace eval { break; case 22: -#line 262 "parser.yy" +#line 268 "parser.yy" { TokenPtr opt(new TokenSubOption(yystack_[8].value.as < uint16_t > (), yystack_[3].value.as < uint16_t > (), yystack_[0].value.as < TokenOption::RepresentationType > ())); ctx.expression.push_back(opt); @@ -1068,7 +1068,7 @@ namespace isc { namespace eval { break; case 23: -#line 267 "parser.yy" +#line 273 "parser.yy" { switch (ctx.getUniverse()) { case Option::V4: @@ -1092,7 +1092,7 @@ namespace isc { namespace eval { break; case 24: -#line 288 "parser.yy" +#line 294 "parser.yy" { switch (ctx.getUniverse()) { case Option::V6: @@ -1110,7 +1110,7 @@ namespace isc { namespace eval { break; case 25: -#line 303 "parser.yy" +#line 309 "parser.yy" { TokenPtr pkt_metadata(new TokenPkt(yystack_[0].value.as < TokenPkt::MetadataType > ())); ctx.expression.push_back(pkt_metadata); @@ -1119,7 +1119,7 @@ namespace isc { namespace eval { break; case 26: -#line 308 "parser.yy" +#line 314 "parser.yy" { switch (ctx.getUniverse()) { case Option::V4: @@ -1137,7 +1137,7 @@ namespace isc { namespace eval { break; case 27: -#line 322 "parser.yy" +#line 328 "parser.yy" { switch (ctx.getUniverse()) { case Option::V6: @@ -1155,7 +1155,7 @@ namespace isc { namespace eval { break; case 28: -#line 336 "parser.yy" +#line 342 "parser.yy" { switch (ctx.getUniverse()) { case Option::V6: @@ -1173,7 +1173,7 @@ namespace isc { namespace eval { break; case 29: -#line 351 "parser.yy" +#line 357 "parser.yy" { TokenPtr sub(new TokenSubstring()); ctx.expression.push_back(sub); @@ -1182,7 +1182,7 @@ namespace isc { namespace eval { break; case 30: -#line 356 "parser.yy" +#line 362 "parser.yy" { TokenPtr conc(new TokenConcat()); ctx.expression.push_back(conc); @@ -1191,7 +1191,7 @@ namespace isc { namespace eval { break; case 31: -#line 361 "parser.yy" +#line 367 "parser.yy" { TokenPtr cond(new TokenIfElse()); ctx.expression.push_back(cond); @@ -1200,7 +1200,7 @@ namespace isc { namespace eval { break; case 32: -#line 366 "parser.yy" +#line 372 "parser.yy" { TokenPtr tohex(new TokenToHexString()); ctx.expression.push_back(tohex); @@ -1209,7 +1209,7 @@ namespace isc { namespace eval { break; case 33: -#line 371 "parser.yy" +#line 377 "parser.yy" { TokenPtr addrtotext(new TokenIpAddressToText()); ctx.expression.push_back(addrtotext); @@ -1218,7 +1218,61 @@ namespace isc { namespace eval { break; case 34: -#line 376 "parser.yy" +#line 382 "parser.yy" + { + TokenPtr int8totext(new TokenInt8ToText()); + ctx.expression.push_back(int8totext); + } +#line 1227 "parser.cc" + break; + + case 35: +#line 387 "parser.yy" + { + TokenPtr int16totext(new TokenInt16ToText()); + ctx.expression.push_back(int16totext); + } +#line 1236 "parser.cc" + break; + + case 36: +#line 392 "parser.yy" + { + TokenPtr int32totext(new TokenInt32ToText()); + ctx.expression.push_back(int32totext); + } +#line 1245 "parser.cc" + break; + + case 37: +#line 397 "parser.yy" + { + TokenPtr uint8totext(new TokenUInt8ToText()); + ctx.expression.push_back(uint8totext); + } +#line 1254 "parser.cc" + break; + + case 38: +#line 402 "parser.yy" + { + TokenPtr uint16totext(new TokenUInt16ToText()); + ctx.expression.push_back(uint16totext); + } +#line 1263 "parser.cc" + break; + + case 39: +#line 407 "parser.yy" + { + TokenPtr uint32totext(new TokenUInt32ToText()); + ctx.expression.push_back(uint32totext); + } +#line 1272 "parser.cc" + break; + + case 40: +#line 412 "parser.yy" { // expression: vendor.enterprise // @@ -1227,11 +1281,11 @@ namespace isc { namespace eval { TokenPtr vendor(new TokenVendor(ctx.getUniverse(), 0, TokenVendor::ENTERPRISE_ID)); ctx.expression.push_back(vendor); } -#line 1231 "parser.cc" +#line 1285 "parser.cc" break; - case 35: -#line 385 "parser.yy" + case 41: +#line 421 "parser.yy" { // expression: vendor-class.enterprise // @@ -1241,11 +1295,11 @@ namespace isc { namespace eval { TokenVendor::ENTERPRISE_ID)); ctx.expression.push_back(vendor); } -#line 1245 "parser.cc" +#line 1299 "parser.cc" break; - case 36: -#line 395 "parser.yy" + case 42: +#line 431 "parser.yy" { // This token will search for vendor option with // specified enterprise-id. If found, will search @@ -1254,11 +1308,11 @@ namespace isc { namespace eval { TokenPtr opt(new TokenVendor(ctx.getUniverse(), yystack_[8].value.as < uint32_t > (), yystack_[0].value.as < TokenOption::RepresentationType > (), yystack_[3].value.as < uint16_t > ())); ctx.expression.push_back(opt); } -#line 1258 "parser.cc" +#line 1312 "parser.cc" break; - case 37: -#line 404 "parser.yy" + case 43: +#line 440 "parser.yy" { // expression: vendor-class[1234].data // @@ -1271,11 +1325,11 @@ namespace isc { namespace eval { TokenVendor::DATA, 0)); ctx.expression.push_back(vendor_class); } -#line 1275 "parser.cc" +#line 1329 "parser.cc" break; - case 38: -#line 417 "parser.yy" + case 44: +#line 453 "parser.yy" { // expression: vendor-class[1234].data[5] // @@ -1288,255 +1342,255 @@ namespace isc { namespace eval { TokenVendor::DATA, index)); ctx.expression.push_back(vendor_class); } -#line 1292 "parser.cc" +#line 1346 "parser.cc" break; - case 39: -#line 430 "parser.yy" + case 45: +#line 466 "parser.yy" { TokenPtr integer(new TokenInteger(yystack_[0].value.as < uint32_t > ())); ctx.expression.push_back(integer); } -#line 1301 "parser.cc" +#line 1355 "parser.cc" break; - case 40: -#line 437 "parser.yy" + case 46: +#line 473 "parser.yy" { yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location); } -#line 1309 "parser.cc" +#line 1363 "parser.cc" break; - case 41: -#line 443 "parser.yy" + case 47: +#line 479 "parser.yy" { yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location); } -#line 1317 "parser.cc" +#line 1371 "parser.cc" break; - case 42: -#line 447 "parser.yy" + case 48: +#line 483 "parser.yy" { yylhs.value.as < uint16_t > () = ctx.convertOptionName(yystack_[0].value.as < std::string > (), yystack_[0].location); } -#line 1325 "parser.cc" +#line 1379 "parser.cc" break; - case 43: -#line 453 "parser.yy" + case 49: +#line 489 "parser.yy" { yylhs.value.as < uint16_t > () = ctx.convertOptionCode(yystack_[0].value.as < std::string > (), yystack_[0].location); } -#line 1333 "parser.cc" +#line 1387 "parser.cc" break; - case 44: -#line 459 "parser.yy" + case 50: +#line 495 "parser.yy" { yylhs.value.as < TokenOption::RepresentationType > () = TokenOption::TEXTUAL; } -#line 1341 "parser.cc" +#line 1395 "parser.cc" break; - case 45: -#line 463 "parser.yy" + case 51: +#line 499 "parser.yy" { yylhs.value.as < TokenOption::RepresentationType > () = TokenOption::HEXADECIMAL; } -#line 1349 "parser.cc" +#line 1403 "parser.cc" break; - case 46: -#line 469 "parser.yy" + case 52: +#line 505 "parser.yy" { yylhs.value.as < int8_t > () = ctx.convertNestLevelNumber(yystack_[0].value.as < std::string > (), yystack_[0].location); } -#line 1357 "parser.cc" +#line 1411 "parser.cc" break; - case 47: -#line 478 "parser.yy" + case 53: +#line 514 "parser.yy" { yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::IFACE; } -#line 1365 "parser.cc" +#line 1419 "parser.cc" break; - case 48: -#line 482 "parser.yy" + case 54: +#line 518 "parser.yy" { yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::SRC; } -#line 1373 "parser.cc" +#line 1427 "parser.cc" break; - case 49: -#line 486 "parser.yy" + case 55: +#line 522 "parser.yy" { yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::DST; } -#line 1381 "parser.cc" +#line 1435 "parser.cc" break; - case 50: -#line 490 "parser.yy" + case 56: +#line 526 "parser.yy" { yylhs.value.as < TokenPkt::MetadataType > () = TokenPkt::LEN; } -#line 1389 "parser.cc" +#line 1443 "parser.cc" break; - case 51: -#line 496 "parser.yy" + case 57: +#line 532 "parser.yy" { yylhs.value.as < uint32_t > () = ctx.convertUint32(yystack_[0].value.as < std::string > (), yystack_[0].location); } -#line 1397 "parser.cc" +#line 1451 "parser.cc" break; - case 52: -#line 500 "parser.yy" + case 58: +#line 536 "parser.yy" { yylhs.value.as < uint32_t > () = 0; } -#line 1405 "parser.cc" +#line 1459 "parser.cc" break; - case 53: -#line 506 "parser.yy" + case 59: +#line 542 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CHADDR; } -#line 1413 "parser.cc" +#line 1467 "parser.cc" break; - case 54: -#line 510 "parser.yy" + case 60: +#line 546 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HLEN; } -#line 1421 "parser.cc" +#line 1475 "parser.cc" break; - case 55: -#line 514 "parser.yy" + case 61: +#line 550 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::HTYPE; } -#line 1429 "parser.cc" +#line 1483 "parser.cc" break; - case 56: -#line 518 "parser.yy" + case 62: +#line 554 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::CIADDR; } -#line 1437 "parser.cc" +#line 1491 "parser.cc" break; - case 57: -#line 522 "parser.yy" + case 63: +#line 558 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::GIADDR; } -#line 1445 "parser.cc" +#line 1499 "parser.cc" break; - case 58: -#line 526 "parser.yy" + case 64: +#line 562 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::YIADDR; } -#line 1453 "parser.cc" +#line 1507 "parser.cc" break; - case 59: -#line 530 "parser.yy" + case 65: +#line 566 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::SIADDR; } -#line 1461 "parser.cc" +#line 1515 "parser.cc" break; - case 60: -#line 534 "parser.yy" + case 66: +#line 570 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::MSGTYPE; } -#line 1469 "parser.cc" +#line 1523 "parser.cc" break; - case 61: -#line 538 "parser.yy" + case 67: +#line 574 "parser.yy" { yylhs.value.as < TokenPkt4::FieldType > () = TokenPkt4::TRANSID; } -#line 1477 "parser.cc" +#line 1531 "parser.cc" break; - case 62: -#line 544 "parser.yy" + case 68: +#line 580 "parser.yy" { yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::MSGTYPE; } -#line 1485 "parser.cc" +#line 1539 "parser.cc" break; - case 63: -#line 548 "parser.yy" + case 69: +#line 584 "parser.yy" { yylhs.value.as < TokenPkt6::FieldType > () = TokenPkt6::TRANSID; } -#line 1493 "parser.cc" +#line 1547 "parser.cc" break; - case 64: -#line 554 "parser.yy" + case 70: +#line 590 "parser.yy" { yylhs.value.as < TokenRelay6Field::FieldType > () = TokenRelay6Field::PEERADDR; } -#line 1501 "parser.cc" +#line 1555 "parser.cc" break; - case 65: -#line 558 "parser.yy" + case 71: +#line 594 "parser.yy" { yylhs.value.as < TokenRelay6Field::FieldType > () = TokenRelay6Field::LINKADDR; } -#line 1509 "parser.cc" +#line 1563 "parser.cc" break; - case 66: -#line 564 "parser.yy" + case 72: +#line 600 "parser.yy" { TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ())); ctx.expression.push_back(str); } -#line 1518 "parser.cc" +#line 1572 "parser.cc" break; - case 67: -#line 571 "parser.yy" + case 73: +#line 607 "parser.yy" { TokenPtr str(new TokenString(yystack_[0].value.as < std::string > ())); ctx.expression.push_back(str); } -#line 1527 "parser.cc" +#line 1581 "parser.cc" break; - case 68: -#line 576 "parser.yy" + case 74: +#line 612 "parser.yy" { TokenPtr str(new TokenString("all")); ctx.expression.push_back(str); } -#line 1536 "parser.cc" +#line 1590 "parser.cc" break; -#line 1540 "parser.cc" +#line 1594 "parser.cc" default: break; @@ -1807,33 +1861,36 @@ namespace isc { namespace eval { } - const signed char EvalParser::yypact_ninf_ = -124; + const short EvalParser::yypact_ninf_ = -146; const signed char EvalParser::yytable_ninf_ = -1; const short EvalParser::yypact_[] = { - 42, 49, 113, 5, 49, 49, 15, 28, 70, 54, - 91, 92, 117, 125, 133, 134, 135, 104, 88, 114, - -124, -124, -124, -124, -124, 17, 132, -124, 126, 127, - 128, 115, 118, -124, -124, 67, -124, 30, 93, 94, - 97, 56, -15, 113, 113, 49, 113, 113, 20, -26, - 96, -26, 108, 49, 49, 113, 30, 93, 94, -26, - -26, -124, -124, -124, 139, -124, 143, -124, 144, 157, - -124, -124, -124, -124, -124, -124, -124, -124, -124, -124, - -124, -124, -124, -124, -124, 131, 136, 3, 137, 158, - -124, -124, -124, -124, -124, 147, -124, 153, -124, -124, - 164, -124, 155, 159, 160, 161, 162, 163, 165, 166, - -124, 122, 113, 113, 113, -124, 167, 168, 169, 170, - 171, 172, 173, 13, 18, 37, -124, 145, 175, 156, - 187, -18, -1, 16, 80, 63, 146, 185, 180, -124, - -124, -124, -124, -124, -124, 181, -124, -124, -124, -31, - -124, 113, -124, -124, 182, 183, -124, 184, 186, 188, - 93, 93, -124, -124, 196, 198, 152, 93, 93, 93, - 93, 189, 190, -124, -124, 191, 192, 193, 194, 195, - 197, 199, -124, 200, 201, 202, 203, 77, 99, 107, - 80, 80, 80, -124, -124, -124, -124, -124, -124 + 40, 101, 144, 8, 101, 101, 28, 78, 88, 46, + 90, 92, 102, 105, 111, 112, 115, 116, 117, 118, + 128, 129, 130, 119, 69, 70, -146, -146, -146, -146, + -146, 91, 126, -146, 122, 134, 135, 73, 74, -146, + -146, 25, -146, 34, 98, 99, 104, 52, -11, 144, + 144, 101, 144, 144, 144, 144, 144, 144, 144, 144, + 51, -24, 109, -24, 110, 101, 101, 144, 34, 98, + 99, -24, -24, -146, -146, -146, 150, -146, 151, -146, + 152, 165, -146, -146, -146, -146, -146, -146, -146, -146, + -146, -146, -146, -146, -146, -146, -146, 136, 138, 0, + 139, 167, 172, 173, 175, 176, 188, 189, -146, -146, + -146, -146, -146, 180, -146, 181, -146, -146, 192, -146, + 183, 184, 190, 191, 193, 187, 194, 195, -146, 155, + 144, 144, 144, -146, -146, -146, -146, -146, -146, -146, + 197, 198, 199, 200, 201, 202, 203, 5, 26, -4, + -146, 174, 204, 185, 218, -18, 6, 21, 83, 50, + 170, 215, 210, -146, -146, -146, -146, -146, -146, 211, + -146, -146, -146, -31, -146, 144, -146, -146, 212, 213, + -146, 214, 216, 217, 98, 98, -146, -146, 226, 229, + 177, 98, 98, 98, 98, 220, 221, -146, -146, 222, + 223, 224, 225, 227, 228, 230, -146, 231, 232, 233, + 234, 42, 60, 63, 83, 83, 83, -146, -146, -146, + -146, -146, -146 }; const signed char @@ -1841,133 +1898,144 @@ namespace isc { namespace eval { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 18, 40, 19, 20, 2, 4, 0, 39, 0, 0, - 0, 0, 0, 3, 1, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 46, 19, 20, + 2, 4, 0, 45, 0, 0, 0, 0, 0, 3, + 1, 0, 6, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 5, 47, 48, 0, 49, 0, 52, + 0, 0, 53, 54, 55, 56, 25, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 68, 69, + 27, 58, 57, 0, 41, 0, 40, 7, 8, 9, + 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, + 0, 0, 0, 33, 34, 35, 36, 37, 38, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 5, 41, 42, 0, 43, 0, 46, 0, 0, - 47, 48, 49, 50, 25, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 26, 0, 0, 0, 0, 0, - 62, 63, 27, 52, 51, 0, 35, 0, 34, 7, - 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, - 45, 10, 21, 12, 23, 0, 64, 65, 28, 0, - 30, 0, 32, 14, 37, 0, 15, 0, 0, 0, - 0, 0, 68, 67, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 29, 31, 0, 0, 0, 0, 0, - 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 11, 22, 13, 24, 16, 36 + 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 50, 51, 10, 21, 12, 23, 0, + 70, 71, 28, 0, 30, 0, 32, 14, 43, 0, + 15, 0, 0, 0, 0, 0, 74, 73, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 29, 31, 0, + 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 22, 13, + 24, 16, 42 }; const short EvalParser::yypgoto_[] = { - -124, -124, -124, 2, -2, -124, 174, -54, -123, 154, - -124, -11, -124, -124, -124, -124, -124 + -146, -146, -146, 7, -2, -146, 166, -68, -145, 182, + -146, -30, -146, -146, -146, -146, -146 }; const short EvalParser::yydefgoto_[] = { - -1, 3, 24, 25, 26, 27, 64, 66, 142, 68, - 74, 95, 84, 92, 148, 127, 164 + -1, 3, 30, 31, 32, 33, 76, 78, 166, 80, + 86, 113, 96, 110, 172, 151, 188 }; const unsigned char EvalParser::yytable_[] = { - 33, 144, 153, 103, 162, 34, 35, 36, 155, 53, - 54, 144, 75, 76, 77, 78, 79, 80, 81, 156, - 93, 163, 138, 53, 54, 157, 94, 82, 83, 154, - 37, 139, 140, 141, 139, 140, 139, 140, 143, 113, - 97, 85, 86, 38, 88, 89, 145, 87, 105, 106, - 146, 147, 4, 101, 5, 99, 100, 40, 6, 7, - 8, 9, 90, 91, 194, 196, 198, 194, 196, 198, - 10, 61, 158, 53, 54, 11, 146, 147, 70, 71, - 72, 73, 62, 12, 63, 39, 13, 14, 15, 16, - 17, 1, 2, 18, 19, 139, 140, 193, 139, 140, - 20, 21, 22, 49, 23, 50, 171, 172, 41, 42, - 128, 129, 130, 176, 177, 178, 179, 139, 140, 195, - 43, 48, 28, 29, 30, 139, 140, 197, 44, 51, - 59, 52, 50, 60, 10, 52, 45, 46, 47, 11, - 55, 56, 57, 58, 96, 65, 67, 12, 69, 165, - 13, 14, 15, 16, 17, 107, 98, 31, 32, 108, - 109, 110, 115, 116, 20, 21, 22, 111, 23, 117, - 53, 118, 112, 114, 126, 119, 120, 121, 122, 150, - 123, 149, 124, 125, 131, 132, 133, 134, 135, 136, - 137, 152, 151, 154, 159, 160, 161, 166, 167, 168, - 173, 169, 174, 170, 175, 180, 181, 182, 183, 184, - 185, 186, 104, 0, 187, 0, 188, 189, 190, 191, - 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 102 + 39, 121, 177, 168, 186, 169, 65, 66, 40, 170, + 171, 41, 42, 168, 162, 179, 87, 88, 89, 90, + 91, 92, 93, 163, 164, 165, 180, 187, 111, 73, + 181, 65, 66, 115, 112, 178, 131, 94, 95, 163, + 164, 123, 124, 43, 163, 164, 167, 97, 98, 46, + 100, 101, 102, 103, 104, 105, 106, 107, 99, 182, + 163, 164, 217, 170, 171, 119, 218, 220, 222, 218, + 220, 222, 117, 118, 82, 83, 84, 85, 163, 164, + 219, 163, 164, 221, 61, 63, 62, 64, 71, 72, + 62, 64, 74, 44, 75, 1, 2, 65, 66, 108, + 109, 163, 164, 45, 4, 49, 5, 47, 50, 48, + 6, 7, 8, 9, 51, 52, 195, 196, 53, 54, + 55, 56, 10, 200, 201, 202, 203, 11, 152, 153, + 154, 57, 58, 59, 67, 12, 60, 68, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 69, + 70, 24, 25, 34, 35, 36, 77, 79, 26, 27, + 28, 81, 29, 114, 116, 10, 125, 126, 127, 128, + 11, 133, 129, 189, 130, 132, 134, 135, 12, 136, + 137, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 138, 139, 37, 38, 140, 141, 65, 142, + 143, 26, 27, 28, 147, 29, 144, 145, 174, 146, + 173, 148, 149, 150, 155, 156, 157, 158, 159, 160, + 161, 175, 176, 178, 183, 184, 185, 190, 191, 192, + 197, 193, 194, 198, 120, 199, 204, 205, 206, 207, + 208, 209, 0, 210, 0, 211, 0, 212, 213, 214, + 215, 216, 122 }; const short EvalParser::yycheck_[] = { - 2, 124, 20, 57, 35, 0, 4, 5, 9, 6, - 7, 134, 27, 28, 29, 30, 31, 32, 33, 20, - 46, 52, 9, 6, 7, 9, 52, 42, 43, 47, - 15, 18, 19, 20, 18, 19, 18, 19, 20, 36, - 51, 43, 44, 15, 46, 47, 9, 45, 59, 60, - 13, 14, 3, 55, 5, 53, 54, 3, 9, 10, - 11, 12, 42, 43, 187, 188, 189, 190, 191, 192, - 21, 4, 9, 6, 7, 26, 13, 14, 22, 23, - 24, 25, 52, 34, 54, 15, 37, 38, 39, 40, - 41, 49, 50, 44, 45, 18, 19, 20, 18, 19, - 51, 52, 53, 15, 55, 17, 160, 161, 17, 17, - 112, 113, 114, 167, 168, 169, 170, 18, 19, 20, - 3, 17, 9, 10, 11, 18, 19, 20, 3, 15, - 15, 17, 17, 15, 21, 17, 3, 3, 3, 26, - 8, 15, 15, 15, 48, 52, 52, 34, 51, 151, - 37, 38, 39, 40, 41, 16, 48, 44, 45, 16, - 16, 4, 4, 16, 51, 52, 53, 36, 55, 16, - 6, 16, 36, 36, 52, 16, 16, 16, 16, 4, - 17, 36, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 4, 36, 47, 9, 15, 15, 15, 15, 15, - 4, 15, 4, 15, 52, 16, 16, 16, 16, 16, - 16, 16, 58, -1, 17, -1, 17, 17, 17, 17, - 17, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 56 + 2, 69, 20, 148, 35, 9, 6, 7, 0, 13, + 14, 4, 5, 158, 9, 9, 27, 28, 29, 30, + 31, 32, 33, 18, 19, 20, 20, 58, 52, 4, + 9, 6, 7, 63, 58, 53, 36, 48, 49, 18, + 19, 71, 72, 15, 18, 19, 20, 49, 50, 3, + 52, 53, 54, 55, 56, 57, 58, 59, 51, 9, + 18, 19, 20, 13, 14, 67, 211, 212, 213, 214, + 215, 216, 65, 66, 22, 23, 24, 25, 18, 19, + 20, 18, 19, 20, 15, 15, 17, 17, 15, 15, + 17, 17, 58, 15, 60, 55, 56, 6, 7, 48, + 49, 18, 19, 15, 3, 3, 5, 17, 3, 17, + 9, 10, 11, 12, 3, 3, 184, 185, 3, 3, + 3, 3, 21, 191, 192, 193, 194, 26, 130, 131, + 132, 3, 3, 3, 8, 34, 17, 15, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 15, + 15, 50, 51, 9, 10, 11, 58, 58, 57, 58, + 59, 57, 61, 54, 54, 21, 16, 16, 16, 4, + 26, 4, 36, 175, 36, 36, 4, 4, 34, 4, + 4, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 46, 47, 4, 4, 50, 51, 16, 16, 6, 16, + 16, 57, 58, 59, 17, 61, 16, 16, 4, 16, + 36, 17, 17, 58, 17, 17, 17, 17, 17, 17, + 17, 36, 4, 53, 9, 15, 15, 15, 15, 15, + 4, 15, 15, 4, 68, 58, 16, 16, 16, 16, + 16, 16, -1, 16, -1, 17, -1, 17, 17, 17, + 17, 17, 70 }; const signed char EvalParser::yystos_[] = { - 0, 49, 50, 57, 3, 5, 9, 10, 11, 12, - 21, 26, 34, 37, 38, 39, 40, 41, 44, 45, - 51, 52, 53, 55, 58, 59, 60, 61, 9, 10, - 11, 44, 45, 60, 0, 59, 59, 15, 15, 15, - 3, 17, 17, 3, 3, 3, 3, 3, 17, 15, - 17, 15, 17, 6, 7, 8, 15, 15, 15, 15, - 15, 4, 52, 54, 62, 52, 63, 52, 65, 51, - 22, 23, 24, 25, 66, 27, 28, 29, 30, 31, - 32, 33, 42, 43, 68, 60, 60, 59, 60, 60, - 42, 43, 69, 46, 52, 67, 48, 67, 48, 59, - 59, 60, 62, 63, 65, 67, 67, 16, 16, 16, - 4, 36, 36, 36, 36, 4, 16, 16, 16, 16, - 16, 16, 16, 17, 17, 17, 52, 71, 60, 60, - 60, 17, 17, 17, 17, 17, 17, 17, 9, 18, - 19, 20, 64, 20, 64, 9, 13, 14, 70, 36, - 4, 36, 4, 20, 47, 9, 20, 9, 9, 9, - 15, 15, 35, 52, 72, 60, 15, 15, 15, 15, - 15, 63, 63, 4, 4, 52, 63, 63, 63, 63, + 0, 55, 56, 63, 3, 5, 9, 10, 11, 12, + 21, 26, 34, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 50, 51, 57, 58, 59, 61, + 64, 65, 66, 67, 9, 10, 11, 50, 51, 66, + 0, 65, 65, 15, 15, 15, 3, 17, 17, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 17, 15, 17, 15, 17, 6, 7, 8, 15, 15, + 15, 15, 15, 4, 58, 60, 68, 58, 69, 58, + 71, 57, 22, 23, 24, 25, 72, 27, 28, 29, + 30, 31, 32, 33, 48, 49, 74, 66, 66, 65, + 66, 66, 66, 66, 66, 66, 66, 66, 48, 49, + 75, 52, 58, 73, 54, 73, 54, 65, 65, 66, + 68, 69, 71, 73, 73, 16, 16, 16, 4, 36, + 36, 36, 36, 4, 4, 4, 4, 4, 4, 4, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, - 17, 17, 17, 20, 64, 20, 64, 20, 64 + 58, 77, 66, 66, 66, 17, 17, 17, 17, 17, + 17, 17, 9, 18, 19, 20, 70, 20, 70, 9, + 13, 14, 76, 36, 4, 36, 4, 20, 53, 9, + 20, 9, 9, 9, 15, 15, 35, 58, 78, 66, + 15, 15, 15, 15, 15, 69, 69, 4, 4, 58, + 69, 69, 69, 69, 16, 16, 16, 16, 16, 16, + 16, 17, 17, 17, 17, 17, 17, 20, 70, 20, + 70, 20, 70 }; const signed char EvalParser::yyr1_[] = { - 0, 56, 57, 57, 58, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 59, 59, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, - 61, 62, 62, 63, 64, 64, 65, 66, 66, 66, - 66, 67, 67, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 69, 69, 70, 70, 71, 72, 72 + 0, 62, 63, 63, 64, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 66, 66, 67, 68, 68, 69, + 70, 70, 71, 72, 72, 72, 72, 73, 73, 74, + 74, 74, 74, 74, 74, 74, 74, 74, 75, 75, + 76, 76, 77, 78, 78 }; const signed char @@ -1976,10 +2044,11 @@ namespace isc { namespace eval { 0, 2, 2, 2, 1, 3, 2, 3, 3, 3, 6, 11, 6, 11, 6, 6, 11, 4, 1, 1, 1, 6, 11, 6, 11, 3, 3, 3, 6, 8, - 6, 8, 6, 4, 3, 3, 11, 6, 9, 1, + 6, 8, 6, 4, 4, 4, 4, 4, 4, 4, + 3, 3, 11, 6, 9, 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, 1, 1 + 1, 1, 1, 1, 1 }; @@ -1996,27 +2065,30 @@ namespace isc { namespace eval { "\"dst\"", "\"len\"", "\"pkt4\"", "\"mac\"", "\"hlen\"", "\"htype\"", "\"ciaddr\"", "\"giaddr\"", "\"yiaddr\"", "\"siaddr\"", "\"substring\"", "\"all\"", "\",\"", "\"concat\"", "\"ifelse\"", "\"hexstring\"", - "\"addrtotext\"", "\"pkt6\"", "\"msgtype\"", "\"transid\"", - "\"vendor-class\"", "\"vendor\"", "\"*\"", "\"data\"", "\"enterprise\"", - "\"top-level bool\"", "\"top-level string\"", "\"constant string\"", - "\"integer\"", "\"constant hexstring\"", "\"option name\"", - "\"ip address\"", "$accept", "start", "expression", "bool_expr", - "string_expr", "integer_expr", "option_code", "sub_option_code", - "option_repr_type", "nest_level", "pkt_metadata", "enterprise_id", - "pkt4_field", "pkt6_field", "relay6_field", "start_expr", "length_expr", YY_NULLPTR + "\"addrtotext\"", "\"int8totext\"", "\"int16totext\"", "\"int32totext\"", + "\"uint8totext\"", "\"uint16totext\"", "\"uint32totext\"", "\"pkt6\"", + "\"msgtype\"", "\"transid\"", "\"vendor-class\"", "\"vendor\"", "\"*\"", + "\"data\"", "\"enterprise\"", "\"top-level bool\"", + "\"top-level string\"", "\"constant string\"", "\"integer\"", + "\"constant hexstring\"", "\"option name\"", "\"ip address\"", "$accept", + "start", "expression", "bool_expr", "string_expr", "integer_expr", + "option_code", "sub_option_code", "option_repr_type", "nest_level", + "pkt_metadata", "enterprise_id", "pkt4_field", "pkt6_field", + "relay6_field", "start_expr", "length_expr", YY_NULLPTR }; #if EVALDEBUG const short EvalParser::yyrline_[] = { - 0, 122, 122, 123, 128, 131, 132, 137, 142, 147, - 152, 157, 162, 182, 196, 205, 214, 224, 241, 246, - 251, 256, 261, 266, 287, 302, 307, 321, 335, 350, - 355, 360, 365, 370, 375, 384, 394, 403, 416, 429, - 436, 442, 446, 452, 458, 462, 468, 477, 481, 485, - 489, 495, 499, 505, 509, 513, 517, 521, 525, 529, - 533, 537, 543, 547, 553, 557, 563, 570, 575 + 0, 128, 128, 129, 134, 137, 138, 143, 148, 153, + 158, 163, 168, 188, 202, 211, 220, 230, 247, 252, + 257, 262, 267, 272, 293, 308, 313, 327, 341, 356, + 361, 366, 371, 376, 381, 386, 391, 396, 401, 406, + 411, 420, 430, 439, 452, 465, 472, 478, 482, 488, + 494, 498, 504, 513, 517, 521, 525, 531, 535, 541, + 545, 549, 553, 557, 561, 565, 569, 573, 579, 583, + 589, 593, 599, 606, 611 }; // Print the state stack on the debug stream. @@ -2051,9 +2123,9 @@ namespace isc { namespace eval { #line 14 "parser.yy" } } // isc::eval -#line 2055 "parser.cc" +#line 2127 "parser.cc" -#line 582 "parser.yy" +#line 618 "parser.yy" void isc::eval::EvalParser::error(const location_type& loc, diff --git a/src/lib/eval/parser.h b/src/lib/eval/parser.h index 9ab029c736..2753e00be6 100644 --- a/src/lib/eval/parser.h +++ b/src/lib/eval/parser.h @@ -520,21 +520,27 @@ namespace isc { namespace eval { TOKEN_IFELSE = 293, TOKEN_TOHEXSTRING = 294, TOKEN_ADDRTOTEXT = 295, - TOKEN_PKT6 = 296, - TOKEN_MSGTYPE = 297, - TOKEN_TRANSID = 298, - TOKEN_VENDOR_CLASS = 299, - TOKEN_VENDOR = 300, - TOKEN_ANY = 301, - TOKEN_DATA = 302, - TOKEN_ENTERPRISE = 303, - TOKEN_TOPLEVEL_BOOL = 304, - TOKEN_TOPLEVEL_STRING = 305, - TOKEN_STRING = 306, - TOKEN_INTEGER = 307, - TOKEN_HEXSTRING = 308, - TOKEN_OPTION_NAME = 309, - TOKEN_IP_ADDRESS = 310 + TOKEN_INT8TOTEXT = 296, + TOKEN_INT16TOTEXT = 297, + TOKEN_INT32TOTEXT = 298, + TOKEN_UINT8TOTEXT = 299, + TOKEN_UINT16TOTEXT = 300, + TOKEN_UINT32TOTEXT = 301, + TOKEN_PKT6 = 302, + TOKEN_MSGTYPE = 303, + TOKEN_TRANSID = 304, + TOKEN_VENDOR_CLASS = 305, + TOKEN_VENDOR = 306, + TOKEN_ANY = 307, + TOKEN_DATA = 308, + TOKEN_ENTERPRISE = 309, + TOKEN_TOPLEVEL_BOOL = 310, + TOKEN_TOPLEVEL_STRING = 311, + TOKEN_STRING = 312, + TOKEN_INTEGER = 313, + TOKEN_HEXSTRING = 314, + TOKEN_OPTION_NAME = 315, + TOKEN_IP_ADDRESS = 316 }; }; @@ -728,45 +734,45 @@ namespace isc { namespace eval { // Type destructor. switch (yytype) { - case 64: // option_repr_type + case 70: // option_repr_type value.template destroy< TokenOption::RepresentationType > (); break; - case 68: // pkt4_field + case 74: // pkt4_field value.template destroy< TokenPkt4::FieldType > (); break; - case 69: // pkt6_field + case 75: // pkt6_field value.template destroy< TokenPkt6::FieldType > (); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.template destroy< TokenPkt::MetadataType > (); break; - case 70: // relay6_field + case 76: // relay6_field value.template destroy< TokenRelay6Field::FieldType > (); break; - case 65: // nest_level + case 71: // nest_level value.template destroy< int8_t > (); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.template destroy< std::string > (); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.template destroy< uint16_t > (); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.template destroy< uint32_t > (); break; @@ -846,13 +852,13 @@ switch (yytype) symbol_type (int tok, location_type l) : super_type(token_type (tok), std::move (l)) { - YY_ASSERT (tok == token::TOKEN_END || tok == token::TOKEN_LPAREN || tok == token::TOKEN_RPAREN || tok == token::TOKEN_NOT || tok == token::TOKEN_AND || tok == token::TOKEN_OR || tok == token::TOKEN_EQUAL || tok == token::TOKEN_OPTION || tok == token::TOKEN_RELAY4 || tok == token::TOKEN_RELAY6 || tok == token::TOKEN_MEMBER || tok == token::TOKEN_PEERADDR || tok == token::TOKEN_LINKADDR || tok == token::TOKEN_LBRACKET || tok == token::TOKEN_RBRACKET || tok == token::TOKEN_DOT || tok == token::TOKEN_TEXT || tok == token::TOKEN_HEX || tok == token::TOKEN_EXISTS || tok == token::TOKEN_PKT || tok == token::TOKEN_IFACE || tok == token::TOKEN_SRC || tok == token::TOKEN_DST || tok == token::TOKEN_LEN || tok == token::TOKEN_PKT4 || tok == token::TOKEN_CHADDR || tok == token::TOKEN_HLEN || tok == token::TOKEN_HTYPE || tok == token::TOKEN_CIADDR || tok == token::TOKEN_GIADDR || tok == token::TOKEN_YIADDR || tok == token::TOKEN_SIADDR || tok == token::TOKEN_SUBSTRING || tok == token::TOKEN_ALL || tok == token::TOKEN_COMA || tok == token::TOKEN_CONCAT || tok == token::TOKEN_IFELSE || tok == token::TOKEN_TOHEXSTRING || tok == token::TOKEN_ADDRTOTEXT || tok == token::TOKEN_PKT6 || tok == token::TOKEN_MSGTYPE || tok == token::TOKEN_TRANSID || tok == token::TOKEN_VENDOR_CLASS || tok == token::TOKEN_VENDOR || tok == token::TOKEN_ANY || tok == token::TOKEN_DATA || tok == token::TOKEN_ENTERPRISE || tok == token::TOKEN_TOPLEVEL_BOOL || tok == token::TOKEN_TOPLEVEL_STRING); + YY_ASSERT (tok == token::TOKEN_END || tok == token::TOKEN_LPAREN || tok == token::TOKEN_RPAREN || tok == token::TOKEN_NOT || tok == token::TOKEN_AND || tok == token::TOKEN_OR || tok == token::TOKEN_EQUAL || tok == token::TOKEN_OPTION || tok == token::TOKEN_RELAY4 || tok == token::TOKEN_RELAY6 || tok == token::TOKEN_MEMBER || tok == token::TOKEN_PEERADDR || tok == token::TOKEN_LINKADDR || tok == token::TOKEN_LBRACKET || tok == token::TOKEN_RBRACKET || tok == token::TOKEN_DOT || tok == token::TOKEN_TEXT || tok == token::TOKEN_HEX || tok == token::TOKEN_EXISTS || tok == token::TOKEN_PKT || tok == token::TOKEN_IFACE || tok == token::TOKEN_SRC || tok == token::TOKEN_DST || tok == token::TOKEN_LEN || tok == token::TOKEN_PKT4 || tok == token::TOKEN_CHADDR || tok == token::TOKEN_HLEN || tok == token::TOKEN_HTYPE || tok == token::TOKEN_CIADDR || tok == token::TOKEN_GIADDR || tok == token::TOKEN_YIADDR || tok == token::TOKEN_SIADDR || tok == token::TOKEN_SUBSTRING || tok == token::TOKEN_ALL || tok == token::TOKEN_COMA || tok == token::TOKEN_CONCAT || tok == token::TOKEN_IFELSE || tok == token::TOKEN_TOHEXSTRING || tok == token::TOKEN_ADDRTOTEXT || tok == token::TOKEN_INT8TOTEXT || tok == token::TOKEN_INT16TOTEXT || tok == token::TOKEN_INT32TOTEXT || tok == token::TOKEN_UINT8TOTEXT || tok == token::TOKEN_UINT16TOTEXT || tok == token::TOKEN_UINT32TOTEXT || tok == token::TOKEN_PKT6 || tok == token::TOKEN_MSGTYPE || tok == token::TOKEN_TRANSID || tok == token::TOKEN_VENDOR_CLASS || tok == token::TOKEN_VENDOR || tok == token::TOKEN_ANY || tok == token::TOKEN_DATA || tok == token::TOKEN_ENTERPRISE || tok == token::TOKEN_TOPLEVEL_BOOL || tok == token::TOKEN_TOPLEVEL_STRING); } #else symbol_type (int tok, const location_type& l) : super_type(token_type (tok), l) { - YY_ASSERT (tok == token::TOKEN_END || tok == token::TOKEN_LPAREN || tok == token::TOKEN_RPAREN || tok == token::TOKEN_NOT || tok == token::TOKEN_AND || tok == token::TOKEN_OR || tok == token::TOKEN_EQUAL || tok == token::TOKEN_OPTION || tok == token::TOKEN_RELAY4 || tok == token::TOKEN_RELAY6 || tok == token::TOKEN_MEMBER || tok == token::TOKEN_PEERADDR || tok == token::TOKEN_LINKADDR || tok == token::TOKEN_LBRACKET || tok == token::TOKEN_RBRACKET || tok == token::TOKEN_DOT || tok == token::TOKEN_TEXT || tok == token::TOKEN_HEX || tok == token::TOKEN_EXISTS || tok == token::TOKEN_PKT || tok == token::TOKEN_IFACE || tok == token::TOKEN_SRC || tok == token::TOKEN_DST || tok == token::TOKEN_LEN || tok == token::TOKEN_PKT4 || tok == token::TOKEN_CHADDR || tok == token::TOKEN_HLEN || tok == token::TOKEN_HTYPE || tok == token::TOKEN_CIADDR || tok == token::TOKEN_GIADDR || tok == token::TOKEN_YIADDR || tok == token::TOKEN_SIADDR || tok == token::TOKEN_SUBSTRING || tok == token::TOKEN_ALL || tok == token::TOKEN_COMA || tok == token::TOKEN_CONCAT || tok == token::TOKEN_IFELSE || tok == token::TOKEN_TOHEXSTRING || tok == token::TOKEN_ADDRTOTEXT || tok == token::TOKEN_PKT6 || tok == token::TOKEN_MSGTYPE || tok == token::TOKEN_TRANSID || tok == token::TOKEN_VENDOR_CLASS || tok == token::TOKEN_VENDOR || tok == token::TOKEN_ANY || tok == token::TOKEN_DATA || tok == token::TOKEN_ENTERPRISE || tok == token::TOKEN_TOPLEVEL_BOOL || tok == token::TOKEN_TOPLEVEL_STRING); + YY_ASSERT (tok == token::TOKEN_END || tok == token::TOKEN_LPAREN || tok == token::TOKEN_RPAREN || tok == token::TOKEN_NOT || tok == token::TOKEN_AND || tok == token::TOKEN_OR || tok == token::TOKEN_EQUAL || tok == token::TOKEN_OPTION || tok == token::TOKEN_RELAY4 || tok == token::TOKEN_RELAY6 || tok == token::TOKEN_MEMBER || tok == token::TOKEN_PEERADDR || tok == token::TOKEN_LINKADDR || tok == token::TOKEN_LBRACKET || tok == token::TOKEN_RBRACKET || tok == token::TOKEN_DOT || tok == token::TOKEN_TEXT || tok == token::TOKEN_HEX || tok == token::TOKEN_EXISTS || tok == token::TOKEN_PKT || tok == token::TOKEN_IFACE || tok == token::TOKEN_SRC || tok == token::TOKEN_DST || tok == token::TOKEN_LEN || tok == token::TOKEN_PKT4 || tok == token::TOKEN_CHADDR || tok == token::TOKEN_HLEN || tok == token::TOKEN_HTYPE || tok == token::TOKEN_CIADDR || tok == token::TOKEN_GIADDR || tok == token::TOKEN_YIADDR || tok == token::TOKEN_SIADDR || tok == token::TOKEN_SUBSTRING || tok == token::TOKEN_ALL || tok == token::TOKEN_COMA || tok == token::TOKEN_CONCAT || tok == token::TOKEN_IFELSE || tok == token::TOKEN_TOHEXSTRING || tok == token::TOKEN_ADDRTOTEXT || tok == token::TOKEN_INT8TOTEXT || tok == token::TOKEN_INT16TOTEXT || tok == token::TOKEN_INT32TOTEXT || tok == token::TOKEN_UINT8TOTEXT || tok == token::TOKEN_UINT16TOTEXT || tok == token::TOKEN_UINT32TOTEXT || tok == token::TOKEN_PKT6 || tok == token::TOKEN_MSGTYPE || tok == token::TOKEN_TRANSID || tok == token::TOKEN_VENDOR_CLASS || tok == token::TOKEN_VENDOR || tok == token::TOKEN_ANY || tok == token::TOKEN_DATA || tok == token::TOKEN_ENTERPRISE || tok == token::TOKEN_TOPLEVEL_BOOL || tok == token::TOKEN_TOPLEVEL_STRING); } #endif #if 201103L <= YY_CPLUSPLUS @@ -1493,6 +1499,96 @@ switch (yytype) #if 201103L <= YY_CPLUSPLUS static symbol_type + make_INT8TOTEXT (location_type l) + { + return symbol_type (token::TOKEN_INT8TOTEXT, std::move (l)); + } +#else + static + symbol_type + make_INT8TOTEXT (const location_type& l) + { + return symbol_type (token::TOKEN_INT8TOTEXT, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_INT16TOTEXT (location_type l) + { + return symbol_type (token::TOKEN_INT16TOTEXT, std::move (l)); + } +#else + static + symbol_type + make_INT16TOTEXT (const location_type& l) + { + return symbol_type (token::TOKEN_INT16TOTEXT, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_INT32TOTEXT (location_type l) + { + return symbol_type (token::TOKEN_INT32TOTEXT, std::move (l)); + } +#else + static + symbol_type + make_INT32TOTEXT (const location_type& l) + { + return symbol_type (token::TOKEN_INT32TOTEXT, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_UINT8TOTEXT (location_type l) + { + return symbol_type (token::TOKEN_UINT8TOTEXT, std::move (l)); + } +#else + static + symbol_type + make_UINT8TOTEXT (const location_type& l) + { + return symbol_type (token::TOKEN_UINT8TOTEXT, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_UINT16TOTEXT (location_type l) + { + return symbol_type (token::TOKEN_UINT16TOTEXT, std::move (l)); + } +#else + static + symbol_type + make_UINT16TOTEXT (const location_type& l) + { + return symbol_type (token::TOKEN_UINT16TOTEXT, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type + make_UINT32TOTEXT (location_type l) + { + return symbol_type (token::TOKEN_UINT32TOTEXT, std::move (l)); + } +#else + static + symbol_type + make_UINT32TOTEXT (const location_type& l) + { + return symbol_type (token::TOKEN_UINT32TOTEXT, l); + } +#endif +#if 201103L <= YY_CPLUSPLUS + static + symbol_type make_PKT6 (location_type l) { return symbol_type (token::TOKEN_PKT6, std::move (l)); @@ -1744,7 +1840,7 @@ switch (yytype) /// \param yyvalue the value to check static bool yy_table_value_is_error_ (int yyvalue); - static const signed char yypact_ninf_; + static const short yypact_ninf_; static const signed char yytable_ninf_; /// Convert a scanner token number \a t to a symbol number. @@ -2021,10 +2117,10 @@ switch (yytype) enum { yyeof_ = 0, - yylast_ = 230, ///< Last index in yytable_. + yylast_ = 252, ///< Last index in yytable_. yynnts_ = 17, ///< Number of nonterminal symbols. - yyfinal_ = 34, ///< Termination state number. - yyntokens_ = 56 ///< Number of tokens. + yyfinal_ = 40, ///< Termination state number. + yyntokens_ = 62 ///< Number of tokens. }; @@ -2073,9 +2169,9 @@ switch (yytype) 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55 + 55, 56, 57, 58, 59, 60, 61 }; - const int user_token_number_max_ = 310; + const int user_token_number_max_ = 316; if (t <= 0) return yyeof_; @@ -2095,45 +2191,45 @@ switch (yytype) { switch (this->type_get ()) { - case 64: // option_repr_type + case 70: // option_repr_type value.move< TokenOption::RepresentationType > (std::move (that.value)); break; - case 68: // pkt4_field + case 74: // pkt4_field value.move< TokenPkt4::FieldType > (std::move (that.value)); break; - case 69: // pkt6_field + case 75: // pkt6_field value.move< TokenPkt6::FieldType > (std::move (that.value)); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.move< TokenPkt::MetadataType > (std::move (that.value)); break; - case 70: // relay6_field + case 76: // relay6_field value.move< TokenRelay6Field::FieldType > (std::move (that.value)); break; - case 65: // nest_level + case 71: // nest_level value.move< int8_t > (std::move (that.value)); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.move< std::string > (std::move (that.value)); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.move< uint16_t > (std::move (that.value)); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.move< uint32_t > (std::move (that.value)); break; @@ -2152,45 +2248,45 @@ switch (yytype) { switch (this->type_get ()) { - case 64: // option_repr_type + case 70: // option_repr_type value.copy< TokenOption::RepresentationType > (YY_MOVE (that.value)); break; - case 68: // pkt4_field + case 74: // pkt4_field value.copy< TokenPkt4::FieldType > (YY_MOVE (that.value)); break; - case 69: // pkt6_field + case 75: // pkt6_field value.copy< TokenPkt6::FieldType > (YY_MOVE (that.value)); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.copy< TokenPkt::MetadataType > (YY_MOVE (that.value)); break; - case 70: // relay6_field + case 76: // relay6_field value.copy< TokenRelay6Field::FieldType > (YY_MOVE (that.value)); break; - case 65: // nest_level + case 71: // nest_level value.copy< int8_t > (YY_MOVE (that.value)); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.copy< std::string > (YY_MOVE (that.value)); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.copy< uint16_t > (YY_MOVE (that.value)); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.copy< uint32_t > (YY_MOVE (that.value)); break; @@ -2216,45 +2312,45 @@ switch (yytype) super_type::move (s); switch (this->type_get ()) { - case 64: // option_repr_type + case 70: // option_repr_type value.move< TokenOption::RepresentationType > (YY_MOVE (s.value)); break; - case 68: // pkt4_field + case 74: // pkt4_field value.move< TokenPkt4::FieldType > (YY_MOVE (s.value)); break; - case 69: // pkt6_field + case 75: // pkt6_field value.move< TokenPkt6::FieldType > (YY_MOVE (s.value)); break; - case 66: // pkt_metadata + case 72: // pkt_metadata value.move< TokenPkt::MetadataType > (YY_MOVE (s.value)); break; - case 70: // relay6_field + case 76: // relay6_field value.move< TokenRelay6Field::FieldType > (YY_MOVE (s.value)); break; - case 65: // nest_level + case 71: // nest_level value.move< int8_t > (YY_MOVE (s.value)); break; - case 51: // "constant string" - case 52: // "integer" - case 53: // "constant hexstring" - case 54: // "option name" - case 55: // "ip address" + case 57: // "constant string" + case 58: // "integer" + case 59: // "constant hexstring" + case 60: // "option name" + case 61: // "ip address" value.move< std::string > (YY_MOVE (s.value)); break; - case 62: // option_code - case 63: // sub_option_code + case 68: // option_code + case 69: // sub_option_code value.move< uint16_t > (YY_MOVE (s.value)); break; - case 61: // integer_expr - case 67: // enterprise_id + case 67: // integer_expr + case 73: // enterprise_id value.move< uint32_t > (YY_MOVE (s.value)); break; @@ -2314,7 +2410,7 @@ switch (yytype) #line 14 "parser.yy" } } // isc::eval -#line 2318 "parser.h" +#line 2414 "parser.h" diff --git a/src/lib/eval/parser.yy b/src/lib/eval/parser.yy index c213f69c0e..d09e04588e 100644 --- a/src/lib/eval/parser.yy +++ b/src/lib/eval/parser.yy @@ -77,6 +77,12 @@ using namespace isc::eval; IFELSE "ifelse" TOHEXSTRING "hexstring" ADDRTOTEXT "addrtotext" + INT8TOTEXT "int8totext" + INT16TOTEXT "int16totext" + INT32TOTEXT "int32totext" + UINT8TOTEXT "uint8totext" + UINT16TOTEXT "uint16totext" + UINT32TOTEXT "uint32totext" PKT6 "pkt6" MSGTYPE "msgtype" TRANSID "transid" @@ -379,6 +385,36 @@ string_expr : STRING TokenPtr addrtotext(new TokenIpAddressToText()); ctx.expression.push_back(addrtotext); } + | INT8TOTEXT "(" string_expr ")" + { + TokenPtr int8totext(new TokenInt8ToText()); + ctx.expression.push_back(int8totext); + } + | INT16TOTEXT "(" string_expr ")" + { + TokenPtr int16totext(new TokenInt16ToText()); + ctx.expression.push_back(int16totext); + } + | INT32TOTEXT "(" string_expr ")" + { + TokenPtr int32totext(new TokenInt32ToText()); + ctx.expression.push_back(int32totext); + } + | UINT8TOTEXT "(" string_expr ")" + { + TokenPtr uint8totext(new TokenUInt8ToText()); + ctx.expression.push_back(uint8totext); + } + | UINT16TOTEXT "(" string_expr ")" + { + TokenPtr uint16totext(new TokenUInt16ToText()); + ctx.expression.push_back(uint16totext); + } + | UINT32TOTEXT "(" string_expr ")" + { + TokenPtr uint32totext(new TokenUInt32ToText()); + ctx.expression.push_back(uint32totext); + } | VENDOR "." ENTERPRISE { // expression: vendor.enterprise diff --git a/src/lib/eval/tests/context_unittest.cc b/src/lib/eval/tests/context_unittest.cc index 19fff964f0..fd71510cb8 100644 --- a/src/lib/eval/tests/context_unittest.cc +++ b/src/lib/eval/tests/context_unittest.cc @@ -492,6 +492,42 @@ public: EXPECT_EQ(value, expected); } + /// @brief checks if the given token is a inttotext operator + template <typename Integer, typename TokenInteger> + void checkTokenIntToText(const TokenPtr& token, + const std::string& expected) { + ASSERT_TRUE(token); + boost::shared_ptr<TokenInteger> inttotext = + boost::dynamic_pointer_cast<TokenInteger>(token); + EXPECT_TRUE(inttotext); + + Pkt4Ptr pkt4(new Pkt4(DHCPDISCOVER, 12345)); + ValueStack values; + + Integer n; + + try { + if (is_signed<Integer>()) { + n = static_cast<Integer>(boost::lexical_cast<int32_t>(expected)); + } else { + n = static_cast<Integer>(boost::lexical_cast<uint32_t>(expected)); + } + } catch (const boost::bad_lexical_cast& e) { + FAIL() << "invalid value " << expected << " while expecting " + << boost::core::demangle(typeid(n).name()) << " error: " + << e.what(); + } + + values.push(std::string(const_cast<const char*>(reinterpret_cast<char*>(&n)), sizeof(Integer))); + + EXPECT_NO_THROW(token->evaluate(*pkt4, values)); + + ASSERT_EQ(1, values.size()); + string value = values.top(); + + EXPECT_EQ(value, expected); + } + /// @brief checks if the given expression raises the expected message /// when it is parsed. void checkError(const string& expr, const string& msg) { @@ -896,7 +932,6 @@ TEST_F(EvalContextTest, ipaddress6prefix) { checkTokenIpAddress(tmp, "2001:db8::"); } - // Test the parsing of an equal expression TEST_F(EvalContextTest, equal) { EvalContext eval(Option::V4); @@ -1518,6 +1553,126 @@ TEST_F(EvalContextTest, addressToText) { } } +// Test the parsing of a int8_t expression +TEST_F(EvalContextTest, int8ToText) { + EvalContext eval(Option::V4); + + EXPECT_NO_THROW(parsed_ = eval.parseString("int8totext(255) == '-1'")); + EXPECT_TRUE(parsed_); + + ASSERT_EQ(4, eval.expression.size()); + + TokenPtr tmp1 = eval.expression.at(0); + TokenPtr tmp2 = eval.expression.at(1); + TokenPtr tmp3 = eval.expression.at(2); + TokenPtr tmp4 = eval.expression.at(3); + + checkTokenInteger(tmp1, 255); + checkTokenIntToText<int8_t, TokenInt8ToText>(tmp2, "-1"); + checkTokenString(tmp3, "-1"); + checkTokenEq(tmp4); +} + +// Test the parsing of a int16_t expression +TEST_F(EvalContextTest, int16ToText) { + EvalContext eval(Option::V4); + + EXPECT_NO_THROW(parsed_ = eval.parseString("int16totext(65535) == '-1'")); + EXPECT_TRUE(parsed_); + + ASSERT_EQ(4, eval.expression.size()); + + TokenPtr tmp1 = eval.expression.at(0); + TokenPtr tmp2 = eval.expression.at(1); + TokenPtr tmp3 = eval.expression.at(2); + TokenPtr tmp4 = eval.expression.at(3); + + checkTokenInteger(tmp1, 65535); + checkTokenIntToText<int16_t, TokenInt16ToText>(tmp2, "-1"); + checkTokenString(tmp3, "-1"); + checkTokenEq(tmp4); +} + +// Test the parsing of a int32_t expression +TEST_F(EvalContextTest, int32ToText) { + EvalContext eval(Option::V4); + + EXPECT_NO_THROW(parsed_ = eval.parseString("int32totext(4294967295) == '-1'")); + EXPECT_TRUE(parsed_); + + ASSERT_EQ(4, eval.expression.size()); + + TokenPtr tmp1 = eval.expression.at(0); + TokenPtr tmp2 = eval.expression.at(1); + TokenPtr tmp3 = eval.expression.at(2); + TokenPtr tmp4 = eval.expression.at(3); + + checkTokenInteger(tmp1, 4294967295); + checkTokenIntToText<int32_t, TokenInt32ToText>(tmp2, "-1"); + checkTokenString(tmp3, "-1"); + checkTokenEq(tmp4); +} + +// Test the parsing of a uint8_t expression +TEST_F(EvalContextTest, uint8ToText) { + EvalContext eval(Option::V4); + + EXPECT_NO_THROW(parsed_ = eval.parseString("uint8totext(255) == '255'")); + EXPECT_TRUE(parsed_); + + ASSERT_EQ(4, eval.expression.size()); + + TokenPtr tmp1 = eval.expression.at(0); + TokenPtr tmp2 = eval.expression.at(1); + TokenPtr tmp3 = eval.expression.at(2); + TokenPtr tmp4 = eval.expression.at(3); + + checkTokenInteger(tmp1, 255); + checkTokenIntToText<uint8_t, TokenUInt8ToText>(tmp2, "255"); + checkTokenString(tmp3, "255"); + checkTokenEq(tmp4); +} + +// Test the parsing of a uint16_t expression +TEST_F(EvalContextTest, uint16ToText) { + EvalContext eval(Option::V4); + + EXPECT_NO_THROW(parsed_ = eval.parseString("uint16totext(65535) == '65535'")); + EXPECT_TRUE(parsed_); + + ASSERT_EQ(4, eval.expression.size()); + + TokenPtr tmp1 = eval.expression.at(0); + TokenPtr tmp2 = eval.expression.at(1); + TokenPtr tmp3 = eval.expression.at(2); + TokenPtr tmp4 = eval.expression.at(3); + + checkTokenInteger(tmp1, 65535); + checkTokenIntToText<uint16_t, TokenUInt16ToText>(tmp2, "65535"); + checkTokenString(tmp3, "65535"); + checkTokenEq(tmp4); +} + +// Test the parsing of a uint32_t expression +TEST_F(EvalContextTest, uint32ToText) { + EvalContext eval(Option::V4); + + EXPECT_NO_THROW(parsed_ = eval.parseString("uint32totext(4294967295) == '4294967295'")); + EXPECT_TRUE(parsed_); + + ASSERT_EQ(4, eval.expression.size()); + + TokenPtr tmp1 = eval.expression.at(0); + TokenPtr tmp2 = eval.expression.at(1); + TokenPtr tmp3 = eval.expression.at(2); + TokenPtr tmp4 = eval.expression.at(3); + + checkTokenInteger(tmp1, 4294967295); + checkTokenIntToText<uint32_t, TokenUInt32ToText>(tmp2, "4294967295"); + checkTokenString(tmp3, "4294967295"); + checkTokenEq(tmp4); +} + // // Test some scanner error cases TEST_F(EvalContextTest, scanErrors) { @@ -1696,6 +1851,42 @@ TEST_F(EvalContextTest, parseErrors) { "<string>:1.31: syntax error, unexpected end of file, expecting =="); checkError("addrtotext('')", "<string>:1.15: syntax error, unexpected end of file, expecting =="); + checkError("int8totext('01', '01')", + "<string>:1.16: syntax error, unexpected \",\", expecting )"); + checkError("int8totext('0123')", + "<string>:1.19: syntax error, unexpected end of file, expecting =="); + checkError("int8totext('')", + "<string>:1.15: syntax error, unexpected end of file, expecting =="); + checkError("int16totext('0123', '0123')", + "<string>:1.19: syntax error, unexpected \",\", expecting )"); + checkError("int16totext('01')", + "<string>:1.18: syntax error, unexpected end of file, expecting =="); + checkError("int16totext('')", + "<string>:1.16: syntax error, unexpected end of file, expecting =="); + checkError("int32totext('01234567', '01234567')", + "<string>:1.23: syntax error, unexpected \",\", expecting )"); + checkError("int32totext('01')", + "<string>:1.18: syntax error, unexpected end of file, expecting =="); + checkError("int32totext('')", + "<string>:1.16: syntax error, unexpected end of file, expecting =="); + checkError("uint8totext('01', '01')", + "<string>:1.17: syntax error, unexpected \",\", expecting )"); + checkError("uint8totext('0123')", + "<string>:1.20: syntax error, unexpected end of file, expecting =="); + checkError("uint8totext('')", + "<string>:1.16: syntax error, unexpected end of file, expecting =="); + checkError("uint16totext('0123', '0123')", + "<string>:1.20: syntax error, unexpected \",\", expecting )"); + checkError("uint16totext('01')", + "<string>:1.19: syntax error, unexpected end of file, expecting =="); + checkError("uint16totext('')", + "<string>:1.17: syntax error, unexpected end of file, expecting =="); + checkError("uint32totext('01234567', '01234567')", + "<string>:1.24: syntax error, unexpected \",\", expecting )"); + checkError("uint32totext('01')", + "<string>:1.19: syntax error, unexpected end of file, expecting =="); + checkError("uint32totext('')", + "<string>:1.17: syntax error, unexpected end of file, expecting =="); } // Tests some type error cases @@ -1751,8 +1942,31 @@ TEST_F(EvalContextTest, typeErrors) { // Addrtotext requires string storing the binary representation of the address. checkError("addrtotext('192.100.1.1')", "<string>:1.26: syntax error, unexpected end of file, expecting =="); -} + // Int8totext requires string storing the binary representation of the 8 bits integer. + checkError("int8totext('0123')", + "<string>:1.19: syntax error, unexpected end of file, expecting =="); + + // Int16totext requires string storing the binary representation of the 16 bits integer. + checkError("int16totext('01')", + "<string>:1.18: syntax error, unexpected end of file, expecting =="); + + // Int32totext requires string storing the binary representation of the 32 bits integer. + checkError("int32totext('01')", + "<string>:1.18: syntax error, unexpected end of file, expecting =="); + + // Uint8totext requires string storing the binary representation of the 8 bits unsigned integer. + checkError("uint8totext('0123')", + "<string>:1.20: syntax error, unexpected end of file, expecting =="); + + // Uint16totext requires string storing the binary representation of the 16 bits unsigned integer. + checkError("uint16totext('01')", + "<string>:1.19: syntax error, unexpected end of file, expecting =="); + + // Uint32totext requires string storing the binary representation of the 32 bits unsigned integer. + checkError("uint32totext('01')", + "<string>:1.19: syntax error, unexpected end of file, expecting =="); +} TEST_F(EvalContextTest, vendor4SpecificVendorExists) { testVendor("vendor[4491].exists", Option::V4, 4491, TokenOption::EXISTS); diff --git a/src/lib/eval/tests/token_unittest.cc b/src/lib/eval/tests/token_unittest.cc index 3a57c8f1d9..8368362e75 100644 --- a/src/lib/eval/tests/token_unittest.cc +++ b/src/lib/eval/tests/token_unittest.cc @@ -812,6 +812,136 @@ TEST_F(TokenTest, addressToText) { EXPECT_TRUE(checkFile()); } +// This test checks that a TokenIntToText, representing an integer as a string, +// can be used in Pkt4/Pkt6 evaluation. +// (The actual packet is not used) +TEST_F(TokenTest, integerToText) { + TokenPtr int8token((new TokenInt8ToText())); + TokenPtr int16token((new TokenInt16ToText())); + TokenPtr int32token((new TokenInt32ToText())); + TokenPtr uint8token((new TokenUInt8ToText())); + TokenPtr uint16token((new TokenUInt16ToText())); + TokenPtr uint32token((new TokenUInt32ToText())); + + std::vector<uint8_t> bytes; + std::string value; + + // Invalid data size fails. + values_.push(value); + EXPECT_THROW(int8token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(int16token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(int32token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(uint8token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(uint16token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(uint32token->evaluate(*pkt4_, values_), EvalTypeError); + + value = "0123456789"; + + // Invalid data size fails. + values_.push(value); + EXPECT_THROW(int8token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(int16token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(int32token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(uint8token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(uint16token->evaluate(*pkt4_, values_), EvalTypeError); + values_.push(value); + EXPECT_THROW(uint32token->evaluate(*pkt4_, values_), EvalTypeError); + + uint64_t data = -1; + + values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(int8_t))); + + EXPECT_NO_THROW(int8token->evaluate(*pkt4_, values_)); + + // Check that the evaluation put its value on the values stack. + ASSERT_EQ(1, values_.size()); + + values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(int16_t))); + + EXPECT_NO_THROW(int16token->evaluate(*pkt4_, values_)); + + // Check that the evaluation put its value on the values stack. + ASSERT_EQ(2, values_.size()); + + values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(int32_t))); + + EXPECT_NO_THROW(int32token->evaluate(*pkt4_, values_)); + + // Check that the evaluation put its value on the values stack. + ASSERT_EQ(3, values_.size()); + + values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(uint8_t))); + + EXPECT_NO_THROW(uint8token->evaluate(*pkt4_, values_)); + + // Check that the evaluation put its value on the values stack. + ASSERT_EQ(4, values_.size()); + + values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(uint16_t))); + + EXPECT_NO_THROW(uint16token->evaluate(*pkt4_, values_)); + + // Check that the evaluation put its value on the values stack. + ASSERT_EQ(5, values_.size()); + + values_.push(std::string(const_cast<const char *>(reinterpret_cast<char*>(&data)), sizeof(uint32_t))); + + EXPECT_NO_THROW(uint32token->evaluate(*pkt4_, values_)); + + // Check that the evaluation put its value on the values stack. + ASSERT_EQ(6, values_.size()); + + // Check uint32 + EXPECT_EQ(10, values_.top().size()); + EXPECT_EQ("4294967295", values_.top()); + values_.pop(); + + // Check uint16 + EXPECT_EQ(5, values_.top().size()); + EXPECT_EQ("65535", values_.top()); + values_.pop(); + + // Check uint8 + EXPECT_EQ(3, values_.top().size()); + EXPECT_EQ("255", values_.top()); + values_.pop(); + + // Check int32 + EXPECT_EQ(2, values_.top().size()); + EXPECT_EQ("-1", values_.top()); + values_.pop(); + + // Check int16 + EXPECT_EQ(2, values_.top().size()); + EXPECT_EQ("-1", values_.top()); + values_.pop(); + + // Check int8 + EXPECT_EQ(2, values_.top().size()); + EXPECT_EQ("-1", values_.top()); + values_.pop(); + + // Check that the debug output was correct. Add the strings + // to the test vector in the class and then call checkFile + // for comparison + addString("EVAL_DEBUG_INT8TOTEXT Pushing Int8 -1"); + addString("EVAL_DEBUG_INT16TOTEXT Pushing Int16 -1"); + addString("EVAL_DEBUG_INT32TOTEXT Pushing Int32 -1"); + addString("EVAL_DEBUG_UINT8TOTEXT Pushing UInt8 255"); + addString("EVAL_DEBUG_UINT16TOTEXT Pushing UInt16 65535"); + addString("EVAL_DEBUG_UINT32TOTEXT Pushing UInt32 4294967295"); + EXPECT_TRUE(checkFile()); +} + // This test checks if a token representing an option value is able to extract // the option from an IPv4 packet and properly store the option's value. TEST_F(TokenTest, optionString4) { diff --git a/src/lib/eval/token.cc b/src/lib/eval/token.cc index 144e096434..4919b657a1 100644 --- a/src/lib/eval/token.cc +++ b/src/lib/eval/token.cc @@ -133,6 +133,144 @@ TokenIpAddressToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { .arg(op); } +void +TokenInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { + if (values.size() == 0) { + isc_throw(EvalBadStack, "Incorrect empty stack."); + } + + string op = values.top(); + values.pop(); + + if (op.size() != sizeof(int8_t)) { + isc_throw(EvalTypeError, "Can not convert to valid int8."); + } + + stringstream tmp; + tmp << static_cast<int32_t>(*(reinterpret_cast<int8_t*>(const_cast<char*>(op.data())))); + op = tmp.str(); + values.push(op); + + // Log what we pushed + LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_INT8TOTEXT) + .arg(op); +} + +void +TokenInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { + if (values.size() == 0) { + isc_throw(EvalBadStack, "Incorrect empty stack."); + } + + string op = values.top(); + values.pop(); + + if (op.size() != sizeof(int16_t)) { + isc_throw(EvalTypeError, "Can not convert to valid int16."); + } + + stringstream tmp; + tmp << *(reinterpret_cast<int16_t*>(const_cast<char*>(op.data()))); + op = tmp.str(); + values.push(op); + + // Log what we pushed + LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_INT16TOTEXT) + .arg(op); +} + +void +TokenInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { + if (values.size() == 0) { + isc_throw(EvalBadStack, "Incorrect empty stack."); + } + + string op = values.top(); + values.pop(); + + if (op.size() != sizeof(int32_t)) { + isc_throw(EvalTypeError, "Can not convert to valid int32."); + } + + stringstream tmp; + tmp << *(reinterpret_cast<int32_t*>(const_cast<char*>(op.data()))); + op = tmp.str(); + values.push(op); + + // Log what we pushed + LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_INT32TOTEXT) + .arg(op); +} + +void +TokenUInt8ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { + if (values.size() == 0) { + isc_throw(EvalBadStack, "Incorrect empty stack."); + } + + string op = values.top(); + values.pop(); + + if (op.size() != sizeof(uint8_t)) { + isc_throw(EvalTypeError, "Can not convert to valid uint8."); + } + + stringstream tmp; + tmp << static_cast<uint32_t>(*(reinterpret_cast<uint8_t*>(const_cast<char*>(op.data())))); + op = tmp.str(); + values.push(op); + + // Log what we pushed + LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_UINT8TOTEXT) + .arg(op); +} + +void +TokenUInt16ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { + if (values.size() == 0) { + isc_throw(EvalBadStack, "Incorrect empty stack."); + } + + string op = values.top(); + values.pop(); + + if (op.size() != sizeof(uint16_t)) { + isc_throw(EvalTypeError, "Can not convert to valid uint16."); + } + + stringstream tmp; + tmp << *(reinterpret_cast<uint16_t*>(const_cast<char*>(op.data()))); + op = tmp.str(); + values.push(op); + + // Log what we pushed + LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_UINT16TOTEXT) + .arg(op); +} + +void +TokenUInt32ToText::evaluate(Pkt& /*pkt*/, ValueStack& values) { + if (values.size() == 0) { + isc_throw(EvalBadStack, "Incorrect empty stack."); + } + + string op = values.top(); + values.pop(); + + if (op.size() != sizeof(uint32_t)) { + isc_throw(EvalTypeError, "Can not convert to valid uint32."); + } + + stringstream tmp; + tmp << *(reinterpret_cast<uint32_t*>(const_cast<char*>(op.data()))); + op = tmp.str(); + values.push(op); + + // Log what we pushed + LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_UINT32TOTEXT) + .arg(op); +} + OptionPtr TokenOption::getOption(Pkt& pkt) { return (pkt.getOption(option_code_)); diff --git a/src/lib/eval/token.h b/src/lib/eval/token.h index b6e61152b8..c42acbe759 100644 --- a/src/lib/eval/token.h +++ b/src/lib/eval/token.h @@ -224,6 +224,114 @@ public: void evaluate(Pkt& pkt, ValueStack& values); }; +/// @brief Token representing an 8 bits integer as a string +/// +/// This token holds the value of an 8 bits integer as a string, for instance +/// 0xff is '-1' +class TokenInt8ToText : public Token { +public: + /// @brief Constructor (does nothing) + TokenInt8ToText() {} + + /// @brief Token evaluation (puts value of the string on the stack after + /// decoding) + /// + /// @param pkt (ignored) + /// @param values (represented 8 bits integer as a string will be pushed + /// here) + void evaluate(Pkt& pkt, ValueStack& values); +}; + +/// @brief Token representing a 16 bits integer as a string +/// +/// This token holds the value of a 16 bits integer as a string, for instance +/// 0xffff is '-1' +class TokenInt16ToText : public Token { +public: + /// @brief Constructor (does nothing) + TokenInt16ToText() {} + + /// @brief Token evaluation (puts value of the string on the stack after + /// decoding) + /// + /// @param pkt (ignored) + /// @param values (represented 16 bits integer as a string will be pushed + /// here) + void evaluate(Pkt& pkt, ValueStack& values); +}; + +/// @brief Token representing a 32 bits integer as a string +/// +/// This token holds the value of a 32 bits integer as a string, for instance +/// 0xffffffff is '-1' +class TokenInt32ToText : public Token { +public: + /// @brief Constructor (does nothing) + TokenInt32ToText() {} + + /// @brief Token evaluation (puts value of the string on the stack after + /// decoding) + /// + /// @param pkt (ignored) + /// @param values (represented 32 bits integer as a string will be pushed + /// here) + void evaluate(Pkt& pkt, ValueStack& values); +}; + +/// @brief Token representing an 8 bits unsigned integer as a string +/// +/// This token holds the value of an 8 bits unsigned integer as a string, for +/// instance 0xff is '255' +class TokenUInt8ToText : public Token { +public: + /// @brief Constructor (does nothing) + TokenUInt8ToText() {} + + /// @brief Token evaluation (puts value of the string on the stack after + /// decoding) + /// + /// @param pkt (ignored) + /// @param values (represented 8 bits unsigned integer as a string will be + /// pushed here) + void evaluate(Pkt& pkt, ValueStack& values); +}; + +/// @brief Token representing a 16 bits unsigned integer as a string +/// +/// This token holds the value of a 16 bits unsigned integer as a string, for +/// instance 0xffff is '65535' +class TokenUInt16ToText : public Token { +public: + /// @brief Constructor (does nothing) + TokenUInt16ToText() {} + + /// @brief Token evaluation (puts value of the string on the stack after + /// decoding) + /// + /// @param pkt (ignored) + /// @param values (represented 16 bits unsigned integer as a string will be + /// pushed here) + void evaluate(Pkt& pkt, ValueStack& values); +}; + +/// @brief Token representing a 32 bits unsigned integer as a string +/// +/// This token holds the value of a 32 bits unsigned integer as a string, for +/// instance 0xffffffff is '4294967295' +class TokenUInt32ToText : public Token { +public: + /// @brief Constructor (does nothing) + TokenUInt32ToText() {} + + /// @brief Token evaluation (puts value of the string on the stack after + /// decoding) + /// + /// @param pkt (ignored) + /// @param values (represented 32 bits unsigned integer as a string will be + /// pushed here) + void evaluate(Pkt& pkt, ValueStack& values); +}; + /// @brief Token that represents a value of an option /// /// This represents a reference to a given option, e.g. in the expression |