From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4533A2EFC for ; Tue, 15 Oct 2019 07:14:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 14A1C1C22C; Tue, 15 Oct 2019 07:14:06 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id CDB871C209 for ; Tue, 15 Oct 2019 07:14:04 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2019 22:14:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,297,1566889200"; d="scan'208";a="198503007" Received: from dpdk-lihong-ub1604.sh.intel.com ([10.67.118.203]) by orsmga003.jf.intel.com with ESMTP; 14 Oct 2019 22:14:03 -0700 From: lihong To: dts@dpdk.org Cc: lihong Date: Tue, 15 Oct 2019 05:49:01 +0800 Message-Id: <1571089742-7077-2-git-send-email-lihongx.ma@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571089742-7077-1-git-send-email-lihongx.ma@intel.com> References: <1571089742-7077-1-git-send-email-lihongx.ma@intel.com> Subject: [dts] [PATCH V2 2/3][nsh] framework/packet: add support of nsh and mpls 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Signed-off-by: lihong --- 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