2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-03 07:25:18 +00:00

[67-expressions-hexa-strings-rebase] Rebased on last master before merge

This commit is contained in:
Francis Dupont
2018-09-19 15:47:33 +02:00
23 changed files with 2012 additions and 1640 deletions

View File

@@ -718,6 +718,7 @@
<row><entry>Concat</entry><entry>concat('foo','bar')</entry><entry>Return the <row><entry>Concat</entry><entry>concat('foo','bar')</entry><entry>Return the
concatenation of the strings</entry></row> concatenation of the strings</entry></row>
<row><entry>Ifelse</entry><entry>ifelse('foo' == 'bar','us','them')</entry><entry>Return the branch value according to the condition</entry></row> <row><entry>Ifelse</entry><entry>ifelse('foo' == 'bar','us','them')</entry><entry>Return the branch value according to the condition</entry></row>
<row><entry>Hexstring</entry><entry>hexstring('foo', '-')</entry><entry>Converts the value to a hexadecimal string, e.g. 0a:1b:2c:3e</entry></row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
@@ -772,6 +773,16 @@ concatenation of the strings</entry></row>
ifelse(option[230].exists, option[230].hex, 'none') ifelse(option[230].exists, option[230].hex, 'none')
</screen> </screen>
</section> </section>
<section>
<title>Hexstring</title>
The hexstring function "hexstring(binary, separator)" returns
the binary value as its hexadecimal string representation:
pairs of hexadecimal digits separated by the separator, e.g
':', '-', '' (empty separator).
<screen>
hexstring(pkt4.mac, ':')
</screen>
</section>
</section> </section>
<note> <note>

View File

@@ -569,7 +569,7 @@ Please make sure that your compilation has the following:
// the incoming packet or even its metadata (e.g. the interface // the incoming packet or even its metadata (e.g. the interface
// it was received over from) // it was received over from)
"name": "Configuration-Token", "name": "Configuration-Token",
"expr": "pkt.iface" "expr": "hexstring(pkt4.mac,':')"
} }
] // End of attributes ] // End of attributes
} // End of access } // End of access

View File

