From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4C125F94 for ; Mon, 18 Jul 2016 04:03:46 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 17 Jul 2016 19:03:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,381,1464678000"; d="scan'208";a="735725466" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 17 Jul 2016 19:03:45 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u6I23has028496; Mon, 18 Jul 2016 10:03:43 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u6I23fum018188; Mon, 18 Jul 2016 10:03:43 +0800 Received: (from yufengmx@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u6I23fA8018184; Mon, 18 Jul 2016 10:03:41 +0800 From: Yufen Mo To: dts@dpdk.org Cc: yufengmx Date: Mon, 18 Jul 2016 10:03:36 +0800 Message-Id: <1468807417-18146-2-git-send-email-yufengx.mo@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1468807417-18146-1-git-send-email-yufengx.mo@intel.com> References: <1468807417-18146-1-git-send-email-yufengx.mo@intel.com> Subject: [dts] [PATCH V1 1/2] add 802.1BR UDP format support in framework/packet module X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 02:03:46 -0000 From: yufengmx Signed-off-by: yufengmx --- 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