tests: nl80211 attr with python3 compatible version

Update nl80211 attribute building helpers to not depend on
python2 implicit conversions.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
Masashi Honma 2019-01-31 17:15:43 +09:00 committed by Jouni Malinen
parent e285418bed
commit a3e00682ab

View file

@ -322,7 +322,7 @@ nl80211_attr = {
def build_nl80211_attr(id, val): def build_nl80211_attr(id, val):
attr = struct.pack("@HH", 4 + len(val), nl80211_attr[id]) + val attr = struct.pack("@HH", 4 + len(val), nl80211_attr[id]) + val
if len(attr) % 4 != 0: if len(attr) % 4 != 0:
attr += '\0' * (4 - (len(attr) % 4)) attr += b'\x00' * (4 - (len(attr) % 4))
return attr return attr
def build_nl80211_attr_u32(id, val): def build_nl80211_attr_u32(id, val):
@ -335,7 +335,7 @@ def build_nl80211_attr_u8(id, val):
return build_nl80211_attr(id, struct.pack("@B", val)) return build_nl80211_attr(id, struct.pack("@B", val))
def build_nl80211_attr_flag(id): def build_nl80211_attr_flag(id):
return build_nl80211_attr(id, '') return build_nl80211_attr(id, b'')
def build_nl80211_attr_mac(id, val): def build_nl80211_attr_mac(id, val):
addr = struct.unpack('6B', binascii.unhexlify(val.replace(':',''))) addr = struct.unpack('6B', binascii.unhexlify(val.replace(':','')))