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>
This commit is contained in:
IWAMOTO Toshihiro 2015-07-03 11:27:09 +09:00 committed by FUJITA Tomonori
parent ed5b3edd27
commit 57f9f8f27d
2 changed files with 5 additions and 4 deletions

View File

@ -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):

View File

@ -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(