summaryrefslogtreecommitdiff
path: root/trafgen_parser.y
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-02-08 08:01:53 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-02-23 13:23:53 +0100
commitd1dfc01a4068e3c15a1195f804448a9a3dee5b2b (patch)
treee0043241653c749215c52db74ed14b96b01abc50 /trafgen_parser.y
parent116835ed0d245f3e73173f2f2057265827416ce6 (diff)
trafgen: parser: Add syntax for MPLS header creating
Add 'mpls()' function for creating MPLS header with parameters: lbl|label MPLS label last Indicates the last label on MPLS stack tc|tclass|exp Traffic Class (TC) ttl TTL (Time To Live) Currently only unicast MPLS is supported, but multicast might be set via 'eth()' function. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_parser.y')
-rw-r--r--trafgen_parser.y34
1 files changed, 33 insertions, 1 deletions
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 655b0ba..0b1c0fb 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -356,9 +356,10 @@ static void proto_add(enum proto_id pid)
%token K_SPORT K_DPORT
%token K_SEQ K_ACK_SEQ K_DOFF K_CWR K_ECE K_URG K_ACK K_PSH K_RST K_SYN K_FIN K_WINDOW K_URG_PTR
%token K_TPID K_TCI K_PCP K_DEI K_1Q K_1AD
+%token K_LABEL K_TC K_LAST K_EXP
%token K_ETH
-%token K_VLAN
+%token K_VLAN K_MPLS
%token K_ARP
%token K_IP4
%token K_UDP K_TCP
@@ -583,6 +584,7 @@ ddec
proto
: eth_proto { }
| vlan_proto { }
+ | mpls_proto { }
| arp_proto { }
| ip4_proto { }
| udp_proto { }
@@ -653,6 +655,36 @@ vlan_field
{ proto_field_set_be16(hdr, VLAN_VID, $5); }
;
+mpls_proto
+ : mpls '(' mpls_param_list ')' { }
+ ;
+
+mpls
+ : K_MPLS { proto_add(PROTO_MPLS); }
+ ;
+
+mpls_param_list
+ : { }
+ | mpls_field { }
+ | mpls_field delimiter mpls_param_list { }
+ ;
+
+mpls_tc
+ : K_TC { }
+ | K_EXP { }
+ ;
+
+mpls_field
+ : K_LABEL skip_white '=' skip_white number
+ { proto_field_set_be32(hdr, MPLS_LABEL, $5); }
+ | mpls_tc skip_white '=' skip_white number
+ { proto_field_set_be32(hdr, MPLS_TC, $5); }
+ | K_LAST skip_white '=' skip_white number
+ { proto_field_set_be32(hdr, MPLS_LAST, $5); }
+ | K_TTL skip_white '=' skip_white number
+ { proto_field_set_be32(hdr, MPLS_TTL, $5); }
+ ;
+
arp_proto
: arp '(' arp_param_list ')' { }
;