@@ -1215,7 +1215,9 @@ $
can be represented as 626174. Alternatively, it can be expressed can be represented as 626174. Alternatively, it can be expressed
as quoted value (using double and single quotes), e.g. "'bar'". as quoted value (using double and single quotes), e.g. "'bar'".
The former is more convenient for printable characters, while hex The former is more convenient for printable characters, while hex
string values are more convenient for non-printable characters. string values are more convenient for non-printable characters
and does not require the use of the <command>hexstring</command>
operator.
</para> </para>
<screen> <screen>
"Dhcp6": { "Dhcp6": {

View File

@@ -160,7 +160,9 @@ instantiated with the appropriate value and put onto the expression vector.
- isc::dhcp::TokenSubstring -- represents the substring(text, start, length) operator. - isc::dhcp::TokenSubstring -- represents the substring(text, start, length) operator.
- isc::dhcp::TokenConcat -- represents the concat operator which - isc::dhcp::TokenConcat -- represents the concat operator which
concatenate two other tokens. concatenate two other tokens.
- isc::dhcp::TokenIfElse == represents the ifelse(cond, iftrue, ifelse) operator. - isc::dhcp::TokenIfElse -- represents the ifelse(cond, iftrue, ifelse) operator.
- isc::dhcp::TokenToHexString -- represents the hexstring operator which
converts a binary value to its hexadecimal string representation.
- isc::dhcp::TokenNot -- the logical not operator. - isc::dhcp::TokenNot -- the logical not operator.
- isc::dhcp::TokenAnd -- the logical and (strict) operator. - isc::dhcp::TokenAnd -- the logical and (strict) operator.
- isc::dhcp::TokenOr -- the logical or (strict) operator (strict means - isc::dhcp::TokenOr -- the logical or (strict) operator (strict means

View File

@@ -144,6 +144,15 @@ string and an empty result will be pushed onto the stack. The start,
length and string are still popped from the stack and the result is length and string are still popped from the stack and the result is
still pushed. The strings are displayed in hex. still pushed. The strings are displayed in hex.
# For use with TokenToHexString
% EVAL_DEBUG_TOHEXSTRING Popping binary value %1 and separator %2, pushing result %3
This debug message indicates that two values are being popped from
the value stack and a result is being pushed onto the value stack.
The values being popped are the binary value to convert and the separator.
The binary value is converted to its hexadecimal string representation
and pushed onto the stack. The binary value is displayed in hex.
% EVAL_DEBUG_VENDOR_CLASS_DATA Data %1 (out of %2 received) in vendor class found, pushing result '%3' % EVAL_DEBUG_VENDOR_CLASS_DATA Data %1 (out of %2 received) in vendor class found, pushing result '%3'
This debug message indicates that vendor class option was found and passed This debug message indicates that vendor class option was found and passed
enterprise-id checks and has sufficient number of data chunks. The total number enterprise-id checks and has sufficient number of data chunks. The total number

View File

@@ -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 \ */\ /* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
(yy_c_buf_p) = yy_cp; (yy_c_buf_p) = yy_cp;
/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
#define YY_NUM_RULES 53 #define YY_NUM_RULES 54
#define YY_END_OF_BUFFER 54 #define YY_END_OF_BUFFER 55
/* This struct is not used in this scanner, /* This struct is not used in this scanner,
but its presence is necessary. */ but its presence is necessary. */
struct yy_trans_info struct yy_trans_info
@@ -719,42 +719,44 @@ struct yy_trans_info
flex_int32_t yy_verify; flex_int32_t yy_verify;
flex_int32_t yy_nxt; flex_int32_t yy_nxt;
}; };
static const flex_int16_t yy_acclist[291] = static const flex_int16_t yy_acclist[298] =
{ 0, { 0,
54, 52, 53, 1, 52, 53, 2, 53, 52, 53, 55, 53, 54, 1, 53, 54, 2, 54, 53, 54,
46, 52, 53, 47, 52, 53, 51, 52, 53, 50, 47, 53, 54, 48, 53, 54, 52, 53, 54, 51,
52, 53, 52, 53, 45, 52, 53, 5, 52, 53, 53, 54, 53, 54, 46, 53, 54, 5, 53, 54,
5, 52, 53, 52, 53, 52, 53, 52, 53,16390, 5, 53, 54, 53, 54, 53, 54, 53, 54,16390,
52, 53,16390, 48, 52, 53, 49, 52, 53, 52, 53, 54,16390, 49, 53, 54, 50, 53, 54, 53,
53,16390, 52, 53,16390, 52, 53,16390, 52, 53, 54,16390, 53, 54,16390, 53, 54,16390, 53, 54,
16390, 52, 53,16390, 52, 53,16390, 52, 53,16390, 16390, 53, 54,16390, 53, 54,16390, 53, 54,16390,
52, 53,16390, 52, 53,16390, 52, 53,16390, 52, 53, 54,16390, 53, 54,16390, 53, 54,16390, 53,
53,16390, 52, 53,16390, 52, 53,16390, 52, 53, 54,16390, 53, 54,16390, 53, 54,16390, 53, 54,
16390, 52, 53,16390, 52, 53,16390, 52, 53,16390, 16390, 53, 54,16390, 53, 54,16390, 53, 54,16390,
1, 2, 3, 5, 5, 7, 8,16390,16390, 8198, 1, 2, 3, 5, 5, 7, 8,16390,16390, 8198,
16390,16390,16390,16390,16390,16390,16390,16390,16390,16390, 16390,16390,16390,16390,16390,16390,16390,16390,16390,16390,
16390,16390,16390,16390,16390,16390,16390,16390,16390,16390, 16390,16390,16390,16390,16390,16390,16390,16390,16390,16390,
43,16390,16390,16390,16390,16390,16390,16390,16390,16390, 44,16390,16390,16390,16390,16390,16390,16390,16390,16390,
16390,16390, 4, 7, 38,16390, 42,16390,16390,16390, 16390,16390, 4, 7, 38,16390, 43,16390,16390,16390,
16390, 20,16390,16390,16390,16390, 15,16390,16390,16390, 16390, 20,16390,16390,16390,16390, 15,16390,16390,16390,
16390,16390, 21,16390,16390, 23,16390,16390,16390, 41, 16390,16390, 21,16390,16390, 23,16390,16390,16390, 42,
16390,16390,16390, 17,16390,16390,16390, 19,16390,16390, 16390,16390,16390, 17,16390,16390,16390, 19,16390,16390,
16390,16390,16390,16390,16390,16390, 35,16390,16390,16390, 16390,16390,16390,16390,16390,16390, 35,16390,16390,16390,
16390, 24,16390,16390,16390,16390,16390,16390,16390,16390, 16390,16390, 24,16390,16390,16390,16390,16390,16390,16390,
16390,16390, 22,16390, 30,16390,16390,16390,16390, 14,
16390,16390,16390,16390,16390,16390,16390,16390,16390,16390,
25,16390, 18,16390,16390,16390,16390,16390,16390,16390,
16390,16390,16390,16390,16390,16390, 26,16390, 39,16390,
16390, 16,16390, 27,16390,16390, 40,16390,16390, 45,
16390,16390, 9,16390,16390, 10,16390, 11,16390, 29,
16390,16390,16390, 33,16390, 28,16390, 7,16390,16390,
16390, 31,16390,16390,16390, 32,16390,16390,16390, 13,
16390, 12,16390,16390,16390,16390, 41,16390, 37,16390,
16390, 36,16390,16390,16390, 34,16390
16390, 22,16390, 30,16390,16390,16390,16390, 14,16390,
16390,16390,16390,16390,16390,16390,16390,16390, 25,16390,
18,16390,16390,16390,16390,16390,16390,16390,16390,16390,
16390,16390,16390,16390, 26,16390, 39,16390,16390, 16,
16390, 27,16390, 40,16390,16390, 44,16390,16390, 9,
16390,16390, 10,16390, 11,16390, 29,16390,16390,16390,
33,16390, 28,16390, 7,16390,16390, 31,16390,16390,
16390, 32,16390,16390, 13,16390, 12,16390,16390,16390,
16390, 37,16390,16390, 36,16390,16390,16390, 34,16390
} ; } ;
static const flex_int16_t yy_accept[208] = static const flex_int16_t yy_accept[214] =
{ 0, { 0,
1, 1, 1, 2, 4, 7, 9, 11, 14, 17, 1, 1, 1, 2, 4, 7, 9, 11, 14, 17,
20, 23, 25, 28, 31, 34, 36, 38, 41, 44, 20, 23, 25, 28, 31, 34, 36, 38, 41, 44,
@@ -769,16 +771,17 @@ static const flex_int16_t yy_accept[208] =
159, 160, 161, 162, 163, 165, 166, 168, 169, 170, 159, 160, 161, 162, 163, 165, 166, 168, 169, 170,
172, 173, 174, 176, 177, 178, 180, 181, 182, 183, 172, 173, 174, 176, 177, 178, 180, 181, 182, 183,
184, 185, 185, 186, 187, 189, 190, 191, 192, 194, 184, 185, 185, 186, 187, 189, 190, 191, 192, 193,
195, 196, 197, 198, 199, 200, 201, 202, 204, 206, 195, 196, 197, 198, 199, 200, 201, 202, 203, 205,
207, 208, 209, 211, 212, 213, 214, 214, 215, 216, 207, 208, 209, 210, 212, 213, 214, 215, 215, 216,
217, 218, 219, 221, 223, 224, 225, 226, 227, 228, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228,
229, 230, 231, 232, 233, 234, 235, 235, 237, 239, 229, 230, 231, 232, 233, 234, 235, 236, 237, 237,
240, 242, 244, 246, 247, 249, 250, 252, 253, 255, 239, 241, 242, 244, 246, 247, 249, 250, 252, 253,
257, 259, 260, 261, 263, 265, 266, 267, 268, 270, 255, 256, 258, 260, 262, 263, 264, 266, 268, 269,
271, 272, 274, 274, 275, 277, 279, 280, 281, 282, 270, 271, 272, 274, 275, 276, 278, 278, 279, 280,
284, 285, 287, 288, 289, 291, 291 282, 284, 285, 286, 287, 289, 291, 292, 294, 295,
296, 298, 298
} ; } ;
static const YY_CHAR yy_ec[256] = static const YY_CHAR yy_ec[256] =
@@ -822,107 +825,107 @@ static const YY_CHAR yy_meta[45] =
1, 1, 1, 1 1, 1, 1, 1
} ; } ;
static const flex_int16_t yy_base[212] = static const flex_int16_t yy_base[218] =
{ 0, { 0,
0, 0, 319, 320, 316, 314, 312, 320, 320, 320, 0, 0, 325, 326, 322, 320, 318, 326, 326, 326,
320, 34, 320, 39, 36, 300, 298, 81, 115, 320, 326, 34, 326, 39, 36, 306, 304, 81, 115, 326,
320, 24, 37, 37, 26, 282, 45, 284, 43, 48, 326, 24, 37, 37, 26, 288, 45, 290, 43, 48,
275, 43, 59, 283, 106, 50, 282, 277, 305, 303, 281, 43, 59, 289, 106, 50, 288, 283, 311, 309,
301, 320, 122, 137, 112, 289, 288, 0, 287, 0, 307, 326, 122, 137, 112, 295, 294, 0, 293, 0,
320, 143, 150, 0, 0, 320, 268, 274, 276, 263, 326, 143, 150, 0, 0, 326, 274, 280, 282, 269,
257, 256, 255, 263, 270, 249, 264, 246, 74, 254, 263, 262, 261, 269, 276, 255, 270, 252, 74, 260,
253, 262, 252, 256, 244, 243, 0, 255, 241, 247, 259, 268, 258, 262, 250, 249, 0, 261, 247, 253,
256, 253, 253, 233, 252, 239, 250, 146, 0, 0, 262, 259, 259, 239, 258, 245, 256, 146, 0, 0,
0, 0, 246, 246, 247, 0, 242, 229, 241, 0, 0, 0, 252, 252, 253, 0, 248, 235, 247, 233,
231, 228, 239, 230, 0, 230, 0, 237, 220, 0, 236, 233, 244, 235, 0, 235, 0, 242, 225, 0,
228, 220, 148, 234, 230, 0, 216, 214, 218, 226, 233, 225, 148, 239, 235, 0, 221, 219, 223, 231,
225, 154, 224, 226, 0, 210, 207, 220, 0, 218, 230, 154, 229, 231, 0, 215, 212, 225, 210, 0,
217, 204, 219, 214, 196, 203, 215, 0, 0, 193, 222, 221, 208, 223, 218, 200, 207, 219, 0, 0,
210, 195, 0, 195, 197, 206, 162, 193, 190, 192, 197, 214, 199, 0, 199, 201, 210, 162, 197, 194,
189, 189, 0, 0, 199, 199, 186, 186, 187, 195, 196, 193, 193, 192, 0, 0, 202, 202, 189, 189,
156, 172, 169, 175, 167, 165, 166, 0, 0, 164, 190, 198, 156, 185, 184, 190, 172, 169, 166, 0,
0, 0, 0, 175, 0, 173, 0, 173, 0, 0, 0, 168, 0, 0, 174, 0, 177, 0, 175, 0,
0, 167, 171, 187, 0, 170, 164, 156, 0, 155, 175, 0, 0, 0, 169, 173, 189, 0, 170, 166,
157, 0, 183, 152, 0, 0, 161, 156, 161, 0, 161, 157, 0, 156, 158, 0, 183, 153, 162, 0,
164, 0, 124, 115, 0, 320, 208, 210, 212, 85, 0, 161, 156, 161, 0, 0, 164, 0, 124, 115,
215 0, 326, 208, 210, 212, 85, 215
} ; } ;
static const flex_int16_t yy_def[212] = static const flex_int16_t yy_def[218] =
{ 0, { 0,
206, 1, 206, 206, 206, 206, 207, 206, 206, 206, 212, 1, 212, 212, 212, 212, 213, 212, 212, 212,
206, 206, 206, 206, 14, 208, 206, 206, 18, 206, 212, 212, 212, 212, 14, 214, 212, 212, 18, 212,
206, 18, 18, 18, 18, 19, 19, 19, 19, 19, 212, 18, 18, 18, 18, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 206, 206, 19, 19, 19, 19, 19, 19, 19, 19, 212, 212,
207, 206, 206, 206, 14, 208, 209, 210, 208, 211, 213, 212, 212, 212, 14, 214, 215, 216, 214, 217,
206, 206, 19, 18, 19, 206, 19, 19, 19, 19, 212, 212, 19, 18, 19, 212, 19, 19, 19, 19,
18, 19, 19, 19, 19, 19, 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, 19, 206, 210, 211, 19, 19, 19, 19, 19, 19, 19, 212, 216, 217,
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, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 206, 19, 19, 19, 19, 19, 19, 19, 19, 19, 212, 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, 206, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 212, 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, 206, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 212, 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, 206, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 212, 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, 206, 206, 206, 206, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
206 19, 0, 212, 212, 212, 212, 212
} ; } ;
static const flex_int16_t yy_nxt[365] = static const flex_int16_t yy_nxt[371] =
{ 0, { 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 15, 15, 16, 17, 18, 19, 19, 20, 14, 15, 15, 15, 16, 17, 18, 19, 19, 20,
21, 4, 22, 18, 23, 24, 25, 18, 26, 27, 21, 4, 22, 18, 23, 24, 25, 18, 26, 27,
28, 19, 29, 30, 31, 32, 33, 34, 35, 36, 28, 19, 29, 30, 31, 32, 33, 34, 35, 36,
19, 37, 19, 38, 43, 43, 43, 43, 44, 45, 19, 37, 19, 38, 43, 43, 43, 43, 44, 45,
45, 45, 45, 46, 206, 47, 57, 48, 58, 61, 45, 45, 45, 46, 212, 47, 57, 48, 58, 61,
63, 47, 47, 47, 47, 47, 47, 59, 64, 70, 63, 47, 47, 47, 47, 47, 47, 59, 64, 70,
72, 66, 60, 71, 73, 62, 84, 67, 206, 76, 72, 66, 60, 71, 73, 62, 84, 67, 212, 76,
77, 48, 52, 52, 68, 78, 74, 85, 89, 53, 77, 48, 52, 52, 68, 78, 74, 85, 89, 53,
79, 54, 54, 54, 54, 46, 103, 54, 55, 55, 79, 54, 54, 54, 54, 46, 103, 54, 55, 55,
104, 56, 53, 54, 54, 54, 54, 54, 54, 55, 104, 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, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 206, 55, 55, 55, 55, 55, 55, 55, 55, 55, 212,
206, 55, 43, 43, 43, 43, 81, 55, 55, 55, 212, 55, 43, 43, 43, 43, 81, 55, 55, 55,
55, 55, 55, 82, 52, 52, 83, 88, 88, 88, 55, 55, 55, 82, 52, 52, 83, 88, 88, 88,
88, 206, 206, 205, 206, 122, 88, 88, 88, 88, 88, 212, 212, 211, 212, 122, 88, 88, 88, 88,
138, 139, 204, 56, 147, 147, 147, 147, 179, 180, 139, 140, 210, 56, 148, 148, 148, 148, 182, 183,
206, 167, 147, 147, 147, 147, 186, 186, 186, 186, 212, 169, 148, 148, 148, 148, 189, 189, 189, 189,
186, 186, 186, 186, 206, 206, 203, 202, 201, 200, 189, 189, 189, 189, 212, 212, 209, 208, 207, 206,
199, 197, 196, 195, 194, 193, 192, 191, 190, 189, 205, 204, 202, 201, 200, 199, 198, 197, 196, 195,
188, 187, 185, 206, 184, 183, 182, 198, 41, 181, 194, 193, 192, 212, 191, 190, 188, 203, 41, 187,
41, 41, 41, 49, 49, 47, 47, 90, 90, 90, 41, 41, 41, 49, 49, 47, 47, 90, 90, 90,
178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 186, 185, 184, 181, 180, 179, 178, 177, 176, 175,
168, 166, 165, 164, 163, 162, 161, 160, 159, 158, 174, 173, 172, 171, 170, 168, 167, 166, 165, 164,
157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154,
146, 145, 144, 143, 142, 141, 140, 137, 136, 135, 153, 152, 151, 150, 149, 147, 146, 145, 144, 143,
134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 142, 141, 138, 137, 136, 135, 134, 133, 132, 131,
124, 123, 121, 120, 119, 118, 117, 116, 115, 114, 130, 129, 128, 127, 126, 125, 124, 123, 121, 120,
113, 112, 111, 110, 109, 108, 107, 106, 105, 102, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110,
101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 109, 108, 107, 106, 105, 102, 101, 100, 99, 98,
91, 50, 46, 50, 42, 40, 39, 87, 86, 80, 97, 96, 95, 94, 93, 92, 91, 50, 46, 50,
75, 69, 65, 51, 50, 42, 40, 39, 206, 3, 42, 40, 39, 87, 86, 80, 75, 69, 65, 51,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 50, 42, 40, 39, 212, 3, 212, 212, 212, 212,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
206, 206, 206, 206 212, 212, 212, 212, 212, 212, 212, 212, 212, 212
} ; } ;
static const flex_int16_t yy_chk[365] = static const flex_int16_t yy_chk[371] =
{ 0, { 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,
@@ -932,7 +935,7 @@ static const flex_int16_t yy_chk[365] =
14, 14, 14, 14, 15, 14, 22, 14, 22, 24, 14, 14, 14, 14, 15, 14, 22, 14, 22, 24,
25, 14, 14, 14, 14, 14, 14, 23, 25, 29, 25, 14, 14, 14, 14, 14, 14, 23, 25, 29,
30, 27, 23, 29, 30, 24, 36, 27, 15, 32, 30, 27, 23, 29, 30, 24, 36, 27, 15, 32,
32, 14, 18, 18, 27, 33, 30, 36, 210, 18, 32, 14, 18, 18, 27, 33, 30, 36, 216, 18,
33, 18, 18, 18, 18, 18, 69, 18, 18, 18, 33, 18, 18, 18, 18, 18, 69, 18, 18, 18,
69, 18, 18, 18, 18, 18, 18, 18, 18, 18, 69, 18, 18, 18, 18, 18, 18, 18, 18, 18,
@@ -940,50 +943,50 @@ static const flex_int16_t yy_chk[365] =
18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
45, 19, 43, 43, 43, 43, 35, 19, 19, 19, 45, 19, 43, 43, 43, 43, 35, 19, 19, 19,
19, 19, 19, 35, 52, 52, 35, 44, 44, 44, 19, 19, 19, 35, 52, 52, 35, 44, 44, 44,
44, 53, 53, 204, 45, 88, 88, 88, 88, 88, 44, 53, 53, 210, 45, 88, 88, 88, 88, 88,
113, 113, 203, 52, 122, 122, 122, 122, 161, 161, 113, 113, 209, 52, 122, 122, 122, 122, 163, 163,
53, 147, 147, 147, 147, 147, 167, 167, 167, 167, 53, 148, 148, 148, 148, 148, 169, 169, 169, 169,
186, 186, 186, 186, 193, 193, 201, 199, 198, 197, 189, 189, 189, 189, 197, 197, 207, 204, 203, 202,
194, 191, 190, 188, 187, 184, 183, 182, 178, 176, 199, 198, 195, 194, 192, 191, 190, 187, 186, 185,
174, 170, 166, 193, 165, 164, 163, 193, 207, 162, 181, 179, 177, 197, 175, 172, 168, 197, 213, 167,
207, 207, 207, 208, 208, 209, 209, 211, 211, 211, 213, 213, 213, 214, 214, 215, 215, 217, 217, 217,
160, 159, 158, 157, 156, 155, 152, 151, 150, 149, 166, 165, 164, 162, 161, 160, 159, 158, 157, 154,
148, 146, 145, 144, 142, 141, 140, 137, 136, 135, 153, 152, 151, 150, 149, 147, 146, 145, 143, 142,
134, 133, 132, 131, 130, 128, 127, 126, 124, 123, 141, 138, 137, 136, 135, 134, 133, 132, 131, 129,
121, 120, 119, 118, 117, 115, 114, 112, 111, 109, 128, 127, 126, 124, 123, 121, 120, 119, 118, 117,
108, 106, 104, 103, 102, 101, 99, 98, 97, 95, 115, 114, 112, 111, 109, 108, 106, 104, 103, 102,
94, 93, 87, 86, 85, 84, 83, 82, 81, 80, 101, 100, 99, 98, 97, 95, 94, 93, 87, 86,
79, 78, 76, 75, 74, 73, 72, 71, 70, 68, 85, 84, 83, 82, 81, 80, 79, 78, 76, 75,
67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 74, 73, 72, 71, 70, 68, 67, 66, 65, 64,
57, 49, 47, 46, 41, 40, 39, 38, 37, 34, 63, 62, 61, 60, 59, 58, 57, 49, 47, 46,
31, 28, 26, 17, 16, 7, 6, 5, 3, 206, 41, 40, 39, 38, 37, 34, 31, 28, 26, 17,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 16, 7, 6, 5, 3, 212, 212, 212, 212, 212,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212,
206, 206, 206, 206 212, 212, 212, 212, 212, 212, 212, 212, 212, 212
} ; } ;
/* Table of booleans, true if rule could match eol. */ /* Table of booleans, true if rule could match eol. */
static const flex_int32_t yy_rule_can_match_eol[54] = static const flex_int32_t yy_rule_can_match_eol[55] =
{ 0, { 0,
0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
extern int yy_flex_debug; extern int yy_flex_debug;
int yy_flex_debug = 1; int yy_flex_debug = 1;
static const flex_int16_t yy_rule_linenum[53] = static const flex_int16_t yy_rule_linenum[54] =
{ 0, { 0,
106, 111, 117, 127, 133, 151, 158, 172, 173, 174, 106, 111, 117, 127, 133, 151, 158, 172, 173, 174,
175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
215, 216 215, 216, 217
} ; } ;
static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;
@@ -1049,7 +1052,7 @@ namespace {
/* To avoid the call to exit... oops! */ /* To avoid the call to exit... oops! */
#define YY_FATAL_ERROR(msg) isc::eval::EvalContext::fatal(msg) #define YY_FATAL_ERROR(msg) isc::eval::EvalContext::fatal(msg)
#line 1052 "lexer.cc" #line 1055 "lexer.cc"
/* noyywrap disables automatic rewinding for the next file to parse. Since we /* 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 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 using yywrap requires linking with -lfl, which provides the default yywrap
@@ -1074,8 +1077,8 @@ namespace {
by moving it ahead by yyleng bytes. yyleng specifies the length of the by moving it ahead by yyleng bytes. yyleng specifies the length of the
currently matched token. */ currently matched token. */
#define YY_USER_ACTION loc.columns(evalleng); #define YY_USER_ACTION loc.columns(evalleng);
#line 1077 "lexer.cc" #line 1080 "lexer.cc"
#line 1078 "lexer.cc" #line 1081 "lexer.cc"
#define INITIAL 0 #define INITIAL 0
@@ -1380,7 +1383,7 @@ YY_DECL
#line 1383 "lexer.cc" #line 1386 "lexer.cc"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{ {
@@ -1408,14 +1411,14 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 207 ) if ( yy_current_state >= 213 )
yy_c = yy_meta[yy_c]; yy_c = yy_meta[yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
*(yy_state_ptr)++ = yy_current_state; *(yy_state_ptr)++ = yy_current_state;
++yy_cp; ++yy_cp;
} }
while ( yy_current_state != 206 ); while ( yy_current_state != 212 );
yy_find_action: yy_find_action:
/* %% [10.0] code to find the action number goes here */ /* %% [10.0] code to find the action number goes here */
@@ -1478,13 +1481,13 @@ do_action: /* This label is used only to access EOF actions. */
{ {
if ( yy_act == 0 ) if ( yy_act == 0 )
fprintf( stderr, "--scanner backing up\n" ); fprintf( stderr, "--scanner backing up\n" );
else if ( yy_act < 53 ) else if ( yy_act < 54 )
fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
(long)yy_rule_linenum[yy_act], yytext ); (long)yy_rule_linenum[yy_act], yytext );
else if ( yy_act == 53 ) else if ( yy_act == 54 )
fprintf( stderr, "--accepting default rule (\"%s\")\n", fprintf( stderr, "--accepting default rule (\"%s\")\n",
yytext ); yytext );
else if ( yy_act == 54 ) else if ( yy_act == 55 )
fprintf( stderr, "--(end of buffer or a NUL)\n" ); fprintf( stderr, "--(end of buffer or a NUL)\n" );
else else
fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
@@ -1750,73 +1753,78 @@ return isc::eval::EvalParser::make_IFELSE(loc);
case 41: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 205 "lexer.ll" #line 205 "lexer.ll"
return isc::eval::EvalParser::make_NOT(loc); return isc::eval::EvalParser::make_TOHEXSTRING(loc);
YY_BREAK YY_BREAK
case 42: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 206 "lexer.ll" #line 206 "lexer.ll"
return isc::eval::EvalParser::make_AND(loc); return isc::eval::EvalParser::make_NOT(loc);
YY_BREAK YY_BREAK
case 43: case 43:
YY_RULE_SETUP YY_RULE_SETUP
#line 207 "lexer.ll" #line 207 "lexer.ll"
return isc::eval::EvalParser::make_OR(loc); return isc::eval::EvalParser::make_AND(loc);
YY_BREAK YY_BREAK
case 44: case 44:
YY_RULE_SETUP YY_RULE_SETUP
#line 208 "lexer.ll" #line 208 "lexer.ll"
return isc::eval::EvalParser::make_MEMBER(loc); return isc::eval::EvalParser::make_OR(loc);
YY_BREAK YY_BREAK
case 45: case 45:
YY_RULE_SETUP YY_RULE_SETUP
#line 209 "lexer.ll" #line 209 "lexer.ll"
return isc::eval::EvalParser::make_DOT(loc); return isc::eval::EvalParser::make_MEMBER(loc);
YY_BREAK YY_BREAK
case 46: case 46:
YY_RULE_SETUP YY_RULE_SETUP
#line 210 "lexer.ll" #line 210 "lexer.ll"
return isc::eval::EvalParser::make_LPAREN(loc); return isc::eval::EvalParser::make_DOT(loc);
YY_BREAK YY_BREAK
case 47: case 47:
YY_RULE_SETUP YY_RULE_SETUP
#line 211 "lexer.ll" #line 211 "lexer.ll"
return isc::eval::EvalParser::make_RPAREN(loc); return isc::eval::EvalParser::make_LPAREN(loc);
YY_BREAK YY_BREAK
case 48: case 48:
YY_RULE_SETUP YY_RULE_SETUP
#line 212 "lexer.ll" #line 212 "lexer.ll"
return isc::eval::EvalParser::make_LBRACKET(loc); return isc::eval::EvalParser::make_RPAREN(loc);
YY_BREAK YY_BREAK
case 49: case 49:
YY_RULE_SETUP YY_RULE_SETUP
#line 213 "lexer.ll" #line 213 "lexer.ll"
return isc::eval::EvalParser::make_RBRACKET(loc); return isc::eval::EvalParser::make_LBRACKET(loc);
YY_BREAK YY_BREAK
case 50: case 50:
YY_RULE_SETUP YY_RULE_SETUP
#line 214 "lexer.ll" #line 214 "lexer.ll"
return isc::eval::EvalParser::make_COMA(loc); return isc::eval::EvalParser::make_RBRACKET(loc);
YY_BREAK YY_BREAK
case 51: case 51:
YY_RULE_SETUP YY_RULE_SETUP
#line 215 "lexer.ll" #line 215 "lexer.ll"
return isc::eval::EvalParser::make_ANY(loc); return isc::eval::EvalParser::make_COMA(loc);
YY_BREAK YY_BREAK
case 52: case 52:
YY_RULE_SETUP YY_RULE_SETUP
#line 216 "lexer.ll" #line 216 "lexer.ll"
driver.error (loc, "Invalid character: " + std::string(evaltext)); return isc::eval::EvalParser::make_ANY(loc);
YY_BREAK
case YY_STATE_EOF(INITIAL):
#line 217 "lexer.ll"
return isc::eval::EvalParser::make_END(loc);
YY_BREAK YY_BREAK
case 53: case 53:
YY_RULE_SETUP YY_RULE_SETUP
#line 217 "lexer.ll"
driver.error (loc, "Invalid character: " + std::string(evaltext));
YY_BREAK
case YY_STATE_EOF(INITIAL):
#line 218 "lexer.ll" #line 218 "lexer.ll"
return isc::eval::EvalParser::make_END(loc);
YY_BREAK
case 54:
YY_RULE_SETUP
#line 219 "lexer.ll"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1819 "lexer.cc" #line 1827 "lexer.cc"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@@ -2102,7 +2110,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 207 ) if ( yy_current_state >= 213 )
yy_c = yy_meta[yy_c]; yy_c = yy_meta[yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -2130,11 +2138,11 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{ {
yy_current_state = (int) yy_def[yy_current_state]; yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 207 ) if ( yy_current_state >= 213 )
yy_c = yy_meta[yy_c]; yy_c = yy_meta[yy_c];
} }
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 206); yy_is_jam = (yy_current_state == 212);
if ( ! yy_is_jam ) if ( ! yy_is_jam )
*(yy_state_ptr)++ = yy_current_state; *(yy_state_ptr)++ = yy_current_state;
@@ -2900,7 +2908,7 @@ void yyfree (void * ptr )
/* %ok-for-header */ /* %ok-for-header */
#line 218 "lexer.ll" #line 219 "lexer.ll"
using namespace isc::eval; using namespace isc::eval;

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") /* Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
This Source Code Form is subject to the terms of the Mozilla Public This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -201,6 +201,7 @@ addr6 [0-9a-fA-F]*\:[0-9a-fA-F]*\:[0-9a-fA-F:.]*
"all" return isc::eval::EvalParser::make_ALL(loc); "all" return isc::eval::EvalParser::make_ALL(loc);
"concat" return isc::eval::EvalParser::make_CONCAT(loc); "concat" return isc::eval::EvalParser::make_CONCAT(loc);
"ifelse" return isc::eval::EvalParser::make_IFELSE(loc); "ifelse" return isc::eval::EvalParser::make_IFELSE(loc);
"hexstring" return isc::eval::EvalParser::make_TOHEXSTRING(loc);
"not" return isc::eval::EvalParser::make_NOT(loc); "not" return isc::eval::EvalParser::make_NOT(loc);
"and" return isc::eval::EvalParser::make_AND(loc); "and" return isc::eval::EvalParser::make_AND(loc);
"or" return isc::eval::EvalParser::make_OR(loc); "or" return isc::eval::EvalParser::make_OR(loc);

