summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trafgen_lexer.l7
-rw-r--r--trafgen_parser.y34
2 files changed, 40 insertions, 1 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index e1d1a3f..3c624f8 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -120,6 +120,12 @@ ip4_addr ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)
"1ad" { return K_1AD; }
"1q" { return K_1Q; }
+ /* MPLS (Multi Protocol Label Switching) */
+"lbl"|"label" { return K_LABEL; }
+"last" { return K_LAST; }
+"tc"|"tclass" { return K_TC; }
+"exp" { return K_EXP; }
+
/* ARP */
"sha"|"smac" { return K_SHA; }
"spa"|"sip" { return K_SPA; }
@@ -167,6 +173,7 @@ ip4_addr ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)
"eth" { return K_ETH; }
"vlan" { return K_VLAN; }
+"mpls" { return K_MPLS; }
"arp" { return K_ARP; }
"ip4"|"ipv4" { return K_IP4; }
"udp" { return K_UDP; }
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 ')' { }
;