From: Francis Dupont Date: Fri, 14 Jun 2019 18:52:25 +0000 (+0200) Subject: [150-add-sub-option-classification] Accept only integers for sub-option codes X-Git-Tag: Kea-1.6.0~41^2~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31a7cba643c4027be23715fe445b912adbde5030;p=thirdparty%2Fkea.git [150-add-sub-option-classification] Accept only integers for sub-option codes --- diff --git a/src/lib/eval/parser.yy b/src/lib/eval/parser.yy index 4f8626c1f8..e4fef3709c 100644 --- a/src/lib/eval/parser.yy +++ b/src/lib/eval/parser.yy @@ -152,12 +152,12 @@ bool_expr : "(" bool_expr ")" TokenPtr opt(new TokenOption($3, TokenOption::EXISTS)); ctx.expression.push_back(opt); } - | OPTION "[" option_code "]" "." OPTION "[" option_code "]" "." EXISTS + | OPTION "[" option_code "]" "." OPTION "[" sub_option_code "]" "." EXISTS { TokenPtr opt(new TokenSubOption($3, $8, TokenOption::EXISTS)); ctx.expression.push_back(opt); } - | RELAY4 "[" option_code "]" "." EXISTS + | RELAY4 "[" sub_option_code "]" "." EXISTS { switch (ctx.getUniverse()) { case Option::V4: @@ -177,7 +177,7 @@ bool_expr : "(" bool_expr ")" error(@1, "relay4 can only be used in DHCPv4."); } } - | RELAY6 "[" nest_level "]" "." OPTION "[" option_code "]" "." EXISTS + | RELAY6 "[" nest_level "]" "." OPTION "[" sub_option_code "]" "." EXISTS { switch (ctx.getUniverse()) { case Option::V6: @@ -209,7 +209,7 @@ bool_expr : "(" bool_expr ")" TokenPtr exist(new TokenVendor(ctx.getUniverse(), $3, TokenOption::EXISTS)); ctx.expression.push_back(exist); } - | VENDOR "[" enterprise_id "]" "." OPTION "[" option_code "]" "." EXISTS + | VENDOR "[" enterprise_id "]" "." OPTION "[" sub_option_code "]" "." EXISTS { // Expression vendor[1234].option[123].exists // @@ -256,12 +256,12 @@ string_expr : STRING TokenPtr opt(new TokenOption($3, $6)); ctx.expression.push_back(opt); } - | OPTION "[" option_code "]" "." OPTION "[" option_code "]" "." option_repr_type + | OPTION "[" option_code "]" "." OPTION "[" sub_option_code "]" "." option_repr_type { TokenPtr opt(new TokenSubOption($3, $8, $11)); ctx.expression.push_back(opt); } - | RELAY4 "[" option_code "]" "." option_repr_type + | RELAY4 "[" sub_option_code "]" "." option_repr_type { switch (ctx.getUniverse()) { case Option::V4: @@ -282,7 +282,7 @@ string_expr : STRING } } - | RELAY6 "[" nest_level "]" "." OPTION "[" option_code "]" "." option_repr_type + | RELAY6 "[" nest_level "]" "." OPTION "[" sub_option_code "]" "." option_repr_type { switch (ctx.getUniverse()) { case Option::V6: @@ -384,7 +384,7 @@ string_expr : STRING TokenVendor::ENTERPRISE_ID)); ctx.expression.push_back(vendor); } - | VENDOR "[" enterprise_id "]" "." OPTION "[" option_code "]" "." option_repr_type + | VENDOR "[" enterprise_id "]" "." OPTION "[" sub_option_code "]" "." option_repr_type { // This token will search for vendor option with // specified enterprise-id. If found, will search @@ -442,6 +442,12 @@ option_code : INTEGER } ; +sub_option_code : INTEGER + { + $$ = ctx.convertOptionCode($1, @1); + } + ; + option_repr_type : TEXT { $$ = TokenOption::TEXTUAL;