]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: HWSimController class with python3 compatible version
authorMasashi Honma <masashi.honma@gmail.com>
Thu, 31 Jan 2019 08:15:43 +0000 (17:15 +0900)
committerJouni Malinen <j@w1.fi>
Mon, 4 Feb 2019 10:26:33 +0000 (12:26 +0200)
Update class HWSimController and netlink helpers to not depend on
python2 implicit conversions.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
tests/hwsim/hwsim.py
tests/hwsim/netlink.py

index 9300922a854dba7a9ea13094bc0427e6c80b418f..bc1be8542491af6ea46b7174002385d803cfd936 100644 (file)
@@ -22,7 +22,7 @@ HWSIM_ATTR_USE_CHANCTX                = 15
 class HWSimController(object):
     def __init__(self):
         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,
                      use_p2p_device=False):
index eef79090ce10fa30afb3b1b276744afd80cd03a3..eba6102a493cd1fb8d0940b2fee6a81e9d8ecaec 100644 (file)
@@ -33,7 +33,7 @@ class Attr(object):
         hdr = struct.pack("HH", len(self._data) + 4, self._type)
         length = len(self._data)
         pad = ((length + 4 - 1) & ~3 ) - length
-        return hdr + self._data + '\0' * pad
+        return hdr + self._data + b'\x00' * pad
 
     def __repr__(self):
         return '<Attr type %d, data "%s">' % (self._type, repr(self._data))
@@ -71,7 +71,7 @@ class U8Attr(Attr):
 
 class FlagAttr(Attr):
     def __init__(self, attr_type):
-        Attr.__init__(self, attr_type, "")
+        Attr.__init__(self, attr_type, b"")
 
 class Nested(Attr):
     def __init__(self, attr_type, attrs):
@@ -113,10 +113,9 @@ class Message(object):
         self.pid = -1
         payload = payload or []
         if isinstance(payload, list):
-            contents = []
+            self.payload = bytes()
             for attr in payload:
-                contents.append(attr._dump())
-            self.payload = ''.join(contents)
+                self.payload += attr._dump()
         else:
             self.payload = payload