From 2ebb9218b2429b627f257d9db6e8ec7fac52c0cf Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Wed, 19 Oct 2016 13:36:15 +0900 Subject: [PATCH] rest_router: Fix conversion of Packet Library to dict On Python3, rest_router fails to compare the type of protocols in the Packet Library instances, because the non-parsed packet data is not str type but bytes type. This patch fixes to compare the protocols instance type with packet_base.PacketBase and enable to convert the Packet Library instances to dict. Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/app/rest_router.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ryu/app/rest_router.py b/ryu/app/rest_router.py index 2098ffae..81a3be46 100644 --- a/ryu/app/rest_router.py +++ b/ryu/app/rest_router.py @@ -40,6 +40,7 @@ from ryu.lib.packet import ethernet from ryu.lib.packet import icmp from ryu.lib.packet import ipv4 from ryu.lib.packet import packet +from ryu.lib.packet import packet_base from ryu.lib.packet import tcp from ryu.lib.packet import udp from ryu.lib.packet import vlan @@ -569,7 +570,8 @@ class Router(dict): # TODO: Packet library convert to string # self.logger.debug('Packet in = %s', str(pkt), self.sw_id) header_list = dict((p.protocol_name, p) - for p in pkt.protocols if type(p) != str) + for p in pkt.protocols + if isinstance(p, packet_base.PacketBase)) if header_list: # Check vlan-tag vlan_id = VLANID_NONE