Add 'pause()' proto header function for PAUSE(802.3X) header
generation with a fields:

    code - MAC Control opcode (default 0x0001)
    time - PAUSE time (default 0)

Signed-off-by: Vadim Kochan <vadi...@gmail.com>
---
 trafgen_lexer.l  |  4 ++++
 trafgen_parser.y | 27 +++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

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 ')' { }
        ;
-- 
2.9.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to