From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id AEBC58D3A for ; Wed, 20 Jan 2016 02:47:53 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 19 Jan 2016 17:47:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,319,1449561600"; d="scan'208";a="636547664" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 19 Jan 2016 17:47:52 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u0K1lnk6027557; Wed, 20 Jan 2016 09:47:49 +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 u0K1llpV011479; Wed, 20 Jan 2016 09:47:49 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u0K1llbZ011475; Wed, 20 Jan 2016 09:47:47 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 20 Jan 2016 09:47:42 +0800 Message-Id: <1453254463-11436-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1453254463-11436-1-git-send-email-yong.liu@intel.com> References: <1453254463-11436-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 2/3] framework packet: support strip packet payload 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: Wed, 20 Jan 2016 01:47:54 -0000 Add new function support strip packet payload according to layer. By now only support strip L2/L3/L4 packet, not support tunnel packet. Signed-off-by: Marvin Liu diff --git a/framework/packet.py b/framework/packet.py index aaa1dd0..a7853e9 100755 --- a/framework/packet.py +++ b/framework/packet.py @@ -322,6 +322,7 @@ class Packet(object): 'TIMESYNC': {'layers': ['ether', 'raw'], 'cfgload': False}, 'ARP': {'layers': ['ether', 'arp'], 'cfgload': False}, 'LLDP': {'layers': ['ether', 'lldp'], 'cfgload': False}, + 'IP_RAW': {'layers': ['ether', 'ipv4', 'raw'], 'cfgload': True}, 'TCP': {'layers': ['ether', 'ipv4', 'tcp', 'raw'], 'cfgload': True}, 'UDP': {'layers': ['ether', 'ipv4', 'udp', 'raw'], 'cfgload': True}, 'VLAN_UDP': {'layers': ['ether', 'dot1q', 'ipv4', 'udp', 'raw'], 'cfgload': True}, @@ -721,6 +722,23 @@ def compare_pktload(pkt1=None, pkt2=None, layer="L2"): else: return False +def strip_pktload(pkt=None, layer="L2"): + if layer == "L2": + l_idx = 0 + elif layer == "L3": + l_idx = 1 + elif layer == "L4": + l_idx = 2 + else: + l_idx = 0 + try: + load = hexstr(str(pkt.pktgen.pkt.getlayer(l_idx)), onlyhex=1) + except: + # return pass when scapy failed to extract packet + load = "" + + return load + ############################################################################### ############################################################################### if __name__ == "__main__": -- 2.4.3