View File

@@ -1,8 +1,9 @@
// A Bison parser, made by GNU Bison 3.0.4. // Generated 201809161042
// A Bison parser, made by GNU Bison 3.0.5.
// Locations for Bison parsers in C++ // Locations for Bison parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@@ -40,9 +41,9 @@
# include "position.hh" # include "position.hh"
#line 14 "parser.yy" // location.cc:296 #line 14 "parser.yy" // location.cc:292
namespace isc { namespace eval { namespace isc { namespace eval {
#line 46 "location.hh" // location.cc:296 #line 46 "location.hh" // location.cc:292
/// Abstract a location. /// Abstract a location.
class location class location
{ {
@@ -52,30 +53,27 @@ namespace isc { namespace eval {
location (const position& b, const position& e) location (const position& b, const position& e)
: begin (b) : begin (b)
, end (e) , end (e)
{ {}
}
/// Construct a 0-width location in \a p. /// Construct a 0-width location in \a p.
explicit location (const position& p = position ()) explicit location (const position& p = position ())
: begin (p) : begin (p)
, end (p) , end (p)
{ {}
}
/// Construct a 0-width location in \a f, \a l, \a c. /// Construct a 0-width location in \a f, \a l, \a c.
explicit location (std::string* f, explicit location (std::string* f,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
: begin (f, l, c) : begin (f, l, c)
, end (f, l, c) , end (f, l, c)
{ {}
}
/// Initialization. /// Initialization.
void initialize (std::string* f = YY_NULLPTR, void initialize (std::string* f = YY_NULLPTR,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
{ {
begin.initialize (f, l, c); begin.initialize (f, l, c);
end = begin; end = begin;
@@ -173,7 +171,7 @@ namespace isc { namespace eval {
inline std::basic_ostream<YYChar>& inline std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc) operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{ {
unsigned int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0; unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
ostr << loc.begin; ostr << loc.begin;
if (loc.end.filename if (loc.end.filename
&& (!loc.begin.filename && (!loc.begin.filename
@@ -186,7 +184,7 @@ namespace isc { namespace eval {
return ostr; return ostr;
} }
#line 14 "parser.yy" // location.cc:296 #line 14 "parser.yy" // location.cc:292
} } // isc::eval } } // isc::eval
#line 192 "location.hh" // location.cc:296 #line 189 "location.hh" // location.cc:292
#endif // !YY_EVAL_LOCATION_HH_INCLUDED #endif // !YY_EVAL_LOCATION_HH_INCLUDED

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.5.
// Skeleton interface for Bison LALR(1) parsers in C++ // Skeleton interface for Bison LALR(1) parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@
#ifndef YY_EVAL_PARSER_H_INCLUDED #ifndef YY_EVAL_PARSER_H_INCLUDED
# define YY_EVAL_PARSER_H_INCLUDED # define YY_EVAL_PARSER_H_INCLUDED
// // "%code requires" blocks. // // "%code requires" blocks.
#line 17 "parser.yy" // lalr1.cc:377 #line 17 "parser.yy" // lalr1.cc:379
#include <string> #include <string>
#include <eval/token.h> #include <eval/token.h>
@@ -51,7 +51,7 @@
using namespace isc::dhcp; using namespace isc::dhcp;
using namespace isc::eval; using namespace isc::eval;
#line 55 "parser.h" // lalr1.cc:377 #line 55 "parser.h" // lalr1.cc:379
# include <cassert> # include <cassert>
# include <cstdlib> // std::abort # include <cstdlib> // std::abort
@@ -134,9 +134,9 @@ using namespace isc::eval;
# endif /* ! defined YYDEBUG */ # endif /* ! defined YYDEBUG */
#endif /* ! defined EVALDEBUG */ #endif /* ! defined EVALDEBUG */
#line 14 "parser.yy" // lalr1.cc:377 #line 14 "parser.yy" // lalr1.cc:379
namespace isc { namespace eval { namespace isc { namespace eval {
#line 140 "parser.h" // lalr1.cc:377 #line 140 "parser.h" // lalr1.cc:379
@@ -393,21 +393,22 @@ namespace isc { namespace eval {
TOKEN_COMA = 291, TOKEN_COMA = 291,
TOKEN_CONCAT = 292, TOKEN_CONCAT = 292,
TOKEN_IFELSE = 293, TOKEN_IFELSE = 293,
TOKEN_PKT6 = 294, TOKEN_TOHEXSTRING = 294,
TOKEN_MSGTYPE = 295, TOKEN_PKT6 = 295,
TOKEN_TRANSID = 296, TOKEN_MSGTYPE = 296,
TOKEN_VENDOR_CLASS = 297, TOKEN_TRANSID = 297,
TOKEN_VENDOR = 298, TOKEN_VENDOR_CLASS = 298,
TOKEN_ANY = 299, TOKEN_VENDOR = 299,
TOKEN_DATA = 300, TOKEN_ANY = 300,
TOKEN_ENTERPRISE = 301, TOKEN_DATA = 301,
TOKEN_TOPLEVEL_BOOL = 302, TOKEN_ENTERPRISE = 302,
TOKEN_TOPLEVEL_STRING = 303, TOKEN_TOPLEVEL_BOOL = 303,
TOKEN_STRING = 304, TOKEN_TOPLEVEL_STRING = 304,
TOKEN_INTEGER = 305, TOKEN_STRING = 305,
TOKEN_HEXSTRING = 306, TOKEN_INTEGER = 306,
TOKEN_OPTION_NAME = 307, TOKEN_HEXSTRING = 307,
TOKEN_IP_ADDRESS = 308 TOKEN_OPTION_NAME = 308,
TOKEN_IP_ADDRESS = 309
}; };
}; };
@@ -678,6 +679,10 @@ namespace isc { namespace eval {
symbol_type symbol_type
make_IFELSE (const location_type& l); make_IFELSE (const location_type& l);
static inline
symbol_type
make_TOHEXSTRING (const location_type& l);
static inline static inline
symbol_type symbol_type
make_PKT6 (const location_type& l); make_PKT6 (const location_type& l);
@@ -823,7 +828,7 @@ namespace isc { namespace eval {
// number is the opposite. If YYTABLE_NINF, syntax error. // number is the opposite. If YYTABLE_NINF, syntax error.
static const unsigned char yytable_[]; static const unsigned char yytable_[];
static const short int yycheck_[]; static const unsigned char yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM. // symbol of state STATE-NUM.
@@ -909,6 +914,8 @@ namespace isc { namespace eval {
typedef basic_symbol<by_state> super_type; typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol. /// Construct an empty symbol.
stack_symbol_type (); stack_symbol_type ();
/// Copy construct.
stack_symbol_type (const stack_symbol_type& that);
/// Steal the contents from \a sym to build this. /// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym); stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back. /// Assignment, needed by push_back.
@@ -937,18 +944,18 @@ namespace isc { namespace eval {
void yypush_ (const char* m, state_type s, symbol_type& sym); void yypush_ (const char* m, state_type s, symbol_type& sym);
/// Pop \a n symbols the three stacks. /// Pop \a n symbols the three stacks.
void yypop_ (unsigned int n = 1); void yypop_ (unsigned n = 1);
/// Constants. /// Constants.
enum enum
{ {
yyeof_ = 0, yyeof_ = 0,
yylast_ = 192, ///< Last index in yytable_. yylast_ = 197, ///< Last index in yytable_.
yynnts_ = 16, ///< Number of nonterminal symbols. yynnts_ = 16, ///< Number of nonterminal symbols.
yyfinal_ = 32, ///< Termination state number. yyfinal_ = 33, ///< Termination state number.
yyterror_ = 1, yyterror_ = 1,
yyerrcode_ = 256, yyerrcode_ = 256,
yyntokens_ = 54 ///< Number of tokens. yyntokens_ = 55 ///< Number of tokens.
}; };
@@ -995,14 +1002,14 @@ namespace isc { namespace eval {
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53 45, 46, 47, 48, 49, 50, 51, 52, 53, 54
}; };
const unsigned int user_token_number_max_ = 308; const unsigned user_token_number_max_ = 309;
const token_number_type undef_token_ = 2; const token_number_type undef_token_ = 2;
if (static_cast<int> (t) <= yyeof_) if (static_cast<int> (t) <= yyeof_)
return yyeof_; return yyeof_;
else if (static_cast<unsigned int> (t) <= user_token_number_max_) else if (static_cast<unsigned> (t) <= user_token_number_max_)
return translate_table[t]; return translate_table[t];
else else
return undef_token_; return undef_token_;
@@ -1016,13 +1023,11 @@ namespace isc { namespace eval {
// basic_symbol. // basic_symbol.
template <typename Base> template <typename Base>
inline
EvalParser::basic_symbol<Base>::basic_symbol () EvalParser::basic_symbol<Base>::basic_symbol ()
: value () : value ()
{} {}
template <typename Base> template <typename Base>
inline
EvalParser::basic_symbol<Base>::basic_symbol (const basic_symbol& other) EvalParser::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other) : Base (other)
, value () , value ()
@@ -1030,44 +1035,44 @@ namespace isc { namespace eval {
{ {
switch (other.type_get ()) switch (other.type_get ())
{ {
case 61: // option_repr_type case 62: // option_repr_type
value.copy< TokenOption::RepresentationType > (other.value); value.copy< TokenOption::RepresentationType > (other.value);
break; break;
case 65: // pkt4_field case 66: // pkt4_field
value.copy< TokenPkt4::FieldType > (other.value); value.copy< TokenPkt4::FieldType > (other.value);
break; break;
case 66: // pkt6_field case 67: // pkt6_field
value.copy< TokenPkt6::FieldType > (other.value); value.copy< TokenPkt6::FieldType > (other.value);
break; break;
case 63: // pkt_metadata case 64: // pkt_metadata
value.copy< TokenPkt::MetadataType > (other.value); value.copy< TokenPkt::MetadataType > (other.value);
break; break;
case 67: // relay6_field case 68: // relay6_field
value.copy< TokenRelay6Field::FieldType > (other.value); value.copy< TokenRelay6Field::FieldType > (other.value);
break; break;
case 62: // nest_level case 63: // nest_level
value.copy< int8_t > (other.value); value.copy< int8_t > (other.value);
break; break;
case 49: // "constant string" case 50: // "constant string"
case 50: // "integer" case 51: // "integer"
case 51: // "constant hexstring" case 52: // "constant hexstring"
case 52: // "option name" case 53: // "option name"
case 53: // "ip address" case 54: // "ip address"
value.copy< std::string > (other.value); value.copy< std::string > (other.value);
break; break;
case 60: // option_code case 61: // option_code
value.copy< uint16_t > (other.value); value.copy< uint16_t > (other.value);
break; break;
case 59: // integer_expr case 60: // integer_expr
case 64: // enterprise_id case 65: // enterprise_id
value.copy< uint32_t > (other.value); value.copy< uint32_t > (other.value);
break; break;
@@ -1077,9 +1082,7 @@ namespace isc { namespace eval {
} }
template <typename Base> template <typename Base>
inline
EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l) EvalParser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l)
: Base (t) : Base (t)
, value () , value ()
@@ -1088,44 +1091,44 @@ namespace isc { namespace eval {
(void) v; (void) v;
switch (this->type_get ()) switch (this->type_get ())
{ {
case 61: // option_repr_type case 62: // option_repr_type
value.copy< TokenOption::RepresentationType > (v); value.copy< TokenOption::RepresentationType > (v);
break; break;
case 65: // pkt4_field case 66: // pkt4_field
value.copy< TokenPkt4::FieldType > (v); value.copy< TokenPkt4::FieldType > (v);
break; break;
case 66: // pkt6_field case 67: // pkt6_field
value.copy< TokenPkt6::FieldType > (v); value.copy< TokenPkt6::FieldType > (v);
break; break;
case 63: // pkt_metadata case 64: // pkt_metadata
value.copy< TokenPkt::MetadataType > (v); value.copy< TokenPkt::MetadataType > (v);
break; break;
case 67: // relay6_field case 68: // relay6_field
value.copy< TokenRelay6Field::FieldType > (v); value.copy< TokenRelay6Field::FieldType > (v);
break; break;
case 62: // nest_level case 63: // nest_level
value.copy< int8_t > (v); value.copy< int8_t > (v);
break; break;
case 49: // "constant string" case 50: // "constant string"
case 50: // "integer" case 51: // "integer"
case 51: // "constant hexstring" case 52: // "constant hexstring"
case 52: // "option name" case 53: // "option name"
case 53: // "ip address" case 54: // "ip address"
value.copy< std::string > (v); value.copy< std::string > (v);
break; break;
case 60: // option_code case 61: // option_code
value.copy< uint16_t > (v); value.copy< uint16_t > (v);
break; break;
case 59: // integer_expr case 60: // integer_expr
case 64: // enterprise_id case 65: // enterprise_id
value.copy< uint32_t > (v); value.copy< uint32_t > (v);
break; break;
@@ -1209,14 +1212,12 @@ namespace isc { namespace eval {
template <typename Base> template <typename Base>
inline
EvalParser::basic_symbol<Base>::~basic_symbol () EvalParser::basic_symbol<Base>::~basic_symbol ()
{ {
clear (); clear ();
} }
template <typename Base> template <typename Base>
inline
void void
EvalParser::basic_symbol<Base>::clear () EvalParser::basic_symbol<Base>::clear ()
{ {
@@ -1233,44 +1234,44 @@ namespace isc { namespace eval {
// Type destructor. // Type destructor.
switch (yytype) switch (yytype)
{ {
case 61: // option_repr_type case 62: // option_repr_type
value.template destroy< TokenOption::RepresentationType > (); value.template destroy< TokenOption::RepresentationType > ();
break; break;
case 65: // pkt4_field case 66: // pkt4_field
value.template destroy< TokenPkt4::FieldType > (); value.template destroy< TokenPkt4::FieldType > ();
break; break;
case 66: // pkt6_field case 67: // pkt6_field
value.template destroy< TokenPkt6::FieldType > (); value.template destroy< TokenPkt6::FieldType > ();
break; break;
case 63: // pkt_metadata case 64: // pkt_metadata
value.template destroy< TokenPkt::MetadataType > (); value.template destroy< TokenPkt::MetadataType > ();
break; break;
case 67: // relay6_field case 68: // relay6_field
value.template destroy< TokenRelay6Field::FieldType > (); value.template destroy< TokenRelay6Field::FieldType > ();
break; break;
case 62: // nest_level case 63: // nest_level
value.template destroy< int8_t > (); value.template destroy< int8_t > ();
break; break;
case 49: // "constant string" case 50: // "constant string"
case 50: // "integer" case 51: // "integer"
case 51: // "constant hexstring" case 52: // "constant hexstring"
case 52: // "option name" case 53: // "option name"
case 53: // "ip address" case 54: // "ip address"
value.template destroy< std::string > (); value.template destroy< std::string > ();
break; break;
case 60: // option_code case 61: // option_code
value.template destroy< uint16_t > (); value.template destroy< uint16_t > ();
break; break;
case 59: // integer_expr case 60: // integer_expr
case 64: // enterprise_id case 65: // enterprise_id
value.template destroy< uint32_t > (); value.template destroy< uint32_t > ();
break; break;
@@ -1282,7 +1283,6 @@ namespace isc { namespace eval {
} }
template <typename Base> template <typename Base>
inline
bool bool
EvalParser::basic_symbol<Base>::empty () const EvalParser::basic_symbol<Base>::empty () const
{ {
@@ -1290,51 +1290,50 @@ namespace isc { namespace eval {
} }
template <typename Base> template <typename Base>
inline
void void
EvalParser::basic_symbol<Base>::move (basic_symbol& s) EvalParser::basic_symbol<Base>::move (basic_symbol& s)
{ {
super_type::move (s); super_type::move (s);
switch (this->type_get ()) switch (this->type_get ())
{ {
case 61: // option_repr_type case 62: // option_repr_type
value.move< TokenOption::RepresentationType > (s.value); value.move< TokenOption::RepresentationType > (s.value);
break; break;
case 65: // pkt4_field case 66: // pkt4_field
value.move< TokenPkt4::FieldType > (s.value); value.move< TokenPkt4::FieldType > (s.value);
break; break;
case 66: // pkt6_field case 67: // pkt6_field
value.move< TokenPkt6::FieldType > (s.value); value.move< TokenPkt6::FieldType > (s.value);
break; break;
case 63: // pkt_metadata case 64: // pkt_metadata
value.move< TokenPkt::MetadataType > (s.value); value.move< TokenPkt::MetadataType > (s.value);
break; break;
case 67: // relay6_field case 68: // relay6_field
value.move< TokenRelay6Field::FieldType > (s.value); value.move< TokenRelay6Field::FieldType > (s.value);
break; break;
case 62: // nest_level case 63: // nest_level
value.move< int8_t > (s.value); value.move< int8_t > (s.value);
break; break;
case 49: // "constant string" case 50: // "constant string"
case 50: // "integer" case 51: // "integer"
case 51: // "constant hexstring" case 52: // "constant hexstring"
case 52: // "option name" case 53: // "option name"
case 53: // "ip address" case 54: // "ip address"
value.move< std::string > (s.value); value.move< std::string > (s.value);
break; break;
case 60: // option_code case 61: // option_code
value.move< uint16_t > (s.value); value.move< uint16_t > (s.value);
break; break;
case 59: // integer_expr case 60: // integer_expr
case 64: // enterprise_id case 65: // enterprise_id
value.move< uint32_t > (s.value); value.move< uint32_t > (s.value);
break; break;
@@ -1398,7 +1397,7 @@ namespace isc { namespace eval {
275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
305, 306, 307, 308 305, 306, 307, 308, 309
}; };
return static_cast<token_type> (yytoken_number_[type]); return static_cast<token_type> (yytoken_number_[type]);
} }
@@ -1625,6 +1624,12 @@ namespace isc { namespace eval {
return symbol_type (token::TOKEN_IFELSE, l); return symbol_type (token::TOKEN_IFELSE, l);
} }
EvalParser::symbol_type
EvalParser::make_TOHEXSTRING (const location_type& l)
{
return symbol_type (token::TOKEN_TOHEXSTRING, l);
}
EvalParser::symbol_type EvalParser::symbol_type
EvalParser::make_PKT6 (const location_type& l) EvalParser::make_PKT6 (const location_type& l)
{ {
@@ -1716,9 +1721,9 @@ namespace isc { namespace eval {
} }
#line 14 "parser.yy" // lalr1.cc:377 #line 14 "parser.yy" // lalr1.cc:379
} } // isc::eval } } // isc::eval
#line 1722 "parser.h" // lalr1.cc:377 #line 1727 "parser.h" // lalr1.cc:379

View File

@@ -74,6 +74,7 @@ using namespace isc::eval;
COMA "," COMA ","
CONCAT "concat" CONCAT "concat"
IFELSE "ifelse" IFELSE "ifelse"
TOHEXSTRING "hexstring"
PKT6 "pkt6" PKT6 "pkt6"
MSGTYPE "msgtype" MSGTYPE "msgtype"
TRANSID "transid" TRANSID "transid"
@@ -349,6 +350,11 @@ string_expr : STRING
TokenPtr cond(new TokenIfElse()); TokenPtr cond(new TokenIfElse());
ctx.expression.push_back(cond); ctx.expression.push_back(cond);
} }
| TOHEXSTRING "(" string_expr "," string_expr ")"
{
TokenPtr tohex(new TokenToHexString());
ctx.expression.push_back(tohex);
}
| VENDOR "." ENTERPRISE | VENDOR "." ENTERPRISE
{ {
// expression: vendor.enterprise // expression: vendor.enterprise

View File

@@ -1,8 +1,9 @@
// A Bison parser, made by GNU Bison 3.0.4. // Generated 201809161042
// A Bison parser, made by GNU Bison 3.0.5.
// Positions for Bison parsers in C++ // Positions for Bison parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@@ -50,28 +51,27 @@
# endif # endif
# endif # endif
#line 14 "parser.yy" // location.cc:296 #line 14 "parser.yy" // location.cc:292
namespace isc { namespace eval { namespace isc { namespace eval {
#line 56 "position.hh" // location.cc:296 #line 56 "position.hh" // location.cc:292
/// Abstract a position. /// Abstract a position.
class position class position
{ {
public: public:
/// Construct a position. /// Construct a position.
explicit position (std::string* f = YY_NULLPTR, explicit position (std::string* f = YY_NULLPTR,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
: filename (f) : filename (f)
, line (l) , line (l)
, column (c) , column (c)
{ {}
}
/// Initialization. /// Initialization.
void initialize (std::string* fn = YY_NULLPTR, void initialize (std::string* fn = YY_NULLPTR,
unsigned int l = 1u, unsigned l = 1u,
unsigned int c = 1u) unsigned c = 1u)
{ {
filename = fn; filename = fn;
line = l; line = l;
@@ -100,15 +100,15 @@ namespace isc { namespace eval {
/// File name to which this position refers. /// File name to which this position refers.
std::string* filename; std::string* filename;
/// Current line number. /// Current line number.
unsigned int line; unsigned line;
/// Current column number. /// Current column number.
unsigned int column; unsigned column;
private: private:
/// Compute max(min, lhs+rhs) (provided min <= lhs). /// Compute max(min, lhs+rhs) (provided min <= lhs).
static unsigned int add_ (unsigned int lhs, int rhs, unsigned int min) static unsigned add_ (unsigned lhs, int rhs, unsigned min)
{ {
return (0 < rhs || -static_cast<unsigned int>(rhs) < lhs return (0 < rhs || -static_cast<unsigned>(rhs) < lhs
? rhs + lhs ? rhs + lhs
: min); : min);
} }
@@ -174,7 +174,7 @@ namespace isc { namespace eval {
return ostr << pos.line << '.' << pos.column; return ostr << pos.line << '.' << pos.column;
} }
#line 14 "parser.yy" // location.cc:296 #line 14 "parser.yy" // location.cc:292
} } // isc::eval } } // isc::eval
#line 180 "position.hh" // location.cc:296 #line 179 "position.hh" // location.cc:292
#endif // !YY_EVAL_POSITION_HH_INCLUDED #endif // !YY_EVAL_POSITION_HH_INCLUDED

View File

@@ -1,8 +1,9 @@
// A Bison parser, made by GNU Bison 3.0.4. // Generated 201809161042
// A Bison parser, made by GNU Bison 3.0.5.
// Stack handling for Bison parsers in C++ // Stack handling for Bison parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@@ -40,9 +41,10 @@
# include <vector> # include <vector>
#line 14 "parser.yy" // stack.hh:132 #line 14 "parser.yy" // stack.hh:131
namespace isc { namespace eval { namespace isc { namespace eval {
#line 46 "stack.hh" // stack.hh:132 #line 46 "stack.hh" // stack.hh:131
/// A stack with random access from its top.
template <class T, class S = std::vector<T> > template <class T, class S = std::vector<T> >
class stack class stack
{ {
@@ -57,20 +59,24 @@ namespace isc { namespace eval {
seq_.reserve (200); seq_.reserve (200);
} }
stack (unsigned int n) stack (unsigned n)
: seq_ (n) : seq_ (n)
{} {}
inline /// Random access.
///
/// Index 0 returns the topmost element.
T& T&
operator[] (unsigned int i) operator[] (unsigned i)
{ {
return seq_[seq_.size () - 1 - i]; return seq_[seq_.size () - 1 - i];
} }
inline /// Random access.
///
/// Index 0 returns the topmost element.
const T& const T&
operator[] (unsigned int i) const operator[] (unsigned i) const
{ {
return seq_[seq_.size () - 1 - i]; return seq_[seq_.size () - 1 - i];
} }
@@ -78,7 +84,6 @@ namespace isc { namespace eval {
/// Steal the contents of \a t. /// Steal the contents of \a t.
/// ///
/// Close to move-semantics. /// Close to move-semantics.
inline
void void
push (T& t) push (T& t)
{ {
@@ -86,9 +91,8 @@ namespace isc { namespace eval {
operator[](0).move (t); operator[](0).move (t);
} }
inline
void void
pop (unsigned int n = 1) pop (unsigned n = 1)
{ {
for (; n; --n) for (; n; --n)
seq_.pop_back (); seq_.pop_back ();
@@ -100,21 +104,18 @@ namespace isc { namespace eval {
seq_.clear (); seq_.clear ();
} }
inline
typename S::size_type typename S::size_type
size () const size () const
{ {
return seq_.size (); return seq_.size ();
} }
inline
const_iterator const_iterator
begin () const begin () const
{ {
return seq_.rbegin (); return seq_.rbegin ();
} }
inline
const_iterator const_iterator
end () const end () const
{ {
@@ -133,25 +134,24 @@ namespace isc { namespace eval {
class slice class slice
{ {
public: public:
slice (const S& stack, unsigned int range) slice (const S& stack, unsigned range)
: stack_ (stack) : stack_ (stack)
, range_ (range) , range_ (range)
{} {}
inline
const T& const T&
operator [] (unsigned int i) const operator [] (unsigned i) const
{ {
return stack_[range_ - i]; return stack_[range_ - i];
} }
private: private:
const S& stack_; const S& stack_;
unsigned int range_; unsigned range_;
}; };
#line 14 "parser.yy" // stack.hh:132 #line 14 "parser.yy" // stack.hh:131
} } // isc::eval } } // isc::eval
#line 156 "stack.hh" // stack.hh:132 #line 155 "stack.hh" // stack.hh:131
#endif // !YY_EVAL_STACK_HH_INCLUDED #endif // !YY_EVAL_STACK_HH_INCLUDED

View File

@@ -462,6 +462,14 @@ public:
EXPECT_TRUE(alt); EXPECT_TRUE(alt);
} }
/// @brief checks if the given token is a hexstring operator
void checkTokenToHexString(const TokenPtr& token) {
ASSERT_TRUE(token);
boost::shared_ptr<TokenToHexString> tohex =
boost::dynamic_pointer_cast<TokenToHexString>(token);
EXPECT_TRUE(tohex);
}
/// @brief checks if the given expression raises the expected message /// @brief checks if the given expression raises the expected message
/// when it is parsed. /// when it is parsed.
void checkError(const string& expr, const string& msg) { void checkError(const string& expr, const string& msg) {
@@ -1056,6 +1064,12 @@ TEST_F(EvalContextTest, pkt4FieldChaddr) {
testPkt4Field("pkt4.mac == 0x000102030405", TokenPkt4::CHADDR, 3); testPkt4Field("pkt4.mac == 0x000102030405", TokenPkt4::CHADDR, 3);
} }
// Tests whether chaddr field in DHCPv4 can be accessed and converted.
TEST_F(EvalContextTest, pkt4FieldChaddrHexa) {
testPkt4Field("hexstring(pkt4.mac, ':') == '00:01:02:03:04:05'",
TokenPkt4::CHADDR, 5);
}
// Tests whether hlen field in DHCPv4 can be accessed. // Tests whether hlen field in DHCPv4 can be accessed.
TEST_F(EvalContextTest, pkt4FieldHlen) { TEST_F(EvalContextTest, pkt4FieldHlen) {
testPkt4Field("pkt4.hlen == 0x6", TokenPkt4::HLEN, 3); testPkt4Field("pkt4.hlen == 0x6", TokenPkt4::HLEN, 3);
@@ -1310,6 +1324,25 @@ TEST_F(EvalContextTest, ifElse) {
checkTokenIfElse(tmp4); checkTokenIfElse(tmp4);
} }
// Test the parsing of a hexstring expression
TEST_F(EvalContextTest, toHexString) {
EvalContext eval(Option::V4);
EXPECT_NO_THROW(parsed_ =
eval.parseString("hexstring(0x666f,'-') == '66-6f'"));
EXPECT_TRUE(parsed_);
ASSERT_EQ(5, eval.expression.size());
TokenPtr tmp1 = eval.expression.at(0);
TokenPtr tmp2 = eval.expression.at(1);
TokenPtr tmp3 = eval.expression.at(2);
checkTokenHexString(tmp1, "fo");
checkTokenString(tmp2, "-");
checkTokenToHexString(tmp3);
}
// //
// Test some scanner error cases // Test some scanner error cases
TEST_F(EvalContextTest, scanErrors) { TEST_F(EvalContextTest, scanErrors) {

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -504,6 +504,12 @@ TEST_F(ExpressionsTest, evaluateString) {
"ifelse(option[100].exists," "ifelse(option[100].exists,"
"option[100].hex,'none?'))", "option[100].hex,'none?'))",
"hundred4"); "hundred4");
// Check that hexstring works as expecting.
testExpressionString(Option::V4, "hexstring(0x1234,':')", "12:34");
testExpressionString(Option::V4, "hexstring(0x56789a,'-')", "56-78-9a");
testExpressionString(Option::V4, "hexstring(0xbcde,'')", "bcde");
testExpressionString(Option::V4, "hexstring(0xf01234,'..')", "f0..12..34");
} }
}; };

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -1954,6 +1954,35 @@ TEST_F(TokenTest, concat) {
EXPECT_TRUE(checkFile()); EXPECT_TRUE(checkFile());
} }
// This test checks if a token representing a hexstring request
// throws an exception if there aren't enough values on the stack.
// The actual packet is not used.
TEST_F(TokenTest, tohexstring) {
ASSERT_NO_THROW(t_.reset(new TokenToHexString()));
// Hexstring equires two values on the stack, try
// with 0 and 1 both should throw an exception
EXPECT_THROW(t_->evaluate(*pkt4_, values_), EvalBadStack);
values_.push("foo");
EXPECT_THROW(t_->evaluate(*pkt4_, values_), EvalBadStack);
// Two should work
values_.push("-");
EXPECT_NO_THROW(t_->evaluate(*pkt4_, values_));
// Check the result
ASSERT_EQ(1, values_.size());
EXPECT_EQ("66-6f-6f", values_.top());
// 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_TOHEXSTRING Popping binary value 0x666F6F and "
"separator -, pushing result 66-6f-6f");
EXPECT_TRUE(checkFile());
}
// This test checks if a token representing an ifelse is able // This test checks if a token representing an ifelse is able
// to select the branch following the condition. // to select the branch following the condition.
TEST_F(TokenTest, ifElse) { TEST_F(TokenTest, ifElse) {

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -21,6 +21,8 @@
#include <dhcp/option_vendor_class.h> #include <dhcp/option_vendor_class.h>
#include <cstring> #include <cstring>
#include <string> #include <string>
#include <iomanip>
#include <sstream>
using namespace isc::dhcp; using namespace isc::dhcp;
using namespace isc::util; using namespace isc::util;
@@ -629,6 +631,39 @@ TokenIfElse::evaluate(Pkt& /*pkt*/, ValueStack& values) {
} }
} }
void
TokenToHexString::evaluate(Pkt& /*pkt*/, ValueStack& values) {
if (values.size() < 2) {
isc_throw(EvalBadStack, "Incorrect stack order. Expected at least "
"2 values for hexstring, got " << values.size());
}
string separator = values.top();
values.pop();
string binary = values.top();
values.pop();
bool first = true;
stringstream tmp;
tmp << hex;
for (size_t i = 0; i < binary.size(); ++i) {
if (!first) {
tmp << separator;
} else {
first = false;
}
tmp << setw(2) << setfill('0')
<< (static_cast<unsigned>(binary[i]) & 0xff);
}
values.push(tmp.str());
// Log what we popped and pushed
LOG_DEBUG(eval_logger, EVAL_DBG_STACK, EVAL_DEBUG_TOHEXSTRING)
.arg(toHex(binary))
.arg(separator)
.arg(tmp.str());
}
void void
TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) { TokenNot::evaluate(Pkt& /*pkt*/, ValueStack& values) {

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -725,6 +725,45 @@ public:
void evaluate(Pkt& pkt, ValueStack& values); void evaluate(Pkt& pkt, ValueStack& values);
}; };
/// @brief Token that converts to hexadecimal string
///
/// For example in the sub-expression "hexstring(pkt4.mac, ':')"
/// the binary MAC address is converted to its usual hexadecimal
/// representation as a list of (6) pairs of hexadecimal digits
/// separated by colons (':').
/// Please note the token is named TokenToHexString when the syntax
/// use the hexstring name without a leading "to".
class TokenToHexString : public Token {
public:
/// @brief Constructor (does nothing)
TokenToHexString() { }
/// @brief Convert a binary value to its hexadecimal string representation
///
/// Evaluation does not use packet information. It requires at least
/// two values to be present on the stack. It will consume the top
/// two values on the stack as parameters and push the resulting
/// hexadecimal string onto the stack.
/// From the top it expects the values on the stack as:
/// - separator
/// - binary
///
/// binary is the binary value (note it can be any value, i.e.
/// it is not checked to really be not printable).
/// separator is litteral for instance '-' or ':'. The empty separator
/// means no separator.
///
/// The following example use a binary MAC address 06:ce:8f:55:b3:33:
/// - <mac>, '-' => "06-ce-8f-55-b3-33"
///
/// @throw EvalBadStack if there are less than 2 values on stack
///
/// @param pkt (unused)
/// @param values - stack of values (2 arguments will be popped, 1 result
/// will be pushed)
void evaluate(Pkt& pkt, ValueStack& values);
};
/// @brief Token that represents logical negation operator /// @brief Token that represents logical negation operator
/// ///
/// For example in the expression "not(option[vendor-class].text == 'MSF')" /// For example in the expression "not(option[vendor-class].text == 'MSF')"

View File

@@ -25,6 +25,11 @@ module ietf-dhcpv6-client {
description "This model defines a YANG data model that can be description "This model defines a YANG data model that can be
used to configure and manage a DHCPv6 client."; used to configure and manage a DHCPv6 client.";
revision 2018-09-04 {
description "";
reference "I-D: draft-ietf-dhc-dhcpv6-yang";
}
revision 2018-03-04 { revision 2018-03-04 {
description "Resolved most issues on the DHC official description "Resolved most issues on the DHC official
github"; github";
@@ -41,7 +46,6 @@ module ietf-dhcpv6-client {
YANG model."; YANG model.";
reference "I-D: draft-ietf-dhc-dhcpv6-yang"; reference "I-D: draft-ietf-dhc-dhcpv6-yang";
} }
/* /*
* Data Nodes * Data Nodes
*/ */

View File

@@ -21,9 +21,14 @@ module ietf-dhcpv6-options {
ian.farrer@telekom.de ian.farrer@telekom.de
sladjana.zechlin@telekom.de sladjana.zechlin@telekom.de
hezihao9512@gmail.com"; hezihao9512@gmail.com";
description "This model defines a YANG data model that can be description "This model defines a YANG data model that can be
used to configure DHCPv6 options."; used to configure DHCPv6 options.";
revision 2018-09-04 {
description "";
reference "I-D: draft-ietf-dhc-dhcpv6-yang";
}
revision 2018-03-04 { revision 2018-03-04 {
description "Resolved most issues on the DHC official description "Resolved most issues on the DHC official
github"; github";
@@ -213,6 +218,7 @@ module ietf-dhcpv6-options {
description "Support for Opion with DNS Wire description "Support for Opion with DNS Wire
Format Domain Name List"; Format Domain Name List";
} }
/* /*
* Groupings * Groupings
*/ */
@@ -234,8 +240,8 @@ module ietf-dhcpv6-options {
} }
container sip-server-domain-name-list-option { container sip-server-domain-name-list-option {
// if-feature sip-server-domain-name-list-op; if-feature sip-server-domain-name-list-op;
// presence "Enable this option"; presence "Enable this option";
description "OPTION_SIP_SERVER_D (21) SIP Servers Domain Name List"; description "OPTION_SIP_SERVER_D (21) SIP Servers Domain Name List";
reference "RFC3319: Dynamic Host Configuration Protocol reference "RFC3319: Dynamic Host Configuration Protocol
(DHCPv6) Options for Session Initiation Protocol (SIP) Servers"; (DHCPv6) Options for Session Initiation Protocol (SIP) Servers";
@@ -247,8 +253,8 @@ module ietf-dhcpv6-options {
} }
container sip-server-address-list-option { container sip-server-address-list-option {
// if-feature sip-server-address-list-op; if-feature sip-server-address-list-op;
// presence "Enable this option"; presence "Enable this option";
description "OPTION_SIP_SERVER_A (22) SIP Servers IPv6 Address List"; description "OPTION_SIP_SERVER_A (22) SIP Servers IPv6 Address List";
reference "RFC3319: Dynamic Host Configuration Protocol (DHCPv6) reference "RFC3319: Dynamic Host Configuration Protocol (DHCPv6)
Options for Session Initiation Protocol (SIP) Servers"; Options for Session Initiation Protocol (SIP) Servers";
@@ -269,8 +275,8 @@ module ietf-dhcpv6-options {
} }
container dns-servers-option { container dns-servers-option {
// if-feature dns-servers-op; if-feature dns-servers-op;
// presence "Enable this option"; presence "Enable this option";
description "OPTION_DNS_SERVERS (23) DNS recursive Name Server option"; description "OPTION_DNS_SERVERS (23) DNS recursive Name Server option";
reference "RFC3646: DNS Configuration options for Dynamic Host Configuration reference "RFC3646: DNS Configuration options for Dynamic Host Configuration
Protocol for IPv6 (DHCPv6)"; Protocol for IPv6 (DHCPv6)";
@@ -291,8 +297,8 @@ module ietf-dhcpv6-options {
} }
container domain-searchlist-option { container domain-searchlist-option {
// if-feature domain-searchlist-op; if-feature domain-searchlist-op;
// presence "Enable this option"; presence "Enable this option";
description "OPTION_DOMAIN_LIST (24) Domain Search List Option"; description "OPTION_DOMAIN_LIST (24) Domain Search List Option";
reference "RFC3646: DNS Configuration options for Dynamic reference "RFC3646: DNS Configuration options for Dynamic
Host Configuration Protocol for IPv6 (DHCPv6)"; Host Configuration Protocol for IPv6 (DHCPv6)";
@@ -311,10 +317,9 @@ module ietf-dhcpv6-options {
} }
} }
} }
container nis-config-option { container nis-config-option {
// if-feature nis-config-op; if-feature nis-config-op;
// presence "Enable this option"; presence "Enable this option";
description "OPTION_NIS_SERVERS (27) Network Information Service (NIS) description "OPTION_NIS_SERVERS (27) Network Information Service (NIS)
Servers Option."; Servers Option.";
reference "RFC3898: Network Information Service (NIS) Configuration reference "RFC3898: Network Information Service (NIS) Configuration
@@ -336,8 +341,8 @@ module ietf-dhcpv6-options {
} }
container nis-plus-config-option { container nis-plus-config-option {
// if-feature nis-plus-config-op; if-feature nis-plus-config-op;
// presence "Enable this option"; presence "Enable this option";
description "OPTION_NISP_SERVERS (28): Network Information Service V2 description "OPTION_NISP_SERVERS (28): Network Information Service V2
(NIS+) Servers Option."; (NIS+) Servers Option.";
reference "RFC3989: Network Information Service (NIS) Configuration reference "RFC3989: Network Information Service (NIS) Configuration
@@ -357,6 +362,7 @@ module ietf-dhcpv6-options {
} }
} }
} }
container nis-domain-name-option { container nis-domain-name-option {
if-feature nis-domain-name-op; if-feature nis-domain-name-op;
presence "Enable this option"; presence "Enable this option";
@@ -391,7 +397,7 @@ module ietf-dhcpv6-options {
container sntp-server-option { container sntp-server-option {
// if-feature sntp-server-op; if-feature sntp-server-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_SNTP_SERVERS (31) Simple Network Time Protocol description "OPTION_SNTP_SERVERS (31) Simple Network Time Protocol
(SNTP) Servers Option"; (SNTP) Servers Option";
@@ -414,7 +420,7 @@ module ietf-dhcpv6-options {
} }
container info-refresh-time-option { container info-refresh-time-option {
//if-feature info-refresh-time-op; if-feature info-refresh-time-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_INFORMATION_REFRESH_TIME (32) Information Refresh description "OPTION_INFORMATION_REFRESH_TIME (32) Information Refresh
Time option."; Time option.";
@@ -428,7 +434,7 @@ module ietf-dhcpv6-options {
} }
container client-fqdn-option { container client-fqdn-option {
//if-feature client-fqdn-op; if-feature client-fqdn-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_CLIENT_FQDN (39) DHCPv6 Client FQDN Option"; description "OPTION_CLIENT_FQDN (39) DHCPv6 Client FQDN Option";
reference "RFC4704: The Dynamic Host Configuration Protocol for IPv6 reference "RFC4704: The Dynamic Host Configuration Protocol for IPv6
@@ -451,7 +457,7 @@ module ietf-dhcpv6-options {
} }
container posix-timezone-option { container posix-timezone-option {
//if-feature posix-timezone-op; if-feature posix-timezone-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_NEW_POSIX_TIMEZONE (41) Posix Timezone option"; description "OPTION_NEW_POSIX_TIMEZONE (41) Posix Timezone option";
reference "RFC4833: Timezone Options for DHCP"; reference "RFC4833: Timezone Options for DHCP";
@@ -463,7 +469,7 @@ module ietf-dhcpv6-options {
} }
container tzdb-timezone-option { container tzdb-timezone-option {
//if-feature tzdb-timezone-op; if-feature tzdb-timezone-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_NEW_TZDB_TIMEZONE (42) Timezone Database option"; description "OPTION_NEW_TZDB_TIMEZONE (42) Timezone Database option";
reference "RFC4822: Timezone Options for DHCP"; reference "RFC4822: Timezone Options for DHCP";
@@ -480,7 +486,7 @@ module ietf-dhcpv6-options {
// Zihao - Re-modelled so it only contains one time source suboption // Zihao - Re-modelled so it only contains one time source suboption
//if-feature ntp-server-op; if-feature ntp-server-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_NTP_SERVER (56) NTP Server Option for DHCPv6"; description "OPTION_NTP_SERVER (56) NTP Server Option for DHCPv6";
reference "RFC5908: Network Time Protocol (NTP) Server Option for reference "RFC5908: Network Time Protocol (NTP) Server Option for
@@ -518,9 +524,9 @@ module ietf-dhcpv6-options {
} }
container boot-file-url-option { container boot-file-url-option {
//if-feature boot-file-url-op; if-feature boot-file-url-op;
presence "Enable this option"; presence "Enable this option";
description "OPT_BOOTFILE_URL (59) Boot File URL option"; description "OPT_BOOTFILE_URL (59) Boot File URL Option";
reference "RFC5970: DHCPv6 Options for Network Boot"; reference "RFC5970: DHCPv6 Options for Network Boot";
list boot-file { list boot-file {
key boot-file-id; key boot-file-id;
@@ -547,7 +553,7 @@ module ietf-dhcpv6-options {
} }
container boot-file-param-option { container boot-file-param-option {
//if-feature boot-file-param-op; if-feature boot-file-param-op;
presence "Enable this option"; presence "Enable this option";
description "OPT_BOOTFiLE_PARAM (60) Boot File Parameters Option"; description "OPT_BOOTFiLE_PARAM (60) Boot File Parameters Option";
reference "RFC5970: DHCPv6 Options for Network Boot"; reference "RFC5970: DHCPv6 Options for Network Boot";
@@ -568,7 +574,7 @@ module ietf-dhcpv6-options {
} }
container aftr-name-option { container aftr-name-option {
//if-feature aftr-name-op; if-feature aftr-name-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_AFTR_NAME (64) AFTR-Name DHCPv6 Option"; description "OPTION_AFTR_NAME (64) AFTR-Name DHCPv6 Option";
reference "RFC6334: Dynamic Host Configuration Protocol for IPv6 reference "RFC6334: Dynamic Host Configuration Protocol for IPv6
@@ -581,7 +587,7 @@ module ietf-dhcpv6-options {
} }
container kbr-default-name-option { container kbr-default-name-option {
//if-feature kbr-default-name-op; if-feature kbr-default-name-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_KRB_DEFAULT_REALM_NAME (77) Kerberos Default Realm Name Option"; description "OPTION_KRB_DEFAULT_REALM_NAME (77) Kerberos Default Realm Name Option";
reference "RFC6784: Kerberos Options for DHCPv6"; reference "RFC6784: Kerberos Options for DHCPv6";
@@ -593,7 +599,7 @@ module ietf-dhcpv6-options {
} }
container kbr-kdc-option { container kbr-kdc-option {
//if-feature kbr-kdc-op; if-feature kbr-kdc-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_KRB_KDC (78) Kerberos KDB Option"; description "OPTION_KRB_KDC (78) Kerberos KDB Option";
reference "RFC6784: Kerberos Options for DHCPv6"; reference "RFC6784: Kerberos Options for DHCPv6";
@@ -639,7 +645,7 @@ module ietf-dhcpv6-options {
} }
container sol-max-rt-option { container sol-max-rt-option {
//if-feature sol-max-rt-op; if-feature sol-max-rt-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_SOL_MAX_RT (82) sol max rt option"; description "OPTION_SOL_MAX_RT (82) sol max rt option";
reference "RFC7083: Modification to Default Values of reference "RFC7083: Modification to Default Values of
@@ -652,7 +658,7 @@ module ietf-dhcpv6-options {
} }
container inf-max-rt-option { container inf-max-rt-option {
//if-feature inf-max-rt-op; if-feature inf-max-rt-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_INF_MAX_RT (83) inf max rt option"; description "OPTION_INF_MAX_RT (83) inf max rt option";
reference "RFC7083: Modification to Default Values of reference "RFC7083: Modification to Default Values of
@@ -665,7 +671,7 @@ module ietf-dhcpv6-options {
} }
container addr-selection-option { container addr-selection-option {
//if-feature addr-selection-op; if-feature addr-selection-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_ADDRSEL (84) and OPTION_ADDRSEL_TABLE (85)"; description "OPTION_ADDRSEL (84) and OPTION_ADDRSEL_TABLE (85)";
reference "RFC7078: Distributing Address Selection Policy Using reference "RFC7078: Distributing Address Selection Policy Using
@@ -715,7 +721,7 @@ module ietf-dhcpv6-options {
} }
container pcp-server-option { container pcp-server-option {
//if-feature pcp-server-op; if-feature pcp-server-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_V6_PCP_SERVER (86) pcp server option"; description "OPTION_V6_PCP_SERVER (86) pcp server option";
reference "RFC7291: DHCP Options for the Port Control reference "RFC7291: DHCP Options for the Port Control
@@ -737,7 +743,7 @@ module ietf-dhcpv6-options {
} }
container s46-rule-option { container s46-rule-option {
//if-feature s46-rule-op; if-feature s46-rule-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_S46_RULE (89) S46 rule option"; description "OPTION_S46_RULE (89) S46 rule option";
reference "RFC7598: DHCPv6 Options for Configuration of reference "RFC7598: DHCPv6 Options for Configuration of
@@ -787,7 +793,7 @@ module ietf-dhcpv6-options {
} }
container s46-br-option { container s46-br-option {
//if-feature s46-br-op; if-feature s46-br-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_S46_BR (90) S46 BR Option"; description "OPTION_S46_BR (90) S46 BR Option";
reference "RFC7598: DHCPv6 Options for Configuration of reference "RFC7598: DHCPv6 Options for Configuration of
@@ -809,7 +815,7 @@ module ietf-dhcpv6-options {
} }
container s46-dmr-option { container s46-dmr-option {
//if-feature s46-dmr-op; if-feature s46-dmr-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_S46_DMR (91) S46 DMR Option"; description "OPTION_S46_DMR (91) S46 DMR Option";
reference "RFC7598: DHCPv6 Options for Configuration of reference "RFC7598: DHCPv6 Options for Configuration of
@@ -836,7 +842,7 @@ module ietf-dhcpv6-options {
} }
container s46-v4-v6-binding-option { container s46-v4-v6-binding-option {
//if-feature s46-v4-v6-binding-op; if-feature s46-v4-v6-binding-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_S46_V4V6BIND (92) S46 IPv4/IPv6 Address description "OPTION_S46_V4V6BIND (92) S46 IPv4/IPv6 Address
Binding option"; Binding option";
@@ -858,7 +864,8 @@ module ietf-dhcpv6-options {
leaf bind-prefix6-len { leaf bind-prefix6-len {
type uint8; type uint8;
mandatory true; mandatory true;
description "bind ipv6 prefix length"; description "bind ipv6 prefix
length";
} }
leaf bind-ipv6-prefix { leaf bind-ipv6-prefix {
type inet:ipv6-address; type inet:ipv6-address;
@@ -878,7 +885,7 @@ module ietf-dhcpv6-options {
description "OPTION_RSOO (66) Relay-Supplied Options option"; description "OPTION_RSOO (66) Relay-Supplied Options option";
reference "RFC6422: Relay-Supplied DHCP Options"; reference "RFC6422: Relay-Supplied DHCP Options";
container erp-local-domain-name-option { container erp-local-domain-name-option {
//if-feature erp-local-domain-name-op; if-feature erp-local-domain-name-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_ERP_LOCAL_DOMAIN_NAME (65) DHCPv6 ERP Local description "OPTION_ERP_LOCAL_DOMAIN_NAME (65) DHCPv6 ERP Local
Domain Name Option"; Domain Name Option";
@@ -942,7 +949,7 @@ module ietf-dhcpv6-options {
} }
container option-request-option { container option-request-option {
//if-feature option-request-op; if-feature option-request-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_ORO (6) Option Request Option"; description "OPTION_ORO (6) Option Request Option";
reference "RFC3315: Dynamic Host Configuration Protocol for reference "RFC3315: Dynamic Host Configuration Protocol for
@@ -965,7 +972,7 @@ module ietf-dhcpv6-options {
} }
container user-class-option { container user-class-option {
//if-feature user-class-op; if-feature user-class-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_USER_CLASS (15) User Class Option"; description "OPTION_USER_CLASS (15) User Class Option";
reference "RFC3315: Dynamic Host Configuration Protocol reference "RFC3315: Dynamic Host Configuration Protocol
@@ -990,7 +997,7 @@ module ietf-dhcpv6-options {
} }
container vendor-class-option { container vendor-class-option {
//if-feature vendor-class-op; if-feature vendor-class-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_VENDOR_CLASS (16) Vendor Class Option"; description "OPTION_VENDOR_CLASS (16) Vendor Class Option";
reference "RFC3315: Dynamic Host Configuration Protocol reference "RFC3315: Dynamic Host Configuration Protocol
@@ -1022,7 +1029,7 @@ module ietf-dhcpv6-options {
} }
container client-fqdn-option { container client-fqdn-option {
//if-feature client-fqdn-op; if-feature client-fqdn-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_CLIENT_FQDN (39) The Dynamic Host description "OPTION_CLIENT_FQDN (39) The Dynamic Host
Configuration Protocol for IPv6 (DHCPv6) Client Fully Configuration Protocol for IPv6 (DHCPv6) Client Fully
@@ -1048,7 +1055,7 @@ module ietf-dhcpv6-options {
} }
container client-arch-type-option { container client-arch-type-option {
//if-feature client-arch-type-op; if-feature client-arch-type-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_CLIENT_ARCH_TYPE (61) Client System description "OPTION_CLIENT_ARCH_TYPE (61) Client System
Architecture Type Option"; Architecture Type Option";
@@ -1070,7 +1077,7 @@ module ietf-dhcpv6-options {
} }
container client-network-interface-identifier-option { container client-network-interface-identifier-option {
//if-feature client-network-interface-identifier-op; if-feature client-network-interface-identifier-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_NII (62) Client Network Interface description "OPTION_NII (62) Client Network Interface
Identifier Option"; Identifier Option";
@@ -1093,7 +1100,7 @@ module ietf-dhcpv6-options {
} }
container kbr-principal-name-option { container kbr-principal-name-option {
//if-feature kbr-principal-name-op; if-feature kbr-principal-name-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_KRB_PRINCIPAL_NAME (75) Kerberos description "OPTION_KRB_PRINCIPAL_NAME (75) Kerberos
Principal Name Option"; Principal Name Option";
@@ -1121,7 +1128,7 @@ module ietf-dhcpv6-options {
} }
container kbr-realm-name-option { container kbr-realm-name-option {
//if-feature kbr-realm-name-op; if-feature kbr-realm-name-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_KRB_REALM_NAME (76) Kerberos Realm Name Option"; description "OPTION_KRB_REALM_NAME (76) Kerberos Realm Name Option";
reference "RFC6784: Kerberos Options for DHCPv6"; reference "RFC6784: Kerberos Options for DHCPv6";
@@ -1133,7 +1140,7 @@ module ietf-dhcpv6-options {
} }
container client-link-layer-addr-option { container client-link-layer-addr-option {
//if-feature client-link-layer-addr-op; if-feature client-link-layer-addr-op;
presence "Enable this option"; presence "Enable this option";
description "OPTION_CLIENT_LINKLAYER_ADDR (79) DHCPv6 Client description "OPTION_CLIENT_LINKLAYER_ADDR (79) DHCPv6 Client
Link-Layer Address Option"; Link-Layer Address Option";
@@ -1160,7 +1167,7 @@ module ietf-dhcpv6-options {
description "operator customized options"; description "operator customized options";
container operator-option-ipv6-address { container operator-option-ipv6-address {
//if-feature operator-op-ipv6-address; if-feature operator-op-ipv6-address;
presence "Enable this option"; presence "Enable this option";
description "operator ipv6 address option"; description "operator ipv6 address option";
reference "RFC7227: Guidelines for Creating New DHCPv6 Options"; reference "RFC7227: Guidelines for Creating New DHCPv6 Options";
@@ -1181,7 +1188,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-single-flag { container operator-option-single-flag {
//if-feature operator-op-single-flag; if-feature operator-op-single-flag;
presence "Enable this option"; presence "Enable this option";
description "operator single flag"; description "operator single flag";
reference "RFC7227: Guidelines for Creating New DHCPv6 reference "RFC7227: Guidelines for Creating New DHCPv6
@@ -1203,7 +1210,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-ipv6-prefix { container operator-option-ipv6-prefix {
//if-feature operator-op-ipv6-prefix; if-feature operator-op-ipv6-prefix;
presence "Enable this option"; presence "Enable this option";
description "operator ipv6 prefix option"; description "operator ipv6 prefix option";
reference "RFC7227: Guidelines for Creating New DHCPv6 reference "RFC7227: Guidelines for Creating New DHCPv6
@@ -1230,7 +1237,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-int32 { container operator-option-int32 {
//if-feature operator-op-int32; if-feature operator-op-int32;
presence "Enable this option"; presence "Enable this option";
description "operator integer 32 option"; description "operator integer 32 option";
reference "RFC7227: Guidelines for Creating New DHCPv6 reference "RFC7227: Guidelines for Creating New DHCPv6
@@ -1252,7 +1259,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-int16 { container operator-option-int16 {
//if-feature operator-op-int16; if-feature operator-op-int16;
presence "Enable this option"; presence "Enable this option";
description "operator integer 16 option"; description "operator integer 16 option";
reference "RFC7227: Guidelines for Creating New DHCPv6 reference "RFC7227: Guidelines for Creating New DHCPv6
@@ -1274,7 +1281,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-int8 { container operator-option-int8 {
//if-feature operator-op-int8; if-feature operator-op-int8;
presence "Enable this option"; presence "Enable this option";
description "operator integer 8 option"; description "operator integer 8 option";
reference "RFC7227: Guidelines for Creating New DHCPv6 reference "RFC7227: Guidelines for Creating New DHCPv6
@@ -1296,7 +1303,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-uri { container operator-option-uri {
//if-feature operator-op-uri; if-feature operator-op-uri;
presence "Enable this option"; presence "Enable this option";
description "operator uri option"; description "operator uri option";
reference "RFC7227: Guidelines for Creating New DHCPv6 Options"; reference "RFC7227: Guidelines for Creating New DHCPv6 Options";
@@ -1317,7 +1324,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-textstring { container operator-option-textstring {
//if-feature operator-op-textstring; if-feature operator-op-textstring;
presence "Enable this option"; presence "Enable this option";
description "operator itext string option"; description "operator itext string option";
reference "RFC7227: Guidelines for Creating New DHCPv6 Options"; reference "RFC7227: Guidelines for Creating New DHCPv6 Options";
@@ -1338,7 +1345,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-var-data { container operator-option-var-data {
//if-feature operator-op-var-data; if-feature operator-op-var-data;
presence "Enable this option"; presence "Enable this option";
description "operator variable length data option"; description "operator variable length data option";
reference "RFC7227: Guidelines for Creating New DHCPv6 Options"; reference "RFC7227: Guidelines for Creating New DHCPv6 Options";
@@ -1359,7 +1366,7 @@ module ietf-dhcpv6-options {
} }
container operator-option-dns-wire { container operator-option-dns-wire {
//if-feature operator-op-dns-wire; if-feature operator-op-dns-wire;
presence "Enable this option"; presence "Enable this option";
description "operator dns wire format domain name list option"; description "operator dns wire format domain name list option";
reference "RFC7227: Guidelines for Creating New DHCPv6 reference "RFC7227: Guidelines for Creating New DHCPv6
@@ -1379,5 +1386,6 @@ module ietf-dhcpv6-options {
} }
} }
} }
} }
} }

View File

@@ -30,6 +30,11 @@ module ietf-dhcpv6-relay {
"This model defines a YANG data model that can be "This model defines a YANG data model that can be
used to configure and manage a DHCPv6 relay."; used to configure and manage a DHCPv6 relay.";
revision 2018-09-04 {
description "";
reference "I-D: draft-ietf-dhc-dhcpv6-yang";
}
revision 2018-03-04 { revision 2018-03-04 {
description "Resolved most issues on the DHC official description "Resolved most issues on the DHC official
github"; github";
@@ -127,6 +132,7 @@ module ietf-dhcpv6-relay {
} }
uses dhcpv6-types:vendor-infor; uses dhcpv6-types:vendor-infor;
} }
container rsoo-option-sets { container rsoo-option-sets {
description description
"DHCPv6 relay agent could provide some information that would "DHCPv6 relay agent could provide some information that would

View File

@@ -26,9 +26,15 @@ module ietf-dhcpv6-server {
ian.farrer@telekom.de ian.farrer@telekom.de
sladjana.zechlin@telekom.de sladjana.zechlin@telekom.de
hezihao9512@gmail.com"; hezihao9512@gmail.com";
description "This model defines a YANG data model that can be description "This model defines a YANG data model that can be
used to configure and manage a DHCPv6 server."; used to configure and manage a DHCPv6 server.";
revision 2018-09-04 {
description "";
reference "I-D: draft-ietf-dhc-dhcpv6-yang";
}
revision 2018-03-04 { revision 2018-03-04 {
description "Resolved most issues on the DHC official description "Resolved most issues on the DHC official
github"; github";
@@ -109,6 +115,114 @@ module ietf-dhcpv6-server {
address with a specific interface, he can use the format like address with a specific interface, he can use the format like
'eth1/2001:db8::1'."; 'eth1/2001:db8::1'.";
} }
container lease-storage {
description "Indicates how the server stores the lease";
choice storage-type {
description "the type of lease storage";
// leaf persist {
// type boolean;
// mandatory true;
// description "controls whether the new leases and updates to existing leases are
// written to the file";
// }
case memfile {
description "the server stores lease information in a CSV file";
leaf memfile-name {
type string;
description "specifies an absolute location of the lease file in which new leases
and lease updates will be recorded";
}
leaf memfile-lfc-interval {
type uint64;
description "specifies the interval in seconds, at which the server will perform a
lease file cleanup (LFC)";
}
}
case mysql {
leaf mysql-name {
type string;
description "type of the database";
}
leaf mysql-host {
type string;
description "If the database is located
on a different system to the DHCPv6 server, the database host name must also be specified.";
}
leaf mysql-password {
type string;
description "the credentials of the account under which the server will access the database";
}
leaf mysql-port {
type uint8;
description "If the database is located on a different system, the port number may be specified";
}
leaf mysql-lfc-interval {
type uint64;
description "specifies the interval in seconds, at which the server will perform a
lease file cleanup (LFC)";
}
leaf mysql-connect-timeout {
type uint64;
description "If the database is located on a different system, a longer interval needs to be specified";
}
}
case postgresql {
leaf postgresql-name {
type string;
description "type of the database";
}
leaf postgresql-host {
type string;
description "If the database is located
on a different system to the DHCPv6 server, the database host name must also be specified.";
}
leaf postgresql-password {
type string;
description "the credentials of the account under which the server will access the database";
}
leaf postgresql-port {
type uint8;
description "If the database is located on a different system, the port number may be specified";
}
leaf postgresql-lfc-interval {
type uint64;
description "specifies the interval in seconds, at which the server will perform a
lease file cleanup (LFC)";
}
leaf postgresql-connect-timeout {
type uint64;
description "If the database is located on a different system, a longer interval needs to be specified";
}
}
case cassandra {
leaf cassandra-name {
type string;
description "type of the database";
}
leaf cassandra-contact-points {
type string;
description "Cassandra takes a list of comma separated IP addresses to contact the cluster";
}
leaf cassandra-password {
type string;
description "the credentials of the account under which the server will access the database";
}
leaf cassandra-lfc-interval {
type uint64;
description "specifies the interval in seconds, at which the server will perform a
lease file cleanup (LFC)";
}
leaf cassandra-connect-timeout {
type uint64;
description "If the database is located on a different system, a longer interval needs to be specified";
}
}
}
}
uses dhcpv6-types:vendor-infor; uses dhcpv6-types:vendor-infor;
} }
@@ -239,7 +353,7 @@ module ietf-dhcpv6-server {
} }
leaf rapid-commit { leaf rapid-commit {
type boolean; type boolean;
mandatory false; mandatory true;
description "A boolean value specifies whether the pool description "A boolean value specifies whether the pool
supports client-server exchanges involving two messages."; supports client-server exchanges involving two messages.";
} }
@@ -266,6 +380,7 @@ module ietf-dhcpv6-server {
} }
} }
} }
container pd-pools { container pd-pools {
description "If a server supports prefix delegation function, this description "If a server supports prefix delegation function, this
container will be used to define the delegating router's prefix container will be used to define the delegating router's prefix
@@ -312,7 +427,7 @@ module ietf-dhcpv6-server {
} }
leaf rapid-commit { leaf rapid-commit {
type boolean; type boolean;
mandatory false; mandatory true;
description "A boolean value specifies whether the server description "A boolean value specifies whether the server
support client-server exchanges involving two messages defined."; support client-server exchanges involving two messages defined.";
} }
@@ -322,14 +437,14 @@ module ietf-dhcpv6-server {
} }
leaf max-pd-space-utilization { leaf max-pd-space-utilization {
type threshold; type threshold;
mandatory false; mandatory true;
description "Maximum utilization of pd space in this pool"; description "Maximum utilization of pd space in this pool";
} }
leaf option-set-id { leaf option-set-id {
type leafref { type leafref {
path "/server/server-config/option-sets/option-set/option-set-id"; path "/server/server-config/option-sets/option-set/option-set-id";
} }
mandatory false; mandatory true;
description "The ID field of relevant option-set to be description "The ID field of relevant option-set to be
provisioned to clients of this prefix-pool."; provisioned to clients of this prefix-pool.";
} }
@@ -351,7 +466,7 @@ module ietf-dhcpv6-server {
choice client-identifier { choice client-identifier {
description "When making reservations, the server needs to choose a description "When making reservations, the server needs to choose a
identifier to identify the server. Currently 'DUID' and 'hardware identifier to identify the client. Currently 'DUID' and 'hardware
address' are supported."; address' are supported.";
case duid { case duid {
description "DUID"; description "DUID";

View File

@@ -21,6 +21,11 @@ module ietf-dhcpv6-types {
description "This model defines a YANG data model that can be description "This model defines a YANG data model that can be
used to define some commonly used DHCPv6 types"; used to define some commonly used DHCPv6 types";
revision 2018-09-04 {
description "";
reference "I-D: draft-ietf-dhc-dhcpv6-yang";
}
revision 2018-01-30 { revision 2018-01-30 {
description "Initial revision"; description "Initial revision";
reference "I-D: draft-ietf-dhc-dhcpv6-yang"; reference "I-D: draft-ietf-dhc-dhcpv6-yang";