Commit 86ad729e authored by Francis Dupont's avatar Francis Dupont
Browse files

[4271] Fixed parser

parent 840d2f71
......@@ -167,33 +167,33 @@ bool_expr : "(" bool_expr ")"
}
}
| VENDOR_CLASS "[" enterprise_id "]" "." EXISTS
{
// Expression: vendor-class[1234].exists
//
// This token will find option 124 (DHCPv4) or 16 (DHCPv6), and will check
// if enterprise-id equals specified value.
TokenPtr exist(new TokenVendorClass(ctx.getUniverse(), $3, TokenOption::EXISTS));
ctx.expression.push_back(exist);
}
{
// Expression: vendor-class[1234].exists
//
// This token will find option 124 (DHCPv4) or 16 (DHCPv6),
// and will check if enterprise-id equals specified value.
TokenPtr exist(new TokenVendorClass(ctx.getUniverse(), $3, TokenOption::EXISTS));
ctx.expression.push_back(exist);
}
| VENDOR "[" enterprise_id "]" "." EXISTS
{
// Expression: vendor[1234].exists
//
// This token will find option 125 (DHCPv4) or 17 (DHCPv6), and will check
// if enterprise-id equals specified value.
TokenPtr exist(new TokenVendor(ctx.getUniverse(), $3, TokenOption::EXISTS));
ctx.expression.push_back(exist);
}
{
// Expression: vendor[1234].exists
//
// This token will find option 125 (DHCPv4) or 17 (DHCPv6),
// and will check if enterprise-id equals specified value.
TokenPtr exist(new TokenVendor(ctx.getUniverse(), $3, TokenOption::EXISTS));
ctx.expression.push_back(exist);
}
| VENDOR "[" enterprise_id "]" "." OPTION "[" option_code "]" "." EXISTS
{
// Expression vendor[1234].option[123].exists
//
// This token will check if specified vendor option exists, has specified
// enterprise-id and if has specified suboption.
TokenPtr exist(new TokenVendor(ctx.getUniverse(), $3, TokenOption::EXISTS, $8));
ctx.expression.push_back(exist);
}
{
// Expression vendor[1234].option[123].exists
//
// This token will check if specified vendor option
// exists, has specified enterprise-id and if has
// specified suboption.
TokenPtr exist(new TokenVendor(ctx.getUniverse(), $3, TokenOption::EXISTS, $8));
ctx.expression.push_back(exist);
}
;
string_expr : STRING
......@@ -287,58 +287,61 @@ string_expr : STRING
TokenPtr conc(new TokenConcat());
ctx.expression.push_back(conc);
}
| VENDOR "." ENTERPRISE
{
// expression: vendor.enterprise
//
// This token will return enterprise-id number of received vendor option.
TokenPtr vendor(new TokenVendor(ctx.getUniverse(), 0, TokenVendor::ENTERPRISE_ID));
ctx.expression.push_back(vendor);
}
| VENDOR_CLASS "." ENTERPRISE
{
// expression: vendor-class.enterprise
//
// This token will return enterprise-id number of received vendor class option.
TokenPtr vendor(new TokenVendorClass(ctx.getUniverse(), 0,
TokenVendor::ENTERPRISE_ID));
ctx.expression.push_back(vendor);
}
| VENDOR "[" enterprise_id "]" "." OPTION "[" option_code "]" "." option_repr_type
{
// expression: vendor[1234].option[56].exists
// expression: vendor[1234].option[56].hex
//
// This token will search for vendor option with specified enterprise-id.
// If found, will search for specified suboption and finally will return
// if it exists ('exists') or its content ('hex')
TokenPtr opt(new TokenVendor(ctx.getUniverse(), $3, $11, $8));
ctx.expression.push_back(opt);
}
| VENDOR_CLASS "[" enterprise_id "]" "." DATA
{
// expression: vendor-class[1234].data
//
// Vendor class option does not have suboptions, but chunks of data (typically 1,
// but the option structure allows multiple of them). If chunk offset is not
// specified, we assume the first (0th) is requested.
TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), $3,
TokenVendor::DATA, 0));
ctx.expression.push_back(vendor_class);
}
| VENDOR_CLASS "[" enterprise_id "]" "." DATA "[" INTEGER "]"
{
// expression: vendor-class[1234].data[5]
//
// Vendor class option does not have suboptions, but chunks of data (typically 1,
// but the option structure allows multiple of them). This syntax specifies
// which data chunk (tuple) we want.
uint8_t index = ctx.convertUint8($8, @8);
TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), $3,
TokenVendor::DATA, index));
ctx.expression.push_back(vendor_class);
}
;
| VENDOR "." ENTERPRISE
{
// expression: vendor.enterprise
//
// This token will return enterprise-id number of
// received vendor option.
TokenPtr vendor(new TokenVendor(ctx.getUniverse(), 0, TokenVendor::ENTERPRISE_ID));
ctx.expression.push_back(vendor);
}
| VENDOR_CLASS "." ENTERPRISE
{
// expression: vendor-class.enterprise
//
// This token will return enterprise-id number of
// received vendor class option.
TokenPtr vendor(new TokenVendorClass(ctx.getUniverse(), 0,
TokenVendor::ENTERPRISE_ID));
ctx.expression.push_back(vendor);
}
| VENDOR "[" enterprise_id "]" "." OPTION "[" option_code "]" "." option_repr_type
{
// This token will search for vendor option with
// specified enterprise-id. If found, will search
// for specified suboption and finally will return
// its content.
TokenPtr opt(new TokenVendor(ctx.getUniverse(), $3, $11, $8));
ctx.expression.push_back(opt);
}
| VENDOR_CLASS "[" enterprise_id "]" "." DATA
{
// expression: vendor-class[1234].data
//
// Vendor class option does not have suboptions,
// but chunks of data (typically 1, but the option
// structure allows multiple of them). If chunk
// offset is not specified, we assume the first (0th)
// is requested.
TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), $3,
TokenVendor::DATA, 0));
ctx.expression.push_back(vendor_class);
}
| VENDOR_CLASS "[" enterprise_id "]" "." DATA "[" INTEGER "]"
{
// expression: vendor-class[1234].data[5]
//
// Vendor class option does not have suboptions,
// but chunks of data (typically 1, but the option
// structure allows multiple of them). This syntax
// specifies which data chunk (tuple) we want.
uint8_t index = ctx.convertUint8($8, @8);
TokenPtr vendor_class(new TokenVendorClass(ctx.getUniverse(), $3,
TokenVendor::DATA, index));
ctx.expression.push_back(vendor_class);
}
;
option_code : INTEGER
{
......@@ -361,13 +364,14 @@ option_repr_type : TEXT
;
enterprise_id : INTEGER
{
$$ = ctx.convertUint32($1, @1);
}
| "*"
{
$$ = 0;
}
{
$$ = ctx.convertUint32($1, @1);
}
| "*"
{
$$ = 0;
}
;
pkt4_field : CHADDR
{
......@@ -400,17 +404,17 @@ pkt4_field : CHADDR
;
start_expr : INTEGER
{
TokenPtr str(new TokenString($1));
ctx.expression.push_back(str);
}
;
length_expr : INTEGER
{
TokenPtr str(new TokenString($1));
ctx.expression.push_back(str);
}
;
length_expr : INTEGER
{
TokenPtr str(new TokenString($1));
ctx.expression.push_back(str);
}
| ALL
{
TokenPtr str(new TokenString("all"));
......@@ -418,22 +422,34 @@ length_expr : INTEGER
}
;
relay6_field : PEERADDR { $$ = TokenRelay6Field::PEERADDR; }
| LINKADDR { $$ = TokenRelay6Field::LINKADDR; }
relay6_field : PEERADDR
{
$$ = TokenRelay6Field::PEERADDR;
}
| LINKADDR
{
$$ = TokenRelay6Field::LINKADDR;
}
;
nest_level : INTEGER
{
$$ = ctx.convertNestLevelNumber($1, @1);
}
// Eventually we may add strings to handle different
// ways of choosing from which relay we want to extract
// an option or field.
{
$$ = ctx.convertNestLevelNumber($1, @1);
}
// Eventually we may add strings to handle different
// ways of choosing from which relay we want to extract
// an option or field.
;
pkt6_field:MSGTYPE { $$ = TokenPkt6::MSGTYPE; }
| TRANSID { $$ = TokenPkt6::TRANSID; }
;
pkt6_field : MSGTYPE
{
$$ = TokenPkt6::MSGTYPE;
}
| TRANSID
{
$$ = TokenPkt6::TRANSID;
}
;
%%
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment