tests: HWSimController class with python3 compatible version
Update class HWSimController and netlink helpers to not depend on python2 implicit conversions. Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
parent
f94df3c0b0
commit
e285418bed
2 changed files with 5 additions and 6 deletions
|
@ -22,7 +22,7 @@ HWSIM_ATTR_USE_CHANCTX = 15
|
||||||
class HWSimController(object):
|
class HWSimController(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._conn = netlink.Connection(netlink.NETLINK_GENERIC)
|
self._conn = netlink.Connection(netlink.NETLINK_GENERIC)
|
||||||
self._fid = netlink.genl_controller.get_family_id('MAC80211_HWSIM')
|
self._fid = netlink.genl_controller.get_family_id(b'MAC80211_HWSIM')
|
||||||
|
|
||||||
def create_radio(self, n_channels=None, use_chanctx=False,
|
def create_radio(self, n_channels=None, use_chanctx=False,
|
||||||
use_p2p_device=False):
|
use_p2p_device=False):
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Attr(object):
|
||||||
hdr = struct.pack("HH", len(self._data) + 4, self._type)
|
hdr = struct.pack("HH", len(self._data) + 4, self._type)
|
||||||
length = len(self._data)
|
length = len(self._data)
|
||||||
pad = ((length + 4 - 1) & ~3 ) - length
|
pad = ((length + 4 - 1) & ~3 ) - length
|
||||||
return hdr + self._data + '\0' * pad
|
return hdr + self._data + b'\x00' * pad
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Attr type %d, data "%s">' % (self._type, repr(self._data))
|
return '<Attr type %d, data "%s">' % (self._type, repr(self._data))
|
||||||
|
@ -71,7 +71,7 @@ class U8Attr(Attr):
|
||||||
|
|
||||||
class FlagAttr(Attr):
|
class FlagAttr(Attr):
|
||||||
def __init__(self, attr_type):
|
def __init__(self, attr_type):
|
||||||
Attr.__init__(self, attr_type, "")
|
Attr.__init__(self, attr_type, b"")
|
||||||
|
|
||||||
class Nested(Attr):
|
class Nested(Attr):
|
||||||
def __init__(self, attr_type, attrs):
|
def __init__(self, attr_type, attrs):
|
||||||
|
@ -113,10 +113,9 @@ class Message(object):
|
||||||
self.pid = -1
|
self.pid = -1
|
||||||
payload = payload or []
|
payload = payload or []
|
||||||
if isinstance(payload, list):
|
if isinstance(payload, list):
|
||||||
contents = []
|
self.payload = bytes()
|
||||||
for attr in payload:
|
for attr in payload:
|
||||||
contents.append(attr._dump())
|
self.payload += attr._dump()
|
||||||
self.payload = ''.join(contents)
|
|
||||||
else:
|
else:
|
||||||
self.payload = payload
|
self.payload = payload
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue