test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH 2/3] framework packet: support strip packet payload
Date: Wed, 20 Jan 2016 09:47:42 +0800	[thread overview]
Message-ID: <1453254463-11436-2-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1453254463-11436-1-git-send-email-yong.liu@intel.com>

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 <yong.liu@intel.com>

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

  reply	other threads:[~2016-01-20  1:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20  1:47 [dts] [PATCH 1/3] framework dut: add port stop when execution exit Yong Liu
2016-01-20  1:47 ` Yong Liu [this message]
2016-01-20  1:47 ` [dts] [PATCH 3/3] nics fm10k: support optimize rule and vlan/jumbo setting Yong Liu

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=1453254463-11436-2-git-send-email-yong.liu@intel.com \
    --to=yong.liu@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).