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 V2 2/3][nsh] framework/packet: add support of nsh and mpls
Date: Tue, 15 Oct 2019 05:49:01 +0800	[thread overview]
Message-ID: <1571089742-7077-2-git-send-email-lihongx.ma@intel.com> (raw)
In-Reply-To: <1571089742-7077-1-git-send-email-lihongx.ma@intel.com>

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

diff --git a/framework/packet.py b/framework/packet.py
index 05b2367..2ceed06 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -53,6 +53,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
 
 from utils import convert_ip2int
 from utils import convert_int2ip
@@ -64,7 +66,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'],
@@ -107,6 +109,8 @@ class scapy(object):
         'gre': GRE(),
         'raw': Raw(),
         'vxlan': VXLAN(),
+        'nsh': NSH(),
+        'mpls': MPLS(),
 
         'inner_mac': Ether(),
         'inner_vlan': Dot1Q(),
@@ -321,6 +325,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
+
 
 class Packet(object):
 
@@ -700,6 +728,8 @@ class Packet(object):
             'GRE': 'gre',
             'VXLAN': 'vxlan',
             'PKT': 'raw',
+            'MPLS': 'mpls',
+            'NSH': 'nsh',
         }
 
         layers = self.pkt_type.split('_')
-- 
2.7.4


  reply	other threads:[~2019-10-15  5:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 21:49 [dts] [PATCH V2 1/3][nsh] dep: add support of mpls and nsh lihong
2019-10-14 21:49 ` lihong [this message]
2019-11-04  5:33   ` [dts] [PATCH V2 2/3][nsh] framework/packet: add support of nsh and mpls Chen, Zhaoyan
2019-11-22  5:38   ` Tu, Lijuan
2019-10-14 21:49 ` [dts] [PATCH V2 3/3][nsh] tests/uni_pkt: update code lihong
2019-10-16  1:59   ` Ma, LihongX
2019-11-04  5:34     ` Chen, Zhaoyan
2019-11-04  5:33 ` [dts] [PATCH V2 1/3][nsh] dep: add support of mpls and nsh Chen, Zhaoyan

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=1571089742-7077-2-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).