]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/hwsim/test_wnm.py
Remove unused wpa_sm_get_param() function
[thirdparty/hostap.git] / tests / hwsim / test_wnm.py
CommitLineData
6435799b
JM
1# WNM tests
2# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
3#
4# This software may be distributed under the terms of the BSD license.
5# See README for more details.
6
7import time
8import logging
9logger = logging.getLogger()
10
11import hostapd
12
13def test_wnm_bss_transition_mgmt(dev, apdev):
14 """WNM BSS Transition Management"""
15 params = { "ssid": "test-wnm",
16 "time_advertisement": "2",
17 "time_zone": "EST5",
18 "wnm_sleep_mode": "1",
19 "bss_transition": "1" }
20 hostapd.add_ap(apdev[0]['ifname'], params)
21
22 dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412")
23 dev[0].request("WNM_BSS_QUERY 0")
24
25def test_wnm_disassoc_imminent(dev, apdev):
26 """WNM Disassociation Imminent"""
27 params = { "ssid": "test-wnm",
28 "time_advertisement": "2",
29 "time_zone": "EST5",
30 "wnm_sleep_mode": "1",
31 "bss_transition": "1" }
32 hostapd.add_ap(apdev[0]['ifname'], params)
33 hapd = hostapd.Hostapd(apdev[0]['ifname'])
34
35 dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412")
36 addr = dev[0].p2p_interface_addr()
37 hapd.request("DISASSOC_IMMINENT " + addr + " 10")
38 ev = dev[0].wait_event(["WNM: Disassociation Imminent"])
39 if ev is None:
40 raise Exception("Timeout while waiting for disassociation imminent")
41 if "Disassociation Timer 10" not in ev:
42 raise Exception("Unexpected disassociation imminent contents")
43 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"])
44 if ev is None:
45 raise Exception("Timeout while waiting for re-connection scan")
46
47def test_wnm_ess_disassoc_imminent(dev, apdev):
48 """WNM ESS Disassociation Imminent"""
49 params = { "ssid": "test-wnm",
50 "time_advertisement": "2",
51 "time_zone": "EST5",
52 "wnm_sleep_mode": "1",
53 "bss_transition": "1" }
54 hostapd.add_ap(apdev[0]['ifname'], params)
55 hapd = hostapd.Hostapd(apdev[0]['ifname'])
56
57 dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412")
58 addr = dev[0].p2p_interface_addr()
59 hapd.request("ESS_DISASSOC " + addr + " 10 http://example.com/session-info")
60 ev = dev[0].wait_event(["ESS-DISASSOC-IMMINENT"])
61 if ev is None:
62 raise Exception("Timeout while waiting for ESS disassociation imminent")
63 if "0 1024 http://example.com/session-info" not in ev:
64 raise Exception("Unexpected ESS disassociation imminent message contents")
65 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"])
66 if ev is None:
67 raise Exception("Timeout while waiting for re-connection scan")
68
69def test_wnm_ess_disassoc_imminent_pmf(dev, apdev):
70 """WNM ESS Disassociation Imminent"""
71 params = hostapd.wpa2_params("test-wnm-rsn", "12345678")
72 params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
73 params["ieee80211w"] = "2";
74 params["bss_transition"] = "1"
75 hostapd.add_ap(apdev[0]['ifname'], params)
76 hapd = hostapd.Hostapd(apdev[0]['ifname'])
77
78 dev[0].connect("test-wnm-rsn", psk="12345678", ieee80211w="2",
79 key_mgmt="WPA-PSK-SHA256", proto="WPA2", scan_freq="2412")
80 addr = dev[0].p2p_interface_addr()
81 hapd.request("ESS_DISASSOC " + addr + " 10 http://example.com/session-info")
82 ev = dev[0].wait_event(["ESS-DISASSOC-IMMINENT"])
83 if ev is None:
84 raise Exception("Timeout while waiting for ESS disassociation imminent")
85 if "1 1024 http://example.com/session-info" not in ev:
86 raise Exception("Unexpected ESS disassociation imminent message contents")
87 ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"])
88 if ev is None:
89 raise Exception("Timeout while waiting for re-connection scan")
90
91def check_wnm_sleep_mode_enter_exit(hapd, dev):
92 addr = dev.p2p_interface_addr()
93 sta = hapd.get_sta(addr)
94 if "[WNM_SLEEP_MODE]" in sta['flags']:
95 raise Exception("Station unexpectedly in WNM-Sleep Mode")
96 logger.info("Going to WNM Sleep Mode")
97 dev.request("WNM_SLEEP enter")
98 time.sleep(0.5)
99 sta = hapd.get_sta(addr)
100 if "[WNM_SLEEP_MODE]" not in sta['flags']:
101 raise Exception("Station failed to enter WNM-Sleep Mode")
102 logger.info("Waking up from WNM Sleep Mode")
103 dev.request("WNM_SLEEP exit")
104 time.sleep(0.5)
105 sta = hapd.get_sta(addr)
106 if "[WNM_SLEEP_MODE]" in sta['flags']:
107 raise Exception("Station failed to exit WNM-Sleep Mode")
108
109def test_wnm_sleep_mode_open(dev, apdev):
110 """WNM Sleep Mode - open"""
111 params = { "ssid": "test-wnm",
112 "time_advertisement": "2",
113 "time_zone": "EST5",
114 "wnm_sleep_mode": "1",
115 "bss_transition": "1" }
116 hostapd.add_ap(apdev[0]['ifname'], params)
117 hapd = hostapd.Hostapd(apdev[0]['ifname'])
118
119 dev[0].connect("test-wnm", key_mgmt="NONE", scan_freq="2412")
120 check_wnm_sleep_mode_enter_exit(hapd, dev[0])
121
122def test_wnm_sleep_mode_rsn(dev, apdev):
123 """WNM Sleep Mode - RSN"""
124 params = hostapd.wpa2_params("test-wnm-rsn", "12345678")
125 params["time_advertisement"] = "2"
126 params["time_zone"] = "EST5"
127 params["wnm_sleep_mode"] = "1"
128 params["bss_transition"] = "1"
129 hostapd.add_ap(apdev[0]['ifname'], params)
130 hapd = hostapd.Hostapd(apdev[0]['ifname'])
131
132 dev[0].connect("test-wnm-rsn", psk="12345678", scan_freq="2412")
133 check_wnm_sleep_mode_enter_exit(hapd, dev[0])
134
135def test_wnm_sleep_mode_rsn_pmf(dev, apdev):
136 """WNM Sleep Mode - RSN with PMF"""
137 params = hostapd.wpa2_params("test-wnm-rsn", "12345678")
138 params["wpa_key_mgmt"] = "WPA-PSK-SHA256";
139 params["ieee80211w"] = "2";
140 params["time_advertisement"] = "2"
141 params["time_zone"] = "EST5"
142 params["wnm_sleep_mode"] = "1"
143 params["bss_transition"] = "1"
144 hostapd.add_ap(apdev[0]['ifname'], params)
145 hapd = hostapd.Hostapd(apdev[0]['ifname'])
146
147 dev[0].connect("test-wnm-rsn", psk="12345678", ieee80211w="2",
148 key_mgmt="WPA-PSK-SHA256", proto="WPA2", scan_freq="2412")
149 check_wnm_sleep_mode_enter_exit(hapd, dev[0])