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 717C5A0352; Thu, 16 Jan 2020 09:58:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5D5EE1C1B2; Thu, 16 Jan 2020 09:58:32 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id BBF011C136 for ; Thu, 16 Jan 2020 09:58:30 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2020 00:58:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,325,1574150400"; d="scan'208";a="425435166" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 16 Jan 2020 00:58:29 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jan 2020 00:58:29 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 16 Jan 2020 00:58:29 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 16 Jan 2020 00:58:29 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.30]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.89]) with mapi id 14.03.0439.000; Thu, 16 Jan 2020 16:58:27 +0800 From: "Tu, Lijuan" To: "Xiao, QimaiX" , "dts@dpdk.org" CC: "Xiao, QimaiX" Thread-Topic: [dts] [PATCH V2]dep/lldp: fix lldp for python3 Thread-Index: AQHVzESyPODYJ2COGUuQjDJc1JBlqafs/arA Date: Thu, 16 Jan 2020 08:58:26 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BBAB922@SHSMSX101.ccr.corp.intel.com> References: <1579162128-439249-1-git-send-email-qimaix.xiao@intel.com> In-Reply-To: <1579162128-439249-1-git-send-email-qimaix.xiao@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V2]dep/lldp: fix lldp for 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" applied > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xiao Qimai > Sent: Thursday, January 16, 2020 4:09 PM > To: dts@dpdk.org > Cc: Xiao, QimaiX > Subject: [dts] [PATCH V2]dep/lldp: fix lldp for python3 >=20 > python3 will not allow concat str to bytes >=20 > Signed-off-by: Xiao Qimai > --- > dep/lldp.py | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) >=20 > diff --git a/dep/lldp.py b/dep/lldp.py > index 9792e05..faa3b4d 100644 > --- a/dep/lldp.py > +++ b/dep/lldp.py > @@ -1,3 +1,4 @@ > +#!/usr/bin/env python > ## This file is part of Scapy > ## See http://www.secdev.org/projects/scapy for more informations ## > Copyright (C) Philippe Biondi @@ -78,7 +79,7 @@ class > LLDPGeneric(Packet): > def post_build(self, p, pay): > if self.length is None: > l =3D len(p) - 2 > - p =3D chr((self.type << 1) ^ (l >> 8)) + chr(l & 0xff) + byt= es.decode(p[2:], > encoding=3D'gbk') > + p =3D chr((self.type << 1) ^ (l >> 8)).encode() + chr(l & > + 0xff).encode() + p[2:] >=20 > return p+pay >=20 > @@ -211,15 +212,13 @@ class LLDPManagementAddress(LLDPGeneric): > # TODO Remove redundant code. LLDPGeneric.post_build() > if self.length is None: > l =3D len(p) - 2 > - p =3D chr((self.type << 1) ^ (l >> 8)) + chr(l & 0xff) + p[2= :].decode() > + p =3D chr((self.type << 1) ^ (l >> 8)).encode() + chr(l & > + 0xff).encode() + p[2:] >=20 > if self.addrlen is None: > addrlen =3D len(p) - 2 - 8 - len(self.oid) + 1 > - if isinstance(p, type('abc')): > - p =3D p[:2]+ struct.pack("B", addrlen).decode() + p[3:] > - else: > - p =3D p[:2].decode() + struct.pack("B", addrlen).decode(= ) + > p[3:].decode() > - return bytes(p, encoding=3D"utf-8")+pay > + p =3D p[:2] + struct.pack("B", addrlen) + p[3:] > + > + return p+pay >=20 >=20 > _LLDPDot1Subtype =3D {1: "Port VLAN Id"} > -- > 2.17.1