aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-12-01 20:37:40 (GMT)
committerJouni Malinen <j@w1.fi>2017-12-02 10:00:32 (GMT)
commit702384f77e53d9eba7aae44204a1ac81428fed1c (patch)
treeb199ac4d5746379e5cd68a5f042a5643a21a6c1a
parent963d3149abfcbab5b83f9023bc50321f777360d1 (diff)
downloadhostap-702384f77e53d9eba7aae44204a1ac81428fed1c.zip
hostap-702384f77e53d9eba7aae44204a1ac81428fed1c.tar.gz
hostap-702384f77e53d9eba7aae44204a1ac81428fed1c.tar.bz2
tests: nl80211.py: Fix attribute padding
The kernel started enforcing attribute lengths, and nl80211.py had been doing it all wrong - the padding must be present, but not part of the length. Fix it to do it the right way. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--tests/hwsim/nl80211.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/hwsim/nl80211.py b/tests/hwsim/nl80211.py
index 80870d9..9103816 100644
--- a/tests/hwsim/nl80211.py
+++ b/tests/hwsim/nl80211.py
@@ -320,24 +320,26 @@ nl80211_attr = {
}
def build_nl80211_attr(id, val):
- return 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:
+ attr += '\0' * (4 - (len(attr) % 4))
+ return attr
def build_nl80211_attr_u32(id, val):
return build_nl80211_attr(id, struct.pack("@I", val))
def build_nl80211_attr_u16(id, val):
- return build_nl80211_attr(id, struct.pack("@HH", val, 0))
+ return build_nl80211_attr(id, struct.pack("@H", val))
def build_nl80211_attr_u8(id, val):
- return build_nl80211_attr(id, struct.pack("@4B", val, 0, 0, 0))
+ return build_nl80211_attr(id, struct.pack("@B", val))
def build_nl80211_attr_flag(id):
return build_nl80211_attr(id, '')
def build_nl80211_attr_mac(id, val):
addr = struct.unpack('6B', binascii.unhexlify(val.replace(':','')))
- t = addr + (0, 0)
- aval = struct.pack('<6BBB', *t)
+ aval = struct.pack('<6B', *addr)
return build_nl80211_attr(id, aval)
def parse_nl80211_attrs(msg):