summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-09-22 23:55:34 +0300
committerTobias Klauser <tklauser@distanz.ch>2016-10-04 17:18:13 +0200
commit12ccf0c12dde24f9b759b1747c88b2f09439c7d8 (patch)
tree1241f30ec581af5b4bdf0788214a106eb8c8180d
parentf4c1856026c0edcc1e2285cf6ae773057bee51cd (diff)
trafgen: parser: Add 'pause()' function for IEEE 802.3X PAUSE header
Add 'pause()' proto header function for IEEE 802.3X PAUSE header generation with the fields: code - MAC Control opcode (default 0x0001) time - PAUSE time (default 0) Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--trafgen_lexer.l4
-rw-r--r--trafgen_parser.y27
2 files changed, 31 insertions, 0 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index 5873eec..324a171 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -118,6 +118,9 @@ ip6_addr (({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:
"etype" { return K_ETYPE; }
"type" { return K_TYPE; }
+ /* IEEE 802.3X PAUSE */
+"time" { return K_TIME; }
+
/* VLAN (802.1Q & 802.1ad) */
"tpid" { return K_TPID; }
"tci" { return K_TCI; }
@@ -192,6 +195,7 @@ ip6_addr (({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:)?({a_hex}?:
"urgptr" { return K_URG_PTR; }
"eth" { return K_ETH; }
+"pause" { return K_PAUSE; }
"vlan" { return K_VLAN; }
"mpls" { return K_MPLS; }
"arp" { return K_ARP; }
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 7e41bff..6526756 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -461,6 +461,7 @@ static void proto_field_expr_eval(void)
%token K_CPU K_CSUMIP K_CSUMUDP K_CSUMTCP K_CSUMUDP6 K_CSUMTCP6 K_CONST8 K_CONST16 K_CONST32 K_CONST64
%token K_DADDR K_SADDR K_ETYPE K_TYPE
+%token K_TIME
%token K_OPER K_SHA K_SPA K_THA K_TPA K_REQUEST K_REPLY K_PTYPE K_HTYPE
%token K_PROT K_TTL K_DSCP K_ECN K_TOS K_LEN K_ID K_FLAGS K_FRAG K_IHL K_VER K_CSUM K_DF K_MF
%token K_FLOW K_NEXT_HDR K_HOP_LIMIT
@@ -473,6 +474,7 @@ static void proto_field_expr_eval(void)
%token K_ADDR K_MTU
%token K_ETH
+%token K_PAUSE
%token K_VLAN K_MPLS
%token K_ARP
%token K_IP4 K_IP6
@@ -699,6 +701,7 @@ ddec
proto
: eth_proto { }
+ | pause_proto { }
| vlan_proto { }
| mpls_proto { }
| arp_proto { }
@@ -779,6 +782,30 @@ eth_expr
{ proto_field_expr_eval(); }
;
+pause_proto
+ : pause '(' pause_param_list ')' { }
+ ;
+
+pause
+ : K_PAUSE { proto_add(PROTO_PAUSE); }
+ ;
+
+pause_param_list
+ : { }
+ | pause_expr { }
+ | pause_expr delimiter pause_param_list { }
+ ;
+
+pause_field
+ : K_CODE { proto_field_set(PAUSE_OPCODE); }
+ | K_TIME { proto_field_set(PAUSE_TIME); }
+ ;
+
+pause_expr
+ : pause_field skip_white '=' skip_white field_expr
+ { proto_field_expr_eval(); }
+ ;
+
vlan_proto
: vlan '(' vlan_param_list ')' { }
;