test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1 1/3][nsh] framwork/packet: add support of mpls and nsh
@ 2019-10-11  0:25 lihong
  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
  0 siblings, 2 replies; 8+ messages in thread
From: lihong @ 2019-10-11  0:25 UTC (permalink / raw)
  To: dts; +Cc: lihong

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-14  5:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11  0:25 [dts] [PATCH V1 1/3][nsh] framwork/packet: add support of mpls and nsh lihong
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

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).