From: xinfengx <xinfengx.zhao@intel.com>
To: dts@dpdk.org
Cc: xinfengx <xinfengx.zhao@intel.com>
Subject: [dts] [next][PATCH V1 3/5] dep: modify dts dep to support python3
Date: Mon, 13 Jan 2020 06:18:29 +0800 [thread overview]
Message-ID: <20200112221831.12192-4-xinfengx.zhao@intel.com> (raw)
In-Reply-To: <20200112221831.12192-1-xinfengx.zhao@intel.com>
Signed-off-by: xinfengx <xinfengx.zhao@intel.com>
---
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 <phil@secdev.org>
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 <decastromonteiro@gmail.com>
# 2017 Alexis Sultan <alexis.sultan@sfr.com>
# 2017 Alessio Deiana <adeiana@gmail.com>
@@ -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 <adeiana@gmail.com>
# 2017 Alexis Sultan <alexis.sultan@sfr.com>
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 <phil@secdev.org>
@@ -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
next prev parent reply other threads:[~2020-01-13 7:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-12 22:18 [dts] [next][PATCH V1 0/5] dts: modify dts " xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 1/5] framework: modify dts framework " xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 2/5] tests: modify test suites " xinfengx
2020-01-12 22:18 ` xinfengx [this message]
2020-01-12 22:18 ` [dts] [next][PATCH V1 4/5] nics: modify dts nics " xinfengx
2020-01-12 22:18 ` [dts] [next][PATCH V1 5/5] tools: modify dts tools " xinfengx
2020-01-16 5:47 ` [dts] [next][PATCH V1 0/5] dts: modify dts " 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=20200112221831.12192-4-xinfengx.zhao@intel.com \
--to=xinfengx.zhao@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).