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 38015A04F0; Mon, 13 Jan 2020 08:38:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2DA4E1D61B; Mon, 13 Jan 2020 08:38:57 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id ECDD91D5EB for ; Mon, 13 Jan 2020 08:38:53 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jan 2020 23:38:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,428,1571727600"; d="scan'208";a="397082425" Received: from unknown (HELO dpdk-xinfengx-dut.sh.intel.com) ([10.67.117.16]) by orsmga005.jf.intel.com with ESMTP; 12 Jan 2020 23:38:52 -0800 From: xinfengx To: dts@dpdk.org Cc: xinfengx Date: Mon, 13 Jan 2020 06:18:29 +0800 Message-Id: <20200112221831.12192-4-xinfengx.zhao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200112221831.12192-1-xinfengx.zhao@intel.com> References: <20200112221831.12192-1-xinfengx.zhao@intel.com> Subject: [dts] [next][PATCH V1 3/5] dep: modify dts dep to support python3 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: xinfengx --- dep/Dot1BR.py | 1 - dep/QMP/qmp.py | 10 +++++----- dep/gtp.py | 4 +--- dep/gtp_v2.py | 2 -- dep/lldp.py | 13 +++++++------ dep/vxlan.py | 3 ++- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/dep/Dot1BR.py b/dep/Dot1BR.py index 114c19a..cc3c01f 100644 --- a/dep/Dot1BR.py +++ b/dep/Dot1BR.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ## This file is part of Scapy ## See http://www.secdev.org/projects/scapy for more informations ## Copyright (C) Philippe Biondi diff --git a/dep/QMP/qmp.py b/dep/QMP/qmp.py index 4ade3ce..9e6f4cf 100755 --- a/dep/QMP/qmp.py +++ b/dep/QMP/qmp.py @@ -50,7 +50,7 @@ class QEMUMonitorProtocol: def __negotiate_capabilities(self): greeting = self.__json_read() - if greeting is None or not greeting.has_key('QMP'): + if greeting is None or 'QMP' not in greeting: raise QMPConnectError # Greeting seems ok, negotiate capabilities resp = self.cmd('qmp_capabilities') @@ -109,7 +109,7 @@ class QEMUMonitorProtocol: """ try: self.__sock.sendall(json.dumps(qmp_cmd)) - except socket.error, err: + except socket.error as err: if err[0] == errno.EPIPE: return raise socket.error(err) @@ -135,7 +135,7 @@ class QEMUMonitorProtocol: if not ret: return else: - if ret.has_key('error'): + if 'error' in ret: raise Exception(ret['error']['desc']) return ret['return'] @@ -148,7 +148,7 @@ class QEMUMonitorProtocol: self.__sock.setblocking(0) try: self.__json_read() - except socket.error, err: + except socket.error as err: if err[0] == errno.EAGAIN: # No data available pass @@ -168,7 +168,7 @@ class QEMUMonitorProtocol: self.__sock.setblocking(0) try: self.__json_read() - except socket.error, err: + except socket.error as err: if err[0] == errno.EAGAIN: # No data available pass diff --git a/dep/gtp.py b/dep/gtp.py index 7d57789..76f5e8e 100644 --- a/dep/gtp.py +++ b/dep/gtp.py @@ -1,5 +1,3 @@ -#! /usr/bin/env python - # Copyright (C) 2018 Leonardo Monteiro # 2017 Alexis Sultan # 2017 Alessio Deiana @@ -11,7 +9,7 @@ # scapy.contrib.description = GPRS Tunneling Protocol (GTP) # scapy.contrib.status = loads -from __future__ import absolute_import + import struct diff --git a/dep/gtp_v2.py b/dep/gtp_v2.py index af94918..6cffd47 100644 --- a/dep/gtp_v2.py +++ b/dep/gtp_v2.py @@ -1,5 +1,3 @@ -#! /usr/bin/env python - # Copyright (C) 2017 Alessio Deiana # 2017 Alexis Sultan diff --git a/dep/lldp.py b/dep/lldp.py index d8fabe2..9792e05 100644 --- a/dep/lldp.py +++ b/dep/lldp.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ## This file is part of Scapy ## See http://www.secdev.org/projects/scapy for more informations ## Copyright (C) Philippe Biondi @@ -79,7 +78,7 @@ class LLDPGeneric(Packet): def post_build(self, p, pay): if self.length is None: l = len(p) - 2 - p = chr((self.type << 1) ^ (l >> 8)) + chr(l & 0xff) + p[2:] + p = chr((self.type << 1) ^ (l >> 8)) + chr(l & 0xff) + bytes.decode(p[2:], encoding='gbk') return p+pay @@ -212,13 +211,15 @@ class LLDPManagementAddress(LLDPGeneric): # TODO Remove redundant code. LLDPGeneric.post_build() if self.length is None: l = len(p) - 2 - p = chr((self.type << 1) ^ (l >> 8)) + chr(l & 0xff) + p[2:] + p = chr((self.type << 1) ^ (l >> 8)) + chr(l & 0xff) + p[2:].decode() if self.addrlen is None: addrlen = len(p) - 2 - 8 - len(self.oid) + 1 - p = p[:2] + struct.pack("B", addrlen) + p[3:] - - return p+pay + if isinstance(p, type('abc')): + p = p[:2]+ struct.pack("B", addrlen).decode() + p[3:] + else: + p = p[:2].decode() + struct.pack("B", addrlen).decode() + p[3:].decode() + return bytes(p, encoding="utf-8")+pay _LLDPDot1Subtype = {1: "Port VLAN Id"} diff --git a/dep/vxlan.py b/dep/vxlan.py index 0683b42..c2661d6 100644 --- a/dep/vxlan.py +++ b/dep/vxlan.py @@ -10,8 +10,9 @@ from scapy.layers.inet6 import IPv6 from scapy.layers.dns import DNS from scapy.layers.l2 import Ether -vxlanmagic = "0x8" +XLAN_PORT=4789 +VXLAN_PORT=4789 _GP_FLAGS = ["R", "R", "R", "A", "R", "R", "D", "R"] class VXLAN(Packet): -- 2.17.1