test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yufen Mo <yufengx.mo@intel.com>
To: dts@dpdk.org
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V2 1/2] add 802.1BR UDP format support in framework/packet module
Date: Tue, 26 Jul 2016 10:01:41 +0800	[thread overview]
Message-ID: <1469498502-28136-2-git-send-email-yufengx.mo@intel.com> (raw)
In-Reply-To: <1469498502-28136-1-git-send-email-yufengx.mo@intel.com>

From: yufengmx <yufengx.mo@intel.com>

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 framework/packet.py | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/framework/packet.py b/framework/packet.py
index a46fd47..98bc5c0 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -69,12 +69,13 @@ sys.path.append(DEP_FOLDER)
 from vxlan import Vxlan
 from nvgre import NVGRE, IPPROTO_NVGRE
 from lldp import LLDP, LLDPManagementAddress
+from Dot1BR import Dot1BR
 
 # packet generator type should be configured later
 PACKETGEN = "scapy"
 
 LayersTypes = {
-    "L2": ['ether', 'vlan', '1588', 'arp', 'lldp'],
+    "L2": ['ether', 'vlan', 'etag', '1588', 'arp', 'lldp'],
     # ipv4_ext_unknown, ipv6_ext_unknown
     "L3": ['ipv4', 'ipv4ihl', 'ipv6', 'ipv4_ext', 'ipv6_ext', 'ipv6_ext2', 'ipv6_frag'],
     "L4": ['tcp', 'udp', 'frag', 'sctp', 'icmp', 'nofrag'],
@@ -98,6 +99,7 @@ class scapy(object):
     SCAPY_LAYERS = {
         'ether': Ether(dst="ff:ff:ff:ff:ff:ff"),
         'vlan': Dot1Q(),
+        'etag': Dot1BR(),
         '1588': Ether(type=0x88f7),
         'arp': ARP(),
         'ipv4': IP(),
@@ -178,6 +180,24 @@ class scapy(object):
             value = int(str(self.pkt[Dot1Q].vlan))
         return value
 
+    def etag(self, pkt_layer, ECIDbase=0, prio=0, type=None):
+        if pkt_layer.name != "802.1BR":
+           return
+        pkt_layer.ECIDbase = int(ECIDbase)
+        pkt_layer.prio = prio
+        if type is not None:
+            pkt_layer.type = type
+
+    def strip_etag(self, element):
+        value = None
+
+        if self.pkt.haslayer('Dot1BR') is 0:
+            return None
+
+        if element == 'ECIDbase':
+            value = int(str(self.pkt[Dot1BR].ECIDbase))
+        return value
+
     def strip_layer2(self, element):
         value = None
         layer = self.pkt.getlayer(0)
@@ -316,6 +336,7 @@ class Packet(object):
         'TCP': {'layers': ['ether', 'ipv4', 'tcp', 'raw'], 'cfgload': True},
         'UDP': {'layers': ['ether', 'ipv4', 'udp', 'raw'], 'cfgload': True},
         'VLAN_UDP': {'layers': ['ether', 'vlan', 'ipv4', 'udp', 'raw'], 'cfgload': True},
+        'ETAG_UDP': {'layers': ['ether', 'etag', 'ipv4', 'udp', 'raw'], 'cfgload': True},
         'SCTP': {'layers': ['ether', 'ipv4', 'sctp', 'raw'], 'cfgload': True},
         'IPv6_TCP': {'layers': ['ether', 'ipv6', 'tcp', 'raw'], 'cfgload': True},
         'IPv6_UDP': {'layers': ['ether', 'ipv6', 'udp', 'raw'], 'cfgload': True},
@@ -446,6 +467,7 @@ class Packet(object):
         name2type = {
             'MAC': 'ether',
             'VLAN': 'vlan',
+            'ETAG': 'etag',
             'IP': 'ipv4',
             'IPihl': 'ipv4ihl',
             'IPFRAG': 'ipv4_ext',
@@ -553,6 +575,9 @@ class Packet(object):
     def _config_layer_vlan(self, pkt_layer, config):
         return self.pktgen.vlan(pkt_layer, **config)
 
+    def _config_layer_etag(self, pkt_layer, config):
+        return self.pktgen.etag(pkt_layer, **config)
+
     def _config_layer_ipv4(self, pkt_layer, config):
         return self.pktgen.ipv4(pkt_layer, **config)
 
@@ -586,6 +611,9 @@ class Packet(object):
     def strip_element_vlan(self, element):
         return self.pktgen.strip_vlan(element)
 
+    def strip_element_etag(self, element):
+        return self.pktgen.strip_etag(element)
+
     def strip_element_layer4(self, element):
         return self.pktgen.strip_layer4(element)
 
-- 
1.9.3

  reply	other threads:[~2016-07-26  2:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26  2:01 [dts] [PATCH V2 0/2] Etag automation testing script Yufen Mo
2016-07-26  2:01 ` Yufen Mo [this message]
2016-07-26  2:01 ` [dts] [PATCH V2 2/2] Etag: upload " Yufen Mo
2016-07-26  4:58 ` [dts] [PATCH V2 0/2] Etag " Liu, Yong
  -- strict thread matches above, loose matches on Subject: below --
2016-07-26  1:30 Yufen Mo
2016-07-26  1:30 ` [dts] [PATCH V2 1/2] add 802.1BR UDP format support in framework/packet module Yufen Mo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1469498502-28136-2-git-send-email-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).