]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_cfg80211.py
2 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
12 def nl80211_command(dev
, cmd
, attr
):
13 res
= dev
.request("VENDOR ffffffff {} {}".format(nl80211_cmd
[cmd
],
14 binascii
.hexlify(attr
)))
16 raise Exception("nl80211 command failed")
17 return binascii
.unhexlify(res
)
19 def test_cfg80211_disassociate(dev
, apdev
):
20 """cfg80211 disassociation command"""
21 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
22 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412")
23 ev
= hapd
.wait_event([ "AP-STA-CONNECTED" ], timeout
=5)
25 raise Exception("No connection event received from hostapd")
27 ifindex
= int(dev
[0].get_driver_status_field("ifindex"))
28 attrs
= build_nl80211_attr_u32('IFINDEX', ifindex
)
29 attrs
+= build_nl80211_attr_u16('REASON_CODE', 1)
30 attrs
+= build_nl80211_attr_mac('MAC', apdev
[0]['bssid'])
31 nl80211_command(dev
[0], 'DISASSOCIATE', attrs
)
33 ev
= hapd
.wait_event([ "AP-STA-DISCONNECTED" ], timeout
=5)
35 raise Exception("No disconnection event received from hostapd")