test suite reviews and discussions
 help / color / mirror / Atom feed
From: lihong <lihongx.ma@intel.com>
To: dts@dpdk.org
Cc: lihong <lihongx.ma@intel.com>
Subject: [dts] [PATCH V1 1/3][nsh] framwork/packet: add support of mpls and nsh
Date: Fri, 11 Oct 2019 08:25:04 +0800	[thread overview]
Message-ID: <1570753506-1810-1-git-send-email-lihongx.ma@intel.com> (raw)

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 framework/packet.py | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/framework/packet.py b/framework/packet.py
index 502d85c..84ab0f8 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -69,6 +69,8 @@ from vxlan import VXLAN
 from nvgre import NVGRE, IPPROTO_NVGRE
 from lldp import LLDP, LLDPManagementAddress
 from Dot1BR import Dot1BR
+from nsh import NSH
+from mpls import MPLS
 
 # get tester logger
 from logger import getLogger
@@ -81,7 +83,7 @@ from utils import get_backtrace_object
 PACKETGEN = "scapy"
 
 LayersTypes = {
-    "L2": ['ether', 'vlan', 'etag', '1588', 'arp', 'lldp'],
+    "L2": ['ether', 'vlan', 'etag', '1588', 'arp', 'lldp', 'mpls', 'nsh'],
     # 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'],
@@ -124,6 +126,8 @@ class scapy(object):
         'gre': GRE(),
         'raw': Raw(),
         'vxlan': VXLAN(),
+        'nsh': NSH(),
+        'mpls': MPLS(),
 
         'inner_mac': Ether(),
         'inner_vlan': Dot1Q(),
@@ -328,6 +332,30 @@ class scapy(object):
     def vxlan(self, pkt_layer, vni=0):
         pkt_layer.vni = vni
 
+    def nsh(self, pkt_layer, ver=0, oam=0, critical=0, reserved=0, len=0, mdtype=1, nextproto=3,
+            nsp=0x0, nsi=1, npc= 0x0, nsc= 0x0, spc= 0x0, ssc= 0x0):
+        pkt_layer.Ver = ver
+        pkt_layer.OAM = oam
+        pkt_layer.Critical = critical
+        pkt_layer.Reserved = reserved
+        if len != 0:
+            pkt_layer.Len = len
+        pkt_layer.MDType = mdtype
+        pkt_layer.NextProto = nextproto
+        pkt_layer.NSP = nsp
+        pkt_layer.NSI = nsi
+        if mdtype == 1:
+            pkt_layer.NPC = npc
+            pkt_layer.NSC = nsc
+            pkt_layer.SPC = spc
+            pkt_layer.SSC = ssc
+
+    def mpls(self, pkt_layer, label=0, cos=0, s=0, ttl=64):
+        pkt_layer.label = label
+        pkt_layer.cos = cos
+        pkt_layer.s = s
+        pkt_layer.ttl = ttl
+
     def read_pcap(self, file):
         pcap_pkts = []
         try:
@@ -555,6 +583,8 @@ class Packet(object):
             'GRE': 'gre',
             'VXLAN': 'vxlan',
             'PKT': 'raw',
+            'MPLS': 'mpls',
+            'NSH': 'nsh',
         }
 
         layers = self.pkt_type.split('_')
@@ -674,6 +704,12 @@ class Packet(object):
     def _config_layer_vxlan(self, pkt_layer, config):
         return self.pktgen.vxlan(pkt_layer, **config)
 
+    def _config_layer_mpls(self, pkt_layer, config):
+        return self.pktgen.mpls(pkt_layer, **config)
+
+    def _config_layer_nsh(self, pkt_layer, config):
+        return self.pktgen.nsh(pkt_layer, **config)
+
     def strip_layer_element(self, layer, element):
         """
         Strip packet layer elements
-- 
2.7.4


             reply	other threads:[~2019-10-11  7:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11  0:25 lihong [this message]
2019-10-11  0:25 ` [dts] [PATCH V1 2/3][nsh] dep: " lihong
2019-10-11  0:25 ` [dts] [PATCH V1 3/3][nsh] tests/uni_pkt: import nsh from current dep lihong
2019-10-12  1:26   ` Mo, YufengX
2019-10-12  2:02     ` Mo, YufengX
2019-10-14  5:15       ` Ma, LihongX
2019-10-14  5:04     ` Ma, LihongX
2019-10-12  6:10   ` Tu, Lijuan

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=1570753506-1810-1-git-send-email-lihongx.ma@intel.com \
    --to=lihongx.ma@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).