summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWAMOTO Toshihiro <iwamoto@valinux.co.jp>2015-07-03 11:27:09 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-07-03 11:38:00 +0900
commit57f9f8f27d21e4db5a0ef55009097786b783f5d4 (patch)
tree6e26974d3f5ce0e764025622840f54eb98037729
parented5b3edd27243d52b69693768e0865ff694ef836 (diff)
python3: Use {encode, decode}('ascii') for text packet data
Some packet data are ascii type. Use {encode,decode} to make python3's struct.pack happy. Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/dhcp.py5
-rw-r--r--ryu/topology/switches.py4
2 files changed, 5 insertions, 4 deletions
diff --git a/ryu/lib/packet/dhcp.py b/ryu/lib/packet/dhcp.py
index eed7a113..e82a6458 100644
--- a/ryu/lib/packet/dhcp.py
+++ b/ryu/lib/packet/dhcp.py
@@ -192,7 +192,8 @@ class dhcp(packet_base.PacketBase):
addrconv.ipv4.bin_to_text(ciaddr),
addrconv.ipv4.bin_to_text(yiaddr),
addrconv.ipv4.bin_to_text(siaddr),
- addrconv.ipv4.bin_to_text(giaddr), sname, boot_file),
+ addrconv.ipv4.bin_to_text(giaddr),
+ sname.decode('ascii'), boot_file),
None, buf[length:])
@classmethod
@@ -213,7 +214,7 @@ class dhcp(packet_base.PacketBase):
addrconv.ipv4.text_to_bin(self.siaddr),
addrconv.ipv4.text_to_bin(self.giaddr),
addrconv.mac.text_to_bin(self.chaddr),
- self.sname, self.boot_file, seri_opt)
+ self.sname.encode('ascii'), self.boot_file, seri_opt)
class options(stringify.StringifyMixin):
diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py
index cbb26594..ba956d15 100644
--- a/ryu/topology/switches.py
+++ b/ryu/topology/switches.py
@@ -374,8 +374,8 @@ class LLDPPacket(object):
tlv_chassis_id = lldp.ChassisID(
subtype=lldp.ChassisID.SUB_LOCALLY_ASSIGNED,
- chassis_id=LLDPPacket.CHASSIS_ID_FMT %
- dpid_to_str(dpid))
+ chassis_id=(LLDPPacket.CHASSIS_ID_FMT %
+ dpid_to_str(dpid)).encode('ascii'))
tlv_port_id = lldp.PortID(subtype=lldp.PortID.SUB_PORT_COMPONENT,
port_id=struct.pack(