commit de3427cac87b7a5a3beffa109f8686511776af46 parent 540c625379032a33c93a3c518625417511075afb Author: illiliti <illiliti@protonmail.com> Date: Mon, 23 Aug 2021 01:25:48 +0300 Merge tag '1.17' Release 1.17 Diffstat:
343 files changed, 3343 insertions(+), 5056 deletions(-)
diff --git a/AUTHORS b/AUTHORS @@ -30,3 +30,4 @@ Daniel Lin <ephemient@gmail.com> Sean Anderson <sean.anderson@seco.com> Joseph Benden <joe@benden.us> Michael Johnson <mjohnson459@gmail.com> +Matt Oberle <matt.r.oberle@gmail.com> diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +ver 1.17: + Fix issue with sending additional and vendor IEs. + Fix issue with IE ordering for 802.11-2020 support. + Fix issue with frequency update on channel switch events. + Fix issue with drivers and handling of IF_OPER_UP setting. + ver 1.16: Fix issue with writing provisioning files with a passphrase. Add support for Authenticator & Supplicant RSN Extension elements. diff --git a/Makefile.am b/Makefile.am @@ -315,7 +315,6 @@ monitor_iwmon_SOURCES = monitor/main.c linux/nl80211.h \ src/crypto.h src/crypto.c \ src/watchlist.h src/watchlist.c \ src/eapolutil.h src/eapolutil.c \ - src/handshake.h src/handshake.c \ src/nl80211cmd.h src/nl80211cmd.c \ src/p2putil.c src/p2putil.h \ src/anqputil.h src/anqputil.c @@ -523,6 +522,7 @@ unit_test_sae_SOURCES = unit/test-sae.c \ src/crypto.h src/crypto.c \ src/ie.h src/ie.c \ src/handshake.h src/handshake.c \ + src/erp.h src/erp.c \ src/util.h src/util.c \ src/mpdu.h src/mpdu.c unit_test_sae_LDADD = $(ell_ldadd) diff --git a/autotests/misc/certs/eap-user-tls.text b/autotests/misc/certs/eap-user-tls.text @@ -1,4 +0,0 @@ -# Phase 1 users -* TLS -# Phase 2 -"abc@example.com" MD5 "testpasswd" [2] diff --git a/autotests/misc/certs/eap-user-ttls-mschapv2.text b/autotests/misc/certs/eap-user-ttls-mschapv2.text @@ -1,4 +0,0 @@ -# Phase 1 users -* TTLS -# Phase 2 -"user" MSCHAPV2 "testpasswd" [2] diff --git a/autotests/misc/certs/eap-user-ttls.text b/autotests/misc/certs/eap-user-ttls.text @@ -1,4 +0,0 @@ -# Phase 1 users -* TTLS -# Phase 2 -"abc@example.com" MD5 "testpasswd" [2] diff --git a/autotests/misc/secrets/eap-user-mschapv2.text b/autotests/misc/secrets/eap-user-mschapv2.text @@ -1 +0,0 @@ -"domain\User" MSCHAPV2 "Password" diff --git a/autotests/misc/secrets/eap-user-peap-mschapv2.text b/autotests/misc/secrets/eap-user-peap-mschapv2.text @@ -1,4 +0,0 @@ -# Phase 1 users -* PEAP -# Phase 2 -"domain\User" MSCHAPV2 "Password" [2] diff --git a/autotests/misc/secrets/eap-user-peap-sim.text b/autotests/misc/secrets/eap-user-peap-sim.text @@ -1,4 +0,0 @@ -# Phase 1 users -* PEAP -# Phase 2 -"112345678@phonesim.org" SIM [2] diff --git a/autotests/misc/secrets/eap-user-peap-v0-mschapv2.text b/autotests/misc/secrets/eap-user-peap-v0-mschapv2.text @@ -1,4 +0,0 @@ -# Phase 1 users -* PEAP [ver=0] -# Phase 2 -"secure@identity.com" MSCHAPV2 "testpasswd" [2] diff --git a/autotests/misc/secrets/eap-user-peap-v0.text b/autotests/misc/secrets/eap-user-peap-v0.text @@ -1,4 +0,0 @@ -# Phase 1 users -* PEAP [ver=0] -# Phase 2 -"secure@identity.com" MD5 "testpasswd" [2] diff --git a/autotests/misc/secrets/eap-user-peap-v1.text b/autotests/misc/secrets/eap-user-peap-v1.text @@ -1,4 +0,0 @@ -# Phase 1 users -* PEAP [ver=1] -# Phase 2 -"secure@identity.com" MD5 "testpasswd" [2] diff --git a/autotests/misc/secrets/eap-user.text b/autotests/misc/secrets/eap-user.text @@ -0,0 +1,22 @@ +"112345678@phonesim.org" SIM +"012345678@phonesim.org" AKA +"612345678@phonesim.org" AKA' +"mschapv2@example.com" MSCHAPV2 "Password" +"pwd@example.com" PWD "Password" + +# Phase 1 users +"tls@example.com" TLS +"ttls@example.com" TTLS +"peap@example.com" PEAP +"peapv0@example.com" PEAP [ver=0] +"peapv1@example.com" PEAP [ver=1] + +# Phase 2 +"md5-phase2@example.com" MD5 "Password" [2] +"gtc-phase2@example.com" GTC "Password" [2] +"mschapv2-phase2@example.com" MSCHAPV2 "Password" [2] +"ttls-chap-phase2@example.com" TTLS-CHAP "Password" [2] +"ttls-mschap-phase2@example.com" TTLS-MSCHAP "Password" [2] +"ttls-mschapv2-phase2@example.com" TTLS-MSCHAPV2 "Password" [2] +"ttls-pap-phase2@example.com" TTLS-PAP "Password" [2] +"112345678@phonesim.org" SIM [2] diff --git a/autotests/testAP/connection_test.py b/autotests/testAP/connection_test.py @@ -15,7 +15,7 @@ class Test(unittest.TestCase): def client_connect(self, wd, dev): hostapd = HostapdCLI(config='psk-ccmp.conf') - ordered_network = dev.get_ordered_network('TestAP1', True) + ordered_network = dev.get_ordered_network('TestAP1') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testAP/hw.conf b/autotests/testAP/hw.conf @@ -1,7 +1,6 @@ [SETUP] num_radios=6 start_iwd=0 -hwsim_medium=no [HOSTAPD] rad0=psk-ccmp.conf diff --git a/autotests/testAPRoam/TestAPRoam.psk b/autotests/testAPRoam/TestAPRoam.psk @@ -0,0 +1,2 @@ +[Security] +Passphrase=secret123 diff --git a/autotests/testAPRoam/connection_test.py b/autotests/testAPRoam/connection_test.py @@ -6,56 +6,22 @@ import sys sys.path.append('../util') import iwd from iwd import IWD -from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI -from hwsim import Hwsim class Test(unittest.TestCase): def test_connection_success(self): - hwsim = Hwsim() - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), HostapdCLI(config='ssid2.conf'), HostapdCLI(config='ssid3.conf') ] - bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1'), - hwsim.get_radio('rad2') ] - - rule0 = hwsim.rules.create() - rule0.source = bss_radio[0].addresses[0] - rule0.bidirectional = True - - rule1 = hwsim.rules.create() - rule1.source = bss_radio[1].addresses[0] - rule1.bidirectional = True - - rule2 = hwsim.rules.create() - rule2.source = bss_radio[2].addresses[0] - rule2.bidirectional = True - - rule0.signal = -6000 - rule1.signal = -6900 - rule2.signal = -8000 wd = IWD() - psk_agent = PSKAgent("secret123") - wd.register_psk_agent(psk_agent) - devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('TestAPRoam') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -63,7 +29,7 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) - ordered_network.network_object.connect() + device.connect_bssid(bss_hostapd[0].bssid) condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) @@ -74,8 +40,7 @@ class Test(unittest.TestCase): self.assertFalse(bss_hostapd[1].list_sta()) bss_hostapd[0].send_bss_transition(device.address, - [(bss_radio[1].addresses[0], '8f0000005102060603000000'), - (bss_radio[2].addresses[0], '8f0000005103060603000000')]) + [(bss_hostapd[1].bssid, '8f0000005102060603000000')]) condition = 'obj.state == DeviceState.roaming' wd.wait_for_object_condition(device, condition) @@ -93,15 +58,9 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) - wd.unregister_psk_agent(psk_agent) - - rule0.remove() - rule1.remove() - rule2.remove() - @classmethod def setUpClass(cls): - pass + IWD.copy_to_storage('TestAPRoam.psk') @classmethod def tearDownClass(cls): diff --git a/autotests/testAddressRandomization/connection_test.py b/autotests/testAddressRandomization/connection_test.py @@ -45,14 +45,6 @@ class Test(unittest.TestCase): perm_addr = device.address - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - # 1. Test per-network deterministic MAC generation os.system('cat pernetwork.psk > /tmp/iwd/ssidCCMP.psk') new_addr = self.try_connection(wd) diff --git a/autotests/testAgent/agent_test.py b/autotests/testAgent/agent_test.py @@ -17,7 +17,7 @@ class Test(unittest.TestCase): def check_connection(self, wd, ssid): device = wd.list_devices(1)[0] - ordered_network = device.get_ordered_network(ssid, scan_if_needed=True) + ordered_network = device.get_ordered_network(ssid) ordered_network.network_object.connect() @@ -58,14 +58,13 @@ class Test(unittest.TestCase): def test_connection_with_other_agent(self): wd = IWD() - iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']).pid + iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']) # Let iwctl to start and register its agent. wd.wait(2) self.check_connection(wd, 'ssid2') - iwctl.terminate() - iwctl.communicate() + iwctl.kill() IWD.clear_storage() @@ -73,7 +72,7 @@ class Test(unittest.TestCase): wd = IWD() - iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']).pid + iwctl = ctx.start_process(['iwctl', '-P', 'secret_ssid2']) # Let iwctl to start and register its agent. wd.wait(2) @@ -84,8 +83,7 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) - iwctl.terminate() - iwctl.communicate() + iwctl.kill() IWD.clear_storage() diff --git a/autotests/testBSSBlacklist/all_blacklisted_test.py b/autotests/testBSSBlacklist/all_blacklisted_test.py @@ -1,97 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI -from hwsim import Hwsim - -class Test(unittest.TestCase): - - def test_connection_success(self): - hwsim = Hwsim() - - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf'), - HostapdCLI(config='ssid3.conf') ] - bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1'), - hwsim.get_radio('rad2') ] - - rule0 = hwsim.rules.create() - rule0.source = bss_radio[0].addresses[0] - rule0.bidirectional = True - rule0.signal = -2000 - - rule1 = hwsim.rules.create() - rule1.source = bss_radio[1].addresses[0] - rule1.bidirectional = True - rule1.signal = -8000 - - rule2 = hwsim.rules.create() - rule2.source = bss_radio[2].addresses[0] - rule2.bidirectional = True - rule2.signal = -9000 - - wd = IWD(True) - - psk_agent = PSKAgent(["secret123", 'secret123']) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - ordered_network = device.get_ordered_network("TestBlacklist", scan_if_needed=True) - - self.assertEqual(ordered_network.type, NetworkType.psk) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - # Have both APs drop all packets, both should get blacklisted - rule0.drop = True - rule1.drop = True - rule2.drop = True - - with self.assertRaises(iwd.FailedEx): - ordered_network.network_object.connect() - - rule0.drop = False - rule1.drop = False - rule2.drop = False - - # Wait for scanning (likely a quick-scan) to finish, otherwise we will - # may not have all BSS's in the list. - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - # This connect should work - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertIn(device.address, bss_hostapd[0].list_sta()) - - wd.unregister_psk_agent(psk_agent) - - rule0.remove() - rule1.remove() - rule2.remove() - - @classmethod - def setUpClass(cls): - pass - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testBSSBlacklist/bad_pass_test.py b/autotests/testBSSBlacklist/bad_pass_test.py @@ -1,90 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI -from hwsim import Hwsim - -class Test(unittest.TestCase): - - def test_connection_success(self): - hwsim = Hwsim() - - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf'), - HostapdCLI(config='ssid3.conf') ] - bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1'), - hwsim.get_radio('rad2') ] - - rule0 = hwsim.rules.create() - rule0.source = bss_radio[0].addresses[0] - rule0.bidirectional = True - rule0.signal = -2000 - - rule1 = hwsim.rules.create() - rule1.source = bss_radio[1].addresses[0] - rule1.bidirectional = True - rule1.signal = -7000 - - rule2 = hwsim.rules.create() - rule2.source = bss_radio[2].addresses[0] - rule2.bidirectional = True - rule2.signal = -8000 - - wd = IWD(True) - - psk_agent = PSKAgent("wrong_password") - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - ordered_network = device.get_ordered_network("TestBlacklist", scan_if_needed=True) - - self.assertEqual(ordered_network.type, NetworkType.psk) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - with self.assertRaises(iwd.FailedEx): - ordered_network.network_object.connect() - - wd.unregister_psk_agent(psk_agent) - - psk_agent = PSKAgent("secret123") - wd.register_psk_agent(psk_agent) - - ordered_network.network_object.connect() - - # We failed to connect bss_hostapd[0], but with a bad password. Verify - # that this did not trigger a blacklist and that we did reconnect - # successfully to bss_hostapd[0] - self.assertIn(device.address, bss_hostapd[0].list_sta()) - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - wd.unregister_psk_agent(psk_agent) - - rule0.remove() - rule1.remove() - rule2.remove() - - @classmethod - def setUpClass(cls): - pass - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testBSSBlacklist/connection_test.py b/autotests/testBSSBlacklist/connection_test.py @@ -8,6 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType +from iwd import IWD_CONFIG_DIR from hostapd import HostapdCLI from hwsim import Hwsim @@ -15,33 +16,166 @@ from hwsim import Hwsim import time class Test(unittest.TestCase): + def test_temp_blacklist(self): + rule0 = self.rule0 + rule1 = self.rule1 + rule2 = self.rule2 - def test_connection_success(self): - hwsim = Hwsim() - - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf'), - HostapdCLI(config='ssid3.conf') ] - bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1'), - hwsim.get_radio('rad2') ] - - rule0 = hwsim.rules.create() - rule0.source = bss_radio[0].addresses[0] - rule0.bidirectional = True - rule0.signal = -2000 - - rule1 = hwsim.rules.create() - rule1.source = bss_radio[1].addresses[0] - rule1.bidirectional = True + bss_hostapd = self.bss_hostapd + wd = self.wd + + rule0.signal = -8000 rule1.signal = -7000 + rule2.signal = -2000 + + psk_agent = PSKAgent("secret123") + wd.register_psk_agent(psk_agent) + + dev1, dev2 = wd.list_devices(2) + + ordered_network = dev1.get_ordered_network("TestBlacklist") + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + ordered_network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev1, condition) + + self.assertIn(dev1.address, bss_hostapd[2].list_sta()) + + # dev1 now connected, this should max out the first AP, causing the next + # connection to fail to this AP. + + ordered_network = dev2.get_ordered_network("TestBlacklist") + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + ordered_network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev2, condition) + + # We should have temporarily blacklisted the first BSS, and connected + # to this one. + self.assertIn(dev2.address, bss_hostapd[1].list_sta()) + + # Now check that the first BSS is still not blacklisted. We can + # disconnect dev1, opening up the AP for more connections + dev1.disconnect() + dev2.disconnect() + + ordered_network = dev2.get_ordered_network("TestBlacklist") + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + ordered_network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(dev2, condition) + + self.assertIn(dev2.address, bss_hostapd[2].list_sta()) + + wd.unregister_psk_agent(psk_agent) + + def test_all_blacklisted(self): + wd = self.wd + bss_hostapd = self.bss_hostapd + + rule0 = self.rule0 + rule1 = self.rule1 + rule2 = self.rule2 + + psk_agent = PSKAgent(["secret123", 'secret123']) + wd.register_psk_agent(psk_agent) + + devices = wd.list_devices(1) + device = devices[0] + + ordered_network = device.get_ordered_network("TestBlacklist") + + self.assertEqual(ordered_network.type, NetworkType.psk) - rule2 = hwsim.rules.create() - rule2.source = bss_radio[2].addresses[0] - rule2.bidirectional = True - rule2.signal = -8000 + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + # Have both APs drop all packets, both should get blacklisted + rule0.drop = True + rule1.drop = True + rule2.drop = True + + with self.assertRaises(iwd.FailedEx): + ordered_network.network_object.connect() + + rule0.drop = False + rule1.drop = False + rule2.drop = False - wd = IWD(True) + # Wait for scanning (likely a quick-scan) to finish, otherwise we will + # may not have all BSS's in the list. + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + # This connect should work + ordered_network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + self.assertIn(device.address, bss_hostapd[0].list_sta()) + + wd.unregister_psk_agent(psk_agent) + + def test_invalid_password(self): + wd = self.wd + bss_hostapd = self.bss_hostapd + + psk_agent = PSKAgent("wrong_password") + wd.register_psk_agent(psk_agent) + + devices = wd.list_devices(1) + device = devices[0] + + ordered_network = device.get_ordered_network("TestBlacklist") + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + with self.assertRaises(iwd.FailedEx): + ordered_network.network_object.connect() + + wd.unregister_psk_agent(psk_agent) + + psk_agent = PSKAgent("secret123") + wd.register_psk_agent(psk_agent) + + ordered_network.network_object.connect() + + # We failed to connect bss_hostapd[0], but with a bad password. Verify + # that this did not trigger a blacklist and that we did reconnect + # successfully to bss_hostapd[0] + self.assertIn(device.address, bss_hostapd[0].list_sta()) + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + wd.unregister_psk_agent(psk_agent) + + def test_connection_success(self): + wd = self.wd + bss_hostapd = self.bss_hostapd + rule0 = self.rule0 psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) @@ -51,7 +185,7 @@ class Test(unittest.TestCase): devices[1].disconnect() - ordered_network = device.get_ordered_network("TestBlacklist", scan_if_needed=True) + ordered_network = device.get_ordered_network("TestBlacklist") self.assertEqual(ordered_network.type, NetworkType.psk) @@ -81,10 +215,8 @@ class Test(unittest.TestCase): rule0.drop = False - # Next try autoconnecting to a network with a blacklisted BSS. Since an - # explicit disconnect call would disable autoconnect we reset - # hostapd which will disconnect IWD. - bss_hostapd[1].reload() + device.disconnect() + device.autoconnect = True condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) @@ -131,19 +263,49 @@ class Test(unittest.TestCase): self.assertIn(device.address, bss_hostapd[0].list_sta()) - wd.unregister_psk_agent(psk_agent) + self.wd.unregister_psk_agent(psk_agent) - rule0.remove() - rule1.remove() - rule2.remove() + def setUp(self): + self.wd = IWD(True) + + def tearDown(self): + IWD.clear_storage() + self.wd = None @classmethod def setUpClass(cls): - IWD.copy_to_storage('main.conf') + cls.hwsim = Hwsim() + + cls.bss_hostapd = [ HostapdCLI(config='ssid1.conf'), + HostapdCLI(config='ssid2.conf'), + HostapdCLI(config='ssid3.conf') ] + cls.bss_radio = [ cls.hwsim.get_radio('rad0'), + cls.hwsim.get_radio('rad1'), + cls.hwsim.get_radio('rad2') ] + + cls.rule0 = cls.hwsim.rules.create() + cls.rule0.source = cls.bss_radio[0].addresses[0] + cls.rule0.bidirectional = True + cls.rule0.signal = -2000 + cls.rule0.enabled = True + + cls.rule1 = cls.hwsim.rules.create() + cls.rule1.source = cls.bss_radio[1].addresses[0] + cls.rule1.bidirectional = True + cls.rule1.signal = -7000 + cls.rule1.enabled = True + + cls.rule2 = cls.hwsim.rules.create() + cls.rule2.source = cls.bss_radio[2].addresses[0] + cls.rule2.bidirectional = True + cls.rule2.signal = -8000 + cls.rule2.enabled = True @classmethod def tearDownClass(cls): IWD.clear_storage() + cls.hwsim.rules.remove_all() + if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testBSSBlacklist/hw.conf b/autotests/testBSSBlacklist/hw.conf @@ -1,6 +1,7 @@ [SETUP] num_radios=5 start_iwd=0 +hwsim_medium=yes [HOSTAPD] rad0=ssid1.conf diff --git a/autotests/testBSSBlacklist/ssid1.conf b/autotests/testBSSBlacklist/ssid1.conf @@ -9,3 +9,4 @@ wpa_passphrase=secret123 ctrl_interface=/var/run/hostapd rrm_neighbor_report=1 +beacon_int=10 diff --git a/autotests/testBSSBlacklist/ssid2.conf b/autotests/testBSSBlacklist/ssid2.conf @@ -9,3 +9,4 @@ wpa_passphrase=secret123 ctrl_interface=/var/run/hostapd rrm_neighbor_report=1 +beacon_int=10 diff --git a/autotests/testBSSBlacklist/ssid3.conf b/autotests/testBSSBlacklist/ssid3.conf @@ -9,4 +9,5 @@ wpa_passphrase=secret123 ctrl_interface=/var/run/hostapd rrm_neighbor_report=1 -max_num_sta=1 -\ No newline at end of file +max_num_sta=1 +beacon_int=10 diff --git a/autotests/testBSSBlacklist/temp_blacklist_test.py b/autotests/testBSSBlacklist/temp_blacklist_test.py @@ -1,132 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI -from hwsim import Hwsim - -class Test(unittest.TestCase): - - def test_connection_success(self): - hwsim = Hwsim() - - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf'), - HostapdCLI(config='ssid3.conf') ] - bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1'), - hwsim.get_radio('rad2') ] - - rule0 = hwsim.rules.create() - rule0.source = bss_radio[0].addresses[0] - rule0.bidirectional = True - rule0.signal = -8000 - - rule1 = hwsim.rules.create() - rule1.source = bss_radio[1].addresses[0] - rule1.bidirectional = True - rule1.signal = -7000 - - rule2 = hwsim.rules.create() - rule2.source = bss_radio[2].addresses[0] - rule2.bidirectional = True - rule2.signal = -2000 - - wd = IWD(True) - - psk_agent = PSKAgent("secret123") - wd.register_psk_agent(psk_agent) - - dev1, dev2 = wd.list_devices(2) - - ordered_network = dev1.get_ordered_network("TestBlacklist", scan_if_needed=True) - - self.assertEqual(ordered_network.type, NetworkType.psk) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(dev1, condition) - - self.assertIn(dev1.address, bss_hostapd[2].list_sta()) - - # dev1 now connected, this should max out the first AP, causing the next - # connection to fail to this AP. - - condition = 'not obj.scanning' - wd.wait_for_object_condition(dev2, condition) - - dev2.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(dev2, condition) - - ordered_network = dev2.get_ordered_network("TestBlacklist") - - self.assertEqual(ordered_network.type, NetworkType.psk) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(dev2, condition) - - # We should have temporarily blacklisted the first BSS, and connected - # to this one. - self.assertIn(dev2.address, bss_hostapd[1].list_sta()) - - # Now check that the first BSS is still not blacklisted. We can - # disconnect dev1, opening up the AP for more connections - dev1.disconnect() - dev2.disconnect() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(dev2, condition) - - dev2.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(dev2, condition) - - ordered_network = dev2.get_ordered_network("TestBlacklist") - - self.assertEqual(ordered_network.type, NetworkType.psk) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(dev2, condition) - - self.assertIn(dev2.address, bss_hostapd[2].list_sta()) - - wd.unregister_psk_agent(psk_agent) - - rule0.remove() - rule1.remove() - rule2.remove() - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('main.conf') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testClientNonInteractive/connect_command_test.py b/autotests/testClientNonInteractive/connect_command_test.py @@ -98,6 +98,9 @@ class Test(unittest.TestCase): device.scan() + condition = 'obj.scanning' + cls.wd.wait_for_object_condition(device, condition) + condition = 'not obj.scanning' cls.wd.wait_for_object_condition(device, condition) diff --git a/autotests/testConnectAutoconnect/ssidEAP-Other.conf b/autotests/testConnectAutoconnect/ssidEAP-Other.conf @@ -6,7 +6,7 @@ wpa=3 wpa_key_mgmt=WPA-EAP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-ttls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testConnectAutoconnect/ssidEAP-TLS.8021x b/autotests/testConnectAutoconnect/ssidEAP-TLS.8021x @@ -3,4 +3,4 @@ EAP-Method=TLS EAP-TLS-CACert=/tmp/certs/cert-ca.pem EAP-TLS-ClientCert=/tmp/certs/cert-client.pem EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-Identity=abc@example.com +EAP-Identity=tls@example.com diff --git a/autotests/testConnectAutoconnect/ssidEAP-TLS.conf b/autotests/testConnectAutoconnect/ssidEAP-TLS.conf @@ -6,7 +6,7 @@ wpa=3 wpa_key_mgmt=WPA-EAP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testConnectAutoconnect/validation.py b/autotests/testConnectAutoconnect/validation.py @@ -28,6 +28,8 @@ class TestConnectAutoConnect(unittest.TestCase): wd.wait_for_object_condition(device, condition) def check_autoconnect(self, wd, device, ssid, throws): + device.autoconnect = True + if throws is None: condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) diff --git a/autotests/testDisconnectOnConnect/connection_test.py b/autotests/testDisconnectOnConnect/connection_test.py @@ -20,14 +20,6 @@ class Test(unittest.TestCase): device = wd.list_devices(1)[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - wpa_net = device.get_ordered_network('ssidTKIP') self.assertEqual(wpa_net.type, NetworkType.psk) diff --git a/autotests/testEAD/connection_test.py b/autotests/testEAD/connection_test.py @@ -22,10 +22,10 @@ class Test(unittest.TestCase): adapter = ead.list_adapters(1)[0] condition = 'obj.connected == True' - ead.wait_for_object_condition(adapter, condition) + IWD._wait_for_object_condition(adapter, condition) condition = 'obj.authenticated == True' - ead.wait_for_object_condition(adapter, condition) + IWD._wait_for_object_condition(adapter, condition) ctx.stop_process(p) @classmethod diff --git a/autotests/testEAD/default.8021x b/autotests/testEAD/default.8021x @@ -1,6 +1,6 @@ [Security] EAP-Method=MSCHAPV2 -EAP-Identity=domain\\User +EAP-Identity=mschapv2@example.com EAP-Password=Password [Settings] diff --git a/autotests/testEAD/wired.conf b/autotests/testEAD/wired.conf @@ -13,5 +13,5 @@ nas_identifier=ap.example.com radius_server_clients=/tmp/certs/radius-clients.text radius_server_auth_port=1812 -eap_user_file=/tmp/secrets/eap-user-mschapv2.text +eap_user_file=/tmp/secrets/eap-user.text eap_server=1 diff --git a/autotests/testEAP-AKA-ofono/connection_test.py b/autotests/testEAP-AKA-ofono/connection_test.py @@ -1,67 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType -from hlrauc import AuthCenter -from ofono import Ofono -from config import ctx - -class Test(unittest.TestCase): - def test_connection_success(self): - ofono = Ofono() - ofono.enable_modem('/phonesim') - ofono.wait_for_sim_auth() - - wd = IWD() - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-AKA') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - @classmethod - def setUpClass(cls): - if not ctx.is_process_running('ofonod'): - cls.skipTest(cls, "ofono not running") - - IWD.copy_to_storage('ssidEAP-AKA.8021x') - - cls.auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - - cls.auth.stop() - cls.auth = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-AKA-ofono/hw.conf b/autotests/testEAP-AKA-ofono/hw.conf @@ -1,6 +0,0 @@ -[SETUP] -num_radios=2 -sim_keys=ofono - -[HOSTAPD] -rad0=ssidEAP-AKA.conf diff --git a/autotests/testEAP-AKA-ofono/sim.eap_user b/autotests/testEAP-AKA-ofono/sim.eap_user @@ -1 +0,0 @@ -"012345678@phonesim.org" AKA diff --git a/autotests/testEAP-AKA-ofono/ssidEAP-AKA.8021x b/autotests/testEAP-AKA-ofono/ssidEAP-AKA.8021x @@ -1,5 +0,0 @@ -[Security] -EAP-Method=AKA - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-AKA-ofono/ssidEAP-AKA.conf b/autotests/testEAP-AKA-ofono/ssidEAP-AKA.conf @@ -1,16 +0,0 @@ -hw_mode=g -channel=1 - -driver=nl80211 -ieee8021x=1 -eap_server=1 -ssid=ssidEAP-AKA -eap_user_file=/tmp/sim.eap_user -eap_sim_db=unix:/tmp/hlrauc.sock -wpa=2 -wpa_key_mgmt=WPA-EAP -wpa_pairwise=TKIP CCMP -rsn_pairwise=CCMP TKIP -wpa_passphrase=secret123 -channel=1 -eap_sim_aka_result_ind=1 diff --git a/autotests/testEAP-AKA-prime-ofono/connection_test.py b/autotests/testEAP-AKA-prime-ofono/connection_test.py @@ -1,66 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType -from hlrauc import AuthCenter -from ofono import Ofono -from config import ctx - -class Test(unittest.TestCase): - def test_connection_success(self): - ofono = Ofono() - ofono.enable_modem('/phonesim') - ofono.wait_for_sim_auth() - - wd = IWD() - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-AKA') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - @classmethod - def setUpClass(cls): - if not ctx.is_process_running('ofonod'): - cls.skipTest(cls, "ofono not running") - - IWD.copy_to_storage('ssidEAP-AKA.8021x') - - cls.auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - cls.auth.stop() - cls.auth = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-AKA-prime-ofono/hw.conf b/autotests/testEAP-AKA-prime-ofono/hw.conf @@ -1,6 +0,0 @@ -[SETUP] -num_radios=2 -sim_keys=ofono - -[HOSTAPD] -rad0=ssidEAP-AKA.conf diff --git a/autotests/testEAP-AKA-prime-ofono/sim.db b/autotests/testEAP-AKA-prime-ofono/sim.db @@ -1,3 +0,0 @@ -# IMSI K OPC AMF SQN - -12345678:90dca4eda45b53cf0f12d7c9c3bc6a89:cb9cccc4b9258e6dca4760379fb82581:61df:000000000021 -\ No newline at end of file diff --git a/autotests/testEAP-AKA-prime-ofono/sim.eap_user b/autotests/testEAP-AKA-prime-ofono/sim.eap_user @@ -1 +0,0 @@ -"612345678@phonesim.org" AKA' -\ No newline at end of file diff --git a/autotests/testEAP-AKA-prime-ofono/ssidEAP-AKA.conf b/autotests/testEAP-AKA-prime-ofono/ssidEAP-AKA.conf @@ -1,16 +0,0 @@ -hw_mode=g -channel=1 - -driver=nl80211 -ieee8021x=1 -eap_server=1 -ssid=ssidEAP-AKA -eap_user_file=/tmp/sim.eap_user -eap_sim_db=unix:/tmp/hlrauc.sock -wpa=2 -wpa_key_mgmt=WPA-EAP -wpa_pairwise=TKIP CCMP -rsn_pairwise=CCMP TKIP -wpa_passphrase=secret123 -channel=1 -eap_sim_aka_result_ind=1 diff --git a/autotests/testEAP-MSCHAPV2/connection_test.py b/autotests/testEAP-MSCHAPV2/connection_test.py @@ -1,75 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType - -class Test(unittest.TestCase): - - def run_connection_test(self, ssid, *secrets): - wd = IWD() - - psk_agent = iwd.PSKAgent(*secrets) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - if not device.get_ordered_networks(): - device.scan() - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network(ssid) - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - wd.unregister_psk_agent(psk_agent) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - def test_agent_none(self): - self.run_connection_test('ssidEAP-MSCHAPV2-1') - - def test_agent_none_hash(self): - self.run_connection_test('ssidEAP-MSCHAPV2-2') - - def test_agent_passwd(self): - self.run_connection_test('ssidEAP-MSCHAPV2-3', [], ('domain\\User', 'Password')) - - def test_agent_username_and_passwd(self): - self.run_connection_test('ssidEAP-MSCHAPV2-4', [], ('domain\\User', 'Password')) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-MSCHAPV2-1.8021x') - IWD.copy_to_storage('ssidEAP-MSCHAPV2-2.8021x') - IWD.copy_to_storage('ssidEAP-MSCHAPV2-3.8021x') - IWD.copy_to_storage('ssidEAP-MSCHAPV2-4.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-MSCHAPV2/hw.conf b/autotests/testEAP-MSCHAPV2/hw.conf @@ -1,5 +0,0 @@ -[SETUP] -num_radios=2 - -[HOSTAPD] -rad0=ssidEAP-MSCHAPV2.conf diff --git a/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2-1.8021x b/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2-1.8021x @@ -1,7 +0,0 @@ -[Security] -EAP-Method=MSCHAPV2 -EAP-Identity=domain\\User -EAP-Password=Password - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2-2.8021x b/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2-2.8021x @@ -1,7 +0,0 @@ -[Security] -EAP-Method=MSCHAPV2 -EAP-Identity=domain\\User -EAP-Password-Hash=a4f49c406510bdcab6824ee7c30fd852 - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2-3.8021x b/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2-3.8021x @@ -1,6 +0,0 @@ -[Security] -EAP-Method=MSCHAPV2 -EAP-Identity=domain\\User - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2.conf b/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2.conf @@ -1,33 +0,0 @@ -ssid=ssidEAP-MSCHAPV2-1 -interface=wln0 -hw_mode=g -channel=1 -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-mschapv2.text - -bss=wln0_1 -ssid=ssidEAP-MSCHAPV2-2 -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-mschapv2.text - -bss=wln0_2 -ssid=ssidEAP-MSCHAPV2-3 -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-mschapv2.text - -bss=wln0_3 -ssid=ssidEAP-MSCHAPV2-4 -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-mschapv2.text diff --git a/autotests/testEAP-PEAP-GTC/eap-user-peap-gtc.text b/autotests/testEAP-PEAP-GTC/eap-user-peap-gtc.text @@ -1,4 +0,0 @@ -# Phase 1 users -* PEAP [ver=1] -# Phase 2 -"secure@identity.com" GTC "testpasswd" [2] diff --git a/autotests/testEAP-PEAP-GTC/hw.conf b/autotests/testEAP-PEAP-GTC/hw.conf @@ -1,7 +0,0 @@ -[SETUP] -num_radios=3 -start_iwd=0 - -[HOSTAPD] -rad0=ssidEAP-PEAPv1-GTC.conf -rad1=ssidEAP-PEAPv1-GTC-nosecret.conf diff --git a/autotests/testEAP-PEAP-GTC/peap_gtc_nosecret_test.py b/autotests/testEAP-PEAP-GTC/peap_gtc_nosecret_test.py @@ -1,67 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import time - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType -from iwd import PSKAgent - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - devices = wd.list_devices(1) - - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PEAPv1-GTC-nosecret') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - def test_connection_success(self): - wd = IWD(True) - - psk_agent = PSKAgent('secure@identity.com', - ('secure@identity.com', 'testpasswd')) - wd.register_psk_agent(psk_agent) - - try: - self.validate_connection(wd) - finally: - wd.unregister_psk_agent(psk_agent) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PEAPv1-GTC-nosecret.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PEAP-GTC/peap_gtc_test.py b/autotests/testEAP-PEAP-GTC/peap_gtc_test.py @@ -1,59 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import time - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - devices = wd.list_devices(1) - - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PEAPv1-GTC') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PEAPv1-GTC.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC-nosecret.8021x b/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC-nosecret.8021x @@ -1,11 +0,0 @@ -[Security] -EAP-Method=PEAP -EAP-Identity=open@identity.com -EAP-PEAP-CACert=/tmp/certs/cert-ca.pem -EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem -EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-PEAP-Phase2-Method=GTC -EAP-PEAP-Phase2-Identity=secure@identity.com - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC-nosecret.conf b/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC-nosecret.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-PEAPv1-GTC-nosecret - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/eap-user-peap-gtc.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC.8021x b/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=PEAP -EAP-Identity=open@identity.com -EAP-PEAP-CACert=/tmp/certs/cert-ca.pem -EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem -EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-PEAP-Phase2-Method=GTC -EAP-PEAP-Phase2-Identity=secure@identity.com -EAP-PEAP-Phase2-Password=testpasswd - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC.conf b/autotests/testEAP-PEAP-GTC/ssidEAP-PEAPv1-GTC.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-PEAPv1-GTC - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/eap-user-peap-gtc.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PEAP-MSCHAPv2/connection_test.py b/autotests/testEAP-PEAP-MSCHAPv2/connection_test.py @@ -1,60 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import time - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType -from hlrauc import AuthCenter - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - devices = wd.list_devices(1) - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PEAP-MSCHAPv2') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PEAP-MSCHAPv2.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PEAP-MSCHAPv2/hw.conf b/autotests/testEAP-PEAP-MSCHAPv2/hw.conf @@ -1,6 +0,0 @@ -[SETUP] -num_radios=2 -start_iwd=0 - -[HOSTAPD] -rad0=ssidEAP-PEAP-MSCHAPv2.conf diff --git a/autotests/testEAP-PEAP-MSCHAPv2/ssidEAP-PEAP-MSCHAPv2.8021x b/autotests/testEAP-PEAP-MSCHAPv2/ssidEAP-PEAP-MSCHAPv2.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=PEAP -EAP-Identity=open@identity.com -EAP-PEAP-CACert=/tmp/certs/cert-ca.pem -EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem -EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-PEAP-Phase2-Method=MSCHAPV2 -EAP-PEAP-Phase2-Identity=domain\\User -EAP-PEAP-Phase2-Password=Password - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PEAP-MSCHAPv2/ssidEAP-PEAP-MSCHAPv2.conf b/autotests/testEAP-PEAP-MSCHAPv2/ssidEAP-PEAP-MSCHAPv2.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-PEAP-MSCHAPv2 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-peap-mschapv2.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PEAP-SIM/connection_test.py b/autotests/testEAP-PEAP-SIM/connection_test.py @@ -1,69 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import time - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType -from hlrauc import AuthCenter -from ofono import Ofono - -class Test(unittest.TestCase): - def validate_connection(self, wd): - devices = wd.list_devices(1) - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PEAP-SIM') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - - def test_connection_success(self): - ofono = Ofono() - ofono.enable_modem('/phonesim') - ofono.wait_for_sim_auth() - - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - cls.auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db') - - IWD.copy_to_storage('ssidEAP-PEAP-SIM.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - - cls.auth.stop() - cls.auth = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PEAP-SIM/hw.conf b/autotests/testEAP-PEAP-SIM/hw.conf @@ -1,7 +0,0 @@ -[SETUP] -num_radios=2 -start_iwd=0 -sim_keys=ofono - -[HOSTAPD] -rad0=ssidEAP-PEAP-SIM.conf diff --git a/autotests/testEAP-PEAP-SIM/sim.eap_user b/autotests/testEAP-PEAP-SIM/sim.eap_user @@ -1 +0,0 @@ -"112345678@phonesim.org" SIM diff --git a/autotests/testEAP-PEAP-SIM/ssidEAP-PEAP-SIM.8021x b/autotests/testEAP-PEAP-SIM/ssidEAP-PEAP-SIM.8021x @@ -1,10 +0,0 @@ -[Security] -EAP-Method=PEAP -EAP-Identity=open@example.com -EAP-PEAP-CACert=/tmp/certs/cert-ca.pem -EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem -EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-PEAP-Phase2-Method=SIM - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PEAP-SIM/ssidEAP-PEAP-SIM.conf b/autotests/testEAP-PEAP-SIM/ssidEAP-PEAP-SIM.conf @@ -1,15 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-PEAP-SIM - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-peap-sim.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem - -eap_sim_db=unix:/tmp/hlrauc.sock -eap_sim_aka_result_ind=1 diff --git a/autotests/testEAP-PEAP/IWD-Frag/main.conf b/autotests/testEAP-PEAP/IWD-Frag/main.conf @@ -1,2 +0,0 @@ -[EAP] -MTU=100 diff --git a/autotests/testEAP-PEAP/hw.conf b/autotests/testEAP-PEAP/hw.conf @@ -1,8 +0,0 @@ -[SETUP] -num_radios=4 -start_iwd=0 - -[HOSTAPD] -rad0=ssidEAP-PEAPv1.conf -rad1=ssidEAP-PEAPv0.conf -rad2=ssidEAP-PEAP-frag.conf diff --git a/autotests/testEAP-PEAP/peap_frag_test.py b/autotests/testEAP-PEAP/peap_frag_test.py @@ -1,58 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import time - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - devices = wd.list_devices(1) - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PEAP-frag') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - def test_connection_success(self): - wd = IWD(True, '/tmp/IWD-Frag') - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PEAP-frag.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PEAP/peap_v0_test.py b/autotests/testEAP-PEAP/peap_v0_test.py @@ -1,58 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import time - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - devices = wd.list_devices(1) - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PEAPv0') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PEAPv0.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PEAP/peap_v1_test.py b/autotests/testEAP-PEAP/peap_v1_test.py @@ -1,58 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import time - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - devices = wd.list_devices(1) - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PEAPv1') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PEAPv1.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PEAP/ssidEAP-PEAP-frag.8021x b/autotests/testEAP-PEAP/ssidEAP-PEAP-frag.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=PEAP -EAP-Identity=open@identity.com -EAP-PEAP-CACert=/tmp/certs/cert-ca.pem -EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem -EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-PEAP-Phase2-Method=MD5 -EAP-PEAP-Phase2-Identity=secure@identity.com -EAP-PEAP-Phase2-Password=testpasswd - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PEAP/ssidEAP-PEAP-frag.conf b/autotests/testEAP-PEAP/ssidEAP-PEAP-frag.conf @@ -1,14 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-PEAP-frag - -fragment_size=256 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-peap-v1.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PEAP/ssidEAP-PEAPv0.8021x b/autotests/testEAP-PEAP/ssidEAP-PEAPv0.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=PEAP -EAP-Identity=open@identity.com -EAP-PEAP-CACert=/tmp/certs/cert-ca.pem -EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem -EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-PEAP-Phase2-Method=MD5 -EAP-PEAP-Phase2-Identity=secure@identity.com -EAP-PEAP-Phase2-Password=testpasswd - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PEAP/ssidEAP-PEAPv0.conf b/autotests/testEAP-PEAP/ssidEAP-PEAPv0.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-PEAPv0 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-peap-v0.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PEAP/ssidEAP-PEAPv1.8021x b/autotests/testEAP-PEAP/ssidEAP-PEAPv1.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=PEAP -EAP-Identity=open@identity.com -EAP-PEAP-CACert=/tmp/certs/cert-ca.pem -EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem -EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-PEAP-Phase2-Method=MD5 -EAP-PEAP-Phase2-Identity=secure@identity.com -EAP-PEAP-Phase2-Password=testpasswd - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PEAP/ssidEAP-PEAPv1.conf b/autotests/testEAP-PEAP/ssidEAP-PEAPv1.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-PEAPv1 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/secrets/eap-user-peap-v1.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py b/autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py @@ -19,14 +19,6 @@ class Test(unittest.TestCase): self.assertIsNotNone(devices) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidEAP-PEAPv0-ISK') self.assertEqual(ordered_network.type, NetworkType.eap) diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py b/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py @@ -23,14 +23,6 @@ class Test(unittest.TestCase): self.assertIsNotNone(devices) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidEAP-PEAPv0-NoISK') self.assertEqual(ordered_network.type, NetworkType.eap) diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-ISK.8021x b/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-ISK.8021x @@ -1,12 +1,12 @@ [Security] EAP-Method=PEAP -EAP-Identity=open@identity.com +EAP-Identity=peapv0@example.com EAP-PEAP-CACert=/tmp/certs/cert-ca.pem EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem EAP-PEAP-Phase2-Method=MSCHAPV2 -EAP-PEAP-Phase2-Identity=secure@identity.com -EAP-PEAP-Phase2-Password=testpasswd +EAP-PEAP-Phase2-Identity=mschapv2-phase2@example.com +EAP-PEAP-Phase2-Password=Password [Settings] AutoConnect=false diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-ISK.conf b/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-ISK.conf @@ -6,7 +6,7 @@ wpa=3 wpa_key_mgmt=WPA-EAP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/secrets/eap-user-peap-v0-mschapv2.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-NoISK.8021x b/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-NoISK.8021x @@ -1,12 +1,12 @@ [Security] EAP-Method=PEAP -EAP-Identity=open@identity.com +EAP-Identity=peapv0@example.com EAP-PEAP-CACert=/tmp/certs/cert-ca.pem EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem EAP-PEAP-Phase2-Method=MD5 -EAP-PEAP-Phase2-Identity=secure@identity.com -EAP-PEAP-Phase2-Password=testpasswd +EAP-PEAP-Phase2-Identity=md5-phase2@example.com +EAP-PEAP-Phase2-Password=Password [Settings] AutoConnect=false diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-NoISK.conf b/autotests/testEAP-PEAPv0-CryptoBinding/ssidEAP-PEAPv0-NoISK.conf @@ -6,7 +6,7 @@ wpa=3 wpa_key_mgmt=WPA-EAP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/secrets/eap-user-peap-v0.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-PWD/IWD-Frag/main.conf b/autotests/testEAP-PWD/IWD-Frag/main.conf @@ -1,2 +0,0 @@ -[EAP] -MTU=40 diff --git a/autotests/testEAP-PWD/connection_test.py b/autotests/testEAP-PWD/connection_test.py @@ -1,78 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - hostapd = HostapdCLI(config='ssidEAP-PWD.conf') - - self.assertIsNotNone(hostapd) - - psk_agent = PSKAgent('eap-pwd-identity', ('eap-pwd-identity', - 'secret123')) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PWD') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - hostapd.eapol_reauth(device.address) - - hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED') - hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS') - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PWD.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PWD/frag_test.py b/autotests/testEAP-PWD/frag_test.py @@ -1,57 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - devices = wd.list_devices(1) - self.assertIsNotNone(devices) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-PWD-frag') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-PWD-frag.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-PWD/hw.conf b/autotests/testEAP-PWD/hw.conf @@ -1,7 +0,0 @@ -[SETUP] -num_radios=3 -start_iwd=0 - -[HOSTAPD] -rad0=ssidEAP-PWD.conf -rad1=ssidEAP-PWD-frag.conf diff --git a/autotests/testEAP-PWD/pwd.eap_user b/autotests/testEAP-PWD/pwd.eap_user @@ -1 +0,0 @@ -"eap-pwd-identity" PWD "secret123" diff --git a/autotests/testEAP-PWD/ssidEAP-PWD-frag.8021x b/autotests/testEAP-PWD/ssidEAP-PWD-frag.8021x @@ -1,7 +0,0 @@ -[Security] -EAP-Method=PWD -EAP-Identity=eap-pwd-identity -EAP-Password=secret123 - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PWD/ssidEAP-PWD-frag.conf b/autotests/testEAP-PWD/ssidEAP-PWD-frag.conf @@ -1,16 +0,0 @@ -hw_mode=g -channel=1 - -driver=nl80211 -ieee8021x=1 -eap_server=1 -ssid=ssidEAP-PWD-frag -eap_user_file=/tmp/pwd.eap_user -wpa=2 -wpa_key_mgmt=WPA-EAP -wpa_pairwise=TKIP CCMP -rsn_pairwise=CCMP TKIP -wpa_passphrase=secret123 -channel=1 -pwd_group=19 -fragment_size=80 diff --git a/autotests/testEAP-PWD/ssidEAP-PWD.8021x b/autotests/testEAP-PWD/ssidEAP-PWD.8021x @@ -1,6 +0,0 @@ -[Security] -EAP-Method=PWD -EAP-Identity=eap-pwd-identity - -[Settings] -AutoConnect=false diff --git a/autotests/testEAP-PWD/ssidEAP-PWD.conf b/autotests/testEAP-PWD/ssidEAP-PWD.conf @@ -1,15 +0,0 @@ -hw_mode=g -channel=1 - -driver=nl80211 -ieee8021x=1 -eap_server=1 -ssid=ssidEAP-PWD -eap_user_file=/tmp/pwd.eap_user -wpa=2 -wpa_key_mgmt=WPA-EAP -wpa_pairwise=TKIP CCMP -rsn_pairwise=CCMP TKIP -wpa_passphrase=secret123 - -pwd_group=20 diff --git a/autotests/testEAP-SIM-ofono/connection_test.py b/autotests/testEAP-SIM-ofono/connection_test.py @@ -1,68 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType -from hlrauc import AuthCenter -from ofono import Ofono -from config import ctx - -class Test(unittest.TestCase): - - def test_connection_success(self): - ofono = Ofono() - ofono.enable_modem('/phonesim') - ofono.wait_for_sim_auth() - - wd = IWD() - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-SIM') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - @classmethod - def setUpClass(cls): - if not ctx.is_process_running('ofonod'): - cls.skipTest(cls, "ofono not running") - - IWD.copy_to_storage('ssidEAP-SIM.8021x') - - cls.auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - - cls.auth.stop() - cls.auth = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-SIM-ofono/hw.conf b/autotests/testEAP-SIM-ofono/hw.conf @@ -1,6 +0,0 @@ -[SETUP] -num_radios=2 -sim_keys=ofono - -[HOSTAPD] -rad0=ssidEAP-SIM.conf diff --git a/autotests/testEAP-SIM-ofono/sim.db b/autotests/testEAP-SIM-ofono/sim.db @@ -1 +0,0 @@ -12345678:673fb8cd35f98800:1fb1e3b5:DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD -\ No newline at end of file diff --git a/autotests/testEAP-SIM-ofono/sim.eap_user b/autotests/testEAP-SIM-ofono/sim.eap_user @@ -1 +0,0 @@ -"112345678@phonesim.org" SIM -\ No newline at end of file diff --git a/autotests/testEAP-SIM-ofono/ssidEAP-SIM.conf b/autotests/testEAP-SIM-ofono/ssidEAP-SIM.conf @@ -1,16 +0,0 @@ -hw_mode=g -channel=1 - -driver=nl80211 -ieee8021x=1 -eap_server=1 -ssid=ssidEAP-SIM -eap_user_file=/tmp/sim.eap_user -eap_sim_db=unix:/tmp/hlrauc.sock -wpa=2 -wpa_key_mgmt=WPA-EAP -wpa_pairwise=TKIP CCMP -rsn_pairwise=CCMP TKIP -wpa_passphrase=secret123 -channel=1 -eap_sim_aka_result_ind=1 diff --git a/autotests/testEAP-TLS-Frag/connection_test.py b/autotests/testEAP-TLS-Frag/connection_test.py @@ -16,14 +16,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidEAP-TLS') self.assertEqual(ordered_network.type, NetworkType.eap) diff --git a/autotests/testEAP-TLS-Frag/ssidEAP-TLS.8021x b/autotests/testEAP-TLS-Frag/ssidEAP-TLS.8021x @@ -3,7 +3,7 @@ EAP-Method=TLS EAP-TLS-CACert=/tmp/certs/cert-ca.pem EAP-TLS-ClientCert=/tmp/certs/cert-client.pem EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-Identity=abc@example.com +EAP-Identity=tls@example.com [Settings] AutoConnect=False diff --git a/autotests/testEAP-TLS-Frag/ssidEAP-TLS.conf b/autotests/testEAP-TLS-Frag/ssidEAP-TLS.conf @@ -8,7 +8,7 @@ wpa=3 wpa_key_mgmt=WPA-EAP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TLS-embedded-pems/connection_test.py b/autotests/testEAP-TLS-embedded-pems/connection_test.py @@ -1,72 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -import testutil -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def do_test_connection_success(self, ssid, passphrase=None): - hostapd = HostapdCLI(config=ssid + '.conf') - wd = IWD() - - if passphrase: - psk_agent = PSKAgent(passphrase) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - if not device.get_ordered_networks(): - device.scan() - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network(ssid) - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected(hostapd.ifname, device.name) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - if passphrase: - wd.unregister_psk_agent(psk_agent) - - def test_eap_tls(self): - self.do_test_connection_success('ssidEAP-TLS') - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TLS.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TLS-embedded-pems/hw.conf b/autotests/testEAP-TLS-embedded-pems/hw.conf @@ -1,5 +0,0 @@ -[SETUP] -num_radios=2 - -[HOSTAPD] -rad0=ssidEAP-TLS.conf diff --git a/autotests/testEAP-TLS-embedded-pems/ssidEAP-TLS.8021x b/autotests/testEAP-TLS-embedded-pems/ssidEAP-TLS.8021x @@ -1,94 +0,0 @@ -[Security] -EAP-Method=TLS -EAP-TLS-CACert=embed:cert_ca -EAP-TLS-ClientCert=embed:cert_client -EAP-TLS-ClientKey=embed:cert_client_key -EAP-Identity=abc@example.com - -[@pem@cert_ca] ------BEGIN CERTIFICATE----- -MIIEVDCCAzygAwIBAgIJAJmt2W7CutHvMA0GCSqGSIb3DQEBCwUAMHgxNTAzBgNV -BAoMLEludGVybmF0aW9uYWwgVW5pb24gb2YgRXhhbXBsZSBPcmdhbml6YXRpb25z -MR8wHQYDVQQDDBZDZXJ0aWZpY2F0ZSBpc3N1ZXIgZ3V5MR4wHAYJKoZIhvcNAQkB -Fg9jYUBtYWlsLmV4YW1wbGUwHhcNMTYwNTE3MjEyMDQ2WhcNNDMxMDAzMjEyMDQ2 -WjB4MTUwMwYDVQQKDCxJbnRlcm5hdGlvbmFsIFVuaW9uIG9mIEV4YW1wbGUgT3Jn -YW5pemF0aW9uczEfMB0GA1UEAwwWQ2VydGlmaWNhdGUgaXNzdWVyIGd1eTEeMBwG -CSqGSIb3DQEJARYPY2FAbWFpbC5leGFtcGxlMIIBIjANBgkqhkiG9w0BAQEFAAOC -AQ8AMIIBCgKCAQEAo3GrGqW49h8kY2Wx/1kd5dIkYGazuWrX93ma9904hHBJNsvu -V34QfHVln6wDpMZMwuvkfct09kl0rQpztJzA9YL4GMdmV6+6J6LiX1kMqLkNaJa+ -Ov+ECG5ypBRbSTYKpqFsc5wPOQf/N8brBiZS1v67va3fCwO6dgLeAf7dZ3Q70oUr -mghbK8UnlC+wLShxCBAW8TUKg7B7M5Gea794CO9wH7NsFyAr963WVcLxrdL3xMHZ -9hcscrljh35nCAc6sum1cTtWI651OGehr0Bhp2o2Exgr2mbo5TobqEW+fe4gc4ik -0nzHGWiOVaszUcvpeeduGV3y6om93atffeKuxQIDAQABo4HgMIHdMA8GA1UdEwQI -MAYBAf8CAQAwHQYDVR0OBBYEFO+M3tJAELTnseUqZyP4vl5X7SmUMIGqBgNVHSME -gaIwgZ+AFO+M3tJAELTnseUqZyP4vl5X7SmUoXykejB4MTUwMwYDVQQKDCxJbnRl -cm5hdGlvbmFsIFVuaW9uIG9mIEV4YW1wbGUgT3JnYW5pemF0aW9uczEfMB0GA1UE -AwwWQ2VydGlmaWNhdGUgaXNzdWVyIGd1eTEeMBwGCSqGSIb3DQEJARYPY2FAbWFp -bC5leGFtcGxlggkAma3ZbsK60e8wDQYJKoZIhvcNAQELBQADggEBAA/Yb9jB94OF -swbyCrA6Qe53YGC4dfqrKGRThtGKTrH0XcM2x2qLIIbiNDogwhRqlUW8iNY6Dm2k -43mJzNsYhy7Nt3IJFCguTJFilfGzQnBtK8wCr/C9qsj//BESOIlo/TDZ2Ho4ixcJ -n+FTnN34F6JJ0DIvA6tNBe1kUFSrbubL8ygNWJ9BKMebEzokGNGCGFNr70DlQj2o -1EOMMOkj0gWO0WegAYFLojzag3l+uvU59YE+/fbZ2iclyvbF7IutQ5M9g5TnQE6F -f+qFKR5+bhlJwry6vLl/6ulihkvF3y1bm7zae62zbFaZRU6PJUl1DtXiA23ZTm9T -VDivqs07R84= ------END CERTIFICATE----- - -[@pem@cert_client] ------BEGIN CERTIFICATE----- -MIIEPTCCAyWgAwIBAgIJAPk7rut4SWQCMA0GCSqGSIb3DQEBCwUAMHgxNTAzBgNV -BAoMLEludGVybmF0aW9uYWwgVW5pb24gb2YgRXhhbXBsZSBPcmdhbml6YXRpb25z -MR8wHQYDVQQDDBZDZXJ0aWZpY2F0ZSBpc3N1ZXIgZ3V5MR4wHAYJKoZIhvcNAQkB -Fg9jYUBtYWlsLmV4YW1wbGUwHhcNMTYwNTE3MjEyMDQ3WhcNNDMxMDAzMjEyMDQ3 -WjBnMSEwHwYDVQQKDBhCYXIgRXhhbXBsZSBPcmdhbml6YXRpb24xITAfBgNVBAMM -GEJhciBFeGFtcGxlIE9yZ2FuaXphdGlvbjEfMB0GCSqGSIb3DQEJARYQYmFyQG1h -aWwuZXhhbXBsZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOE5D/lU -haTC3xL281ttZPRURXlKJqLwcHGXQSuQm6wwYWtAhLyMLEHrryE0oChKdw3eV7Nn -/IODxvk1S8uIuKfHWuNd5qX/yu7CjCWvyim2CSJHF24rQFmb9ePoddOZnDMMAIz7 -PC325JVhbr/LSBLbqhZ0smHy1HKyrzzHHzKU4YcTH/3+3H4MHZwnNZfbfG5qhRZG -Nuu/8t+AWVcEocPRGYZpzWJNq6AAzojAHSSOxxiscBMiuQ+BdofPw9XhwpS+Fstk -rvF8J9FfZj5U3FOm/EgOQn8efnrUL231PqB1R9PIKYv/938p3iDMIi0ETiKi5ced -WV8m2PcykPdNOKMCAwEAAaOB2jCB1zAJBgNVHRMEAjAAMB0GA1UdDgQWBBTs9eey -OkMw3uiPpDOa3b9KErbEfzCBqgYDVR0jBIGiMIGfgBTvjN7SQBC057HlKmcj+L5e -V+0plKF8pHoweDE1MDMGA1UECgwsSW50ZXJuYXRpb25hbCBVbmlvbiBvZiBFeGFt -cGxlIE9yZ2FuaXphdGlvbnMxHzAdBgNVBAMMFkNlcnRpZmljYXRlIGlzc3VlciBn -dXkxHjAcBgkqhkiG9w0BCQEWD2NhQG1haWwuZXhhbXBsZYIJAJmt2W7CutHvMA0G -CSqGSIb3DQEBCwUAA4IBAQA8MxPjU2h5gwntQeSs8eeaEUILMkoU6JSDS4s5Hex5 -xYMLfcSoPPI0E6ahvKtWkSM0UZThyWsulSDTI1EgAiebjms06m1Ogh9V+0VbcOlQ -D/k3+fSRIiyY+v3J/h8ArUby+m5O2g1TgECr/nZl4avoAI0RpBi3lH6tC8GQYdbc -SA6hpNCM/dY3LWtAo2W6mdE8+RlCuTj4VZiQ1g6GE77t6XwDFL6vQBzLLXrinvXK -Ha+IssV5sGdpH9bVFWIJV2q3OZuv3HLhQfGmeUrGyWVcokQQ8d6kRwg65Zb1+KT2 -bNlVKhPAMBk4ayEocpqFIfqfCKDjGdPUruIh8IVDc684 ------END CERTIFICATE----- - -[@pem@cert_client_key] ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDhOQ/5VIWkwt8S -9vNbbWT0VEV5Siai8HBxl0ErkJusMGFrQIS8jCxB668hNKAoSncN3lezZ/yDg8b5 -NUvLiLinx1rjXeal/8ruwowlr8optgkiRxduK0BZm/Xj6HXTmZwzDACM+zwt9uSV -YW6/y0gS26oWdLJh8tRysq88xx8ylOGHEx/9/tx+DB2cJzWX23xuaoUWRjbrv/Lf -gFlXBKHD0RmGac1iTaugAM6IwB0kjscYrHATIrkPgXaHz8PV4cKUvhbLZK7xfCfR -X2Y+VNxTpvxIDkJ/Hn561C9t9T6gdUfTyCmL//d/Kd4gzCItBE4iouXHnVlfJtj3 -MpD3TTijAgMBAAECggEBAIbg9YAL7j1NtupUmkkWqm7oSPLqRVkvRSfBvXWplJD6 -KF1itht0lsyjqK3qJj/62HGlxj/a9o6MTIzSLiImLu/Lo9KmWYrwNUfnmqa3MArq -yW2NxapknJUNoaRrgqTGSZUIiwvjKZcdVKdhQkH6K5+fja0FFg8yrahC+k8bsMNI -5mw8NwRdR3SvHJWHCLfKCQ31tju7On/4C6jr0siUCc2//W+SO5c+FHDY1bma02cp -jXTEiFpw91YcyKxiADIaH9/qfxWdefxqYg1WlUeXF3jYt5xYnYr34qKW1gOZ3jy1 -QJ3esn382ZTml3TFZWy+g9tkYyOSgmDwQZbLk/ppBAECgYEA8RzLBFwP018ieMBv -khDtwcKk6ZihkWZxEPQPuUljWzzAHn/f3dXOcrfmflAKeoDEeYDimDYDizTLDPC4 -zmWkMJHNadcM5H065BbGVFQWXo47ltccfIlB/1vzG8aywfJ/yNfHvH87wbH2eg6N -yOr+96ZjLJszQ+Rv189BbXDzTcMCgYEA7yEbUL/A1J0l2kLoYyS0vfVa7AyBVOFW -vPgfkF7HdNpIiFWlukMr+DWOolaoZp5iHqQXFwJsL8qCcrbZuHbaNHAI/5vDE9xG -fh8KzrfBrjIPIyNm6EWpsBo5unXK+wTeqIAGKdzDo5Q3zEE6G5DkkHItKA7yjPOM -gz/b/MR3W6ECgYBBv3dA3hXWrreIs/j4nLMoxfoQVPWh34xvcg4jmXaFd6Bv8LDM -HjRopestgIgK9bgd5d5kYT5AJIpGIhJS/fZy5B9egCzc1aVMc0Vr024yJJjtPgVf -lFIx3xIA/gLazlS4INcveIaEABJVIEjbg/E4+N9MV5n4Jn+1GqgdvtIp3wKBgQC0 -C3lFkxrc+nVFoJrYCwsK+3E5yTCXeBKWtTsOuE307WUvQU1GsMyqVajPEfA5U4cN -Cv9Xk7thQFh3hrTm7pXcZX5g9iYrDe8FhtncSv7I6Wf8TOtudwUMUrKkcYwi88ex -lrMNUer7ft2ELJhTqQRuvYjCYH6/IaDqMWqxJju4AQKBgQDPjOh75ykQc93SsYpt -Tb4gQKLeqOb57pofT8D44DccatfEgk31D4fBIIQu6XKopQmCtQyX9DUDjOWFTxuo -IMPysN6Fh1quCbC6Xt5xfKoaJG5yQYKeKtLhknwEW9SUifU2xVrOcPikLs7Iwmmp -BkDLsu/YKwRFSfrbYZXbTlU8tQ== ------END PRIVATE KEY----- - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TLS-embedded-pems/ssidEAP-TLS.conf b/autotests/testEAP-TLS-embedded-pems/ssidEAP-TLS.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-TLS - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TLS/connection_test.py b/autotests/testEAP-TLS/connection_test.py @@ -1,84 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -import testutil -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def do_test_connection_success(self, ssid, passphrase=None): - hapd = HostapdCLI(config=ssid + '.conf') - wd = IWD() - - if passphrase: - psk_agent = PSKAgent(passphrase) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - if not device.get_ordered_networks(): - device.scan() - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network(ssid) - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected(hapd.ifname, device.name) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - if passphrase: - wd.unregister_psk_agent(psk_agent) - - def test_eap_tls(self): - self.do_test_connection_success('ssidEAP-TLS') - - def test_eap_tls2(self): - self.do_test_connection_success('ssidEAP-TLS2') - - def test_eap_tls3(self): - self.do_test_connection_success('ssidEAP-TLS3', 'abc') - - def test_eap_tls4(self): - self.do_test_connection_success('ssidEAP-TLS4') - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TLS.8021x') - IWD.copy_to_storage('ssidEAP-TLS2.8021x') - IWD.copy_to_storage('ssidEAP-TLS3.8021x') - IWD.copy_to_storage('ssidEAP-TLS4.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TLS/hw.conf b/autotests/testEAP-TLS/hw.conf @@ -1,8 +0,0 @@ -[SETUP] -num_radios=5 - -[HOSTAPD] -rad0=ssidEAP-TLS.conf -rad1=ssidEAP-TLS2.conf -rad2=ssidEAP-TLS3.conf -rad3=ssidEAP-TLS4.conf diff --git a/autotests/testEAP-TLS/ssidEAP-TLS.8021x b/autotests/testEAP-TLS/ssidEAP-TLS.8021x @@ -1,9 +0,0 @@ -[Security] -EAP-Method=TLS -EAP-TLS-CACert=/tmp/certs/cert-ca.pem -EAP-TLS-ClientCert=/tmp/certs/cert-client.pem -EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-Identity=abc@example.com - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TLS/ssidEAP-TLS.conf b/autotests/testEAP-TLS/ssidEAP-TLS.conf @@ -1,13 +0,0 @@ -ctrl_interface=/var/run/hostapd -hw_mode=g -channel=1 -ssid=ssidEAP-TLS - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TLS/ssidEAP-TLS2.8021x b/autotests/testEAP-TLS/ssidEAP-TLS2.8021x @@ -1,10 +0,0 @@ -[Security] -EAP-Method=TLS -EAP-TLS-CACert=/tmp/certs/cert-ca.pem -EAP-TLS-ClientCert=/tmp/certs/cert-client.pem -EAP-TLS-ClientKey=/tmp/certs/cert-client-key-md5-des.pem -EAP-TLS-ClientKeyPassphrase=abc -EAP-Identity=abc@example.com - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TLS/ssidEAP-TLS2.conf b/autotests/testEAP-TLS/ssidEAP-TLS2.conf @@ -1,13 +0,0 @@ -ctrl_interface=/var/run/hostapd -hw_mode=g -channel=2 -ssid=ssidEAP-TLS2 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TLS/ssidEAP-TLS3.8021x b/autotests/testEAP-TLS/ssidEAP-TLS3.8021x @@ -1,9 +0,0 @@ -[Security] -EAP-Method=TLS -EAP-TLS-CACert=/tmp/certs/cert-ca.pem -EAP-TLS-ClientCert=/tmp/certs/cert-client.crt -EAP-TLS-ClientKey=/tmp/certs/cert-client-key-v2-des-ede3.pem -EAP-Identity=abc@example.com - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TLS/ssidEAP-TLS3.conf b/autotests/testEAP-TLS/ssidEAP-TLS3.conf @@ -1,13 +0,0 @@ -ctrl_interface=/var/run/hostapd -hw_mode=g -channel=3 -ssid=ssidEAP-TLS3 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TLS/ssidEAP-TLS4.8021x b/autotests/testEAP-TLS/ssidEAP-TLS4.8021x @@ -1,9 +0,0 @@ -[Security] -EAP-Method=TLS -EAP-TLS-CACert=/tmp/certs/cert-ca.pem -EAP-TLS-ClientKeyBundle=/tmp/certs/cert-client.p12 -EAP-TLS-ClientKeyPassphrase=abc -EAP-Identity=abc@example.com - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TLS/ssidEAP-TLS4.conf b/autotests/testEAP-TLS/ssidEAP-TLS4.conf @@ -1,13 +0,0 @@ -ctrl_interface=/var/run/hostapd -hw_mode=g -channel=4 -ssid=ssidEAP-TLS4 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TLSwithMFPC/connection_test.py b/autotests/testEAP-TLSwithMFPC/connection_test.py @@ -16,14 +16,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidEAP-TLS') self.assertEqual(ordered_network.type, NetworkType.eap) diff --git a/autotests/testEAP-TLSwithMFPC/ssidEAP-TLS.8021x b/autotests/testEAP-TLSwithMFPC/ssidEAP-TLS.8021x @@ -3,7 +3,7 @@ EAP-Method=TLS EAP-TLS-CACert=/tmp/certs/cert-ca.pem EAP-TLS-ClientCert=/tmp/certs/cert-client.pem EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-Identity=abc@example.com +EAP-Identity=tls@example.com [Settings] AutoConnect=False diff --git a/autotests/testEAP-TLSwithMFPC/ssidEAP-TLS.conf b/autotests/testEAP-TLSwithMFPC/ssidEAP-TLS.conf @@ -5,7 +5,7 @@ ssid=ssidEAP-TLS wpa=2 ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TLSwithMFPR/connection_test.py b/autotests/testEAP-TLSwithMFPR/connection_test.py @@ -16,14 +16,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidEAP-TLS') self.assertEqual(ordered_network.type, NetworkType.eap) diff --git a/autotests/testEAP-TLSwithMFPR/ssidEAP-TLS.8021x b/autotests/testEAP-TLSwithMFPR/ssidEAP-TLS.8021x @@ -3,7 +3,7 @@ EAP-Method=TLS EAP-TLS-CACert=/tmp/certs/cert-ca.pem EAP-TLS-ClientCert=/tmp/certs/cert-client.pem EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-Identity=abc@example.com +EAP-Identity=tls@example.com [Settings] AutoConnect=False diff --git a/autotests/testEAP-TLSwithMFPR/ssidEAP-TLS.conf b/autotests/testEAP-TLSwithMFPR/ssidEAP-TLS.conf @@ -5,7 +5,7 @@ ssid=ssidEAP-TLS wpa=2 ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TTLS-CHAP/connection_test.py b/autotests/testEAP-TTLS-CHAP/connection_test.py @@ -1,76 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -import testutil -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def test_connection_success(self): - hostapd = HostapdCLI(config='ssidEAP-TTLS-CHAP.conf') - - self.assertIsNotNone(hostapd) - - wd = IWD() - - psk_agent = PSKAgent('abc', ('user', 'testpasswd')) - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-TTLS-CHAP') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - hostapd.eapol_reauth(device.address) - - hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED') - hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS') - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected() - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TTLS-CHAP.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TTLS-CHAP/eap-user-ttls-chap.text b/autotests/testEAP-TTLS-CHAP/eap-user-ttls-chap.text @@ -1,4 +0,0 @@ -# Phase 1 users -* TTLS -# Phase 2 -"user" TTLS-CHAP "testpasswd" [2] diff --git a/autotests/testEAP-TTLS-CHAP/hw.conf b/autotests/testEAP-TTLS-CHAP/hw.conf @@ -1,5 +0,0 @@ -[SETUP] -num_radios=2 - -[HOSTAPD] -rad0=ssidEAP-TTLS-CHAP.conf diff --git a/autotests/testEAP-TTLS-CHAP/ssidEAP-TTLS-CHAP.8021x b/autotests/testEAP-TTLS-CHAP/ssidEAP-TTLS-CHAP.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=TTLS -EAP-Identity=anonymous -EAP-TTLS-Phase2-Method=Tunneled-CHAP - -# If CHAP Identity and Password are left out, they will be requested through -# the agent. -#EAP-TTLS-Phase2-Identity=user -#EAP-TTLS-Phase2-Password=testpasswd - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TTLS-CHAP/ssidEAP-TTLS-CHAP.conf b/autotests/testEAP-TTLS-CHAP/ssidEAP-TTLS-CHAP.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-TTLS-CHAP - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/eap-user-ttls-chap.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TTLS-EAP-MSCHAPV2/connection_test.py b/autotests/testEAP-TTLS-EAP-MSCHAPV2/connection_test.py @@ -1,65 +0,0 @@ -#! /usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -import testutil - -class Test(unittest.TestCase): - - def test_connection_success(self): - wd = IWD() - - psk_agent = PSKAgent('abc', ('user', 'testpasswd')) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - if not device.get_ordered_networks(): - device.scan() - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-TTLS') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected() - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TTLS.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TTLS-EAP-MSCHAPV2/hw.conf b/autotests/testEAP-TTLS-EAP-MSCHAPV2/hw.conf @@ -1,5 +0,0 @@ -[SETUP] -num_radios=2 - -[HOSTAPD] -rad0=ssidEAP-TTLS.conf diff --git a/autotests/testEAP-TTLS-EAP-MSCHAPV2/ssidEAP-TTLS.8021x b/autotests/testEAP-TTLS-EAP-MSCHAPV2/ssidEAP-TTLS.8021x @@ -1,8 +0,0 @@ -[Security] -EAP-Method=TTLS -EAP-Identity=abc@example.com -EAP-TTLS-CACert=/tmp/certs/cert-ca.pem -EAP-TTLS-ClientCert=/tmp/certs/cert-client.pem -EAP-TTLS-ClientKey=/tmp/certs/cert-client-key-v2-des-ede3.pem -EAP-TTLS-Phase2-Method=MSCHAPV2 -EAP-TTLS-Phase2-Identity=user diff --git a/autotests/testEAP-TTLS-EAP-MSCHAPV2/ssidEAP-TTLS.conf b/autotests/testEAP-TTLS-EAP-MSCHAPV2/ssidEAP-TTLS.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-TTLS - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/certs/eap-user-ttls-mschapv2.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TTLS-Frag/connection_test.py b/autotests/testEAP-TTLS-Frag/connection_test.py @@ -16,14 +16,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidEAP-TTLS') self.assertEqual(ordered_network.type, NetworkType.eap) diff --git a/autotests/testEAP-TTLS-Frag/ssidEAP-TTLS.8021x b/autotests/testEAP-TTLS-Frag/ssidEAP-TTLS.8021x @@ -1,12 +1,12 @@ [Security] EAP-Method=TTLS -EAP-Identity=abc@example.com +EAP-Identity=ttls@example.com EAP-TTLS-CACert=/tmp/certs/cert-ca.pem EAP-TTLS-ClientCert=/tmp/certs/cert-client.pem EAP-TTLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem EAP-TTLS-Phase2-Method=MD5 -EAP-TTLS-Phase2-Identity=abc@example.com -EAP-TTLS-Phase2-Password=testpasswd +EAP-TTLS-Phase2-Identity=md5-phase2@example.com +EAP-TTLS-Phase2-Password=Password [Settings] AutoConnect=False diff --git a/autotests/testEAP-TTLS-Frag/ssidEAP-TTLS.conf b/autotests/testEAP-TTLS-Frag/ssidEAP-TTLS.conf @@ -8,7 +8,7 @@ wpa=3 wpa_key_mgmt=WPA-EAP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-ttls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TTLS-MSCHAP/connection_test.py b/autotests/testEAP-TTLS-MSCHAP/connection_test.py @@ -1,76 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -import testutil -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def test_connection_success(self): - hostapd = HostapdCLI(config='ssidEAP-TTLS-MSCHAP.conf') - - self.assertIsNotNone(hostapd) - - wd = IWD() - - psk_agent = PSKAgent('abc', ('user', 'testpasswd')) - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-TTLS-MSCHAP') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - hostapd.eapol_reauth(device.address) - - hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED') - hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS') - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected() - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TTLS-MSCHAP.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TTLS-MSCHAP/eap-user-ttls-mschap.text b/autotests/testEAP-TTLS-MSCHAP/eap-user-ttls-mschap.text @@ -1,4 +0,0 @@ -# Phase 1 users -* TTLS -# Phase 2 -"user" TTLS-MSCHAP "testpasswd" [2] diff --git a/autotests/testEAP-TTLS-MSCHAP/hw.conf b/autotests/testEAP-TTLS-MSCHAP/hw.conf @@ -1,5 +0,0 @@ -[SETUP] -num_radios=2 - -[HOSTAPD] -rad0=ssidEAP-TTLS-MSCHAP.conf diff --git a/autotests/testEAP-TTLS-MSCHAP/ssidEAP-TTLS-MSCHAP.8021x b/autotests/testEAP-TTLS-MSCHAP/ssidEAP-TTLS-MSCHAP.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=TTLS -EAP-Identity=anonymous -EAP-TTLS-Phase2-Method=Tunneled-MSCHAP - -# If MSCHAP Identity and Password are left out, they will be requested through -# the agent. -#EAP-TTLS-Phase2-Identity=user -#EAP-TTLS-Phase2-Password=testpasswd - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TTLS-MSCHAP/ssidEAP-TTLS-MSCHAP.conf b/autotests/testEAP-TTLS-MSCHAP/ssidEAP-TTLS-MSCHAP.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-TTLS-MSCHAP - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/eap-user-ttls-mschap.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TTLS-MSCHAPv2/connection_test.py b/autotests/testEAP-TTLS-MSCHAPv2/connection_test.py @@ -1,81 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -import testutil -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - hostapd = HostapdCLI(config='ssidEAP-TTLS-MSCHAPv2.conf') - - self.assertIsNotNone(hostapd) - - psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0]; - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_networks = device.get_ordered_networks() - ordered_network = ordered_networks[0] - - self.assertEqual(ordered_network.name, "ssidEAP-TTLS-MSCHAPv2") - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - hostapd.eapol_reauth(device.address) - - hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED') - hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS') - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected() - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - def test_connection_success(self): - wd = IWD(True) - - self.validate_connection(wd) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TTLS-MSCHAPv2.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TTLS-MSCHAPv2/eap-user-ttls-mschapv2.text b/autotests/testEAP-TTLS-MSCHAPv2/eap-user-ttls-mschapv2.text @@ -1,4 +0,0 @@ -# Phase 1 users -* TTLS -# Phase 2 -"domain\user" TTLS-MSCHAPV2 "testpasswd" [2] diff --git a/autotests/testEAP-TTLS-MSCHAPv2/failure_test.py b/autotests/testEAP-TTLS-MSCHAPv2/failure_test.py @@ -1,66 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -import testutil -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def validate_connection(self, wd): - hostapd = HostapdCLI(config='ssidEAP-TTLS-MSCHAPv2.conf') - - self.assertIsNotNone(hostapd) - - psk_agent = PSKAgent('abc', ('user', 'incorrect_password')) - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0]; - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_networks = device.get_ordered_networks() - ordered_network = ordered_networks[0] - - self.assertEqual(ordered_network.name, "ssidEAP-TTLS-MSCHAPv2") - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - with self.assertRaises(iwd.FailedEx): - ordered_network.network_object.connect() - - wd.unregister_psk_agent(psk_agent) - - def test_connection_success(self): - wd = IWD(True) - - try: - self.validate_connection(wd) - finally: - del wd - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TTLS-MSCHAPv2.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TTLS-MSCHAPv2/hw.conf b/autotests/testEAP-TTLS-MSCHAPv2/hw.conf @@ -1,6 +0,0 @@ -[SETUP] -num_radios=2 -start_iwd=False - -[HOSTAPD] -rad0=ssidEAP-TTLS-MSCHAPv2.conf diff --git a/autotests/testEAP-TTLS-MSCHAPv2/ssidEAP-TTLS-MSCHAPv2.8021x b/autotests/testEAP-TTLS-MSCHAPv2/ssidEAP-TTLS-MSCHAPv2.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=TTLS -EAP-Identity=anonymous -EAP-TTLS-Phase2-Method=Tunneled-MSCHAPv2 - -# If MSCHAP Identity and Password are left out, they will be requested through -# the agent. -#EAP-TTLS-Phase2-Identity=user -#EAP-TTLS-Phase2-Password=testpasswd - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TTLS-MSCHAPv2/ssidEAP-TTLS-MSCHAPv2.conf b/autotests/testEAP-TTLS-MSCHAPv2/ssidEAP-TTLS-MSCHAPv2.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-TTLS-MSCHAPv2 - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/eap-user-ttls-mschapv2.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TTLS-PAP/connection_test.py b/autotests/testEAP-TTLS-PAP/connection_test.py @@ -1,76 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -import testutil -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType - -from hostapd import HostapdCLI - -class Test(unittest.TestCase): - - def test_connection_success(self): - hostapd = HostapdCLI(config='ssidEAP-TTLS-PAP.conf') - - self.assertIsNotNone(hostapd) - - wd = IWD() - - psk_agent = PSKAgent('abc', ('user', 'testpasswd')) - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-TTLS-PAP') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - hostapd.eapol_reauth(device.address) - - hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED') - hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS') - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected() - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TTLS-PAP.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TTLS-PAP/eap-user-ttls-pap.text b/autotests/testEAP-TTLS-PAP/eap-user-ttls-pap.text @@ -1,4 +0,0 @@ -# Phase 1 users -* TTLS -# Phase 2 -"user" TTLS-PAP "testpasswd" [2] diff --git a/autotests/testEAP-TTLS-PAP/hw.conf b/autotests/testEAP-TTLS-PAP/hw.conf @@ -1,5 +0,0 @@ -[SETUP] -num_radios=2 - -[HOSTAPD] -rad0=ssidEAP-TTLS-PAP.conf diff --git a/autotests/testEAP-TTLS-PAP/ssidEAP-TTLS-PAP.8021x b/autotests/testEAP-TTLS-PAP/ssidEAP-TTLS-PAP.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=TTLS -EAP-Identity=anonymous -EAP-TTLS-Phase2-Method=Tunneled-PAP - -# If PAP Identity and Password are left out, they will be requested through -# the agent. -#EAP-TTLS-Phase2-Identity=user -#EAP-TTLS-Phase2-Password=testpasswd - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TTLS-PAP/ssidEAP-TTLS-PAP.conf b/autotests/testEAP-TTLS-PAP/ssidEAP-TTLS-PAP.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-TTLS-PAP - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/eap-user-ttls-pap.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP-TTLS/connection_test.py b/autotests/testEAP-TTLS/connection_test.py @@ -1,57 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import NetworkType -import testutil - -class Test(unittest.TestCase): - - def test_connection_success(self): - wd = IWD() - - devices = wd.list_devices(1) - device = devices[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidEAP-TTLS') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected() - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - @classmethod - def setUpClass(cls): - IWD.copy_to_storage('ssidEAP-TTLS.8021x') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testEAP-TTLS/hw.conf b/autotests/testEAP-TTLS/hw.conf @@ -1,5 +0,0 @@ -[SETUP] -num_radios=2 - -[HOSTAPD] -rad0=ssidEAP-TTLS.conf diff --git a/autotests/testEAP-TTLS/ssidEAP-TTLS.8021x b/autotests/testEAP-TTLS/ssidEAP-TTLS.8021x @@ -1,12 +0,0 @@ -[Security] -EAP-Method=TTLS -EAP-Identity=abc@example.com -EAP-TTLS-CACert=/tmp/certs/cert-ca.pem -EAP-TTLS-ClientCert=/tmp/certs/cert-client.pem -EAP-TTLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-TTLS-Phase2-Method=MD5 -EAP-TTLS-Phase2-Identity=abc@example.com -EAP-TTLS-Phase2-Password=testpasswd - -[Settings] -AutoConnect=False diff --git a/autotests/testEAP-TTLS/ssidEAP-TTLS.conf b/autotests/testEAP-TTLS/ssidEAP-TTLS.conf @@ -1,12 +0,0 @@ -hw_mode=g -channel=1 -ssid=ssidEAP-TTLS - -wpa=3 -wpa_key_mgmt=WPA-EAP -ieee8021x=1 -eap_server=1 -eap_user_file=/tmp/certs/eap-user-ttls.text -ca_cert=/tmp/certs/cert-ca.pem -server_cert=/tmp/certs/cert-server.pem -private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testEAP/connection_test.py b/autotests/testEAP/connection_test.py @@ -0,0 +1,261 @@ +#!/usr/bin/python3 + +from typing import Iterable +import unittest +import sys + +sys.path.append('../util') +from iwd import IWD +from iwd import NetworkType +from iwd import PSKAgent +from hlrauc import AuthCenter +from ofono import Ofono +from config import ctx +import testutil +import traceback + +class Test(unittest.TestCase): + def copy_network(self, name): + IWD.copy_to_storage(name, name='ssidEAP.8021x') + self.wd.wait_for_object_condition(self.wd, + '"ssidEAP" in [n.name for n in obj.list_known_networks()]') + + def remove_network(self): + networks = self.wd.list_known_networks() + [n.forget() for n in networks if n.name == 'ssidEAP'] + self.wd.wait_for_object_condition(self.wd, + '"ssidEAP" not in [n.name for n in obj.list_known_networks()]') + + def validate_connection(self, wd, *secrets): + if secrets: + psk_agent = PSKAgent(*secrets) + wd.register_psk_agent(psk_agent) + + devices = wd.list_devices(1) + self.assertIsNotNone(devices) + device = devices[0] + + ordered_network = device.get_ordered_network('ssidEAP') + + self.assertEqual(ordered_network.type, NetworkType.eap) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + ordered_network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + testutil.test_iface_operstate() + testutil.test_ifaces_connected() + + if secrets: + wd.unregister_psk_agent(psk_agent) + + device.disconnect() + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + # + # EAP-AKA + # + def test_eap_aka(self): + if not ctx.is_process_running('ofonod'): + self.skipTest("ofono not running") + + ofono = Ofono() + ofono.enable_modem('/phonesim') + ofono.wait_for_sim_auth() + + auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim/aka.db') + + self.copy_network('sim/ssidEAP-AKA.8021x') + + try: + self.validate_connection(self.wd) + finally: + auth.stop() + + # + # EAP-AKA' + # + def test_eap_aka_prime(self): + if not ctx.is_process_running('ofonod'): + self.skipTest("ofono not running") + + ofono = Ofono() + ofono.enable_modem('/phonesim') + ofono.wait_for_sim_auth() + + auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim/aka.db') + + self.copy_network('sim/ssidEAP-AKA-prime.8021x') + + try: + self.validate_connection(self.wd) + finally: + auth.stop() + + # + # EAP-SIM + # + def test_eap_sim(self): + if not ctx.is_process_running('ofonod'): + self.skipTest("ofono not running") + + ofono = Ofono() + ofono.enable_modem('/phonesim') + ofono.wait_for_sim_auth() + + auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim/sim.db') + + self.copy_network('sim/ssidEAP-SIM.8021x') + + try: + self.validate_connection(self.wd) + finally: + auth.stop() + + # + # EAP-MSCHAPv2 + # + # * Credentials in 8021x file + # * Password-Hash in 8021x file + # * Agent request for password + # * Agent request for user + password + # + def test_eap_mschapv2(self): + self.copy_network('mschapv2/ssidEAP-MSCHAPV2.8021x') + self.validate_connection(self.wd) + + self.copy_network('mschapv2/ssidEAP-MSCHAPV2-hash.8021x') + self.validate_connection(self.wd) + + self.copy_network('mschapv2/ssidEAP-MSCHAPV2-nopass.8021x') + self.validate_connection(self.wd, [], ('mschapv2@example.com', 'Password')) + + self.copy_network('mschapv2/ssidEAP-MSCHAPV2-nouserpass.8021x') + self.validate_connection(self.wd, [], ('mschapv2@example.com', 'Password')) + + # + # EAP-PEAP + # + # * Test all combinations of PEAP, PEAPv0, PEAPv1 with MD5, GTC, MSCHAPv2 + # + def test_eap_peap(self): + for ver in ['PEAP', 'PEAPv0', 'PEAPv1']: + for inner in ['MD5', 'GTC', 'MSCHAPv2']: + self.copy_network('peap/ssidEAP-%s-%s.8021x' % (ver, inner)) + + try: + self.validate_connection(self.wd) + except Exception as e: + # Catch an error here and print the actual PEAP combo that failed + traceback.print_exc() + raise Exception("%s-%s test failed" % (ver, inner)) + + self.remove_network() + + # + # EAP-PEAP + SIM + # + # * Tests EAP-PEAP + SIM separately to allow skipping if ofono is not found + # + def test_eap_peap_sim(self): + if not ctx.is_process_running('ofonod'): + self.skipTest("ofono not running") + + ofono = Ofono() + ofono.enable_modem('/phonesim') + ofono.wait_for_sim_auth() + + auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim/sim.db') + + for ver in ['PEAP', 'PEAPv0', 'PEAPv1']: + self.copy_network('peap/ssidEAP-%s-SIM.8021x' % ver) + + try: + self.validate_connection(self.wd) + except Exception as e: + # Catch an error here and print the actual PEAP combo that failed + traceback.print_exc() + auth.stop() + raise Exception("%s-SIM test failed" % ver) + + self.remove_network() + + auth.stop() + + # + # EAP-PWD + # + def test_eap_pwd(self): + self.copy_network('ssidEAP-PWD.8021x') + + self.validate_connection(self.wd) + + # + # EAP-TLS + # + # * Encrypted private key, passphrase in 8021x file + # * Unencrypted private key + # * Encrypted private key, passphrase provided by agent + # * Embedded PEM inside 8021x file + # * KeyBundle + # + def test_eap_tls(self): + for name, secrets in [('keypass', None), ('nokeypass', None), + ('des-ede3', 'abc'), ('embedded', None), ('keybundle', None)]: + self.copy_network('tls/ssidEAP-TLS-%s.8021x' % name) + try: + self.validate_connection(self.wd, secrets) + except Exception as e: + traceback.print_exc() + raise Exception('EAP-TLS (%s) failed' % name) + + self.remove_network() + + # + # EAP-TTLS + # + # * CHAP, MD5, MSCHAPV2 as phase 2 + # * Tunneled-MSCHAP, Tunneled-MSCHAPV2, Tunneled-PAP as phase 2 + # + def test_eap_ttls(self): + for name, secrets in [('CHAP', ('ttls@example.com', ('ttls-chap-phase2@example.com', 'Password'))), + ('MD5', None), + ('MSCHAPV2', ('ttls@example.com', ('mschapv2-phase2@example.com', 'Password'))), + ('Tunneled-MSCHAP', ('ttls@example.com', ('ttls-mschap-phase2@example.com', 'Password'))), + ('Tunneled-MSCHAPV2', ('ttls@example.com', ('ttls-mschapv2-phase2@example.com', 'Password'))), + ('Tunneled-PAP', ('ttls@example.com', ('ttls-pap-phase2@example.com', 'Password')))]: + self.copy_network('ttls/ssidEAP-TTLS-%s.8021x' % name) + try: + if isinstance(secrets, Iterable): + self.validate_connection(self.wd, *secrets) + else: + self.validate_connection(self.wd, None) + except Exception as e: + traceback.print_exc() + raise Exception('EAP-TTLS (%s) failed' % name) + + self.remove_network() + + def setUp(self): + IWD.clear_storage() + + def tearDown(self): + self.remove_network() + + @classmethod + def setUpClass(cls): + cls.wd = IWD() + + @classmethod + def tearDownClass(cls): + cls.wd = None + IWD.clear_storage() + +if __name__ == '__main__': + unittest.main(exit=True) diff --git a/autotests/testEAP/hw.conf b/autotests/testEAP/hw.conf @@ -0,0 +1,6 @@ +[SETUP] +num_radios=2 +sim_keys=ofono + +[HOSTAPD] +rad0=ssidEAP.conf diff --git a/autotests/testEAP/mschapv2/ssidEAP-MSCHAPV2-hash.8021x b/autotests/testEAP/mschapv2/ssidEAP-MSCHAPV2-hash.8021x @@ -0,0 +1,7 @@ +[Security] +EAP-Method=MSCHAPV2 +EAP-Identity=mschapv2@example.com +EAP-Password-Hash=a4f49c406510bdcab6824ee7c30fd852 + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/mschapv2/ssidEAP-MSCHAPV2-nopass.8021x b/autotests/testEAP/mschapv2/ssidEAP-MSCHAPV2-nopass.8021x @@ -0,0 +1,6 @@ +[Security] +EAP-Method=MSCHAPV2 +EAP-Identity=mschapv2@example.com + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP-MSCHAPV2/ssidEAP-MSCHAPV2-4.8021x b/autotests/testEAP/mschapv2/ssidEAP-MSCHAPV2-nouserpass.8021x diff --git a/autotests/testEAP/mschapv2/ssidEAP-MSCHAPV2.8021x b/autotests/testEAP/mschapv2/ssidEAP-MSCHAPV2.8021x @@ -0,0 +1,7 @@ +[Security] +EAP-Method=MSCHAPV2 +EAP-Identity=mschapv2@example.com +EAP-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAP-GTC.8021x b/autotests/testEAP/peap/ssidEAP-PEAP-GTC.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peap@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=GTC +EAP-PEAP-Phase2-Identity=gtc-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAP-MD5.8021x b/autotests/testEAP/peap/ssidEAP-PEAP-MD5.8021x @@ -0,0 +1,14 @@ +[Security] +EAP-Method=PEAP + +EAP-Identity=peap@example.com + +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=MD5 +EAP-PEAP-Phase2-Identity=md5-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAP-MSCHAPv2.8021x b/autotests/testEAP/peap/ssidEAP-PEAP-MSCHAPv2.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peap@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=MSCHAPV2 +EAP-PEAP-Phase2-Identity=mschapv2-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAP-SIM.8021x b/autotests/testEAP/peap/ssidEAP-PEAP-SIM.8021x @@ -0,0 +1,10 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peap@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=SIM + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv0-GTC.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv0-GTC.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv0@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=GTC +EAP-PEAP-Phase2-Identity=gtc-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv0-MD5.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv0-MD5.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv0@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=MD5 +EAP-PEAP-Phase2-Identity=md5-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv0-MSCHAPv2.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv0-MSCHAPv2.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv0@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=MSCHAPV2 +EAP-PEAP-Phase2-Identity=mschapv2-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv0-SIM.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv0-SIM.8021x @@ -0,0 +1,10 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv0@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=SIM + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv1-GTC.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv1-GTC.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv1@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=GTC +EAP-PEAP-Phase2-Identity=gtc-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv1-MD5.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv1-MD5.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv1@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=MD5 +EAP-PEAP-Phase2-Identity=md5-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv1-MSCHAPv2.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv1-MSCHAPv2.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv1@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=MSCHAPV2 +EAP-PEAP-Phase2-Identity=mschapv2-phase2@example.com +EAP-PEAP-Phase2-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/peap/ssidEAP-PEAPv1-SIM.8021x b/autotests/testEAP/peap/ssidEAP-PEAPv1-SIM.8021x @@ -0,0 +1,10 @@ +[Security] +EAP-Method=PEAP +EAP-Identity=peapv1@example.com +EAP-PEAP-CACert=/tmp/certs/cert-ca.pem +EAP-PEAP-ClientCert=/tmp/certs/cert-client.pem +EAP-PEAP-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-PEAP-Phase2-Method=SIM + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP-AKA-ofono/sim.db b/autotests/testEAP/sim/aka.db diff --git a/autotests/testEAP-PEAP-SIM/sim.db b/autotests/testEAP/sim/sim.db diff --git a/autotests/testEAP-AKA-prime-ofono/ssidEAP-AKA.8021x b/autotests/testEAP/sim/ssidEAP-AKA-prime.8021x diff --git a/autotests/testEAP/sim/ssidEAP-AKA.8021x b/autotests/testEAP/sim/ssidEAP-AKA.8021x @@ -0,0 +1,2 @@ +[Security] +EAP-Method=AKA diff --git a/autotests/testEAP-SIM-ofono/ssidEAP-SIM.8021x b/autotests/testEAP/sim/ssidEAP-SIM.8021x diff --git a/autotests/testEAP/ssidEAP-PWD.8021x b/autotests/testEAP/ssidEAP-PWD.8021x @@ -0,0 +1,7 @@ +[Security] +EAP-Method=PWD +EAP-Identity=pwd@example.com +EAP-Password=Password + +[Settings] +AutoConnect=false diff --git a/autotests/testEAP/ssidEAP.conf b/autotests/testEAP/ssidEAP.conf @@ -0,0 +1,14 @@ +hw_mode=g +channel=1 +ssid=ssidEAP +wpa=3 +wpa_key_mgmt=WPA-EAP +ieee8021x=1 +eap_server=1 +eap_user_file=/tmp/secrets/eap-user.text +ca_cert=/tmp/certs/cert-ca.pem +server_cert=/tmp/certs/cert-server.pem +private_key=/tmp/certs/cert-server-key.pem + +eap_sim_db=unix:/tmp/hlrauc.sock +eap_sim_aka_result_ind=1 diff --git a/autotests/testEAP/tls/ssidEAP-TLS-des-ede3.8021x b/autotests/testEAP/tls/ssidEAP-TLS-des-ede3.8021x @@ -0,0 +1,9 @@ +[Security] +EAP-Method=TLS +EAP-TLS-CACert=/tmp/certs/cert-ca.pem +EAP-TLS-ClientCert=/tmp/certs/cert-client.crt +EAP-TLS-ClientKey=/tmp/certs/cert-client-key-v2-des-ede3.pem +EAP-Identity=tls@example.com + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/tls/ssidEAP-TLS-embedded.8021x b/autotests/testEAP/tls/ssidEAP-TLS-embedded.8021x @@ -0,0 +1,94 @@ +[Security] +EAP-Method=TLS +EAP-TLS-CACert=embed:cert_ca +EAP-TLS-ClientCert=embed:cert_client +EAP-TLS-ClientKey=embed:cert_client_key +EAP-Identity=tls@example.com + +[@pem@cert_ca] +-----BEGIN CERTIFICATE----- +MIIEVDCCAzygAwIBAgIJAJmt2W7CutHvMA0GCSqGSIb3DQEBCwUAMHgxNTAzBgNV +BAoMLEludGVybmF0aW9uYWwgVW5pb24gb2YgRXhhbXBsZSBPcmdhbml6YXRpb25z +MR8wHQYDVQQDDBZDZXJ0aWZpY2F0ZSBpc3N1ZXIgZ3V5MR4wHAYJKoZIhvcNAQkB +Fg9jYUBtYWlsLmV4YW1wbGUwHhcNMTYwNTE3MjEyMDQ2WhcNNDMxMDAzMjEyMDQ2 +WjB4MTUwMwYDVQQKDCxJbnRlcm5hdGlvbmFsIFVuaW9uIG9mIEV4YW1wbGUgT3Jn +YW5pemF0aW9uczEfMB0GA1UEAwwWQ2VydGlmaWNhdGUgaXNzdWVyIGd1eTEeMBwG +CSqGSIb3DQEJARYPY2FAbWFpbC5leGFtcGxlMIIBIjANBgkqhkiG9w0BAQEFAAOC +AQ8AMIIBCgKCAQEAo3GrGqW49h8kY2Wx/1kd5dIkYGazuWrX93ma9904hHBJNsvu +V34QfHVln6wDpMZMwuvkfct09kl0rQpztJzA9YL4GMdmV6+6J6LiX1kMqLkNaJa+ +Ov+ECG5ypBRbSTYKpqFsc5wPOQf/N8brBiZS1v67va3fCwO6dgLeAf7dZ3Q70oUr +mghbK8UnlC+wLShxCBAW8TUKg7B7M5Gea794CO9wH7NsFyAr963WVcLxrdL3xMHZ +9hcscrljh35nCAc6sum1cTtWI651OGehr0Bhp2o2Exgr2mbo5TobqEW+fe4gc4ik +0nzHGWiOVaszUcvpeeduGV3y6om93atffeKuxQIDAQABo4HgMIHdMA8GA1UdEwQI +MAYBAf8CAQAwHQYDVR0OBBYEFO+M3tJAELTnseUqZyP4vl5X7SmUMIGqBgNVHSME +gaIwgZ+AFO+M3tJAELTnseUqZyP4vl5X7SmUoXykejB4MTUwMwYDVQQKDCxJbnRl +cm5hdGlvbmFsIFVuaW9uIG9mIEV4YW1wbGUgT3JnYW5pemF0aW9uczEfMB0GA1UE +AwwWQ2VydGlmaWNhdGUgaXNzdWVyIGd1eTEeMBwGCSqGSIb3DQEJARYPY2FAbWFp +bC5leGFtcGxlggkAma3ZbsK60e8wDQYJKoZIhvcNAQELBQADggEBAA/Yb9jB94OF +swbyCrA6Qe53YGC4dfqrKGRThtGKTrH0XcM2x2qLIIbiNDogwhRqlUW8iNY6Dm2k +43mJzNsYhy7Nt3IJFCguTJFilfGzQnBtK8wCr/C9qsj//BESOIlo/TDZ2Ho4ixcJ +n+FTnN34F6JJ0DIvA6tNBe1kUFSrbubL8ygNWJ9BKMebEzokGNGCGFNr70DlQj2o +1EOMMOkj0gWO0WegAYFLojzag3l+uvU59YE+/fbZ2iclyvbF7IutQ5M9g5TnQE6F +f+qFKR5+bhlJwry6vLl/6ulihkvF3y1bm7zae62zbFaZRU6PJUl1DtXiA23ZTm9T +VDivqs07R84= +-----END CERTIFICATE----- + +[@pem@cert_client] +-----BEGIN CERTIFICATE----- +MIIEPTCCAyWgAwIBAgIJAPk7rut4SWQCMA0GCSqGSIb3DQEBCwUAMHgxNTAzBgNV +BAoMLEludGVybmF0aW9uYWwgVW5pb24gb2YgRXhhbXBsZSBPcmdhbml6YXRpb25z +MR8wHQYDVQQDDBZDZXJ0aWZpY2F0ZSBpc3N1ZXIgZ3V5MR4wHAYJKoZIhvcNAQkB +Fg9jYUBtYWlsLmV4YW1wbGUwHhcNMTYwNTE3MjEyMDQ3WhcNNDMxMDAzMjEyMDQ3 +WjBnMSEwHwYDVQQKDBhCYXIgRXhhbXBsZSBPcmdhbml6YXRpb24xITAfBgNVBAMM +GEJhciBFeGFtcGxlIE9yZ2FuaXphdGlvbjEfMB0GCSqGSIb3DQEJARYQYmFyQG1h +aWwuZXhhbXBsZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOE5D/lU +haTC3xL281ttZPRURXlKJqLwcHGXQSuQm6wwYWtAhLyMLEHrryE0oChKdw3eV7Nn +/IODxvk1S8uIuKfHWuNd5qX/yu7CjCWvyim2CSJHF24rQFmb9ePoddOZnDMMAIz7 +PC325JVhbr/LSBLbqhZ0smHy1HKyrzzHHzKU4YcTH/3+3H4MHZwnNZfbfG5qhRZG +Nuu/8t+AWVcEocPRGYZpzWJNq6AAzojAHSSOxxiscBMiuQ+BdofPw9XhwpS+Fstk +rvF8J9FfZj5U3FOm/EgOQn8efnrUL231PqB1R9PIKYv/938p3iDMIi0ETiKi5ced +WV8m2PcykPdNOKMCAwEAAaOB2jCB1zAJBgNVHRMEAjAAMB0GA1UdDgQWBBTs9eey +OkMw3uiPpDOa3b9KErbEfzCBqgYDVR0jBIGiMIGfgBTvjN7SQBC057HlKmcj+L5e +V+0plKF8pHoweDE1MDMGA1UECgwsSW50ZXJuYXRpb25hbCBVbmlvbiBvZiBFeGFt +cGxlIE9yZ2FuaXphdGlvbnMxHzAdBgNVBAMMFkNlcnRpZmljYXRlIGlzc3VlciBn +dXkxHjAcBgkqhkiG9w0BCQEWD2NhQG1haWwuZXhhbXBsZYIJAJmt2W7CutHvMA0G +CSqGSIb3DQEBCwUAA4IBAQA8MxPjU2h5gwntQeSs8eeaEUILMkoU6JSDS4s5Hex5 +xYMLfcSoPPI0E6ahvKtWkSM0UZThyWsulSDTI1EgAiebjms06m1Ogh9V+0VbcOlQ +D/k3+fSRIiyY+v3J/h8ArUby+m5O2g1TgECr/nZl4avoAI0RpBi3lH6tC8GQYdbc +SA6hpNCM/dY3LWtAo2W6mdE8+RlCuTj4VZiQ1g6GE77t6XwDFL6vQBzLLXrinvXK +Ha+IssV5sGdpH9bVFWIJV2q3OZuv3HLhQfGmeUrGyWVcokQQ8d6kRwg65Zb1+KT2 +bNlVKhPAMBk4ayEocpqFIfqfCKDjGdPUruIh8IVDc684 +-----END CERTIFICATE----- + +[@pem@cert_client_key] +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDhOQ/5VIWkwt8S +9vNbbWT0VEV5Siai8HBxl0ErkJusMGFrQIS8jCxB668hNKAoSncN3lezZ/yDg8b5 +NUvLiLinx1rjXeal/8ruwowlr8optgkiRxduK0BZm/Xj6HXTmZwzDACM+zwt9uSV +YW6/y0gS26oWdLJh8tRysq88xx8ylOGHEx/9/tx+DB2cJzWX23xuaoUWRjbrv/Lf +gFlXBKHD0RmGac1iTaugAM6IwB0kjscYrHATIrkPgXaHz8PV4cKUvhbLZK7xfCfR +X2Y+VNxTpvxIDkJ/Hn561C9t9T6gdUfTyCmL//d/Kd4gzCItBE4iouXHnVlfJtj3 +MpD3TTijAgMBAAECggEBAIbg9YAL7j1NtupUmkkWqm7oSPLqRVkvRSfBvXWplJD6 +KF1itht0lsyjqK3qJj/62HGlxj/a9o6MTIzSLiImLu/Lo9KmWYrwNUfnmqa3MArq +yW2NxapknJUNoaRrgqTGSZUIiwvjKZcdVKdhQkH6K5+fja0FFg8yrahC+k8bsMNI +5mw8NwRdR3SvHJWHCLfKCQ31tju7On/4C6jr0siUCc2//W+SO5c+FHDY1bma02cp +jXTEiFpw91YcyKxiADIaH9/qfxWdefxqYg1WlUeXF3jYt5xYnYr34qKW1gOZ3jy1 +QJ3esn382ZTml3TFZWy+g9tkYyOSgmDwQZbLk/ppBAECgYEA8RzLBFwP018ieMBv +khDtwcKk6ZihkWZxEPQPuUljWzzAHn/f3dXOcrfmflAKeoDEeYDimDYDizTLDPC4 +zmWkMJHNadcM5H065BbGVFQWXo47ltccfIlB/1vzG8aywfJ/yNfHvH87wbH2eg6N +yOr+96ZjLJszQ+Rv189BbXDzTcMCgYEA7yEbUL/A1J0l2kLoYyS0vfVa7AyBVOFW +vPgfkF7HdNpIiFWlukMr+DWOolaoZp5iHqQXFwJsL8qCcrbZuHbaNHAI/5vDE9xG +fh8KzrfBrjIPIyNm6EWpsBo5unXK+wTeqIAGKdzDo5Q3zEE6G5DkkHItKA7yjPOM +gz/b/MR3W6ECgYBBv3dA3hXWrreIs/j4nLMoxfoQVPWh34xvcg4jmXaFd6Bv8LDM +HjRopestgIgK9bgd5d5kYT5AJIpGIhJS/fZy5B9egCzc1aVMc0Vr024yJJjtPgVf +lFIx3xIA/gLazlS4INcveIaEABJVIEjbg/E4+N9MV5n4Jn+1GqgdvtIp3wKBgQC0 +C3lFkxrc+nVFoJrYCwsK+3E5yTCXeBKWtTsOuE307WUvQU1GsMyqVajPEfA5U4cN +Cv9Xk7thQFh3hrTm7pXcZX5g9iYrDe8FhtncSv7I6Wf8TOtudwUMUrKkcYwi88ex +lrMNUer7ft2ELJhTqQRuvYjCYH6/IaDqMWqxJju4AQKBgQDPjOh75ykQc93SsYpt +Tb4gQKLeqOb57pofT8D44DccatfEgk31D4fBIIQu6XKopQmCtQyX9DUDjOWFTxuo +IMPysN6Fh1quCbC6Xt5xfKoaJG5yQYKeKtLhknwEW9SUifU2xVrOcPikLs7Iwmmp +BkDLsu/YKwRFSfrbYZXbTlU8tQ== +-----END PRIVATE KEY----- + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/tls/ssidEAP-TLS-keybundle.8021x b/autotests/testEAP/tls/ssidEAP-TLS-keybundle.8021x @@ -0,0 +1,9 @@ +[Security] +EAP-Method=TLS +EAP-TLS-CACert=/tmp/certs/cert-ca.pem +EAP-TLS-ClientKeyBundle=/tmp/certs/cert-client.p12 +EAP-TLS-ClientKeyPassphrase=abc +EAP-Identity=tls@example.com + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/tls/ssidEAP-TLS-keypass.8021x b/autotests/testEAP/tls/ssidEAP-TLS-keypass.8021x @@ -0,0 +1,10 @@ +[Security] +EAP-Method=TLS +EAP-TLS-CACert=/tmp/certs/cert-ca.pem +EAP-TLS-ClientCert=/tmp/certs/cert-client.pem +EAP-TLS-ClientKey=/tmp/certs/cert-client-key-md5-des.pem +EAP-TLS-ClientKeyPassphrase=abc +EAP-Identity=tls@example.com + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/tls/ssidEAP-TLS-nokeypass.8021x b/autotests/testEAP/tls/ssidEAP-TLS-nokeypass.8021x @@ -0,0 +1,9 @@ +[Security] +EAP-Method=TLS +EAP-TLS-CACert=/tmp/certs/cert-ca.pem +EAP-TLS-ClientCert=/tmp/certs/cert-client.pem +EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-Identity=tls@example.com + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/ttls/ssidEAP-TTLS-CHAP.8021x b/autotests/testEAP/ttls/ssidEAP-TTLS-CHAP.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=TTLS +EAP-Identity=ttls@example.com +EAP-TTLS-Phase2-Method=Tunneled-CHAP + +# If CHAP Identity and Password are left out, they will be requested through +# the agent. +#EAP-TTLS-Phase2-Identity=ttls-chap-phase2@example.com +#EAP-TTLS-Phase2-Password=Password + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/ttls/ssidEAP-TTLS-MD5.8021x b/autotests/testEAP/ttls/ssidEAP-TTLS-MD5.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=TTLS +EAP-Identity=ttls@example.com +EAP-TTLS-CACert=/tmp/certs/cert-ca.pem +EAP-TTLS-ClientCert=/tmp/certs/cert-client.pem +EAP-TTLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem +EAP-TTLS-Phase2-Method=MD5 +EAP-TTLS-Phase2-Identity=md5-phase2@example.com +EAP-TTLS-Phase2-Password=Password + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/ttls/ssidEAP-TTLS-MSCHAPV2.8021x b/autotests/testEAP/ttls/ssidEAP-TTLS-MSCHAPV2.8021x @@ -0,0 +1,8 @@ +[Security] +EAP-Method=TTLS +EAP-Identity=ttls@example.com +EAP-TTLS-CACert=/tmp/certs/cert-ca.pem +EAP-TTLS-ClientCert=/tmp/certs/cert-client.pem +EAP-TTLS-ClientKey=/tmp/certs/cert-client-key-v2-des-ede3.pem +EAP-TTLS-Phase2-Method=MSCHAPV2 +EAP-TTLS-Phase2-Identity=mschapv2-phase2@example.com diff --git a/autotests/testEAP/ttls/ssidEAP-TTLS-Tunneled-MSCHAP.8021x b/autotests/testEAP/ttls/ssidEAP-TTLS-Tunneled-MSCHAP.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=TTLS +EAP-Identity=ttls@example.com +EAP-TTLS-Phase2-Method=Tunneled-MSCHAP + +# If MSCHAP Identity and Password are left out, they will be requested through +# the agent. +#EAP-TTLS-Phase2-Identity=ttls-mschap-phase2@example.com +#EAP-TTLS-Phase2-Password=Password + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/ttls/ssidEAP-TTLS-Tunneled-MSCHAPV2.8021x b/autotests/testEAP/ttls/ssidEAP-TTLS-Tunneled-MSCHAPV2.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=TTLS +EAP-Identity=ttls@example.com +EAP-TTLS-Phase2-Method=Tunneled-MSCHAPv2 + +# If MSCHAP Identity and Password are left out, they will be requested through +# the agent. +#EAP-TTLS-Phase2-Identity=ttls-mschapv2-phase2@example.com +#EAP-TTLS-Phase2-Password=Password + +[Settings] +AutoConnect=False diff --git a/autotests/testEAP/ttls/ssidEAP-TTLS-Tunneled-PAP.8021x b/autotests/testEAP/ttls/ssidEAP-TTLS-Tunneled-PAP.8021x @@ -0,0 +1,12 @@ +[Security] +EAP-Method=TTLS +EAP-Identity=ttls@example.com +EAP-TTLS-Phase2-Method=Tunneled-PAP + +# If PAP Identity and Password are left out, they will be requested through +# the agent. +#EAP-TTLS-Phase2-Identity=ttls-pap@example.com +#EAP-TTLS-Phase2-Password=Password + +[Settings] +AutoConnect=False diff --git a/autotests/testFILS/fils_256_test.py b/autotests/testFILS/fils_256_test.py @@ -7,7 +7,6 @@ import os sys.path.append('../util') import iwd from iwd import IWD -from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI import testutil @@ -18,21 +17,9 @@ class Test(unittest.TestCase): wd = IWD(True) - psk_agent = PSKAgent('user@example.com', ('user@example.com', - 'secret123')) - wd.register_psk_agent(psk_agent) - devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidFILS-256') self.assertEqual(ordered_network.type, NetworkType.eap) @@ -70,8 +57,6 @@ class Test(unittest.TestCase): device.disconnect() - wd.unregister_psk_agent(psk_agent) - @classmethod def setUpClass(cls): IWD.copy_to_storage('ssidFILS-256.8021x') diff --git a/autotests/testFILS/fils_384_test.py b/autotests/testFILS/fils_384_test.py @@ -7,7 +7,6 @@ import os sys.path.append('../util') import iwd from iwd import IWD -from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI import testutil @@ -18,21 +17,9 @@ class Test(unittest.TestCase): wd = IWD(True) - psk_agent = PSKAgent('user@example.com', ('user@example.com', - 'secret123')) - wd.register_psk_agent(psk_agent) - devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidFILS-384') self.assertEqual(ordered_network.type, NetworkType.eap) @@ -70,8 +57,6 @@ class Test(unittest.TestCase): device.disconnect() - wd.unregister_psk_agent(psk_agent) - @classmethod def setUpClass(cls): IWD.copy_to_storage('ssidFILS-384.8021x') diff --git a/autotests/testFILS/pwd.eap_user b/autotests/testFILS/pwd.eap_user @@ -1 +0,0 @@ -"user@example.com" PWD "secret123" diff --git a/autotests/testFILS/radius.conf b/autotests/testFILS/radius.conf @@ -1,7 +1,7 @@ driver=none radius_server_clients=/tmp/certs/radius-clients.text radius_server_auth_port=1812 -eap_user_file=/tmp/pwd.eap_user +eap_user_file=/tmp/secrets/eap-user.text eap_server=0 eap_server_erp=1 diff --git a/autotests/testFILS/ssidFILS-256.8021x b/autotests/testFILS/ssidFILS-256.8021x @@ -1,2 +1,4 @@ [Security] EAP-Method=PWD +EAP-Identity=pwd@example.com +EAP-Password=Password diff --git a/autotests/testFILS/ssidFILS-384.8021x b/autotests/testFILS/ssidFILS-384.8021x @@ -1,2 +1,4 @@ [Security] EAP-Method=PWD +EAP-Identity=pwd@example.com +EAP-Password=Password diff --git a/autotests/testFT-8021x-roam/TestFT.8021x b/autotests/testFT-8021x-roam/TestFT.8021x @@ -3,7 +3,7 @@ EAP-Method=TLS EAP-TLS-CACert=/tmp/certs/cert-ca.pem EAP-TLS-ClientCert=/tmp/certs/cert-client.pem EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-Identity=abc@example.com +EAP-Identity=tls@example.com [Settings] AutoConnect=False diff --git a/autotests/testFT-8021x-roam/connection_test.py b/autotests/testFT-8021x-roam/connection_test.py @@ -4,56 +4,25 @@ import unittest import sys, os sys.path.append('../util') -import iwd from iwd import IWD from iwd import NetworkType -from hwsim import Hwsim from hostapd import HostapdCLI import testutil class Test(unittest.TestCase): def test_roam_success(self): - hwsim = Hwsim() - - rule0 = hwsim.rules.create() - rule0.source = self.bss_radio[0].addresses[0] - rule0.bidirectional = True - - rule1 = hwsim.rules.create() - rule1.source = self.bss_radio[1].addresses[0] - rule1.bidirectional = True - - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -6900 - wd = IWD(True) device = wd.list_devices(1)[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('TestFT') self.assertEqual(ordered_network.type, NetworkType.eap) - self.assertEqual(ordered_network.signal_strength, -2000) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) self.assertFalse(self.bss_hostapd[0].list_sta()) self.assertFalse(self.bss_hostapd[1].list_sta()) - ordered_network.network_object.connect() + device.connect_bssid(self.bss_hostapd[0].bssid) condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) @@ -64,15 +33,9 @@ class Test(unittest.TestCase): testutil.test_iface_operstate(device.name) testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) + (self.bss_hostapd[1].ifname, device.name, True, True)) - # Check that iwd starts transition to BSS 1 in less than 10 seconds. - # The 10 seconds is longer than needed to scan on just two channels - # but short enough that a full scan on the 2.4 + 5.8 bands supported - # by mac80211_hwsim will not finish. If this times out then, but - # device_roam_trigger_cb has happened, it probably means that - # Neighbor Reports are broken. - rule0.signal = -8000 + device.roam(self.bss_hostapd[1].bssid) condition = 'obj.state == DeviceState.roaming' wd.wait_for_object_condition(device, condition) @@ -88,7 +51,7 @@ class Test(unittest.TestCase): testutil.test_iface_operstate(device.name) testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[0].ifname, device.name)) + (self.bss_hostapd[0].ifname, device.name, True, True)) def tearDown(self): os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') @@ -96,20 +59,12 @@ class Test(unittest.TestCase): os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') - hwsim = Hwsim() - for rule in list(hwsim.rules.keys()): - del hwsim.rules[rule] - @classmethod def setUpClass(cls): IWD.copy_to_storage('TestFT.8021x') - hwsim = Hwsim() - cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'), HostapdCLI(config='ft-eap-ccmp-2.conf') ] - cls.bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1') ] # Set interface addresses to those expected by hostapd config files os.system('ifconfig "' + cls.bss_hostapd[0].ifname + @@ -136,7 +91,6 @@ class Test(unittest.TestCase): def tearDownClass(cls): IWD.clear_storage() cls.bss_hostapd = None - cls.bss_radio = None if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testFT-8021x-roam/ft-eap-ccmp-1.conf b/autotests/testFT-8021x-roam/ft-eap-ccmp-1.conf @@ -13,7 +13,7 @@ wpa_key_mgmt=FT-EAP wpa_pairwise=CCMP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testFT-8021x-roam/ft-eap-ccmp-2.conf b/autotests/testFT-8021x-roam/ft-eap-ccmp-2.conf @@ -13,7 +13,7 @@ wpa_key_mgmt=FT-EAP wpa_pairwise=CCMP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testFT-FILS-SHA256/TestFT.8021x b/autotests/testFT-FILS-SHA256/TestFT.8021x @@ -1,5 +0,0 @@ -[Security] -EAP-Method=PWD - -[Settings] -AutoConnect=False diff --git a/autotests/testFT-FILS-SHA256/connection_test.py b/autotests/testFT-FILS-SHA256/connection_test.py @@ -1,173 +0,0 @@ -#! /usr/bin/python3 - -import unittest -import sys, os - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -from hwsim import Hwsim -from hostapd import HostapdCLI -import testutil - -class Test(unittest.TestCase): - def test_roam_success(self): - hwsim = Hwsim() - - rule0 = hwsim.rules.create() - rule0.source = self.bss_radio[0].addresses[0] - rule0.bidirectional = True - - rule1 = hwsim.rules.create() - rule1.source = self.bss_radio[1].addresses[0] - rule1.bidirectional = True - - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -6900 - - wd = IWD(True) - - psk_agent = PSKAgent('user@example.com', ('user@example.com', - 'secret123')) - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('TestFT') - - self.assertEqual(ordered_network.type, NetworkType.eap) - self.assertEqual(ordered_network.signal_strength, -2000) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - self.assertFalse(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertTrue(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network = device.get_ordered_network('TestFT') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertTrue(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - # Check that iwd starts transition to BSS 1 in less than 10 seconds. - # The 10 seconds is longer than needed to scan on just two channels - # but short enough that a full scan on the 2.4 + 5.8 bands supported - # by mac80211_hwsim will not finish. If this times out then, but - # device_roam_trigger_cb has happened, it probably means that - # Neighbor Reports are broken. - rule0.signal = -8000 - - condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - # Check that iwd is on BSS 1 once out of roaming state and doesn't - # go through 'disconnected', 'autoconnect', 'connecting' in between - from_condition = 'obj.state == DeviceState.roaming' - to_condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_change(device, from_condition, to_condition) - - self.assertTrue(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[0].ifname, device.name)) - - def tearDown(self): - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') - - hwsim = Hwsim() - for rule in list(hwsim.rules.keys()): - del hwsim.rules[rule] - - @classmethod - def setUpClass(cls): - os.system('ifconfig lo up') - IWD.copy_to_storage('TestFT.8021x') - - hwsim = Hwsim() - - cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'), - HostapdCLI(config='ft-eap-ccmp-2.conf') ] - cls.bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1') ] - - # Set interface addresses to those expected by hostapd config files - os.system('ifconfig "' + cls.bss_hostapd[0].ifname + - '" down hw ether 12:00:00:00:00:01 up') - os.system('ifconfig "' + cls.bss_hostapd[1].ifname + - '" down hw ether 12:00:00:00:00:02 up') - - cls.bss_hostapd[0].reload() - cls.bss_hostapd[0].wait_for_event("AP-ENABLED") - cls.bss_hostapd[1].reload() - cls.bss_hostapd[1].wait_for_event("AP-ENABLED") - - # Fill in the neighbor AP tables in both BSSes. By default each - # instance knows only about current BSS, even inside one hostapd - # process. - # FT still works without the neighbor AP table but neighbor reports - # have to be disabled in the .conf files - cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', - '1200000000028f0000005102060603000000') - cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', - '1200000000018f0000005101060603000000') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - cls.bss_hostapd = None - cls.bss_radio = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testFT-FILS-SHA256/hw.conf b/autotests/testFT-FILS-SHA256/hw.conf @@ -1,8 +0,0 @@ -[SETUP] -num_radios=3 -start_iwd=0 - -[HOSTAPD] -rad0=ft-eap-ccmp-1.conf -rad1=ft-eap-ccmp-2.conf -radius_server=radius.conf diff --git a/autotests/testFT-FILS-SHA256/pwd.eap_user b/autotests/testFT-FILS-SHA256/pwd.eap_user @@ -1 +0,0 @@ -"user@example.com" PWD "secret123" diff --git a/autotests/testFT-FILS-SHA256/radius.conf b/autotests/testFT-FILS-SHA256/radius.conf @@ -1,15 +0,0 @@ -driver=none -radius_server_clients=/tmp/certs/radius-clients.text -radius_server_auth_port=1812 -eap_user_file=/tmp/pwd.eap_user -eap_server=0 -eap_server_erp=1 - -erp_send_reauth_start=1 -erp_domain=example.com -fils_realm=example.com -disable_pmksa_caching=1 - -pwd_group=19 -wpa_group_rekey=30 -wpa_ptk_rekey=30 diff --git a/autotests/testFT-FILS-SHA384/TestFT.8021x b/autotests/testFT-FILS-SHA384/TestFT.8021x @@ -1,5 +0,0 @@ -[Security] -EAP-Method=PWD - -[Settings] -AutoConnect=False diff --git a/autotests/testFT-FILS-SHA384/connection_test.py b/autotests/testFT-FILS-SHA384/connection_test.py @@ -1,174 +0,0 @@ -#! /usr/bin/python3 - -import unittest -import sys, os - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -from hwsim import Hwsim -from hostapd import HostapdCLI -import testutil - -class Test(unittest.TestCase): - def test_roam_success(self): - hwsim = Hwsim() - - rule0 = hwsim.rules.create() - rule0.source = self.bss_radio[0].addresses[0] - rule0.bidirectional = True - - rule1 = hwsim.rules.create() - rule1.source = self.bss_radio[1].addresses[0] - rule1.bidirectional = True - - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -6900 - - wd = IWD(True) - - psk_agent = PSKAgent('user@example.com', ('user@example.com', - 'secret123')) - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('TestFT') - - self.assertEqual(ordered_network.type, NetworkType.eap) - self.assertEqual(ordered_network.signal_strength, -2000) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - self.assertFalse(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertTrue(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network = device.get_ordered_network('TestFT') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertTrue(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - # Check that iwd starts transition to BSS 1 in less than 10 seconds. - # The 10 seconds is longer than needed to scan on just two channels - # but short enough that a full scan on the 2.4 + 5.8 bands supported - # by mac80211_hwsim will not finish. If this times out then, but - # device_roam_trigger_cb has happened, it probably means that - # Neighbor Reports are broken. - rule0.signal = -8000 - - condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - # Check that iwd is on BSS 1 once out of roaming state and doesn't - # go through 'disconnected', 'autoconnect', 'connecting' in between - from_condition = 'obj.state == DeviceState.roaming' - to_condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_change(device, from_condition, to_condition) - - self.assertTrue(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[0].ifname, device.name)) - - def tearDown(self): - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') - - hwsim = Hwsim() - for rule in list(hwsim.rules.keys()): - del hwsim.rules[rule] - - @classmethod - def setUpClass(cls): - os.system('ifconfig lo up') - IWD.copy_to_storage('TestFT.8021x') - - hwsim = Hwsim() - - cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'), - HostapdCLI(config='ft-eap-ccmp-2.conf') ] - cls.bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1') ] - - # Set interface addresses to those expected by hostapd config files - os.system('ifconfig "' + cls.bss_hostapd[0].ifname + - '" down hw ether 12:00:00:00:00:01 up') - os.system('ifconfig "' + cls.bss_hostapd[1].ifname + - '" down hw ether 12:00:00:00:00:02 up') - - cls.bss_hostapd[0].reload() - cls.bss_hostapd[0].wait_for_event("AP-ENABLED") - cls.bss_hostapd[1].reload() - cls.bss_hostapd[1].wait_for_event("AP-ENABLED") - - # Fill in the neighbor AP tables in both BSSes. By default each - # instance knows only about current BSS, even inside one hostapd - # process. - # FT still works without the neighbor AP table but neighbor reports - # have to be disabled in the .conf files - cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', - '1200000000028f0000005102060603000000') - cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', - '1200000000018f0000005101060603000000') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - cls.bss_hostapd = None - cls.bss_radio = None - - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testFT-FILS-SHA384/ft-eap-ccmp-1.conf b/autotests/testFT-FILS-SHA384/ft-eap-ccmp-1.conf @@ -1,42 +0,0 @@ -hw_mode=g -channel=1 -ssid=TestFT -utf8_ssid=1 -ctrl_interface=/var/run/hostapd -r1_key_holder=000000000001 -nas_identifier=dummy1 - -wpa=2 -# Can support WPA-EAP and FT-EAP (space separated list) at the same -# time but we want to force FT -wpa_key_mgmt=FT-EAP FILS-SHA384 FT-FILS-SHA384 -wpa_pairwise=CCMP -ieee8021x=1 - -fils_realm=example.com - -wpa_ptk_rekey=30 -wpa_group_rekey=80 -ieee80211w=1 -rsn_preauth=1 -disable_pmksa_caching=1 -# Allow PMK cache to be shared opportunistically among configured interfaces -# and BSSes (i.e., all configurations within a single hostapd process). -okc=1 -mobility_domain=1234 -reassociation_deadline=60000 -r0kh=12:00:00:00:00:01 nas1.w1.fi 000102030405060708090a0b0c0d0e0f -r0kh=12:00:00:00:00:02 nas2.w1.fi 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f -# Push mode only needed for 8021x, not PSK mode since msk already known -pmk_r1_push=1 -ft_over_ds=0 -ap_table_expiration_time=36000 -ap_table_max_size=10 -rrm_neighbor_report=1 - -auth_server_addr=127.0.0.1 -auth_server_port=1812 -auth_server_shared_secret=secret -nas_identifier=nas1.w1.fi diff --git a/autotests/testFT-FILS-SHA384/ft-eap-ccmp-2.conf b/autotests/testFT-FILS-SHA384/ft-eap-ccmp-2.conf @@ -1,42 +0,0 @@ -hw_mode=g -channel=2 -ssid=TestFT -utf8_ssid=1 -ctrl_interface=/var/run/hostapd -r1_key_holder=000000000002 -nas_identifier=dummy2 - -wpa=2 -# Can support WPA-EAP and FT-EAP (space separated list) at the same -# time but we want to force FT -wpa_key_mgmt=WPA-EAP FT-FILS-SHA384 -wpa_pairwise=CCMP -ieee8021x=1 - -fils_realm=example.com - -wpa_ptk_rekey=30 -wpa_group_rekey=80 -ieee80211w=1 -rsn_preauth=1 -disable_pmksa_caching=1 -# Allow PMK cache to be shared opportunistically among configured interfaces -# and BSSes (i.e., all configurations within a single hostapd process). -okc=1 -mobility_domain=1234 -reassociation_deadline=60000 -r0kh=12:00:00:00:00:01 nas1.w1.fi 000102030405060708090a0b0c0d0e0f -r0kh=12:00:00:00:00:02 nas2.w1.fi 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f -# Push mode only needed for 8021x, not PSK mode since msk already known -pmk_r1_push=1 -ft_over_ds=0 -ap_table_expiration_time=36000 -ap_table_max_size=10 -rrm_neighbor_report=1 - -auth_server_addr=127.0.0.1 -auth_server_port=1812 -auth_server_shared_secret=secret -nas_identifier=nas2.w1.fi diff --git a/autotests/testFT-FILS-SHA384/hw.conf b/autotests/testFT-FILS-SHA384/hw.conf @@ -1,8 +0,0 @@ -[SETUP] -num_radios=3 -start_iwd=0 - -[HOSTAPD] -rad0=ft-eap-ccmp-1.conf -rad1=ft-eap-ccmp-2.conf -radius_server=radius.conf diff --git a/autotests/testFT-FILS-SHA384/pwd.eap_user b/autotests/testFT-FILS-SHA384/pwd.eap_user @@ -1 +0,0 @@ -"user@example.com" PWD "secret123" diff --git a/autotests/testFT-FILS-SHA384/radius.conf b/autotests/testFT-FILS-SHA384/radius.conf @@ -1,15 +0,0 @@ -driver=none -radius_server_clients=/tmp/certs/radius-clients.text -radius_server_auth_port=1812 -eap_user_file=/tmp/pwd.eap_user -eap_server=0 -eap_server_erp=1 - -erp_send_reauth_start=1 -erp_domain=example.com -fils_realm=example.com -disable_pmksa_caching=1 - -pwd_group=19 -wpa_group_rekey=30 -wpa_ptk_rekey=30 diff --git a/autotests/testFT-FILS/TestFT.8021x b/autotests/testFT-FILS/TestFT.8021x @@ -0,0 +1,7 @@ +[Security] +EAP-Method=PWD +EAP-Identity=pwd@example.com +EAP-Password=Password + +[Settings] +AutoConnect=False diff --git a/autotests/testFT-FILS/connection_test.py b/autotests/testFT-FILS/connection_test.py @@ -0,0 +1,166 @@ +#! /usr/bin/python3 + +import unittest +import sys, os + +sys.path.append('../util') +from iwd import IWD +from iwd import NetworkType +from hostapd import HostapdCLI +import testutil + +class Test(unittest.TestCase): + def validate_connection(self, wd): + device = wd.list_devices(1)[0] + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + # Scanning is unavoidable in this case since both FILS-SHA256 and + # FILS-SHA384 are tested. Without a new scan the cached scan results + # would cause IWD to choose an incorrect AKM for the second test. + device.scan() + + condition = 'obj.scanning' + wd.wait_for_object_condition(device, condition) + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + ordered_network = device.get_ordered_network('TestFT') + + self.assertEqual(ordered_network.type, NetworkType.eap) + + self.assertFalse(self.bss_hostapd[0].list_sta()) + self.assertFalse(self.bss_hostapd[1].list_sta()) + + device.connect_bssid(self.bss_hostapd[0].bssid) + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + self.assertTrue(self.bss_hostapd[0].list_sta()) + self.assertFalse(self.bss_hostapd[1].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[1].ifname, device.name, True, True)) + + device.disconnect() + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + ordered_network = device.get_ordered_network('TestFT') + + self.assertEqual(ordered_network.type, NetworkType.eap) + + # TODO: verify FILS was actually used on this second connection + device.connect_bssid(self.bss_hostapd[0].bssid) + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + self.assertTrue(self.bss_hostapd[0].list_sta()) + self.assertFalse(self.bss_hostapd[1].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[1].ifname, device.name, True, True)) + + # Check that iwd starts transition to BSS 1 in less than 10 seconds. + # The 10 seconds is longer than needed to scan on just two channels + # but short enough that a full scan on the 2.4 + 5.8 bands supported + # by mac80211_hwsim will not finish. If this times out then, but + # device_roam_trigger_cb has happened, it probably means that + # Neighbor Reports are broken. + #rule0.signal = -8000 + device.roam(self.bss_hostapd[1].bssid) + + condition = 'obj.state == DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + # Check that iwd is on BSS 1 once out of roaming state and doesn't + # go through 'disconnected', 'autoconnect', 'connecting' in between + from_condition = 'obj.state == DeviceState.roaming' + to_condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_change(device, from_condition, to_condition) + + self.assertTrue(self.bss_hostapd[1].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[0].ifname, device.name, True, True)) + + def test_fils_ft_roam_sha256(self): + wd = IWD(True) + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-EAP FILS-SHA256 FT-FILS-SHA256') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-EAP FILS-SHA256 FT-FILS-SHA256') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + + self.validate_connection(wd) + + def test_fils_ft_roam_sha384(self): + wd = IWD(True) + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-EAP FILS-SHA384 FT-FILS-SHA384') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-EAP FILS-SHA384 FT-FILS-SHA384') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + + self.validate_connection(wd) + + def tearDown(self): + os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') + os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') + os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') + os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') + + @classmethod + def setUpClass(cls): + os.system('ifconfig lo up') + IWD.copy_to_storage('TestFT.8021x') + + cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'), + HostapdCLI(config='ft-eap-ccmp-2.conf') ] + + # Set interface addresses to those expected by hostapd config files + os.system('ifconfig "' + cls.bss_hostapd[0].ifname + + '" down hw ether 12:00:00:00:00:01 up') + os.system('ifconfig "' + cls.bss_hostapd[1].ifname + + '" down hw ether 12:00:00:00:00:02 up') + + cls.bss_hostapd[0].reload() + cls.bss_hostapd[0].wait_for_event("AP-ENABLED") + cls.bss_hostapd[1].reload() + cls.bss_hostapd[1].wait_for_event("AP-ENABLED") + + # Fill in the neighbor AP tables in both BSSes. By default each + # instance knows only about current BSS, even inside one hostapd + # process. + # FT still works without the neighbor AP table but neighbor reports + # have to be disabled in the .conf files + cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', + '1200000000028f0000005102060603000000') + cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', + '1200000000018f0000005101060603000000') + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + cls.bss_hostapd = None + #cls.bss_radio = None + +if __name__ == '__main__': + unittest.main(exit=True) diff --git a/autotests/testFT-FILS-SHA256/ft-eap-ccmp-1.conf b/autotests/testFT-FILS/ft-eap-ccmp-1.conf diff --git a/autotests/testFT-FILS-SHA256/ft-eap-ccmp-2.conf b/autotests/testFT-FILS/ft-eap-ccmp-2.conf diff --git a/autotests/testFT-FILS/hw.conf b/autotests/testFT-FILS/hw.conf @@ -0,0 +1,9 @@ +[SETUP] +num_radios=3 +start_iwd=0 +hwsim_medium=yes + +[HOSTAPD] +rad0=ft-eap-ccmp-1.conf +rad1=ft-eap-ccmp-2.conf +radius_server=radius.conf diff --git a/autotests/testFT-FILS-SHA256/main.conf b/autotests/testFT-FILS/main.conf diff --git a/autotests/testFT-FILS/radius.conf b/autotests/testFT-FILS/radius.conf @@ -0,0 +1,15 @@ +driver=none +radius_server_clients=/tmp/certs/radius-clients.text +radius_server_auth_port=1812 +eap_user_file=/tmp/secrets/eap-user.text +eap_server=0 +eap_server_erp=1 + +erp_send_reauth_start=1 +erp_domain=example.com +fils_realm=example.com +disable_pmksa_caching=1 + +pwd_group=19 +wpa_group_rekey=30 +wpa_ptk_rekey=30 diff --git a/autotests/testFT-PSK-over-DS/connection_test.py b/autotests/testFT-PSK-over-DS/connection_test.py @@ -1,151 +0,0 @@ -#! /usr/bin/python3 - -import unittest -import sys, os - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -from hwsim import Hwsim -from hostapd import HostapdCLI -import testutil - -class Test(unittest.TestCase): - def test_roam_success(self): - hwsim = Hwsim() - - rule0 = hwsim.rules.create() - rule0.source = self.bss_radio[0].addresses[0] - rule0.bidirectional = True - - rule1 = hwsim.rules.create() - rule1.source = self.bss_radio[1].addresses[0] - rule1.bidirectional = True - - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -6900 - - wd = IWD(True) - - psk_agent = PSKAgent("EasilyGuessedPassword") - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('TestFT') - - self.assertEqual(ordered_network.type, NetworkType.psk) - self.assertEqual(ordered_network.signal_strength, -2000) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - self.assertFalse(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.bss_hostapd[0].wait_for_event('AP-STA-CONNECTED %s' % device.address) - - # list_sta actually reports any authenticated stations. Due to the - # nature of FT-over-DS IWD should authenticate to all stations with - # the same mobility domain. This means both APs should show our station. - self.assertTrue(self.bss_hostapd[0].list_sta()) - self.assertTrue(self.bss_hostapd[1].list_sta()) - - wd.unregister_psk_agent(psk_agent) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - # Check that iwd starts transition to BSS 1 in less than 10 seconds. - # The 10 seconds is longer than needed to scan on just two channels - # but short enough that a full scan on the 2.4 + 5.8 bands supported - # by mac80211_hwsim will not finish. If this times out then, but - # device_roam_trigger_cb has happened, it probably means that - # Neighbor Reports are broken. - rule0.signal = -8000 - - condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - # Check that iwd is on BSS 1 once out of roaming state and doesn't - # go through 'disconnected', 'autoconnect', 'connecting' in between - from_condition = 'obj.state == DeviceState.roaming' - to_condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_change(device, from_condition, to_condition) - - self.assertTrue(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[0].ifname, device.name)) - - def tearDown(self): - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') - - hwsim = Hwsim() - for rule in list(hwsim.rules.keys()): - del hwsim.rules[rule] - - @classmethod - def setUpClass(cls): - hwsim = Hwsim() - - cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] - cls.bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1') ] - - # Set interface addresses to those expected by hostapd config files - os.system('ifconfig "' + cls.bss_hostapd[0].ifname + - '" down hw ether 12:00:00:00:00:01 up') - os.system('ifconfig "' + cls.bss_hostapd[1].ifname + - '" down hw ether 12:00:00:00:00:02 up') - - cls.bss_hostapd[0].reload() - cls.bss_hostapd[0].wait_for_event("AP-ENABLED") - cls.bss_hostapd[1].reload() - cls.bss_hostapd[1].wait_for_event("AP-ENABLED") - - # Fill in the neighbor AP tables in both BSSes. By default each - # instance knows only about current BSS, even inside one hostapd - # process. - # FT still works without the neighbor AP table but neighbor reports - # have to be disabled in the .conf files - cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', - '1200000000028f0000005102060603000000') - cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', - '1200000000018f0000005101060603000000') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - cls.bss_hostapd = None - cls.bss_radio = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testFT-PSK-over-DS/ft-psk-ccmp-1.conf b/autotests/testFT-PSK-over-DS/ft-psk-ccmp-1.conf @@ -1,41 +0,0 @@ -hw_mode=g -channel=1 -ssid=TestFT -utf8_ssid=1 -ctrl_interface=/var/run/hostapd - -r1_key_holder=120000000001 -nas_identifier=dummy1 - -wpa=2 -# Can support WPA-PSK and FT-PSK (space separated list) and/or EAP at the same -# time but we want to force FT -wpa_key_mgmt=FT-PSK -wpa_pairwise=CCMP -wpa_passphrase=EasilyGuessedPassword -wpa_ptk_rekey=30 -wpa_group_rekey=80 -ieee80211w=1 -rsn_preauth=1 -rsn_preauth_interfaces=lo -disable_pmksa_caching=0 -# Allow PMK cache to be shared opportunistically among configured interfaces -# and BSSes (i.e., all configurations within a single hostapd process). -okc=1 -mobility_domain=1234 -reassociation_deadline=60000 -r0kh=12:00:00:00:00:01 dummy1 000102030405060708090a0b0c0d0e0f -r0kh=12:00:00:00:00:02 dummy2 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f -# Push mode only needed for 8021x, not PSK mode since msk already known -pmk_r1_push=0 -# Allow locally generated FT response so we don't have to configure push/pull -# between BSSes running as separate hostapd processes as in the test-runner -# case. Only works with FT-PSK, otherwise brctl needs to be installed and -# CONFIG_BRIDGE enabled in the kernel. -ft_psk_generate_local=1 -ft_over_ds=1 -ap_table_expiration_time=36000 -ap_table_max_size=10 -rrm_neighbor_report=1 diff --git a/autotests/testFT-PSK-over-DS/ft-psk-ccmp-2.conf b/autotests/testFT-PSK-over-DS/ft-psk-ccmp-2.conf @@ -1,41 +0,0 @@ -hw_mode=g -channel=2 -ssid=TestFT -utf8_ssid=1 -ctrl_interface=/var/run/hostapd - -r1_key_holder=120000000002 -nas_identifier=dummy2 - -wpa=2 -# Can support WPA-PSK and FT-PSK (space separated list) and/or EAP at the same -# time but we want to force FT -wpa_key_mgmt=FT-PSK -wpa_pairwise=CCMP -wpa_passphrase=EasilyGuessedPassword -wpa_ptk_rekey=30 -wpa_group_rekey=80 -ieee80211w=1 -rsn_preauth=1 -rsn_preauth_interfaces=lo -disable_pmksa_caching=0 -# Allow PMK cache to be shared opportunistically among configured interfaces -# and BSSes (i.e., all configurations within a single hostapd process). -okc=1 -mobility_domain=1234 -reassociation_deadline=60000 -r0kh=12:00:00:00:00:01 dummy1 000102030405060708090a0b0c0d0e0f -r0kh=12:00:00:00:00:02 dummy2 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f -r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f -# Push mode only needed for 8021x, not PSK mode since msk already known -pmk_r1_push=0 -# Allow locally generated FT response so we don't have to configure push/pull -# between BSSes running as separate hostapd processes as in the test-runner -# case. Only works with FT-PSK, otherwise brctl needs to be installed and -# CONFIG_BRIDGE enabled in the kernel. -ft_psk_generate_local=1 -ft_over_ds=1 -ap_table_expiration_time=36000 -ap_table_max_size=10 -rrm_neighbor_report=1 diff --git a/autotests/testFT-PSK-over-DS/hw.conf b/autotests/testFT-PSK-over-DS/hw.conf @@ -1,7 +0,0 @@ -[SETUP] -num_radios=3 -start_iwd=0 - -[HOSTAPD] -rad0=ft-psk-ccmp-1.conf -rad1=ft-psk-ccmp-2.conf diff --git a/autotests/testFT-PSK-roam/connection_test.py b/autotests/testFT-PSK-roam/connection_test.py @@ -1,165 +0,0 @@ -#! /usr/bin/python3 - -import unittest -import sys, os - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -from hwsim import Hwsim -from hostapd import HostapdCLI -import testutil - -class Test(unittest.TestCase): - def test_roam_success(self): - hwsim = Hwsim() - - rule0 = hwsim.rules.create() - rule0.source = self.bss_radio[0].addresses[0] - rule0.bidirectional = True - - rule1 = hwsim.rules.create() - rule1.source = self.bss_radio[1].addresses[0] - rule1.bidirectional = True - - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -2500 - - wd = IWD(True) - - psk_agent = PSKAgent("EasilyGuessedPassword") - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('TestFT') - - self.assertEqual(ordered_network.type, NetworkType.psk) - self.assertEqual(ordered_network.signal_strength, -2000) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - self.assertFalse(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertTrue(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - wd.unregister_psk_agent(psk_agent) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - # Check that iwd starts transition to BSS 1 in less than 10 seconds. - # The 10 seconds is longer than needed to scan on just two channels - # but short enough that a full scan on the 2.4 + 5.8 bands supported - # by mac80211_hwsim will not finish. If this times out then, but - # device_roam_trigger_cb has happened, it probably means that - # Neighbor Reports are broken. - rule0.signal = -8000 - - condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - # Check that iwd is on BSS 1 once out of roaming state and doesn't - # go through 'disconnected', 'autoconnect', 'connecting' in between - from_condition = 'obj.state == DeviceState.roaming' - to_condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_change(device, from_condition, to_condition) - - self.assertTrue(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[0].ifname, device.name)) - - rule0.signal = -2000 - rule1.signal = -8000 - - condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - # Check that iwd is on BSS 0 once out of roaming state and doesn't - # go through 'disconnected', 'autoconnect', 'connecting' in between - from_condition = 'obj.state == DeviceState.roaming' - to_condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_change(device, from_condition, to_condition) - - self.assertTrue(self.bss_hostapd[0].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - def tearDown(self): - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') - - hwsim = Hwsim() - for rule in list(hwsim.rules.keys()): - del hwsim.rules[rule] - - @classmethod - def setUpClass(cls): - hwsim = Hwsim() - - cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] - cls.bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1') ] - - # Set interface addresses to those expected by hostapd config files - os.system('ifconfig "' + cls.bss_hostapd[0].ifname + - '" down hw ether 12:00:00:00:00:01 up') - os.system('ifconfig "' + cls.bss_hostapd[1].ifname + - '" down hw ether 12:00:00:00:00:02 up') - - cls.bss_hostapd[0].reload() - cls.bss_hostapd[0].wait_for_event("AP-ENABLED") - cls.bss_hostapd[1].reload() - cls.bss_hostapd[1].wait_for_event("AP-ENABLED") - - # Fill in the neighbor AP tables in both BSSes. By default each - # instance knows only about current BSS, even inside one hostapd - # process. - # FT still works without the neighbor AP table but neighbor reports - # have to be disabled in the .conf files - cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', - '1200000000028f0000005102060603000000') - cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', - '1200000000018f0000005101060603000000') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - cls.bss_hostapd = None - cls.bss_radio = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testFT-PSK-roam/hw.conf b/autotests/testFT-PSK-roam/hw.conf @@ -1,7 +0,0 @@ -[SETUP] -num_radios=3 -start_iwd=0 - -[HOSTAPD] -rad0=ft-psk-ccmp-1.conf -rad1=ft-psk-ccmp-2.conf diff --git a/autotests/testFT-SAE-roam/connection_test.py b/autotests/testFT-SAE-roam/connection_test.py @@ -1,194 +0,0 @@ -#! /usr/bin/python3 - -import unittest -import sys, os - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -from hwsim import Hwsim -from hostapd import HostapdCLI -import testutil -from config import ctx - -class Test(unittest.TestCase): - def test_roam_success(self): - hwsim = Hwsim() - - rule0 = hwsim.rules.create() - rule0.source = self.bss_radio[0].addresses[0] - rule0.bidirectional = True - - rule1 = hwsim.rules.create() - rule1.source = self.bss_radio[1].addresses[0] - rule1.bidirectional = True - - rule2 = hwsim.rules.create() - rule2.source = self.bss_radio[2].addresses[0] - rule2.bidirectional = True - - # Check that iwd selects BSS 0 first - rule0.signal = -2000 - rule1.signal = -6900 - rule2.signal = -7200 - - wd = IWD(True) - - psk_agent = PSKAgent("EasilyGuessedPassword") - wd.register_psk_agent(psk_agent) - - device = wd.list_devices(1)[0] - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('TestFT') - - self.assertEqual(ordered_network.type, NetworkType.psk) - self.assertEqual(ordered_network.signal_strength, -2000) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - self.assertFalse(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - ordered_network.network_object.connect() - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - self.assertTrue(self.bss_hostapd[0].list_sta()) - self.assertFalse(self.bss_hostapd[1].list_sta()) - - wd.unregister_psk_agent(psk_agent) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - # Check that iwd starts transition to BSS 1 in less than 10 seconds. - # The 10 seconds is longer than needed to scan on just two channels - # but short enough that a full scan on the 2.4 + 5.8 bands supported - # by mac80211_hwsim will not finish. If this times out then, but - # device_roam_trigger_cb has happened, it probably means that - # Neighbor Reports are broken. - rule0.signal = -8000 - - condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - # Check that iwd is on BSS 1 once out of roaming state and doesn't - # go through 'disconnected', 'autoconnect', 'connecting' in between - from_condition = 'obj.state == DeviceState.roaming' - to_condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_change(device, from_condition, to_condition) - - rule1.signal = -2000 - - # wait for IWD's signal levels to recover - wd.wait(5) - - self.assertTrue(self.bss_hostapd[1].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[0].ifname, device.name)) - - # test FT-PSK after FT-SAE - rule1.signal = -8000 - rule0.signal = -8000 - rule2.signal = -1000 - - condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - condition = 'obj.state != DeviceState.roaming' - wd.wait_for_object_condition(device, condition) - - self.assertEqual(device.state, iwd.DeviceState.connected) - self.assertTrue(self.bss_hostapd[2].list_sta()) - - testutil.test_iface_operstate(device.name) - testutil.test_ifaces_connected(self.bss_hostapd[2].ifname, device.name) - self.assertRaises(Exception, testutil.test_ifaces_connected, - (self.bss_hostapd[1].ifname, device.name)) - - def tearDown(self): - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[2].ifname + '" down') - os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') - os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') - os.system('ifconfig "' + self.bss_hostapd[2].ifname + '" up') - - hwsim = Hwsim() - for rule in list(hwsim.rules.keys()): - del hwsim.rules[rule] - - @classmethod - def setUpClass(cls): - hwsim = Hwsim() - - cls.bss_hostapd = [ HostapdCLI(config='ft-sae-1.conf'), - HostapdCLI(config='ft-sae-2.conf'), - HostapdCLI(config='ft-psk-3.conf') ] - cls.bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1'), - hwsim.get_radio('rad2') ] - - ctx.start_process(['ifconfig', cls.bss_hostapd[0].ifname, 'down', 'hw', \ - 'ether', '12:00:00:00:00:01', 'up'], wait=True) - ctx.start_process(['ifconfig', cls.bss_hostapd[1].ifname, 'down', 'hw', \ - 'ether', '12:00:00:00:00:02', 'up'], wait=True) - ctx.start_process(['ifconfig', cls.bss_hostapd[2].ifname, 'down', 'hw', \ - 'ether', '12:00:00:00:00:03', 'up'], wait=True) - - # Set interface addresses to those expected by hostapd config files - cls.bss_hostapd[0].reload() - cls.bss_hostapd[0].wait_for_event("AP-ENABLED") - cls.bss_hostapd[1].reload() - cls.bss_hostapd[1].wait_for_event("AP-ENABLED") - cls.bss_hostapd[2].reload() - cls.bss_hostapd[2].wait_for_event("AP-ENABLED") - - # Fill in the neighbor AP tables in both BSSes. By default each - # instance knows only about current BSS, even inside one hostapd - # process. - # FT still works without the neighbor AP table but neighbor reports - # have to be disabled in the .conf files - cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', - '1200000000028f0000005102060603000000') - cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:03', 'TestFT', - '1200000000038f0000005102060603000000') - - cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', - '1200000000018f0000005101060603000000') - cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:03', 'TestFT', - '1200000000038f0000005101060603000000') - - cls.bss_hostapd[2].set_neighbor('12:00:00:00:00:01', 'TestFT', - '1200000000018f0000005101060603000000') - cls.bss_hostapd[2].set_neighbor('12:00:00:00:00:02', 'TestFT', - '1200000000028f0000005101060603000000') - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - cls.bss_hostapd = None - cls.bss_radio = None - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testFT-SAE-roam/main.conf b/autotests/testFT-SAE-roam/main.conf @@ -1,2 +0,0 @@ -[Scan] -DisableMacAddressRandomization=true diff --git a/autotests/testHT-VHT/connection_test.py b/autotests/testHT-VHT/connection_test.py @@ -25,7 +25,11 @@ class Test(unittest.TestCase): condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('testSSID') + # + # Scanning must be explicitly done to get updated RSSI values. Therefore + # scan_if_needed is set false because of the previous scan. + # + ordered_network = device.get_ordered_network('testSSID', scan_if_needed=False) self.assertEqual(ordered_network.type, NetworkType.psk) @@ -62,16 +66,19 @@ class Test(unittest.TestCase): rule0.source = vht_radio.addresses[0] rule0.bidirectional = True rule0.signal = -5100 + rule0.enabled = True rule1 = hwsim.rules.create() rule1.source = ht_radio.addresses[0] rule1.bidirectional = True rule1.signal = -5200 + rule1.enabled = True rule2 = hwsim.rules.create() rule2.source = non_ht_radio.addresses[0] rule2.bidirectional = True rule2.signal = -5300 + rule2.enabled = True wd = IWD() diff --git a/autotests/testHT-VHT/ht.conf b/autotests/testHT-VHT/ht.conf @@ -9,3 +9,4 @@ wpa_passphrase=secret123 ieee80211n=1 channel=36 +beacon_int=10 diff --git a/autotests/testHT-VHT/hw.conf b/autotests/testHT-VHT/hw.conf @@ -1,6 +1,7 @@ [SETUP] num_radios=4 reg_domain=US +hwsim_medium=yes [HOSTAPD] rad0=non-ht-vht.conf diff --git a/autotests/testHT-VHT/non-ht-vht.conf b/autotests/testHT-VHT/non-ht-vht.conf @@ -6,3 +6,4 @@ ssid=testSSID wpa=2 wpa_pairwise=CCMP wpa_passphrase=secret123 +beacon_int=10 diff --git a/autotests/testHT-VHT/vht.conf b/autotests/testHT-VHT/vht.conf @@ -12,3 +12,4 @@ ieee80211n=1 ieee80211ac=1 channel=36 +beacon_int=10 diff --git a/autotests/testHiddenNetworks/connect_after_hidden_connect_test.py b/autotests/testHiddenNetworks/connect_after_hidden_connect_test.py @@ -33,8 +33,7 @@ class TestConnectionAfterHiddenNetwork(unittest.TestCase): wd.register_psk_agent(psk_agent) device = wd.list_devices(1)[0] - ordered_network = device.get_ordered_network('ssidOpen', - scan_if_needed=True) + ordered_network = device.get_ordered_network('ssidOpen') device.connect_hidden_network_async(name='ssidSomeHidden', reply_handler = self._success, diff --git a/autotests/testHiddenNetworks/hw.conf b/autotests/testHiddenNetworks/hw.conf @@ -1,7 +1,6 @@ [SETUP] num_radios=7 start_iwd=0 -hwsim_medium=no [HOSTAPD] rad0=ssidHiddenOpen.conf diff --git a/autotests/testHiddenNetworks/validation.py b/autotests/testHiddenNetworks/validation.py @@ -48,11 +48,13 @@ class TestConnectAutoConnect(unittest.TestCase): devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] + device.autoconnect = autoconnect if autoconnect: self.check_autoconnect_hidden_network(wd, device, ssid, throws) else: if wait_periodic_scan: + device.autoconnect = True condition = 'obj.scanning' wd.wait_for_object_condition(device, condition) condition = 'not obj.scanning' diff --git a/autotests/testHotspot/anqp_delay_test.py b/autotests/testHotspot/anqp_delay_test.py @@ -1,86 +0,0 @@ -#!/usr/bin/python3 - -import unittest -import sys -import os - -sys.path.append('../util') -import iwd -from iwd import IWD -from iwd import PSKAgent -from iwd import NetworkType -from hostapd import HostapdCLI -from hwsim import Hwsim -import testutil -from time import sleep - -class Test(unittest.TestCase): - - def test_connection_success(self): - hwsim = Hwsim() - - bss_radio = hwsim.get_radio('rad0') - rule0 = hwsim.rules.create() - rule0.source = bss_radio.addresses[0] - rule0.bidirectional = True - - wd = IWD(True) - - hapd = HostapdCLI(config='ssidHotspot.conf') - - psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) - wd.register_psk_agent(psk_agent) - - devices = wd.list_devices(1) - device = devices[0] - - # We are dependent on a periodic scan here. We want to wait for this - # because this is the first opportunity IWD has to do ANQP. Once ANQP - # has been done once the network is set up and we cannot simulate the - # 'Connect() before ANQP' race condition anymore. - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('Hotspot') - - self.assertEqual(ordered_network.type, NetworkType.eap) - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - # Force the case where ANQP does not finish before Connect() comes in - rule0.delay = 100 - - ordered_network.network_object.connect() - - rule0.delay = 1 - - condition = 'obj.state == DeviceState.connected' - wd.wait_for_object_condition(device, condition) - - testutil.test_iface_operstate() - testutil.test_ifaces_connected(device.name, hapd.ifname) - - device.disconnect() - - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) - - wd.unregister_psk_agent(psk_agent) - - @classmethod - def setUpClass(cls): - IWD.copy_to_hotspot('example.conf') - conf = '[General]\nDisableANQP=0\n' - os.system('echo "%s" > /tmp/main.conf' % conf) - - @classmethod - def tearDownClass(cls): - IWD.clear_storage() - os.remove('/tmp/main.conf') - -if __name__ == '__main__': - unittest.main(exit=True) diff --git a/autotests/testHotspot/anqp_disabled.conf b/autotests/testHotspot/anqp_disabled.conf @@ -0,0 +1,5 @@ +[General] +DisableANQP=1 + +[Scan] +DisableMacAddressRandomization=true diff --git a/autotests/testHotspot/anqp_enabled.conf b/autotests/testHotspot/anqp_enabled.conf @@ -0,0 +1,5 @@ +[General] +DisableANQP=0 + +[Scan] +DisableMacAddressRandomization=true diff --git a/autotests/testHotspot/autoconnect_test.py b/autotests/testHotspot/autoconnect_test.py @@ -5,8 +5,8 @@ import sys import os sys.path.append('../util') -import iwd from iwd import IWD +from iwd import IWD_CONFIG_DIR from iwd import NetworkType from hostapd import HostapdCLI import testutil @@ -14,7 +14,7 @@ import testutil class Test(unittest.TestCase): def test_connection_success(self): - wd = IWD(True, '/tmp') + wd = self.wd hapd_hotspot = HostapdCLI(config='ssidHotspot.conf') hapd_wpa = HostapdCLI(config='ssidWPA2-1.conf') @@ -23,6 +23,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] + device.autoconnect = True condition = 'obj.scanning' wd.wait_for_object_condition(device, condition) @@ -108,13 +109,16 @@ class Test(unittest.TestCase): def setUpClass(cls): IWD.copy_to_hotspot('autoconnect.conf') IWD.copy_to_storage('ssidWPA2-1.psk') - conf = '[General]\nDisableANQP=0\n' - os.system('echo "%s" > /tmp/main.conf' % conf) + IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf') + + cls.wd = IWD(True) @classmethod def tearDownClass(cls): IWD.clear_storage() os.remove('/tmp/main.conf') + cls.wd = None + if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testHotspot/hessid_test.py b/autotests/testHotspot/hessid_test.py @@ -5,8 +5,8 @@ import sys import os sys.path.append('../util') -import iwd from iwd import IWD +from iwd import IWD_CONFIG_DIR from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI @@ -15,7 +15,7 @@ import testutil class Test(unittest.TestCase): def test_connection_success(self): - wd = IWD(True, '/tmp') + wd = self.wd hapd = HostapdCLI(config='ssidHotspot.conf') @@ -25,14 +25,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('Hotspot') self.assertEqual(ordered_network.type, NetworkType.eap) @@ -58,13 +50,16 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): IWD.copy_to_hotspot('hessid.conf') - conf = '[General]\nDisableANQP=1\n' - os.system('echo "%s" > /tmp/main.conf' % conf) + IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf') + + cls.wd = IWD(True) @classmethod def tearDownClass(cls): IWD.clear_storage() os.remove('/tmp/main.conf') + cls.wd = None + if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testHotspot/hotspot_test.py b/autotests/testHotspot/hotspot_test.py @@ -5,8 +5,8 @@ import sys import os sys.path.append('../util') -import iwd from iwd import IWD +from iwd import IWD_CONFIG_DIR from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI @@ -15,7 +15,7 @@ import testutil class Test(unittest.TestCase): def test_connection_success(self): - wd = IWD(True, '/tmp') + wd = self.wd hapd = HostapdCLI(config='ssidHotspot.conf') @@ -25,14 +25,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('Hotspot') self.assertEqual(ordered_network.type, NetworkType.eap) @@ -58,13 +50,16 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): IWD.copy_to_hotspot('example.conf') - conf = '[General]\nDisableANQP=0\n' - os.system('echo "%s" > /tmp/main.conf' % conf) + IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf') + + cls.wd = IWD(True) @classmethod def tearDownClass(cls): IWD.clear_storage() os.remove('/tmp/main.conf') + cls.wd = None + if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testHotspot/hw.conf b/autotests/testHotspot/hw.conf @@ -1,6 +1,7 @@ [SETUP] num_radios=6 start_iwd=0 +hwsim_medium=yes [HOSTAPD] rad0=ssidHotspot.conf diff --git a/autotests/testHotspot/roaming_test.py b/autotests/testHotspot/roaming_test.py @@ -5,8 +5,8 @@ import sys import os sys.path.append('../util') -import iwd from iwd import IWD +from iwd import IWD_CONFIG_DIR from iwd import PSKAgent from iwd import NetworkType from hostapd import HostapdCLI @@ -15,24 +15,13 @@ import testutil class Test(unittest.TestCase): def test_connection_success(self): - wd = IWD(True, '/tmp') + wd = self.wd hapd = HostapdCLI(config='ssidHotspot.conf') - psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) - wd.register_psk_agent(psk_agent) - devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('Hotspot') self.assertEqual(ordered_network.type, NetworkType.eap) @@ -53,18 +42,22 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) - wd.unregister_psk_agent(psk_agent) - @classmethod def setUpClass(cls): IWD.copy_to_hotspot('roaming.conf') - conf = '[General]\nDisableANQP=1\n' - os.system('echo "%s" > /tmp/main.conf' % conf) + IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf') + + cls.wd = IWD(True) + cls.psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) + cls.wd.register_psk_agent(cls.psk_agent) @classmethod def tearDownClass(cls): IWD.clear_storage() os.remove('/tmp/main.conf') + cls.wd.unregister_psk_agent(cls.psk_agent) + cls.wd = None + if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testHotspot/ssidHotspot.conf b/autotests/testHotspot/ssidHotspot.conf @@ -44,3 +44,4 @@ eap_user_file=/tmp/eap_users.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem +beacon_int=10 diff --git a/autotests/testHotspot/ssidHotspotUnconfigured.conf b/autotests/testHotspot/ssidHotspotUnconfigured.conf @@ -44,3 +44,4 @@ eap_user_file=/tmp/eap_users.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem +beacon_int=10 diff --git a/autotests/testHotspot/ssidWPA2-1.conf b/autotests/testHotspot/ssidWPA2-1.conf @@ -6,3 +6,4 @@ ssid=ssidWPA2-1 wpa=2 wpa_pairwise=CCMP wpa_passphrase=secret123 +beacon_int=10 diff --git a/autotests/testHotspot/ssidWPA2-2.conf b/autotests/testHotspot/ssidWPA2-2.conf @@ -6,3 +6,4 @@ ssid=ssidWPA2-2 wpa=2 wpa_pairwise=CCMP wpa_passphrase=secret123 +beacon_int=10 diff --git a/autotests/testHotspot/ssidWPA2-3.conf b/autotests/testHotspot/ssidWPA2-3.conf @@ -6,3 +6,4 @@ ssid=ssidWPA2-3 wpa=2 wpa_pairwise=CCMP wpa_passphrase=secret123 +beacon_int=10 diff --git a/autotests/testKnownNetworks/frequency_test.py b/autotests/testKnownNetworks/frequency_test.py @@ -38,14 +38,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - # # Connect to the PSK network, then Hotspot so IWD creates 2 entries in # the known frequency file. diff --git a/autotests/testKnownNetworks/known_network_test.py b/autotests/testKnownNetworks/known_network_test.py @@ -14,14 +14,6 @@ class Test(unittest.TestCase): self.assertIsNotNone(devices) device = devices[0] - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidNew') condition = 'not obj.connected' diff --git a/autotests/testKnownNetworks/ssidCCMP-2G.conf b/autotests/testKnownNetworks/ssidCCMP-2G.conf @@ -5,3 +5,4 @@ ssid=ssidCCMP wpa=2 wpa_pairwise=CCMP wpa_passphrase=secret123 +beacon_int=10 diff --git a/autotests/testKnownNetworks/ssidCCMP-5G.conf b/autotests/testKnownNetworks/ssidCCMP-5G.conf @@ -6,3 +6,4 @@ country_code=US wpa=2 wpa_pairwise=CCMP wpa_passphrase=secret123 +beacon_int=10 diff --git a/autotests/testKnownNetworks/ssidHotspot.conf b/autotests/testKnownNetworks/ssidHotspot.conf @@ -44,3 +44,4 @@ eap_user_file=/tmp/eap_users.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem +beacon_int=10 diff --git a/autotests/testMFP-Options/connection_test.py b/autotests/testMFP-Options/connection_test.py @@ -61,14 +61,6 @@ class TestMFP(unittest.TestCase): self.assertIsNotNone(devices) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - if config_dir == '/tmp/IWD-MFP2': self.check_mfp_connection(wd, device, 'ssidMFP0', True) else: diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py @@ -24,14 +24,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidTKIP') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -56,6 +48,13 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): + def remove_lease(): + try: + os.remove('/tmp/dhcpd.leases') + os.remove('/tmp/dhcpd.leases~') + except: + pass + hapd = HostapdCLI() # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since its simple @@ -65,14 +64,13 @@ class Test(unittest.TestCase): ctx.start_process(['touch', '/tmp/dhcpd.leases'], wait=True) cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases', - hapd.ifname]) + hapd.ifname], cleanup=remove_lease) @classmethod def tearDownClass(cls): IWD.clear_storage() ctx.stop_process(cls.dhcpd_pid) cls.dhcpd_pid = None - os.remove('/tmp/dhcpd.leases') if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testNetconfig/hw.conf b/autotests/testNetconfig/hw.conf @@ -1,7 +1,6 @@ [SETUP] num_radios=3 start_iwd=0 -hwsim_medium=no [HOSTAPD] rad0=ssidTKIP.conf diff --git a/autotests/testNetconfig/static_test.py b/autotests/testNetconfig/static_test.py @@ -30,14 +30,6 @@ class Test(unittest.TestCase): dev1 = wd.list_devices(1)[0] dev2 = wd_ns0.list_devices(1)[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(dev1, condition) - - dev1.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(dev1, condition) - ordered_network = dev1.get_ordered_network('ssidTKIP') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -83,6 +75,13 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): + def remove_lease(): + try: + os.remove('/tmp/dhcpd.leases') + os.remove('/tmp/dhcpd.leases~') + except: + pass + hapd = HostapdCLI() # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since its simple @@ -92,14 +91,13 @@ class Test(unittest.TestCase): ctx.start_process(['touch', '/tmp/dhcpd.leases'], wait=True) cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases', - hapd.ifname]) + hapd.ifname], cleanup=remove_lease) IWD.copy_to_storage('ssidTKIP.psk', '/tmp/storage') @classmethod def tearDownClass(cls): IWD.clear_storage() cls.dhcpd_pid.kill() - os.system('rm -rf /tmp/dhcpd.leases') if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testOWE/connection_test.py b/autotests/testOWE/connection_test.py @@ -13,40 +13,59 @@ import testutil class Test(unittest.TestCase): def test_connection_success(self): - hapd = HostapdCLI(config='ssidOWE.conf') + hapd = HostapdCLI(config='ssidOWE-1.conf') wd = IWD() devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) + device.get_ordered_network('ssidOWE') - device.scan() + device.connect_bssid(hapd.bssid) - condition = 'not obj.scanning' + condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidOWE') + testutil.test_iface_operstate() + testutil.test_ifaces_connected(device.name, hapd.ifname) - self.assertEqual(ordered_network.type, NetworkType.open) + device.disconnect() - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + def test_reassociate(self): + hapd0 = HostapdCLI(config='ssidOWE-1.conf') + hapd1 = HostapdCLI(config='ssidOWE-2.conf') - ordered_network.network_object.connect() + wd = IWD() + + devices = wd.list_devices(1) + device = devices[0] + + device.get_ordered_network('ssidOWE') + + device.connect_bssid(hapd0.bssid) condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() - testutil.test_ifaces_connected(device.name, hapd.ifname) + testutil.test_ifaces_connected(device.name, hapd0.ifname) - device.disconnect() + device.roam(hapd1.bssid) + + condition = 'obj.state == DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + from_condition = 'obj.state == DeviceState.roaming' + to_condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_change(device, from_condition, to_condition) + + self.assertTrue(hapd1.list_sta()) - condition = 'not obj.connected' - wd.wait_for_object_condition(ordered_network.network_object, condition) + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(hapd1.ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (hapd0.ifname, device.name, True, True)) @classmethod def setUpClass(cls): diff --git a/autotests/testOWE/hw.conf b/autotests/testOWE/hw.conf @@ -1,6 +1,8 @@ [SETUP] -num_radios=3 +num_radios=4 +hwsim_medium=yes [HOSTAPD] -rad0=ssidOWE.conf -rad1=ssidGroup20.conf +rad0=ssidOWE-1.conf +rad1=ssidOWE-2.conf +rad2=ssidGroup20.conf diff --git a/autotests/testFT-FILS-SHA384/main.conf b/autotests/testOWE/main.conf diff --git a/autotests/testOWE/ssidOWE.conf b/autotests/testOWE/ssidOWE-1.conf diff --git a/autotests/testOWE/ssidOWE-2.conf b/autotests/testOWE/ssidOWE-2.conf @@ -0,0 +1,8 @@ +ctrl_interface=/var/run/hostapd +hw_mode=g +channel=2 +ssid=ssidOWE +wpa=2 +wpa_key_mgmt=OWE +rsn_pairwise=CCMP +owe_groups=19 diff --git a/autotests/testOWE/timeout_test.py b/autotests/testOWE/timeout_test.py @@ -17,23 +17,16 @@ class Test(unittest.TestCase): def test_connection_success(self): hwsim = Hwsim() - bss_radio = hwsim.get_radio('rad0') + bss_radio0 = hwsim.get_radio('rad0') + bss_radio1 = hwsim.get_radio('rad1') - self.assertIsNotNone(bss_radio) + self.assertIsNotNone(bss_radio0) wd = IWD() devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidOWE') self.assertEqual(ordered_network.type, NetworkType.open) @@ -42,10 +35,18 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(ordered_network.network_object, condition) rule0 = hwsim.rules.create() - rule0.source = bss_radio.addresses[0] + rule0.source = bss_radio0.addresses[0] rule0.bidirectional = True rule0.drop = True rule0.prefix = 'b0' + rule0.enabled = True + + rule1 = hwsim.rules.create() + rule1.source = bss_radio1.addresses[0] + rule1.bidirectional = True + rule1.drop = True + rule1.prefix = 'b0' + rule1.enabled = True # Test Authenticate (b0) and Association (00) timeouts @@ -53,10 +54,16 @@ class Test(unittest.TestCase): ordered_network.network_object.connect() rule0.prefix = '00' + rule1.prefix = '00' with self.assertRaises(iwd.FailedEx): ordered_network.network_object.connect() + def tearDown(self): + hwsim = Hwsim() + for rule in list(hwsim.rules.keys()): + del hwsim.rules[rule] + @classmethod def setUpClass(cls): pass diff --git a/autotests/testOpen/connection_test.py b/autotests/testOpen/connection_test.py @@ -17,14 +17,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidOpen') self.assertEqual(ordered_network.type, NetworkType.open) diff --git a/autotests/testP2P/hw.conf b/autotests/testP2P/hw.conf @@ -1,6 +1,5 @@ [SETUP] num_radios=2 -hwsim_medium=no [WPA_SUPPLICANT] rad1=rad1-p2p.conf diff --git a/autotests/testPSK-roam/TestFT.psk b/autotests/testPSK-roam/TestFT.psk @@ -0,0 +1,5 @@ +[Security] +Passphrase=EasilyGuessedPassword + +[Settings] +AutoConnect=False diff --git a/autotests/testPSK-roam/connection_test.py b/autotests/testPSK-roam/connection_test.py @@ -0,0 +1,183 @@ +#! /usr/bin/python3 + +import unittest +import sys, os + +sys.path.append('../util') +import iwd +from iwd import IWD +from iwd import PSKAgent +from iwd import NetworkType +from hwsim import Hwsim +from hostapd import HostapdCLI +import testutil + +class Test(unittest.TestCase): + def validate_connection(self, wd, over_ds=False): + device = wd.list_devices(1)[0] + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + # Scanning is unavoidable in this case since several hostapd + # configurations are tested and changed mid-test + device.scan() + + condition = 'obj.scanning' + wd.wait_for_object_condition(device, condition) + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + ordered_network = device.get_ordered_network('TestFT') + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + wd.wait_for_object_condition(ordered_network.network_object, condition) + + self.assertFalse(self.bss_hostapd[0].list_sta()) + self.assertFalse(self.bss_hostapd[1].list_sta()) + + device.connect_bssid(self.bss_hostapd[0].bssid) + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + self.assertTrue(self.bss_hostapd[0].list_sta()) + + # list_sta actually reports any authenticated stations. Due to the + # nature of FT-over-DS IWD should authenticate to all stations with + # the same mobility domain. This means both APs should show our station. + if over_ds: + self.assertTrue(self.bss_hostapd[1].list_sta()) + else: + self.assertFalse(self.bss_hostapd[1].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[1].ifname, device.name, True, True)) + + device.roam(self.bss_hostapd[1].bssid) + + condition = 'obj.state == DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + # Check that iwd is on BSS 1 once out of roaming state and doesn't + # go through 'disconnected', 'autoconnect', 'connecting' in between + from_condition = 'obj.state == DeviceState.roaming' + to_condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_change(device, from_condition, to_condition) + + self.assertTrue(self.bss_hostapd[1].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[0].ifname, device.name, True, True)) + + device.roam(self.bss_hostapd[0].bssid) + + condition = 'obj.state == DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + # Check that iwd is on BSS 0 once out of roaming state and doesn't + # go through 'disconnected', 'autoconnect', 'connecting' in between + from_condition = 'obj.state == DeviceState.roaming' + to_condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_change(device, from_condition, to_condition) + + self.assertTrue(self.bss_hostapd[0].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[1].ifname, device.name, True, True)) + + def test_ft_psk(self): + wd = IWD(True) + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK') + self.bss_hostapd[0].set_value('ft_over_ds', '0') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK') + self.bss_hostapd[1].set_value('ft_over_ds', '0') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + + self.validate_connection(wd) + + def test_ft_psk_over_ds(self): + wd = IWD(True) + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK') + self.bss_hostapd[0].set_value('ft_over_ds', '1') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK') + self.bss_hostapd[1].set_value('ft_over_ds', '1') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + + self.validate_connection(wd, over_ds=True) + + def test_reassociate_psk(self): + wd = IWD(True) + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'WPA-PSK') + self.bss_hostapd[0].set_value('ft_over_ds', '0') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'WPA-PSK') + self.bss_hostapd[1].set_value('ft_over_ds', '0') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + + self.validate_connection(wd) + + def tearDown(self): + os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') + os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') + os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') + os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') + + @classmethod + def setUpClass(cls): + IWD.copy_to_storage('TestFT.psk') + + cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), + HostapdCLI(config='ft-psk-ccmp-2.conf') ] + + # Set interface addresses to those expected by hostapd config files + os.system('ifconfig "' + cls.bss_hostapd[0].ifname + + '" down hw ether 12:00:00:00:00:01 up') + os.system('ifconfig "' + cls.bss_hostapd[1].ifname + + '" down hw ether 12:00:00:00:00:02 up') + + cls.bss_hostapd[0].reload() + cls.bss_hostapd[0].wait_for_event("AP-ENABLED") + cls.bss_hostapd[1].reload() + cls.bss_hostapd[1].wait_for_event("AP-ENABLED") + + # Fill in the neighbor AP tables in both BSSes. By default each + # instance knows only about current BSS, even inside one hostapd + # process. + # FT still works without the neighbor AP table but neighbor reports + # have to be disabled in the .conf files + cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', + '1200000000028f0000005102060603000000') + cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', + '1200000000018f0000005101060603000000') + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + cls.bss_hostapd = None + +if __name__ == '__main__': + unittest.main(exit=True) diff --git a/autotests/testFT-PSK-roam/ft-psk-ccmp-1.conf b/autotests/testPSK-roam/ft-psk-ccmp-1.conf diff --git a/autotests/testFT-PSK-roam/ft-psk-ccmp-2.conf b/autotests/testPSK-roam/ft-psk-ccmp-2.conf diff --git a/autotests/testPSK-roam/hw.conf b/autotests/testPSK-roam/hw.conf @@ -0,0 +1,8 @@ +[SETUP] +num_radios=3 +start_iwd=0 +hwsim_medium=yes + +[HOSTAPD] +rad0=ft-psk-ccmp-1.conf +rad1=ft-psk-ccmp-2.conf diff --git a/autotests/testFT-PSK-over-DS/main.conf b/autotests/testPSK-roam/main.conf diff --git a/autotests/testPreauth-roam/TestPreauth.8021x b/autotests/testPreauth-roam/TestPreauth.8021x @@ -3,7 +3,7 @@ EAP-Method=TLS EAP-TLS-CACert=/tmp/certs/cert-ca.pem EAP-TLS-ClientCert=/tmp/certs/cert-client.pem EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem -EAP-Identity=abc@example.com +EAP-Identity=tls@example.com [Settings] AutoConnect=false diff --git a/autotests/testPreauth-roam/connection_test.py b/autotests/testPreauth-roam/connection_test.py @@ -4,69 +4,39 @@ import unittest import sys, os sys.path.append('../util') -import iwd from iwd import IWD -from iwd import PSKAgent from iwd import NetworkType -from hwsim import Hwsim from hostapd import HostapdCLI import testutil class Test(unittest.TestCase): def test_preauth_success(self): - hwsim = Hwsim() - bss_hostapd = [ HostapdCLI(config='eaptls-preauth-1.conf'), HostapdCLI(config='eaptls-preauth-2.conf') ] - bss_radio = [ hwsim.get_radio('rad0'), - hwsim.get_radio('rad1') ] - - rule0 = hwsim.rules.create() - rule0.source = bss_radio[0].addresses[0] - rule0.bidirectional = True - rule1 = hwsim.rules.create() - rule1.source = bss_radio[1].addresses[0] - rule1.bidirectional = True + bss0_addr = bss_hostapd[0].bssid + bss1_addr = bss_hostapd[1].bssid # Fill in the neighbor AP tables in both BSSes. By default each # instance knows only about current BSS, even inside one hostapd # process. # Roaming still works without the neighbor AP table but neighbor # reports have to be disabled in the .conf files - bss0_nr = ''.join(bss_radio[0].addresses[0].split(':')) + \ + bss0_nr = ''.join(bss0_addr.split(':')) + \ '8f0000005101060603000000' - bss1_nr = ''.join(bss_radio[1].addresses[0].split(':')) + \ + bss1_nr = ''.join(bss1_addr.split(':')) + \ '8f0000005102060603000000' - bss_hostapd[0].set_neighbor(bss_radio[1].addresses[0], 'TestPreauth', - bss1_nr) - bss_hostapd[1].set_neighbor(bss_radio[0].addresses[0], 'TestPreauth', - bss0_nr) - - # Check that iwd selects BSS 0 first - rule0.signal = -2500 - rule1.signal = -6900 + bss_hostapd[0].set_neighbor(bss1_addr, 'TestPreauth', bss1_nr) + bss_hostapd[1].set_neighbor(bss0_addr, 'TestPreauth', bss0_nr) wd = IWD(True) device = wd.list_devices(1)[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('TestPreauth') self.assertEqual(ordered_network.type, NetworkType.eap) - self.assertEqual(ordered_network.signal_strength, -2500) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) @@ -74,7 +44,7 @@ class Test(unittest.TestCase): self.assertFalse(bss_hostapd[0].list_sta()) self.assertFalse(bss_hostapd[1].list_sta()) - ordered_network.network_object.connect() + device.connect_bssid(bss0_addr) condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) @@ -85,10 +55,9 @@ class Test(unittest.TestCase): testutil.test_iface_operstate(device.name) testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, - bss_hostapd[1].ifname, device.name) + bss_hostapd[1].ifname, device.name, True, True) - # Check that iwd starts transition to BSS 1 in less than 15 seconds - rule0.signal = -8000 + device.roam(bss1_addr) condition = 'obj.state == DeviceState.roaming' wd.wait_for_object_condition(device, condition) @@ -106,7 +75,7 @@ class Test(unittest.TestCase): testutil.test_iface_operstate(device.name) testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, - (bss_hostapd[0].ifname, device.name)) + (bss_hostapd[0].ifname, device.name, True, True)) device.disconnect() diff --git a/autotests/testPreauth-roam/eaptls-preauth-1.conf b/autotests/testPreauth-roam/eaptls-preauth-1.conf @@ -13,7 +13,7 @@ ieee80211w=1 # Run the RADIUS server in the BSS 0 hostapd only, listen for BSS 1 connections eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testRRM/connection_test.py b/autotests/testRRM/connection_test.py @@ -36,14 +36,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidRRM') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testRSSIAgent/connection_test.py b/autotests/testRSSIAgent/connection_test.py @@ -20,6 +20,7 @@ class Test(unittest.TestCase): def test_rssi_agent(self): rule = Hwsim().rules.create() rule.signal = -4000 + rule.enabled = True wd = IWD() diff --git a/autotests/testRSSIAgent/hw.conf b/autotests/testRSSIAgent/hw.conf @@ -1,5 +1,6 @@ [SETUP] num_radios=2 +hwsim_medium=yes [HOSTAPD] rad0=open.conf diff --git a/autotests/testRoamRetry/fast_retry_test.py b/autotests/testRoamRetry/fast_retry_test.py @@ -29,10 +29,12 @@ class Test(unittest.TestCase): rule0 = hwsim.rules.create() rule0.source = bss_radio[0].addresses[0] rule0.bidirectional = True + rule0.enabled = True rule1 = hwsim.rules.create() rule1.source = bss_radio[1].addresses[0] rule1.bidirectional = True + rule1.enabled = True # Fill in the neighbor AP tables in both BSSes. By default each # instance knows only about current BSS, even inside one hostapd @@ -61,14 +63,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('TestRoamRetry') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -90,7 +84,7 @@ class Test(unittest.TestCase): # schedule another attempt for 60 seconds later rule0.signal = -8000 - wd.wait(20) + device.wait_for_event('no-roam-candidates') self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(bss_hostapd[0].list_sta()) @@ -107,13 +101,12 @@ class Test(unittest.TestCase): wd.wait(1) # Assert low signal for BSS 0, check that iwd starts transition to BSS 1 - # in less than 10 seconds. Because of the neighbor report a scan should - # not be necessary. + # in less than 10 seconds. rule0.signal = -8000 rule1.signal = -2000 condition = 'obj.state == DeviceState.roaming' - wd.wait_for_object_condition(device, condition, max_wait=10) + wd.wait_for_object_condition(device, condition, max_wait=15) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between diff --git a/autotests/testRoamRetry/hw.conf b/autotests/testRoamRetry/hw.conf @@ -1,5 +1,6 @@ [SETUP] num_radios=3 +hwsim_medium=yes [HOSTAPD] rad0=ssid1.conf diff --git a/autotests/testRoamRetry/main.conf b/autotests/testRoamRetry/main.conf @@ -0,0 +1,2 @@ +[General] +RoamRetryInterval=5 diff --git a/autotests/testRoamRetry/ssid1.conf b/autotests/testRoamRetry/ssid1.conf @@ -9,3 +9,4 @@ wpa_passphrase=secret123 ctrl_interface=/var/run/hostapd rrm_neighbor_report=1 +beacon_int=10 diff --git a/autotests/testRoamRetry/ssid2.conf b/autotests/testRoamRetry/ssid2.conf @@ -9,3 +9,4 @@ wpa_passphrase=secret123 ctrl_interface=/var/run/hostapd rrm_neighbor_report=1 +beacon_int=10 diff --git a/autotests/testRoamRetry/stop_retry_test.py b/autotests/testRoamRetry/stop_retry_test.py @@ -28,10 +28,12 @@ class Test(unittest.TestCase): rule0 = hwsim.rules.create() rule0.source = bss_radio[0].addresses[0] rule0.bidirectional = True + rule0.enabled = True rule1 = hwsim.rules.create() rule1.source = bss_radio[1].addresses[0] rule1.bidirectional = True + rule1.enabled = True # Fill in the neighbor AP tables in both BSSes. By default each # instance knows only about current BSS, even inside one hostapd @@ -60,14 +62,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('TestRoamRetry') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -107,7 +101,7 @@ class Test(unittest.TestCase): condition = 'obj.state == DeviceState.roaming' self.assertRaises(TimeoutError, wd.wait_for_object_condition, device, - condition, max_wait=70) + condition, max_wait=10) device.disconnect() diff --git a/autotests/testSAE-roam/TestFT.psk b/autotests/testSAE-roam/TestFT.psk @@ -0,0 +1,5 @@ +[Security] +Passphrase=EasilyGuessedPassword + +[Settings] +AutoConnect=False diff --git a/autotests/testSAE-roam/connection_test.py b/autotests/testSAE-roam/connection_test.py @@ -0,0 +1,171 @@ +#! /usr/bin/python3 + +import unittest +import sys, os + +sys.path.append('../util') +import iwd +from iwd import IWD +from iwd import PSKAgent +from iwd import NetworkType +from hostapd import HostapdCLI +import testutil +from config import ctx + +class Test(unittest.TestCase): + def validate_connection(self, wd, ft=True): + device = wd.list_devices(1)[0] + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + device.scan() + + condition = 'obj.scanning' + wd.wait_for_object_condition(device, condition) + + condition = 'not obj.scanning' + wd.wait_for_object_condition(device, condition) + + self.assertFalse(self.bss_hostapd[0].list_sta()) + self.assertFalse(self.bss_hostapd[1].list_sta()) + + device.connect_bssid(self.bss_hostapd[0].bssid) + + condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_condition(device, condition) + + self.assertTrue(self.bss_hostapd[0].list_sta()) + self.assertFalse(self.bss_hostapd[1].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[1].ifname, device.name, True, True)) + + device.roam(self.bss_hostapd[1].bssid) + + condition = 'obj.state == DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + # Check that iwd is on BSS 1 once out of roaming state and doesn't + # go through 'disconnected', 'autoconnect', 'connecting' in between + from_condition = 'obj.state == DeviceState.roaming' + to_condition = 'obj.state == DeviceState.connected' + wd.wait_for_object_change(device, from_condition, to_condition) + + self.assertTrue(self.bss_hostapd[1].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[0].ifname, device.name, True, True)) + + if not ft: + return + + device.roam(self.bss_hostapd[2].bssid) + + condition = 'obj.state == DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + condition = 'obj.state != DeviceState.roaming' + wd.wait_for_object_condition(device, condition) + + self.assertEqual(device.state, iwd.DeviceState.connected) + self.assertTrue(self.bss_hostapd[2].list_sta()) + + testutil.test_iface_operstate(device.name) + testutil.test_ifaces_connected(self.bss_hostapd[2].ifname, device.name) + self.assertRaises(Exception, testutil.test_ifaces_connected, + (self.bss_hostapd[1].ifname, device.name, True, True)) + + def test_ft_roam_success(self): + wd = IWD(True) + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-SAE SAE') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-SAE SAE') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + self.bss_hostapd[2].set_value('wpa_key_mgmt', 'FT-PSK') + self.bss_hostapd[2].reload() + self.bss_hostapd[2].wait_for_event("AP-ENABLED") + + self.validate_connection(wd, True) + + def test_reassociate_roam_success(self): + wd = IWD(True) + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'SAE') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'SAE') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + self.bss_hostapd[2].set_value('wpa_key_mgmt', 'WPA-PSK') + self.bss_hostapd[2].reload() + self.bss_hostapd[2].wait_for_event("AP-ENABLED") + + self.validate_connection(wd, False) + + def tearDown(self): + os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down') + os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down') + os.system('ifconfig "' + self.bss_hostapd[2].ifname + '" down') + os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up') + os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up') + os.system('ifconfig "' + self.bss_hostapd[2].ifname + '" up') + + @classmethod + def setUpClass(cls): + cls.bss_hostapd = [ HostapdCLI(config='ft-sae-1.conf'), + HostapdCLI(config='ft-sae-2.conf'), + HostapdCLI(config='ft-psk-3.conf') ] + + ctx.start_process(['ifconfig', cls.bss_hostapd[0].ifname, 'down', 'hw', \ + 'ether', '12:00:00:00:00:01', 'up'], wait=True) + ctx.start_process(['ifconfig', cls.bss_hostapd[1].ifname, 'down', 'hw', \ + 'ether', '12:00:00:00:00:02', 'up'], wait=True) + ctx.start_process(['ifconfig', cls.bss_hostapd[2].ifname, 'down', 'hw', \ + 'ether', '12:00:00:00:00:03', 'up'], wait=True) + + # Set interface addresses to those expected by hostapd config files + cls.bss_hostapd[0].reload() + cls.bss_hostapd[0].wait_for_event("AP-ENABLED") + cls.bss_hostapd[1].reload() + cls.bss_hostapd[1].wait_for_event("AP-ENABLED") + cls.bss_hostapd[2].reload() + cls.bss_hostapd[2].wait_for_event("AP-ENABLED") + + # Fill in the neighbor AP tables in both BSSes. By default each + # instance knows only about current BSS, even inside one hostapd + # process. + # FT still works without the neighbor AP table but neighbor reports + # have to be disabled in the .conf files + cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:02', 'TestFT', + '1200000000028f0000005102060603000000') + cls.bss_hostapd[0].set_neighbor('12:00:00:00:00:03', 'TestFT', + '1200000000038f0000005102060603000000') + + cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:01', 'TestFT', + '1200000000018f0000005101060603000000') + cls.bss_hostapd[1].set_neighbor('12:00:00:00:00:03', 'TestFT', + '1200000000038f0000005101060603000000') + + cls.bss_hostapd[2].set_neighbor('12:00:00:00:00:01', 'TestFT', + '1200000000018f0000005101060603000000') + cls.bss_hostapd[2].set_neighbor('12:00:00:00:00:02', 'TestFT', + '1200000000028f0000005101060603000000') + + IWD.copy_to_storage('TestFT.psk') + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + + cls.bss_hostapd = None + +if __name__ == '__main__': + unittest.main(exit=True) diff --git a/autotests/testFT-SAE-roam/ft-psk-3.conf b/autotests/testSAE-roam/ft-psk-3.conf diff --git a/autotests/testFT-SAE-roam/ft-sae-1.conf b/autotests/testSAE-roam/ft-sae-1.conf diff --git a/autotests/testFT-SAE-roam/ft-sae-2.conf b/autotests/testSAE-roam/ft-sae-2.conf diff --git a/autotests/testFT-SAE-roam/hw.conf b/autotests/testSAE-roam/hw.conf diff --git a/autotests/testFT-PSK-roam/main.conf b/autotests/testSAE-roam/main.conf diff --git a/autotests/testSAE/autoconnect_test.py b/autotests/testSAE/autoconnect_test.py @@ -17,6 +17,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] + device.autoconnect = True condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) diff --git a/autotests/testSAE/connection_test.py b/autotests/testSAE/connection_test.py @@ -30,7 +30,12 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(device, 'obj.scanning') wd.wait_for_object_condition(device, 'not obj.scanning') - network = device.get_ordered_network('ssidSAE') + # + # An explicit scan was done prior due to hostapd options changing. + # Because of this scan_if_needed is set to False to avoid a redundant + # scan + # + network = device.get_ordered_network('ssidSAE', scan_if_needed=False) self.assertEqual(network.type, NetworkType.psk) diff --git a/autotests/testSAE/failure_test.py b/autotests/testSAE/failure_test.py @@ -19,14 +19,6 @@ class Test(unittest.TestCase): self.assertIsNotNone(devices) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - network = device.get_ordered_network('ssidSAE') self.assertEqual(network.type, NetworkType.psk) diff --git a/autotests/testSAE/hw.conf b/autotests/testSAE/hw.conf @@ -1,6 +1,7 @@ [SETUP] num_radios=2 start_iwd=0 +hwsim_medium=yes [HOSTAPD] rad0=ssidSAE.conf diff --git a/autotests/testSAE/timeout_test.py b/autotests/testSAE/timeout_test.py @@ -23,14 +23,6 @@ class Test(unittest.TestCase): self.assertIsNotNone(devices) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - network = device.get_ordered_network('ssidSAE') self.assertEqual(network.type, NetworkType.psk) @@ -43,6 +35,7 @@ class Test(unittest.TestCase): rule0.bidirectional = True rule0.drop = True rule0.prefix = 'b0' + rule0.enabled = True wd.wait(1) print(rule0) diff --git a/autotests/testSAQuery-spoofing/connection_test.py b/autotests/testSAQuery-spoofing/connection_test.py @@ -29,10 +29,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - ordered_network = device.get_ordered_network('ssidCCMP', scan_if_needed=True) + ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -52,7 +49,7 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(device, condition) # Spoof a disassociate frame. This will kick off SA Query procedure. - hwsim.spoof_disassociate(radio, hostapd.get_freq(), device.address) + hwsim.spoof_disassociate(radio, hostapd.frequency, device.address) # sleep to ensure hostapd responds and SA Query does not timeout sleep(4) diff --git a/autotests/testSAQuery-spoofing/hw.conf b/autotests/testSAQuery-spoofing/hw.conf @@ -1,5 +1,6 @@ [SETUP] num_radios=2 +hwsim_medium=yes [HOSTAPD] rad0=ssidCCMP.conf diff --git a/autotests/testSAQuery-spoofing/ssidCCMP.conf b/autotests/testSAQuery-spoofing/ssidCCMP.conf @@ -8,3 +8,4 @@ wpa_passphrase=secret123 ieee80211w=2 wpa_key_mgmt=WPA-PSK-SHA256 +beacon_int=10 diff --git a/autotests/testSAQuery/connection_test.py b/autotests/testSAQuery/connection_test.py @@ -23,14 +23,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testScan/periodic_scan_test.py b/autotests/testScan/periodic_scan_test.py @@ -28,6 +28,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] + device.autoconnect = True # Device initiates a passive periodic scan. condition = 'obj.scanning' diff --git a/autotests/testScan/requested_scan_test.py b/autotests/testScan/requested_scan_test.py @@ -30,6 +30,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] + device.autoconnect = True condition = 'obj.scanning' wd.wait_for_object_condition(device, condition) diff --git a/autotests/testScan/ssid_8021x.conf b/autotests/testScan/ssid_8021x.conf @@ -6,7 +6,7 @@ wpa=3 wpa_key_mgmt=WPA-EAP ieee8021x=1 eap_server=1 -eap_user_file=/tmp/certs/eap-user-tls.text +eap_user_file=/tmp/secrets/eap-user.text ca_cert=/tmp/certs/cert-ca.pem server_cert=/tmp/certs/cert-server.pem private_key=/tmp/certs/cert-server-key.pem diff --git a/autotests/testScanKnownFreqs/quick_scan_test.py b/autotests/testScanKnownFreqs/quick_scan_test.py @@ -24,6 +24,7 @@ class Test(unittest.TestCase): def validate_quick_scan(self, wd): devices = wd.list_devices(1) device = devices[0] + device.autoconnect = True # Device initiates a passive quick scan and scans only for the known # frequencies (listed in .known_network.freq file). diff --git a/autotests/testWPA/connection_test.py b/autotests/testWPA/connection_test.py @@ -21,14 +21,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidTKIP') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testWPA2-SHA256/connection_test.py b/autotests/testWPA2-SHA256/connection_test.py @@ -20,14 +20,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testWPA2-no-CCMP/connection_test.py b/autotests/testWPA2-no-CCMP/connection_test.py @@ -21,14 +21,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testWPA2/connection_test.py b/autotests/testWPA2/connection_test.py @@ -21,14 +21,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testWPA2/failure_test.py b/autotests/testWPA2/failure_test.py @@ -22,14 +22,6 @@ class Test(unittest.TestCase): self.assertIsNotNone(devices) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/testWPA2/password_test.py b/autotests/testWPA2/password_test.py @@ -22,16 +22,6 @@ class Test(unittest.TestCase): condition = 'obj.state == DeviceState.disconnected' wd.wait_for_object_condition(device, condition) - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - if not device.get_ordered_networks(): - device.scan() - condition = 'obj.scanning' - wd.wait_for_object_condition(device, condition) - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network("ssidCCMP") self.assertEqual(ordered_network.type, NetworkType.psk) network = ordered_network.network_object diff --git a/autotests/testWPA2withMFP/connection_test.py b/autotests/testWPA2withMFP/connection_test.py @@ -20,14 +20,6 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - - device.scan() - - condition = 'not obj.scanning' - wd.wait_for_object_condition(device, condition) - ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) diff --git a/autotests/util/ead.py b/autotests/util/ead.py @@ -81,12 +81,8 @@ class EAD(iwd.AsyncOpAbstract): _adapters = None def __init__(self): - tries = 0 - while not self._bus.name_has_owner(EAD_SERVICE): - if tries > 200: - raise TimeoutError('IWD has failed to start') - tries += 1 - time.sleep(0.1) + ctx.non_block_wait(self._bus.name_has_owner, 20, EAD_SERVICE, + exception=TimeoutError('EAD has failed to start')) self._adapters = AdapterList(self) @@ -103,39 +99,7 @@ class EAD(iwd.AsyncOpAbstract): if not wait_to_appear: return list(self._adapters.values()) - self._wait_timed_out = False - def wait_timeout_cb(): - self._wait_timed_out = True - return False - - try: - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = ctx.mainloop.get_context() - while len(self._adapters) < wait_to_appear: - context.iteration(may_block=True) - if self._wait_timed_out: - raise TimeoutError('IWD has no associated devices') - finally: - if not self._wait_timed_out: - GLib.source_remove(timeout) + ctx.non_block_wait(lambda s, num : len(s._adapters) >= num, max_wait, self, wait_to_appear, + exception=TimeoutError('EAD has no associated devices')) return list(self._adapters.values()) - - def wait_for_object_condition(self, obj, condition_str, max_wait = 50): - self._wait_timed_out = False - def wait_timeout_cb(): - self._wait_timed_out = True - return False - - try: - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = ctx.mainloop.get_context() - while not eval(condition_str): - context.iteration(may_block=True) - if self._wait_timed_out and ctx.args.gdb == None: - raise TimeoutError('[' + condition_str + ']'\ - ' condition was not met in '\ - + str(max_wait) + ' sec') - finally: - if not self._wait_timed_out: - GLib.source_remove(timeout) diff --git a/autotests/util/hostapd.py b/autotests/util/hostapd.py @@ -28,10 +28,28 @@ chan_freq_map = [ ctrl_count = 0 mainloop = GLib.MainLoop() -class HostapdCLI: - def _init_hostapd(self, config=None): +class HostapdCLI(object): + _instances = {} + + def __new__(cls, config=None, *args, **kwargs): + hapd = ctx.hostapd[config] + + if not config: + config = hapd.config + + if not config in cls._instances.keys(): + cls._instances[config] = object.__new__(cls, *args, **kwargs) + cls._instances[config]._initialized = False + + return cls._instances[config] + + def _init_hostapd(self, config, reinit=False): global ctrl_count - interface = None + + if self._initialized and not reinit: + return + + self._initialized = True self.ctrl_sock = None if not ctx.hostapd: @@ -53,9 +71,6 @@ class HostapdCLI: self.cmdline = ['hostapd_cli', '-p', self.socket_path, '-i', self.ifname] - if not hasattr(self, '_hostapd_restarted'): - self._hostapd_restarted = False - self.local_ctrl = '/tmp/hostapd_' + str(os.getpid()) + '_' + \ str(ctrl_count) self.ctrl_sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) @@ -68,33 +83,22 @@ class HostapdCLI: ctrl_count = ctrl_count + 1 - def __init__(self, config=None): + def __init__(self, config=None, *args, **kwargs): self._init_hostapd(config) - def wait_for_event(self, event, timeout=10): - global mainloop - self._wait_timed_out = False - - def wait_timeout_cb(): - self._wait_timed_out = True + def _poll_event(self, event): + if not self._data_available(0.25): return False - timeout = GLib.timeout_add_seconds(timeout, wait_timeout_cb) - context = mainloop.get_context() + data = self.ctrl_sock.recv(4096).decode('utf-8') + if event in data: + return data - while True: - context.iteration(may_block=False) - - while self._data_available(0.25): - data = self.ctrl_sock.recv(4096).decode('utf-8') - if event in data: - GLib.source_remove(timeout) - return data - - if self._wait_timed_out: - raise TimeoutError('waiting for hostapd event timed out') + return False - return None + def wait_for_event(self, event, timeout=10): + return ctx.non_block_wait(self._poll_event, timeout, event, + exception=TimeoutError("waiting for event")) def _data_available(self, timeout=2): [r, w, e] = select.select([self.ctrl_sock], [], [], timeout) @@ -108,10 +112,10 @@ class HostapdCLI: self.ctrl_sock.send(bytes(command)) - if self._data_available(timeout): - return self.ctrl_sock.recv(4096).decode('utf-8') + ctx.non_block_wait(self._data_available, timeout, + exception=TimeoutError("waiting for control response")) - raise Exception('timeout waiting for control response') + return self.ctrl_sock.recv(4096).decode('utf-8') def _del_hostapd(self, force=False): if not self.ctrl_sock: @@ -124,15 +128,16 @@ class HostapdCLI: except: pass - if self._hostapd_restarted: - ctx.stop_process(ctx.hostapd.process, force) - - self.interface.set_interface_state('down') - self.interface.set_interface_state('up') - def __del__(self): self._del_hostapd() + HostapdCLI._instances[self.config] = None + + # Check if this is the final instance + destroy = len([hapd for hapd in HostapdCLI._instances.values() if hapd is not None]) == 0 + if destroy: + HostapdCLI._instances = {} + def set_value(self, key, value): cmd = self.cmdline + ['set', key, value] ctx.start_process(cmd, wait=True) @@ -197,26 +202,14 @@ class HostapdCLI: if 'OK' not in proc.out: raise Exception('BSS_TM_REQ failed, is hostapd built with CONFIG_WNM_AP=y?') - def get_config_value(self, key): - # first find the right config file - with open(self.config, 'r') as f: - # read in config file and search for key - cfg = f.read() - match = re.search(r'%s=.*' % key, cfg) - if match: - return match.group(0).split('=')[1] - return None - - - def get_freq(self): - return chan_freq_map[int(self.get_config_value('channel'))] - def ungraceful_restart(self): ''' Ungracefully kill and restart hostapd ''' - # set flag so hostapd can be killed after the test - self._hostapd_restarted = True + ctx.stop_process(ctx.hostapd.process, True) + + self.interface.set_interface_state('down') + self.interface.set_interface_state('up') self._del_hostapd(force=True) @@ -226,7 +219,7 @@ class HostapdCLI: time.sleep(1) # New hostapd process, so re-init - self._init_hostapd(config=self.config) + self._init_hostapd(config=self.config, reinit=True) def req_beacon(self, addr, request): ''' @@ -234,3 +227,24 @@ class HostapdCLI: ''' cmd = self.cmdline + ['req_beacon', addr, request] ctx.start_process(cmd, wait=True) + + @property + def bssid(self): + cmd = self.cmdline + ['status'] + status = ctx.start_process(cmd, wait=True, need_out=True).out + status = status.split('\n') + + bssid = [x for x in status if x.startswith('bssid')] + bssid = bssid[0].split('=') + return bssid[1] + + @property + def frequency(self): + cmd = self.cmdline + ['status'] + status = ctx.start_process(cmd, wait=True, need_out=True).out + status = status.split('\n') + + frequency = [x for x in status if x.startswith('freq')][0] + frequency = frequency.split('=')[1] + + return int(frequency) diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py @@ -142,6 +142,16 @@ class Rule(HwsimDBusAbstract): reply_handler=self._success, error_handler=self._failure) self._wait_for_async_op() + @property + def enabled(self): + return self._properties['Enabled'] + + @enabled.setter + def enabled(self, value): + self._prop_proxy.Set(self._iface_name, 'Enabled', value, + reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() + def remove(self): self._iface.Remove(reply_handler=self._success, error_handler=self._failure) @@ -161,7 +171,9 @@ class Rule(HwsimDBusAbstract): prefix + '\tFrequency:\t' + str(self.frequency) + '\n' + \ prefix + '\tApply rssi:\t' + str(self.signal) + '\n' + \ prefix + '\tApply drop:\t' + str(self.drop) + '\n' + \ - prefix + '\tPrefix:\t' + str([hex(b) for b in self.prefix]) + '\n' + prefix + '\tPrefix:\t' + str([hex(b) for b in self.prefix]) + '\n' + \ + prefix + '\tDelay:\t' + str(self.delay) + '\n' + \ + prefix + '\tEnabled:\t' + str(self.enabled) + '\n' class RuleSet(collections.Mapping): def __init__(self, hwsim, objects): @@ -202,6 +214,10 @@ class RuleSet(collections.Mapping): self._dict[path] = obj return obj + def remove_all(self): + for rule in self._dict.values(): + rule.remove() + class Radio(HwsimDBusAbstract): _iface_name = HWSIM_RADIO_INTERFACE diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py @@ -39,6 +39,7 @@ IWD_P2P_INTERFACE = 'net.connman.iwd.p2p.Device' IWD_P2P_PEER_INTERFACE = 'net.connman.iwd.p2p.Peer' IWD_P2P_SERVICE_MANAGER_INTERFACE = 'net.connman.iwd.p2p.ServiceManager' IWD_P2P_WFD_INTERFACE = 'net.connman.iwd.p2p.Display' +IWD_STATION_DEBUG_INTERFACE = 'net.connman.iwd.StationDebug' IWD_AGENT_MANAGER_PATH = '/net/connman/iwd' IWD_TOP_LEVEL_PATH = '/' @@ -108,9 +109,7 @@ class AsyncOpAbstract(object): self._exception = _convert_dbus_ex(ex) def _wait_for_async_op(self): - context = ctx.mainloop.get_context() - while not self._is_completed: - context.iteration(may_block=True) + ctx.non_block_wait(lambda s: s._is_completed, 30, self, exception=None) self._is_completed = False if self._exception is not None: @@ -225,6 +224,54 @@ class AdHocDevice(IWDDBusAbstract): def connected_peers(self): return self._properties['ConnectedPeers'] +class StationDebug(IWDDBusAbstract): + ''' + Class represents net.connman.iwd.StationDebug + ''' + _iface_name = IWD_STATION_DEBUG_INTERFACE + + def __init__(self, *args, **kwargs): + self._debug_props = None + self._debug_iface = None + self._last_event = None + self._last_event_data = [] + + IWDDBusAbstract.__init__(self, *args, **kwargs) + + self._iface.connect_to_signal("Event", self._event_handler) + + def _event_handler(self, event, data): + self._last_event = event + self._last_event_data = data + + @property + def autoconnect(self): + return self._properties['AutoConnect'] + + def connect_bssid(self, address): + self._iface.ConnectBssid(dbus.ByteArray.fromhex(address.replace(':', ''))) + + def roam(self, address): + self._iface.Roam(dbus.ByteArray.fromhex(address.replace(':', ''))) + + def scan(self, frequencies): + frequencies = dbus.Array([dbus.UInt16(f) for f in frequencies]) + self._iface.Scan(frequencies) + + def wait_for_event(self, event, timeout=10): + try: + if self._last_event is not None: + return self._last_event_data + + ctx.non_block_wait(lambda s, e : s._last_event == e, timeout, self, event, + exception=TimeoutError("waiting for StationDebug.Event")) + + return self._last_event_data + finally: + # Consume the event + self._last_event_data = None + self._last_event = None + class Device(IWDDBusAbstract): ''' @@ -237,8 +284,11 @@ class Device(IWDDBusAbstract): self._wps_manager_if = None self._station_if = None self._station_props = None + IWDDBusAbstract.__init__(self, *args, **kwargs) + self._station_debug = StationDebug(*args, **kwargs) + @property def _wps_manager(self): if self._wps_manager_if is None: @@ -353,6 +403,15 @@ class Device(IWDDBusAbstract): props = self._station_properties() return bool(props['Scanning']) + @property + def autoconnect(self): + return self._station_debug.autoconnect + + @autoconnect.setter + def autoconnect(self, value): + self._station_debug._prop_proxy.Set(IWD_STATION_DEBUG_INTERFACE, + 'AutoConnect', value) + def scan(self): '''Schedule a network scan. @@ -378,7 +437,7 @@ class Device(IWDDBusAbstract): self._wait_for_async_op() - def get_ordered_networks(self, scan_if_needed = False): + def get_ordered_networks(self, scan_if_needed = True, full_scan = False): '''Return the list of networks found in the most recent scan, sorted by their user interface importance score as calculated by iwd. If the device is @@ -400,7 +459,16 @@ class Device(IWDDBusAbstract): elif not scan_if_needed: return None - self.scan() + condition = 'not obj.scanning' + IWD._wait_for_object_condition(self, condition) + + try: + if full_scan: + self.scan() + else: + self.debug_scan(ctx.get_frequencies()) + except InProgressEx: + pass condition = 'obj.scanning' IWD._wait_for_object_condition(self, condition) @@ -416,21 +484,29 @@ class Device(IWDDBusAbstract): return None - def get_ordered_network(self, network, scan_if_needed = False): + def get_ordered_network(self, network, scan_if_needed = True, full_scan = False): '''Returns a single network from ordered network call, or None if the network wasn't found. If the network is not found an exception is raised, this removes the need to extra asserts in autotests. ''' - ordered_networks = self.get_ordered_networks(scan_if_needed) + def wait_for_network(self, network, scan_if_needed): + networks = self.get_ordered_networks(scan_if_needed) - if not ordered_networks: - raise Exception('Network %s not found' % network) + if not networks: + # No point in continuing if we aren't going to re-scan + if not scan_if_needed: + raise Exception("Network %s not found" % network) - for n in ordered_networks: - if n.name == network: - return n + return False - raise Exception('Network %s not found' % network) + for n in networks: + if n.name == network: + return n + + return False + + return ctx.non_block_wait(wait_for_network, 30, self, network, scan_if_needed, + exception=Exception("Network %s not found" % network)) def wps_push_button(self): self._wps_manager.PushButton(dbus_interface=IWD_WSC_INTERFACE, @@ -535,6 +611,18 @@ class Device(IWDDBusAbstract): def stop_adhoc(self): self._prop_proxy.Set(IWD_DEVICE_INTERFACE, 'Mode', 'station') + def connect_bssid(self, address): + self._station_debug.connect_bssid(address) + + def roam(self, address): + self._station_debug.roam(address) + + def debug_scan(self, frequencies): + self._station_debug.scan(frequencies) + + def wait_for_event(self, event, timeout=10): + self._station_debug.wait_for_event(event, timeout) + def __str__(self, prefix = ''): return prefix + 'Device: ' + self.device_path + '\n'\ + prefix + '\tName:\t\t' + self.name + '\n'\ @@ -956,16 +1044,8 @@ class IWD(AsyncOpAbstract): self._iwd_proc = self.namespace.start_iwd(iwd_config_dir, iwd_storage_dir) - tries = 0 - while not self._bus.name_has_owner(IWD_SERVICE): - if not ctx.args.gdb: - if tries > 200: - if start_iwd_daemon: - self.namespace.stop_process(self._iwd_proc) - self._iwd_proc = None - raise TimeoutError('IWD has failed to start') - tries += 1 - time.sleep(0.1) + ctx.non_block_wait(self._bus.name_has_owner, 20, IWD_SERVICE, + exception=TimeoutError('IWD has failed to start')) self._devices = DeviceList(self) @@ -1011,27 +1091,13 @@ class IWD(AsyncOpAbstract): @staticmethod def _wait_for_object_condition(obj, condition_str, max_wait = 50): - class TimeoutData: - _wait_timed_out = False - - data = TimeoutData() + def _eval_wrap(obj, condition_str): + return eval(condition_str) - def wait_timeout_cb(data): - data._wait_timed_out = True - return False - - try: - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb, data) - context = ctx.mainloop.get_context() - while not eval(condition_str): - context.iteration(may_block=True) - if data._wait_timed_out and ctx.args.gdb == None: - raise TimeoutError('[' + condition_str + ']'\ - ' condition was not met in '\ - + str(max_wait) + ' sec') - finally: - if not data._wait_timed_out: - GLib.source_remove(timeout) + ctx.non_block_wait(_eval_wrap, max_wait, obj, condition_str, + exception=TimeoutError('[' + condition_str + ']'\ + ' condition was not met in '\ + + str(max_wait) + ' sec')) def wait_for_object_condition(self, *args, **kwargs): self._wait_for_object_condition(*args, **kwargs) @@ -1045,54 +1111,30 @@ class IWD(AsyncOpAbstract): This allows an object to be checked for a state transition without any intermediate state changes. ''' - self._wait_timed_out = False + def _eval_from_to(obj, from_str, to_str): + # If neither the initial or expected condition evaluate the + # object must be in another unexpected state. + if not eval(from_str) and not eval(to_str): + raise Exception('unexpected condition between [%s] and [%s]' % + (from_str, to_str)) + + # Initial condition does not evaluate but expected does, pass + if not eval(from_str) and eval(to_str): + return True - def wait_timeout_cb(): - self._wait_timed_out = True return False # Does initial condition pass? if not eval(from_str): raise Exception("initial condition [%s] not met" % from_str) - try: - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = ctx.mainloop.get_context() - while True: - context.iteration(may_block=True) - - # If neither the initial or expected condition evaluate the - # object must be in another unexpected state. - if not eval(from_str) and not eval(to_str): - raise Exception('unexpected condition between [%s] and [%s]' % - (from_str, to_str)) - - # Initial condition does not evaluate but expected does, pass - if not eval(from_str) and eval(to_str): - break - - if self._wait_timed_out and ctx.args.gdb == None: - raise TimeoutError('[' + to_str + ']'\ + ctx.non_block_wait(_eval_from_to, max_wait, obj, from_str, to_str, + exception=TimeoutError('[' + to_str + ']'\ ' condition was not met in '\ - + str(max_wait) + ' sec') - finally: - if not self._wait_timed_out: - GLib.source_remove(timeout) + + str(max_wait) + ' sec')) def wait(self, time): - self._wait_timed_out = False - def wait_timeout_cb(): - self._wait_timed_out = True - return False - - try: - timeout = GLib.timeout_add(int(time * 1000), wait_timeout_cb) - context = ctx.mainloop.get_context() - while not self._wait_timed_out: - context.iteration(may_block=True) - finally: - if not self._wait_timed_out: - GLib.source_remove(timeout) + ctx.non_block_wait(lambda : False, time, exception=False) @staticmethod def clear_storage(storage_dir=IWD_STORAGE_DIR): @@ -1108,11 +1150,14 @@ class IWD(AsyncOpAbstract): fo.close() @staticmethod - def copy_to_storage(source, storage_dir=IWD_STORAGE_DIR): + def copy_to_storage(source, storage_dir=IWD_STORAGE_DIR, name=None): import shutil assert not os.path.isabs(source) + if name: + storage_dir += '/%s' % name + shutil.copy(source, storage_dir) @staticmethod @@ -1137,21 +1182,8 @@ class IWD(AsyncOpAbstract): if not wait_to_appear: return list(self._devices.values() if not p2p else self._devices.p2p_dict.values()) - self._wait_timed_out = False - def wait_timeout_cb(): - self._wait_timed_out = True - return False - - try: - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = ctx.mainloop.get_context() - while len(self._devices) < wait_to_appear: - context.iteration(may_block=True) - if self._wait_timed_out: - raise TimeoutError('IWD has no associated devices') - finally: - if not self._wait_timed_out: - GLib.source_remove(timeout) + ctx.non_block_wait(lambda s, n: len(s._devices) >= n, max_wait, self, wait_to_appear, + exception=TimeoutError('IWD has no associated devices')) return list(self._devices.values() if not p2p else self._devices.p2p_dict.values())[:wait_to_appear] diff --git a/autotests/util/ofono.py b/autotests/util/ofono.py @@ -9,13 +9,8 @@ class Ofono(dbus.service.Object): def __init__(self, namespace=ctx): self._bus = namespace.get_bus() - tries = 0 - - while not self._bus.name_has_owner('org.ofono'): - if tries > 100: - raise TimeoutError('Waiting for org.ofono service timed out') - tries += 1 - time.sleep(0.1) + ctx.non_block_wait(self._bus.name_has_owner, 10, 'org.ofono', + exception=TimeoutError('Waiting for org.ofono service timed out')) def enable_modem(self, path): self._modem_path = path @@ -31,7 +26,6 @@ class Ofono(dbus.service.Object): self._sim_auth_up = True def wait_for_sim_auth(self, max_wait = 15): - mainloop = GLib.MainLoop() self._sim_auth_up = False props = self._modem_iface.GetProperties() @@ -42,18 +36,5 @@ class Ofono(dbus.service.Object): self._modem_iface.connect_to_signal('PropertyChanged', self._modem_prop_changed) - self._wait_timed_out = False - def wait_timeout_cb(): - self._wait_timed_out = True - return False - - try: - timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) - context = mainloop.get_context() - while (not self._sim_auth_up): - context.iteration(may_block=True) - if self._wait_timed_out: - raise TimeoutError('waiting for SimAuthentication timed out') - - finally: - GLib.source_remove(timeout) + ctx.non_block_wait(lambda s : s._sim_auth_up, max_wait, self, + exception=TimeoutError('waiting for SimAuthetication timed out')) diff --git a/autotests/util/testutil.py b/autotests/util/testutil.py @@ -51,7 +51,12 @@ def tx(fromsock, tosock, src, dst): return (frame, fromsock, tosock, src, dst) -def test_connected(if0=None, if1=None, group=True): +def test_connected(if0=None, if1=None, group=True, expect_fail=False): + if expect_fail: + timeout = 0 + else: + timeout = 10 + if if0 is None or if1 is None: iwd_list = [dev.name for dev in iwd.IWD.get_instance().list_devices()] @@ -82,7 +87,7 @@ def test_connected(if0=None, if1=None, group=True): rec.append(False) while not all(rec): - r, w, x = select.select([sock0, sock1], [], [], 10) + r, w, x = select.select([sock0, sock1], [], [], timeout) if not r: raise Exception('timeout waiting for packets: ' + repr(rec)) @@ -110,15 +115,15 @@ def test_connected(if0=None, if1=None, group=True): sock0.close() sock1.close() -def test_ifaces_connected(if0=None, if1=None, group=True): +def test_ifaces_connected(if0=None, if1=None, group=True, expect_fail=False): retry = 0 while True: try: - test_connected(if0, if1, group) + test_connected(if0, if1, group, expect_fail) break except Exception as e: - if retry < 3: + if retry < 3 and not expect_fail: print('retrying connection test: %i' % retry) retry += 1 continue diff --git a/configure.ac b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(iwd, 1.16) +AC_INIT(iwd, 1.17) AC_CONFIG_HEADERS(config.h) AC_CONFIG_AUX_DIR(build-aux) @@ -267,7 +267,7 @@ if (test "${enable_external_ell}" = "yes"); then test "${enable_monitor}" != "no" || test "${enable_wired}" = "yes" || test "${enable_hwsim}" = "yes"); then - ell_min_version="0.42" + ell_min_version="0.43" else ell_min_version="0.5" fi diff --git a/src/anqp.c b/src/anqp.c @@ -248,7 +248,7 @@ uint32_t anqp_request(uint64_t wdev_id, const uint8_t *addr, iov[0].iov_len = request->frame_len; iov[1].iov_base = NULL; - l_debug("Sending ANQP request"); + l_debug("Sending ANQP request to "MAC, MAC_STR(bss->addr)); request->id = frame_xchg_start(request->wdev_id, iov, request->frequency, 0, 300, 0, diff --git a/src/ap.c b/src/ap.c @@ -251,6 +251,11 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason, sta->rsna = false; } + if (sta->assoc_resp_cmd_id) { + l_genl_family_cancel(ap->nl80211, sta->assoc_resp_cmd_id); + sta->assoc_resp_cmd_id = 0; + } + if (sta->gtk_query_cmd_id) { l_genl_family_cancel(ap->nl80211, sta->gtk_query_cmd_id); sta->gtk_query_cmd_id = 0; @@ -258,6 +263,10 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason, ap_stop_handshake(sta); + /* + * If the event handler tears the AP down, we've made sure above that + * a subsequent ap_sta_free(sta) has no need to access sta->ap. + */ if (send_event) ap->ops->handle_event(AP_EVENT_STATION_REMOVED, &event_data, ap->user_data); @@ -526,7 +535,6 @@ static size_t ap_write_wsc_ie(struct ap_state *ap, size_t client_frame_len, uint8_t *out_buf) { - const uint8_t *from = client_frame->address_2; uint8_t *wsc_data; size_t wsc_data_size; uint8_t *wsc_ie; @@ -535,6 +543,7 @@ static size_t ap_write_wsc_ie(struct ap_state *ap, /* WSC IE */ if (type == MPDU_MANAGEMENT_SUBTYPE_PROBE_RESPONSE) { + const uint8_t *from = client_frame->address_2; struct wsc_probe_response wsc_pr = {}; const struct mmpdu_probe_request *req = mmpdu_body(client_frame); @@ -597,6 +606,7 @@ static size_t ap_write_wsc_ie(struct ap_state *ap, wsc_data = wsc_build_beacon(&wsc_beacon, &wsc_data_size); } else if (L_IN_SET(type, MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_RESPONSE, MPDU_MANAGEMENT_SUBTYPE_REASSOCIATION_RESPONSE)) { + const uint8_t *from = client_frame->address_2; struct wsc_association_response wsc_resp = {}; struct sta_state *sta = l_queue_find(ap->sta_states, ap_sta_match_addr, from); @@ -2003,7 +2013,6 @@ static void ap_deauth_cb(const struct mmpdu_header *hdr, const void *body, size_t body_len, int rssi, void *user_data) { struct ap_state *ap = user_data; - struct sta_state *sta; const struct mmpdu_deauthentication *deauth = body; const uint8_t *bssid = netdev_get_address(ap->netdev); @@ -2015,14 +2024,8 @@ static void ap_deauth_cb(const struct mmpdu_header *hdr, const void *body, memcmp(hdr->address_3, bssid, 6)) return; - sta = l_queue_remove_if(ap->sta_states, ap_sta_match_addr, - hdr->address_2); - if (!sta) - return; - - ap_del_station(sta, L_LE16_TO_CPU(deauth->reason_code), false); - - ap_sta_free(sta); + ap_station_disconnect(ap, hdr->address_2, + L_LE16_TO_CPU(deauth->reason_code)); } static void do_debug(const char *str, void *user_data) @@ -2338,7 +2341,6 @@ cleanup: static void ap_handle_del_station(struct ap_state *ap, struct l_genl_msg *msg) { - struct sta_state *sta; struct l_genl_attr attr; uint16_t type; uint16_t len; @@ -2365,12 +2367,7 @@ static void ap_handle_del_station(struct ap_state *ap, struct l_genl_msg *msg) } } - sta = l_queue_find(ap->sta_states, ap_sta_match_addr, mac); - if (!sta) - return; - - ap_del_station(sta, reason, true); - ap_remove_sta(sta); + ap_station_disconnect(ap, mac, reason); } static void ap_mlme_notify(struct l_genl_msg *msg, void *user_data) diff --git a/src/auth-proto.h b/src/auth-proto.h @@ -31,6 +31,7 @@ struct auth_proto { const uint8_t *frame, size_t len); bool (*auth_timeout)(struct auth_proto *ap); bool (*assoc_timeout)(struct auth_proto *ap); + uint8_t prev_bssid[6]; }; static inline void auth_proto_free(struct auth_proto *ap) diff --git a/src/dbus.h b/src/dbus.h @@ -42,6 +42,7 @@ #define IWD_P2P_WFD_INTERFACE "net.connman.iwd.p2p.Display" #define IWD_STATION_DIAGNOSTIC_INTERFACE "net.connman.iwd.StationDiagnostic" #define IWD_AP_DIAGNOSTIC_INTERFACE "net.connman.iwd.AccessPointDiagnostic" +#define IWD_STATION_DEBUG_INTERFACE "net.connman.iwd.StationDebug" #define IWD_BASE_PATH "/net/connman/iwd" #define IWD_AGENT_MANAGER_PATH IWD_BASE_PATH diff --git a/src/eapol.c b/src/eapol.c @@ -1356,11 +1356,11 @@ static void eapol_send_ptk_3_of_4(struct eapol_sm *sm) key_data_buf[key_data_len++] = 4 + 12; l_put_be32(HANDSHAKE_KDE_IP_ADDRESS_ALLOC, key_data_buf + key_data_len + 0); - l_put_be32(sm->handshake->client_ip_addr, + l_put_u32(sm->handshake->client_ip_addr, key_data_buf + key_data_len + 4); - l_put_be32(sm->handshake->subnet_mask, + l_put_u32(sm->handshake->subnet_mask, key_data_buf + key_data_len + 8); - l_put_be32(sm->handshake->go_ip_addr, + l_put_u32(sm->handshake->go_ip_addr, key_data_buf + key_data_len + 12); key_data_len += 4 + 12; } @@ -1810,9 +1810,9 @@ static void eapol_handle_ptk_3_of_4(struct eapol_sm *sm, hs->support_ip_allocation = ip_alloc_kde != NULL; if (ip_alloc_kde) { - hs->client_ip_addr = l_get_be32(ip_alloc_kde); - hs->subnet_mask = l_get_be32(ip_alloc_kde + 4); - hs->go_ip_addr = l_get_be32(ip_alloc_kde + 8); + hs->client_ip_addr = l_get_u32(ip_alloc_kde); + hs->subnet_mask = l_get_u32(ip_alloc_kde + 4); + hs->go_ip_addr = l_get_u32(ip_alloc_kde + 8); } else l_debug("Authenticator ignored our IP Address Request"); } diff --git a/src/erp.c b/src/erp.c @@ -336,6 +336,7 @@ struct erp_state *erp_new(struct erp_cache_entry *cache, erp->tx_packet = tx_packet; erp->user_data = user_data; erp->cache = cache; + cache->ref++; return erp; } diff --git a/src/handshake.c b/src/handshake.c @@ -41,6 +41,7 @@ #include "src/ie.h" #include "src/util.h" #include "src/handshake.h" +#include "src/erp.h" static inline unsigned int n_ecc_groups() { @@ -106,6 +107,9 @@ void handshake_state_free(struct handshake_state *s) l_free(s->mde); l_free(s->fte); + if (s->erp_cache) + erp_cache_put(s->erp_cache); + if (s->passphrase) { explicit_bzero(s->passphrase, strlen(s->passphrase)); l_free(s->passphrase); @@ -293,6 +297,33 @@ void handshake_state_set_fte(struct handshake_state *s, const uint8_t *fte) replace_ie(&s->fte, fte); } +void handshake_state_set_vendor_ies(struct handshake_state *s, + const struct iovec *iov, + size_t n_iovs) +{ + size_t i; + size_t len; + + l_free(s->vendor_ies); + s->vendor_ies = NULL; + + if (n_iovs == 0) { + s->vendor_ies_len = 0; + return; + } + + for (i = 0, len = 0; i < n_iovs; i++) + len += iov[i].iov_len; + + s->vendor_ies_len = len; + s->vendor_ies = l_malloc(len); + + for (i = 0, len = 0; i < n_iovs; i++) { + memcpy(s->vendor_ies + len, iov[i].iov_base, iov[i].iov_len); + len += iov[i].iov_len; + } +} + void handshake_state_set_kh_ids(struct handshake_state *s, const uint8_t *r0khid, size_t r0khid_len, const uint8_t *r1khid) diff --git a/src/handshake.h b/src/handshake.h @@ -92,6 +92,8 @@ struct handshake_state { uint8_t *supplicant_rsnxe; uint8_t *mde; uint8_t *fte; + uint8_t *vendor_ies; + size_t vendor_ies_len; enum ie_rsn_cipher_suite pairwise_cipher; enum ie_rsn_cipher_suite group_cipher; enum ie_rsn_cipher_suite group_management_cipher; @@ -178,6 +180,9 @@ void handshake_state_set_ssid(struct handshake_state *s, void handshake_state_set_mde(struct handshake_state *s, const uint8_t *mde); void handshake_state_set_fte(struct handshake_state *s, const uint8_t *fte); +void handshake_state_set_vendor_ies(struct handshake_state *s, + const struct iovec *iov, + size_t n_iovs); void handshake_state_set_kh_ids(struct handshake_state *s, const uint8_t *r0khid, size_t r0khid_len, diff --git a/src/hotspot.c b/src/hotspot.c @@ -495,12 +495,17 @@ static int hotspot_init(void) char *filename; struct network_config config; - if (dirent->d_type != DT_REG && dirent->d_type != DT_LNK) - continue; - filename = l_strdup_printf("%s/%s", hs20_dir, dirent->d_name); s = l_settings_new(); + if (dirent->d_type == DT_UNKNOWN) { + if (!storage_is_file(filename)) + goto next; + } else if (dirent->d_type != DT_REG && + dirent->d_type != DT_LNK) { + goto next; + } + if (!l_settings_load_from_file(s, filename)) goto next; diff --git a/src/ie.h b/src/ie.h @@ -265,9 +265,21 @@ enum ie_type { IE_TYPE_FILS_PUBLIC_KEY = 256 + 12, IE_TYPE_FILS_NONCE = 256 + 13, IE_TYPE_FUTURE_CHANNEL_GUIDANCE = 256 + 14, + IE_TYPE_SERVICE_HINT = 256 + 15, + IE_TYPE_SERVICE_HASH = 256 + 16, + IE_TYPE_CDMG_CAPABILITIES = 256 + 17, + IE_TYPE_CLUSTER_PROBE = 256 + 21, + IE_TYPE_CMMG_CAPABILITIES = 256 + 27, + IE_TYPE_CMMG_OPERATION = 256 + 28, IE_TYPE_OWE_DH_PARAM = 256 + 32, IE_TYPE_PASSWORD_IDENTIFIER = 256 + 33, + IE_TYPE_GLK_GCR_PARAMETER_SET = 256 + 34, + IE_TYPE_VENDOR_SPECIFIC_REQUEST = 256 + 44, + IE_TYPE_MAX_CHANNEL_SWITCH_TIME = 256 + 52, + IE_TYPE_ESTIMATED_SERVICE_PARAMETERS_OUT = 256 + 53, IE_TYPE_OCI = 256 + 54, + IE_TYPE_MSCS_DESCRIPTOR = 256 + 88, + IE_TYPE_SUPPLEMENTAL_CLASS_2_CAPABILITIES = 256 + 90, IE_TYPE_REJECTED_GROUPS = 256 + 92, IE_TYPE_ANTI_CLOGGING_TOKEN_CONTAINER = 256 + 93, }; diff --git a/src/knownnetworks.c b/src/knownnetworks.c @@ -1087,8 +1087,13 @@ static int known_networks_init(void) struct l_settings *settings; L_AUTO_FREE_VAR(char *, full_path) = NULL; - if (dirent->d_type != DT_REG && dirent->d_type != DT_LNK) + if (dirent->d_type == DT_UNKNOWN) { + if (!storage_is_file(dirent->d_name)) + continue; + } else if (dirent->d_type != DT_REG && + dirent->d_type != DT_LNK) { continue; + } ssid = storage_network_ssid_from_path(dirent->d_name, &security); diff --git a/src/mpdu.c b/src/mpdu.c @@ -24,11 +24,274 @@ #include <config.h> #endif +#include <limits.h> +#include <errno.h> + #include <ell/ell.h> #include "src/ie.h" #include "src/mpdu.h" +/* 802.11-2020 section 9.3.3.5 */ +static const enum ie_type association_request_ie_order[] = { + IE_TYPE_SSID, + IE_TYPE_SUPPORTED_RATES, + IE_TYPE_EXTENDED_SUPPORTED_RATES, + IE_TYPE_POWER_CAPABILITY, + IE_TYPE_SUPPORTED_CHANNELS, + IE_TYPE_RSN, + IE_TYPE_QOS_CAPABILITY, + IE_TYPE_RM_ENABLED_CAPABILITIES, + IE_TYPE_MOBILITY_DOMAIN, + IE_TYPE_SUPPORTED_OPERATING_CLASSES, + IE_TYPE_HT_CAPABILITIES, + IE_TYPE_BSS_COEXISTENCE, + IE_TYPE_EXTENDED_CAPABILITIES, + IE_TYPE_QOS_TRAFFIC_CAPABILITY, + IE_TYPE_TIM_BROADCAST_REQUEST, + IE_TYPE_INTERWORKING, + IE_TYPE_MULTIBAND, + IE_TYPE_DMG_CAPABILITIES, + IE_TYPE_MULTIPLE_MAC_SUBLAYERS, + IE_TYPE_VHT_CAPABILITIES, + IE_TYPE_OPERATING_MODE_NOTIFICATION, + IE_TYPE_FILS_SESSION, + IE_TYPE_FILS_PUBLIC_KEY, + IE_TYPE_FILS_KEY_CONFIRMATION, + IE_TYPE_FILS_HLP_CONTAINER, + IE_TYPE_FILS_IP_ADDRESS, + IE_TYPE_TWT, + IE_TYPE_AID_REQUEST, + IE_TYPE_S1G_CAPABILITIES, + IE_TYPE_EL_OPERATION, + IE_TYPE_S1G_RELAY, + IE_TYPE_BSS_MAX_IDLE_PERIOD, + IE_TYPE_HEADER_COMPRESSION, + IE_TYPE_MAD, + IE_TYPE_REACHABLE_ADDRESS, + IE_TYPE_S1G_RELAY_ACTIVATION, + IE_TYPE_CDMG_CAPABILITIES, + IE_TYPE_CMMG_CAPABILITIES, + IE_TYPE_GLK_GCR_PARAMETER_SET, + IE_TYPE_FAST_BSS_TRANSITION, + IE_TYPE_RSNX, + IE_TYPE_SUPPLEMENTAL_CLASS_2_CAPABILITIES, + IE_TYPE_MSCS_DESCRIPTOR, + IE_TYPE_VENDOR_SPECIFIC, +}; + +/* 802.11-2020 section 9.3.3.6 */ +static const enum ie_type association_response_ie_order[] = { + IE_TYPE_AID, + IE_TYPE_SUPPORTED_RATES, + IE_TYPE_EXTENDED_SUPPORTED_RATES, + IE_TYPE_EDCA_PARAMETER_SET, + IE_TYPE_RCPI, + IE_TYPE_RSNI, + IE_TYPE_RM_ENABLED_CAPABILITIES, + IE_TYPE_RSN, + IE_TYPE_MOBILITY_DOMAIN, + IE_TYPE_FAST_BSS_TRANSITION, + IE_TYPE_DSE_REGISTERED_LOCATION, + IE_TYPE_TIMEOUT_INTERVAL, + IE_TYPE_HT_CAPABILITIES, + IE_TYPE_HT_OPERATION, + IE_TYPE_BSS_COEXISTENCE, + IE_TYPE_OVERLAPPING_BSS_SCAN_PARAMETERS, + IE_TYPE_EXTENDED_CAPABILITIES, + IE_TYPE_BSS_MAX_IDLE_PERIOD, + IE_TYPE_TIM_BROADCAST_RESPONSE, + IE_TYPE_QOS_MAP_SET, + IE_TYPE_QMF_POLICY, + IE_TYPE_MULTIBAND, + IE_TYPE_DMG_CAPABILITIES, + IE_TYPE_DMG_OPERATION, + IE_TYPE_MULTIPLE_MAC_SUBLAYERS, + IE_TYPE_NEIGHBOR_REPORT, + IE_TYPE_VHT_CAPABILITIES, + IE_TYPE_VHT_OPERATION, + IE_TYPE_OPERATING_MODE_NOTIFICATION, + IE_TYPE_FUTURE_CHANNEL_GUIDANCE, + IE_TYPE_FILS_SESSION, + IE_TYPE_FILS_PUBLIC_KEY, + IE_TYPE_FILS_KEY_CONFIRMATION, + IE_TYPE_FILS_HLP_CONTAINER, + IE_TYPE_FILS_IP_ADDRESS, + IE_TYPE_KEY_DELIVERY, + IE_TYPE_S1G_SECTOR_OPERATION, + IE_TYPE_TWT, + IE_TYPE_TSF_TIMER_ACCURACY, + IE_TYPE_S1G_CAPABILITIES, + IE_TYPE_S1G_OPERATION, + IE_TYPE_AID_RESPONSE, + IE_TYPE_SECTORIZED_GROUP_ID_LIST, + IE_TYPE_S1G_RELAY, + IE_TYPE_HEADER_COMPRESSION, + IE_TYPE_SST_OPERATION, + IE_TYPE_MAD, + IE_TYPE_S1G_RELAY_ACTIVATION, + IE_TYPE_CDMG_CAPABILITIES, + IE_TYPE_CMMG_CAPABILITIES, + IE_TYPE_CMMG_OPERATION, + IE_TYPE_GLK_GCR_PARAMETER_SET, + IE_TYPE_RSNX, + IE_TYPE_MSCS_DESCRIPTOR, + IE_TYPE_VENDOR_SPECIFIC, +}; + +/* 802.11-2020 section 9.3.3.7 */ +static const enum ie_type reassociation_request_ie_order[] = { + IE_TYPE_SSID, + IE_TYPE_SUPPORTED_RATES, + IE_TYPE_EXTENDED_SUPPORTED_RATES, + IE_TYPE_POWER_CAPABILITY, + IE_TYPE_SUPPORTED_CHANNELS, + IE_TYPE_RSN, + IE_TYPE_QOS_CAPABILITY, + IE_TYPE_RM_ENABLED_CAPABILITIES, + IE_TYPE_MOBILITY_DOMAIN, + IE_TYPE_FAST_BSS_TRANSITION, + IE_TYPE_RIC_DATA, + IE_TYPE_SUPPORTED_OPERATING_CLASSES, + IE_TYPE_HT_CAPABILITIES, + IE_TYPE_BSS_COEXISTENCE, + IE_TYPE_EXTENDED_CAPABILITIES, + IE_TYPE_QOS_TRAFFIC_CAPABILITY, + IE_TYPE_TIM_BROADCAST_REQUEST, + IE_TYPE_FMS_REQUEST, + IE_TYPE_DMS_REQUEST, + IE_TYPE_INTERWORKING, + IE_TYPE_MULTIBAND, + IE_TYPE_DMG_CAPABILITIES, + IE_TYPE_MULTIPLE_MAC_SUBLAYERS, + IE_TYPE_VHT_CAPABILITIES, + IE_TYPE_OPERATING_MODE_NOTIFICATION, + IE_TYPE_FILS_SESSION, + IE_TYPE_FILS_PUBLIC_KEY, + IE_TYPE_FILS_KEY_CONFIRMATION, + IE_TYPE_FILS_HLP_CONTAINER, + IE_TYPE_FILS_IP_ADDRESS, + IE_TYPE_TWT, + IE_TYPE_AID_REQUEST, + IE_TYPE_S1G_CAPABILITIES, + IE_TYPE_EL_OPERATION, + IE_TYPE_BSS_MAX_IDLE_PERIOD, + IE_TYPE_S1G_RELAY, + IE_TYPE_HEADER_COMPRESSION, + IE_TYPE_MAD, + IE_TYPE_REACHABLE_ADDRESS, + IE_TYPE_S1G_RELAY_ACTIVATION, + IE_TYPE_CDMG_CAPABILITIES, + IE_TYPE_CMMG_CAPABILITIES, + IE_TYPE_OCI, + IE_TYPE_GLK_GCR_PARAMETER_SET, + IE_TYPE_RSNX, + IE_TYPE_SUPPLEMENTAL_CLASS_2_CAPABILITIES, + IE_TYPE_MSCS_DESCRIPTOR, + IE_TYPE_VENDOR_SPECIFIC, +}; + +/* 802.11-2020 section 9.3.3.8 */ +static const enum ie_type reassociation_response_ie_order[] = { + IE_TYPE_AID, + IE_TYPE_SUPPORTED_RATES, + IE_TYPE_EXTENDED_SUPPORTED_RATES, + IE_TYPE_EDCA_PARAMETER_SET, + IE_TYPE_RCPI, + IE_TYPE_RSNI, + IE_TYPE_RM_ENABLED_CAPABILITIES, + IE_TYPE_RSN, + IE_TYPE_MOBILITY_DOMAIN, + IE_TYPE_FAST_BSS_TRANSITION, + IE_TYPE_RIC_DATA, + IE_TYPE_DSE_REGISTERED_LOCATION, + IE_TYPE_TIMEOUT_INTERVAL, + IE_TYPE_HT_CAPABILITIES, + IE_TYPE_HT_OPERATION, + IE_TYPE_BSS_COEXISTENCE, + IE_TYPE_OVERLAPPING_BSS_SCAN_PARAMETERS, + IE_TYPE_EXTENDED_CAPABILITIES, + IE_TYPE_BSS_MAX_IDLE_PERIOD, + IE_TYPE_TIM_BROADCAST_RESPONSE, + IE_TYPE_FMS_RESPONSE, + IE_TYPE_DMS_RESPONSE, + IE_TYPE_QOS_MAP_SET, + IE_TYPE_QMF_POLICY, + IE_TYPE_MULTIBAND, + IE_TYPE_DMG_CAPABILITIES, + IE_TYPE_DMG_OPERATION, + IE_TYPE_MULTIPLE_MAC_SUBLAYERS, + IE_TYPE_NEIGHBOR_REPORT, + IE_TYPE_VHT_CAPABILITIES, + IE_TYPE_VHT_OPERATION, + IE_TYPE_OPERATING_MODE_NOTIFICATION, + IE_TYPE_FUTURE_CHANNEL_GUIDANCE, + IE_TYPE_FILS_SESSION, + IE_TYPE_FILS_PUBLIC_KEY, + IE_TYPE_FILS_KEY_CONFIRMATION, + IE_TYPE_FILS_HLP_CONTAINER, + IE_TYPE_FILS_IP_ADDRESS, + IE_TYPE_KEY_DELIVERY, + IE_TYPE_S1G_SECTOR_OPERATION, + IE_TYPE_TWT, + IE_TYPE_TSF_TIMER_ACCURACY, + IE_TYPE_S1G_CAPABILITIES, + IE_TYPE_S1G_OPERATION, + IE_TYPE_AID_RESPONSE, + IE_TYPE_SECTORIZED_GROUP_ID_LIST, + IE_TYPE_S1G_RELAY, + IE_TYPE_HEADER_COMPRESSION, + IE_TYPE_SST_OPERATION, + IE_TYPE_MAD, + IE_TYPE_S1G_RELAY_ACTIVATION, + IE_TYPE_CDMG_CAPABILITIES, + IE_TYPE_CMMG_CAPABILITIES, + IE_TYPE_CMMG_OPERATION, + IE_TYPE_OCI, + IE_TYPE_GLK_GCR_PARAMETER_SET, + IE_TYPE_RSNX, + IE_TYPE_MSCS_DESCRIPTOR, + IE_TYPE_VENDOR_SPECIFIC, +}; + +/* 802.11-2020 section 9.3.3.9 */ +static const enum ie_type probe_request_ie_order[] = { + IE_TYPE_SSID, + IE_TYPE_SUPPORTED_RATES, + IE_TYPE_REQUEST, + IE_TYPE_EXTENDED_SUPPORTED_RATES, + IE_TYPE_DSSS_PARAMETER_SET, + IE_TYPE_SUPPORTED_OPERATING_CLASSES, + IE_TYPE_HT_CAPABILITIES, + IE_TYPE_BSS_COEXISTENCE, + IE_TYPE_EXTENDED_CAPABILITIES, + IE_TYPE_SSID_LIST, + IE_TYPE_CHANNEL_USAGE, + IE_TYPE_INTERWORKING, + IE_TYPE_MESH_ID, + IE_TYPE_MULTIBAND, + IE_TYPE_DMG_CAPABILITIES, + IE_TYPE_MULTIPLE_MAC_SUBLAYERS, + IE_TYPE_VHT_CAPABILITIES, + IE_TYPE_ESTIMATED_SERVICE_PARAMETERS, + IE_TYPE_EXTENDED_REQUEST, + IE_TYPE_FILS_REQUEST_PARAMETERS, + IE_TYPE_AP_CSN, + IE_TYPE_CHANGE_SEQUENCE, + IE_TYPE_S1G_RELAY_DISCOVERY, + IE_TYPE_PV1_PROBE_RESPONSE_OPTION, + IE_TYPE_S1G_CAPABILITIES, + IE_TYPE_EL_OPERATION, + IE_TYPE_MAD, + IE_TYPE_VENDOR_SPECIFIC_REQUEST, + IE_TYPE_CDMG_CAPABILITIES, + IE_TYPE_CLUSTER_PROBE, + IE_TYPE_CMMG_CAPABILITIES, + IE_TYPE_ESTIMATED_SERVICE_PARAMETERS_OUT, + IE_TYPE_SUPPLEMENTAL_CLASS_2_CAPABILITIES, + IE_TYPE_VENDOR_SPECIFIC, +}; + static bool validate_mgmt_header(const struct mmpdu_header *mpdu, int len, int *offset) { @@ -128,7 +391,8 @@ static bool validate_mgmt_ies(const uint8_t *ies, size_t ies_len, tag != IE_TYPE_EMERGENCY_ALERT_IDENTIFIER && tag != IE_TYPE_MULTIPLE_BSSID && tag != IE_TYPE_NEIGHBOR_REPORT && - tag != IE_TYPE_QUIET_CHANNEL) { + tag != IE_TYPE_QUIET_CHANNEL && + tag != IE_TYPE_FILS_HLP_CONTAINER) { struct ie_tlv_iter clone; memcpy(&clone, &iter, sizeof(clone)); @@ -148,195 +412,85 @@ static bool validate_mgmt_ies(const uint8_t *ies, size_t ies_len, return true; } -/* 802.11-2016 section 9.3.3.6 */ static bool validate_association_request_mmpdu(const struct mmpdu_header *mpdu, int len, int *offset) { const struct mmpdu_association_request *body = (const void *) mpdu + *offset; - static const enum ie_type ie_order[] = { - IE_TYPE_SSID, - IE_TYPE_SUPPORTED_RATES, - IE_TYPE_EXTENDED_SUPPORTED_RATES, - IE_TYPE_POWER_CAPABILITY, - IE_TYPE_SUPPORTED_CHANNELS, - IE_TYPE_RSN, - IE_TYPE_QOS_CAPABILITY, - IE_TYPE_RM_ENABLED_CAPABILITIES, - IE_TYPE_MOBILITY_DOMAIN, - IE_TYPE_SUPPORTED_OPERATING_CLASSES, - IE_TYPE_HT_CAPABILITIES, - IE_TYPE_BSS_COEXISTENCE, - IE_TYPE_EXTENDED_CAPABILITIES, - IE_TYPE_QOS_TRAFFIC_CAPABILITY, - IE_TYPE_TIM_BROADCAST_REQUEST, - IE_TYPE_INTERWORKING, - IE_TYPE_VENDOR_SPECIFIC, - }; if (len < *offset + (int) sizeof(struct mmpdu_association_request)) return false; *offset += sizeof(struct mmpdu_association_request); - return validate_mgmt_ies(body->ies, len - *offset, ie_order, - L_ARRAY_SIZE(ie_order)); + return validate_mgmt_ies(body->ies, len - *offset, + association_request_ie_order, + L_ARRAY_SIZE(association_request_ie_order)); } -/* 802.11-2016 section 9.3.3.7 */ static bool validate_association_response_mmpdu(const struct mmpdu_header *mpdu, int len, int *offset) { const struct mmpdu_association_response *body = (const void *) mpdu + *offset; - static const enum ie_type ie_order[] = { - IE_TYPE_SUPPORTED_RATES, - IE_TYPE_EXTENDED_SUPPORTED_RATES, - IE_TYPE_EDCA_PARAMETER_SET, - IE_TYPE_RCPI, - IE_TYPE_RSNI, - IE_TYPE_RM_ENABLED_CAPABILITIES, - IE_TYPE_MOBILITY_DOMAIN, - IE_TYPE_FAST_BSS_TRANSITION, - IE_TYPE_DSE_REGISTERED_LOCATION, - IE_TYPE_TIMEOUT_INTERVAL, - IE_TYPE_HT_CAPABILITIES, - IE_TYPE_HT_OPERATION, - IE_TYPE_BSS_COEXISTENCE, - IE_TYPE_OVERLAPPING_BSS_SCAN_PARAMETERS, - IE_TYPE_EXTENDED_CAPABILITIES, - IE_TYPE_BSS_MAX_IDLE_PERIOD, - IE_TYPE_TIM_BROADCAST_RESPONSE, - IE_TYPE_QOS_MAP_SET, - IE_TYPE_VENDOR_SPECIFIC, - }; if (len < *offset + (int) sizeof(struct mmpdu_association_response)) return false; *offset += sizeof(struct mmpdu_association_response); - return validate_mgmt_ies(body->ies, len - *offset, ie_order, - L_ARRAY_SIZE(ie_order)); + return validate_mgmt_ies(body->ies, len - *offset, + association_response_ie_order, + L_ARRAY_SIZE(association_response_ie_order)); } -/* 802.11-2016 section 9.3.3.8 */ static bool validate_reassociation_request_mmpdu( const struct mmpdu_header *mpdu, int len, int *offset) { const struct mmpdu_reassociation_request *body = (const void *) mpdu + *offset; - static const enum ie_type ie_order[] = { - IE_TYPE_SSID, - IE_TYPE_SUPPORTED_RATES, - IE_TYPE_EXTENDED_SUPPORTED_RATES, - IE_TYPE_POWER_CAPABILITY, - IE_TYPE_SUPPORTED_CHANNELS, - IE_TYPE_RSN, - IE_TYPE_QOS_CAPABILITY, - IE_TYPE_RM_ENABLED_CAPABILITIES, - IE_TYPE_MOBILITY_DOMAIN, - IE_TYPE_FAST_BSS_TRANSITION, - IE_TYPE_RIC_DATA, - IE_TYPE_SUPPORTED_OPERATING_CLASSES, - IE_TYPE_HT_CAPABILITIES, - IE_TYPE_BSS_COEXISTENCE, - IE_TYPE_EXTENDED_CAPABILITIES, - IE_TYPE_QOS_TRAFFIC_CAPABILITY, - IE_TYPE_TIM_BROADCAST_REQUEST, - IE_TYPE_FMS_REQUEST, - IE_TYPE_DMS_REQUEST, - IE_TYPE_INTERWORKING, - IE_TYPE_VENDOR_SPECIFIC, - }; if (len < *offset + (int) sizeof(struct mmpdu_reassociation_request)) return false; *offset += sizeof(struct mmpdu_reassociation_request); - return validate_mgmt_ies(body->ies, len - *offset, ie_order, - L_ARRAY_SIZE(ie_order)); + return validate_mgmt_ies(body->ies, len - *offset, + reassociation_request_ie_order, + L_ARRAY_SIZE(reassociation_request_ie_order)); } -/* 802.11-2016 section 9.3.3.9 */ static bool validate_reassociation_response_mmpdu( const struct mmpdu_header *mpdu, int len, int *offset) { const struct mmpdu_reassociation_response *body = (const void *) mpdu + *offset; - static const enum ie_type ie_order[] = { - IE_TYPE_SUPPORTED_RATES, - IE_TYPE_EXTENDED_SUPPORTED_RATES, - IE_TYPE_EDCA_PARAMETER_SET, - IE_TYPE_RCPI, - IE_TYPE_RSNI, - IE_TYPE_RM_ENABLED_CAPABILITIES, - IE_TYPE_RSN, - IE_TYPE_MOBILITY_DOMAIN, - IE_TYPE_FAST_BSS_TRANSITION, - IE_TYPE_RIC_DATA, - IE_TYPE_DSE_REGISTERED_LOCATION, - IE_TYPE_TIMEOUT_INTERVAL, - IE_TYPE_HT_CAPABILITIES, - IE_TYPE_HT_OPERATION, - IE_TYPE_BSS_COEXISTENCE, - IE_TYPE_OVERLAPPING_BSS_SCAN_PARAMETERS, - IE_TYPE_EXTENDED_CAPABILITIES, - IE_TYPE_BSS_MAX_IDLE_PERIOD, - IE_TYPE_TIM_BROADCAST_RESPONSE, - IE_TYPE_FMS_RESPONSE, - IE_TYPE_DMS_RESPONSE, - IE_TYPE_QOS_MAP_SET, - IE_TYPE_VENDOR_SPECIFIC, - }; if (len < *offset + (int) sizeof(struct mmpdu_reassociation_response)) return false; *offset += sizeof(struct mmpdu_reassociation_response); - return validate_mgmt_ies(body->ies, len - *offset, ie_order, - L_ARRAY_SIZE(ie_order)); + return validate_mgmt_ies(body->ies, len - *offset, + reassociation_response_ie_order, + L_ARRAY_SIZE(reassociation_response_ie_order)); } -/* 802.11-2016 section 9.3.3.10 */ static bool validate_probe_request_mmpdu(const struct mmpdu_header *mpdu, int len, int *offset) { const struct mmpdu_probe_request *body = (const void *) mpdu + *offset; - static const enum ie_type ie_order[] = { - IE_TYPE_SSID, - IE_TYPE_SUPPORTED_RATES, - IE_TYPE_REQUEST, - IE_TYPE_EXTENDED_SUPPORTED_RATES, - IE_TYPE_DSSS_PARAMETER_SET, - IE_TYPE_SUPPORTED_OPERATING_CLASSES, - IE_TYPE_HT_CAPABILITIES, - IE_TYPE_BSS_COEXISTENCE, - IE_TYPE_EXTENDED_CAPABILITIES, - IE_TYPE_SSID_LIST, - IE_TYPE_CHANNEL_USAGE, - IE_TYPE_INTERWORKING, - IE_TYPE_MESH_ID, - IE_TYPE_MULTIBAND, - IE_TYPE_DMG_CAPABILITIES, - IE_TYPE_MULTIPLE_MAC_SUBLAYERS, - IE_TYPE_VHT_CAPABILITIES, - IE_TYPE_ESTIMATED_SERVICE_PARAMETERS, - IE_TYPE_EXTENDED_REQUEST, - IE_TYPE_VENDOR_SPECIFIC, - }; if (len < *offset + (int) sizeof(struct mmpdu_probe_request)) return false; *offset += sizeof(struct mmpdu_probe_request); - return validate_mgmt_ies(body->ies, len - *offset, ie_order, - L_ARRAY_SIZE(ie_order)); + return validate_mgmt_ies(body->ies, len - *offset, + probe_request_ie_order, + L_ARRAY_SIZE(probe_request_ie_order)); } /* 802.11-2016 section 9.3.3.11 */ @@ -360,7 +514,7 @@ static bool validate_probe_response_mmpdu(const struct mmpdu_header *mpdu, return true; } -/* 802.11-2016 section 9.3.3.16 */ +/* 802.11-2020 section 9.3.3.15 */ static bool validate_timing_advertisement_mmpdu(const struct mmpdu_header *mpdu, int len, int *offset) { @@ -383,7 +537,7 @@ static bool validate_timing_advertisement_mmpdu(const struct mmpdu_header *mpdu, L_ARRAY_SIZE(ie_order)); } -/* 802.11-2016 section 9.3.3.3 */ +/* 802.11-2020 section 9.3.3.2 */ static bool validate_beacon_mmpdu(const struct mmpdu_header *mpdu, int len, int *offset) { @@ -453,6 +607,15 @@ static bool validate_beacon_mmpdu(const struct mmpdu_header *mpdu, IE_TYPE_TVHT_OPERATION, IE_TYPE_ESTIMATED_SERVICE_PARAMETERS, IE_TYPE_FUTURE_CHANNEL_GUIDANCE, + IE_TYPE_CAG_NUMBER, + IE_TYPE_FILS_INDICATION, + IE_TYPE_AP_CSN, + IE_TYPE_DILS, + IE_TYPE_MAX_CHANNEL_SWITCH_TIME, + IE_TYPE_ESTIMATED_SERVICE_PARAMETERS_OUT, + IE_TYPE_SERVICE_HINT, + IE_TYPE_SERVICE_HASH, + IE_TYPE_RSNX, IE_TYPE_VENDOR_SPECIFIC, }; @@ -632,3 +795,80 @@ const void *mmpdu_body(const struct mmpdu_header *mmpdu) { return ((const uint8_t *) mmpdu + mmpdu_header_len(mmpdu)); } + +struct ie_sort_info { + const enum ie_type *ie_order; + size_t n_elem; +}; + +static struct ie_sort_info sortinfo; + +static unsigned int ie_order_find(const struct iovec *iov) +{ + const uint8_t *ie = iov->iov_base; + enum ie_type type = ie[0]; + unsigned int i; + + if (ie[0] == IE_TYPE_EXTENSION) + type = 256 + ie[2]; + + for (i = 0; i < sortinfo.n_elem; i++) { + if (sortinfo.ie_order[i] != type) + continue; + + return i; + } + + return UINT_MAX; +} + +static int ie_order_compare(const void *a, const void *b) +{ + const struct iovec *iova = a; + const struct iovec *iovb = b; + unsigned int ia = ie_order_find(iova); + unsigned int ib = ie_order_find(iovb); + + if (ia < ib) + return -1; + if (ia > ib) + return 1; + return 0; +} + +int mpdu_sort_ies(enum mpdu_management_subtype type, + struct iovec *iov, size_t n_iovs) +{ + switch (type) { + case MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST: + sortinfo.ie_order = association_request_ie_order; + sortinfo.n_elem = L_ARRAY_SIZE(association_request_ie_order); + break; + case MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_RESPONSE: + sortinfo.ie_order = association_response_ie_order; + sortinfo.n_elem = L_ARRAY_SIZE(association_response_ie_order); + break; + case MPDU_MANAGEMENT_SUBTYPE_REASSOCIATION_REQUEST: + sortinfo.ie_order = reassociation_request_ie_order; + sortinfo.n_elem = L_ARRAY_SIZE(reassociation_request_ie_order); + break; + case MPDU_MANAGEMENT_SUBTYPE_REASSOCIATION_RESPONSE: + sortinfo.ie_order = reassociation_response_ie_order; + sortinfo.n_elem = L_ARRAY_SIZE(reassociation_response_ie_order); + break; + case MPDU_MANAGEMENT_SUBTYPE_PROBE_REQUEST: + sortinfo.ie_order = probe_request_ie_order; + sortinfo.n_elem = L_ARRAY_SIZE(probe_request_ie_order); + break; + default: + return -ENOTSUP; + } + + /* + * qsort_r would be better, but it is still missing on some non-glibc + * implementations, and since iwd is not multi-threaded, qsort is + * just as good + */ + qsort(iov, n_iovs, sizeof(struct iovec), ie_order_compare); + return 0; +} diff --git a/src/mpdu.h b/src/mpdu.h @@ -411,3 +411,6 @@ struct mmpdu_deauthentication { const struct mmpdu_header *mpdu_validate(const uint8_t *frame, int len); const void *mmpdu_body(const struct mmpdu_header *mpdu); size_t mmpdu_header_len(const struct mmpdu_header *mmpdu); + +int mpdu_sort_ies(enum mpdu_management_subtype type, + struct iovec *iov, size_t n_iovs); diff --git a/src/netdev.c b/src/netdev.c @@ -110,7 +110,6 @@ struct netdev { struct wiphy *wiphy; unsigned int ifi_flags; uint32_t frequency; - uint32_t prev_frequency; netdev_event_func_t event_filter; netdev_connect_cb_t connect_cb; @@ -135,7 +134,6 @@ struct netdev { struct l_timeout *sa_query_timeout; struct l_timeout *group_handshake_timeout; uint16_t sa_query_id; - uint8_t prev_bssid[ETH_ALEN]; uint8_t prev_snonce[32]; int8_t rssi_levels[16]; uint8_t rssi_levels_num; @@ -182,6 +180,7 @@ struct netdev { bool aborting : 1; bool events_ready : 1; bool retry_auth : 1; + bool in_reassoc : 1; }; struct netdev_preauth_state { @@ -270,6 +269,32 @@ static inline bool is_offload(struct handshake_state *hs) return false; } +static unsigned int netdev_populate_common_ies(struct netdev *netdev, + struct handshake_state *hs, + struct l_genl_msg *msg, + struct iovec *iov, + unsigned int n_iov, + unsigned int c_iov) +{ + const uint8_t *extended_capabilities; + const uint8_t *rm_enabled_capabilities; + + extended_capabilities = wiphy_get_extended_capabilities(netdev->wiphy, + netdev->type); + c_iov = iov_ie_append(iov, n_iov, c_iov, extended_capabilities); + + rm_enabled_capabilities = + wiphy_get_rm_enabled_capabilities(netdev->wiphy); + c_iov = iov_ie_append(iov, n_iov, c_iov, rm_enabled_capabilities); + + if (rm_enabled_capabilities) + l_genl_msg_append_attr(msg, NL80211_ATTR_USE_RRM, 0, NULL); + + c_iov = iov_ie_append(iov, n_iov, c_iov, hs->vendor_ies); + + return c_iov; +} + /* Cancels ongoing GTK/IGTK related commands (if any) */ static void netdev_handshake_state_cancel_rekey( struct netdev_handshake_state *nhs) @@ -756,6 +781,7 @@ static void netdev_connect_free(struct netdev *netdev) netdev->result = NETDEV_RESULT_OK; netdev->last_code = 0; netdev->in_ft = false; + netdev->in_reassoc = false; netdev->ignore_connect_event = false; netdev->expect_connect_failure = false; netdev->cur_rssi_low = false; @@ -1098,7 +1124,7 @@ static void netdev_disconnect_event(struct l_genl_msg *msg, l_debug(""); if (!netdev->connected || netdev->disconnect_cmd_id > 0 || - netdev->in_ft) + netdev->in_ft || netdev->in_reassoc) return; if (!l_genl_attr_init(&attr, msg)) { @@ -2535,6 +2561,7 @@ static void netdev_associate_event(struct l_genl_msg *msg, false); netdev->in_ft = false; + netdev->in_reassoc = false; netdev->associated = true; return; } else if (ret == -EAGAIN) { @@ -2704,18 +2731,28 @@ static void netdev_sae_tx_associate(void *user_data) struct netdev *netdev = user_data; struct handshake_state *hs = netdev->handshake; struct l_genl_msg *msg; - struct iovec iov[3]; + struct iovec iov[64]; unsigned int n_iov = L_ARRAY_SIZE(iov); unsigned int n_used = 0; + enum mpdu_management_subtype subtype = + MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST; msg = netdev_build_cmd_associate_common(netdev); n_used = iov_ie_append(iov, n_iov, n_used, hs->supplicant_ie); n_used = iov_ie_append(iov, n_iov, n_used, hs->mde); n_used = iov_ie_append(iov, n_iov, n_used, hs->supplicant_rsnxe); + n_used = netdev_populate_common_ies(netdev, hs, msg, + iov, n_iov, n_used); + mpdu_sort_ies(subtype, iov, n_used); l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, n_used); + /* If doing a non-FT Reassociation */ + if (netdev->in_reassoc) + l_genl_msg_append_attr(msg, NL80211_ATTR_PREV_BSSID, 6, + netdev->ap->prev_bssid); + if (!l_genl_family_send(nl80211, msg, netdev_assoc_cb, netdev, NULL)) { l_genl_msg_unref(msg); netdev_connect_failed(netdev, NETDEV_RESULT_ASSOCIATION_FAILED, @@ -2743,15 +2780,35 @@ static void netdev_owe_tx_authenticate(void *user_data) netdev->auth_cmd = l_genl_msg_ref(msg); } -static void netdev_owe_tx_associate(struct iovec *ie_iov, size_t iov_len, +static void netdev_owe_tx_associate(struct iovec *owe_iov, size_t n_owe_iov, void *user_data) { struct netdev *netdev = user_data; + struct handshake_state *hs = netdev->handshake; struct l_genl_msg *msg; + struct iovec iov[64]; + unsigned int n_iov = L_ARRAY_SIZE(iov); + unsigned int c_iov = 0; + enum mpdu_management_subtype subtype = + MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST; msg = netdev_build_cmd_associate_common(netdev); - l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, ie_iov, iov_len); + c_iov = netdev_populate_common_ies(netdev, hs, msg, iov, n_iov, c_iov); + + if (!L_WARN_ON(n_iov - c_iov < n_owe_iov)) { + memcpy(iov + c_iov, owe_iov, sizeof(*owe_iov) * n_owe_iov); + c_iov += n_owe_iov; + } + + mpdu_sort_ies(subtype, iov, c_iov); + + l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, c_iov); + + /* If doing a non-FT Reassociation */ + if (netdev->in_reassoc) + l_genl_msg_append_attr(msg, NL80211_ATTR_PREV_BSSID, 6, + netdev->ap->prev_bssid); if (!l_genl_family_send(nl80211, msg, netdev_assoc_cb, netdev, NULL)) { @@ -2784,20 +2841,41 @@ static void netdev_fils_tx_authenticate(const uint8_t *body, netdev->auth_cmd = l_genl_msg_ref(msg); } -static void netdev_fils_tx_associate(struct iovec *iov, size_t iov_len, +static void netdev_fils_tx_associate(struct iovec *fils_iov, size_t n_fils_iov, const uint8_t *kek, size_t kek_len, - const uint8_t *nonces, size_t nonces_len, + const uint8_t *nonces, + size_t nonces_len, void *user_data) { struct netdev *netdev = user_data; + struct handshake_state *hs = netdev->handshake; struct l_genl_msg *msg; + struct iovec iov[64]; + unsigned int n_iov = L_ARRAY_SIZE(iov); + unsigned int c_iov = 0; + enum mpdu_management_subtype subtype = + MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST; msg = netdev_build_cmd_associate_common(netdev); + c_iov = netdev_populate_common_ies(netdev, hs, msg, iov, n_iov, c_iov); + + if (!L_WARN_ON(n_iov - c_iov < n_fils_iov)) { + memcpy(iov + c_iov, fils_iov, sizeof(*fils_iov) * n_fils_iov); + c_iov += n_fils_iov; + } + + mpdu_sort_ies(subtype, iov, c_iov); - l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, iov_len); + l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, c_iov); l_genl_msg_append_attr(msg, NL80211_ATTR_FILS_KEK, kek_len, kek); - l_genl_msg_append_attr(msg, NL80211_ATTR_FILS_NONCES, nonces_len, nonces); + l_genl_msg_append_attr(msg, NL80211_ATTR_FILS_NONCES, + nonces_len, nonces); + + /* If doing a non-FT Reassociation */ + if (netdev->in_reassoc) + l_genl_msg_append_attr(msg, NL80211_ATTR_PREV_BSSID, 6, + netdev->ap->prev_bssid); if (!l_genl_family_send(nl80211, msg, netdev_assoc_cb, netdev, NULL)) { @@ -2819,12 +2897,14 @@ static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev, uint32_t auth_type = IE_AKM_IS_SAE(hs->akm_suite) ? NL80211_AUTHTYPE_SAE : NL80211_AUTHTYPE_OPEN_SYSTEM; + enum mpdu_management_subtype subtype = prev_bssid ? + MPDU_MANAGEMENT_SUBTYPE_REASSOCIATION_REQUEST : + MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST; struct l_genl_msg *msg; - struct iovec iov[4 + num_vendor_ies]; - int iov_elems = 0; + struct iovec iov[64]; + unsigned int n_iov = L_ARRAY_SIZE(iov); + unsigned int c_iov = 0; bool is_rsn = hs->supplicant_ie != NULL; - const uint8_t *extended_capabilities; - const uint8_t *rm_enabled_capabilities; msg = l_genl_msg_new_sized(NL80211_CMD_CONNECT, 512); l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index); @@ -2903,10 +2983,7 @@ static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev, 4, &wpa_version); l_genl_msg_append_attr(msg, NL80211_ATTR_CONTROL_PORT, 0, NULL); - - iov[iov_elems].iov_base = (void *) hs->supplicant_ie; - iov[iov_elems].iov_len = hs->supplicant_ie[1] + 2; - iov_elems += 1; + c_iov = iov_ie_append(iov, n_iov, c_iov, hs->supplicant_ie); } if (netdev->pae_over_nl80211) @@ -2914,40 +2991,19 @@ static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev, NL80211_ATTR_CONTROL_PORT_OVER_NL80211, 0, NULL); - rm_enabled_capabilities = - wiphy_get_rm_enabled_capabilities(netdev->wiphy); - if (rm_enabled_capabilities && bss->capability & IE_BSS_CAP_RM) { - iov[iov_elems].iov_base = (void *) rm_enabled_capabilities; - iov[iov_elems].iov_len = rm_enabled_capabilities[1] + 2; - iov_elems += 1; - - l_genl_msg_append_attr(msg, NL80211_ATTR_USE_RRM, 0, NULL); - } - - if (hs->mde) { - iov[iov_elems].iov_base = (void *) hs->mde; - iov[iov_elems].iov_len = hs->mde[1] + 2; - iov_elems += 1; - } + c_iov = iov_ie_append(iov, n_iov, c_iov, hs->mde); + c_iov = netdev_populate_common_ies(netdev, hs, msg, iov, n_iov, c_iov); - /* - * This element should be added after MDE - * See 802.11-2016, Section 9.3.3.6 - */ - extended_capabilities = wiphy_get_extended_capabilities(netdev->wiphy, - netdev->type); - iov[iov_elems].iov_base = (void *) extended_capabilities; - iov[iov_elems].iov_len = extended_capabilities[1] + 2; - iov_elems += 1; + mpdu_sort_ies(subtype, iov, c_iov); - if (vendor_ies) { - memcpy(iov + iov_elems, vendor_ies, + if (vendor_ies && !L_WARN_ON(n_iov - c_iov < num_vendor_ies)) { + memcpy(iov + c_iov, vendor_ies, sizeof(*vendor_ies) * num_vendor_ies); - iov_elems += num_vendor_ies; + c_iov += num_vendor_ies; } - if (iov_elems) - l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, iov_elems); + if (c_iov) + l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, c_iov); return msg; } @@ -3308,6 +3364,9 @@ static int netdev_handshake_state_setup_connection_type( bool softmac = wiphy_supports_cmds_auth_assoc(wiphy); bool canroam = wiphy_supports_firmware_roam(wiphy); + if (hs->supplicant_ie == NULL) + goto softmac; + /* * Sanity check that any FT AKMs are set only on softmac or on * devices that support firmware roam @@ -3386,66 +3445,24 @@ offload_1x: return 0; } -static int netdev_connect_common(struct netdev *netdev, - struct l_genl_msg *cmd_connect, +static void netdev_connect_common(struct netdev *netdev, struct scan_bss *bss, + struct scan_bss *prev_bss, struct handshake_state *hs, - struct eapol_sm *sm, + const struct iovec *vendor_ies, + size_t num_vendor_ies, netdev_event_func_t event_filter, netdev_connect_cb_t cb, void *user_data) { - netdev->connect_cmd = cmd_connect; - netdev->event_filter = event_filter; - netdev->connect_cb = cb; - netdev->user_data = user_data; - netdev->handshake = hs; - netdev->sm = sm; - netdev->frequency = bss->frequency; - netdev->cur_rssi = bss->signal_strength / 100; - netdev_rssi_level_init(netdev); - netdev_cqm_rssi_update(netdev); - - handshake_state_set_authenticator_address(hs, bss->addr); - - if (!wiphy_has_ext_feature(netdev->wiphy, - NL80211_EXT_FEATURE_CAN_REPLACE_PTK0)) - handshake_state_set_no_rekey(hs, true); - - wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1, - &connect_work_ops); - return 0; -} - -int netdev_connect(struct netdev *netdev, struct scan_bss *bss, - struct handshake_state *hs, - const struct iovec *vendor_ies, - size_t num_vendor_ies, - netdev_event_func_t event_filter, - netdev_connect_cb_t cb, void *user_data) -{ struct netdev_handshake_state *nhs = l_container_of(hs, struct netdev_handshake_state, super); struct l_genl_msg *cmd_connect = NULL; struct eapol_sm *sm = NULL; bool is_rsn = hs->supplicant_ie != NULL; + const uint8_t *prev_bssid = prev_bss ? prev_bss->addr : NULL; - if (!(netdev->ifi_flags & IFF_UP)) - return -ENETDOWN; - - if (netdev->type != NL80211_IFTYPE_STATION && - netdev->type != NL80211_IFTYPE_P2P_CLIENT) - return -ENOTSUP; - - if (netdev->connected || netdev->connect_cmd_id || netdev->work.id) - return -EISCONN; - - if (!is_rsn) { - nhs->type = CONNECTION_TYPE_SOFTMAC; + if (!is_rsn) goto build_cmd_connect; - } - - if (netdev_handshake_state_setup_connection_type(hs) < 0) - return -ENOTSUP; if (nhs->type != CONNECTION_TYPE_SOFTMAC) goto build_cmd_connect; @@ -3485,7 +3502,7 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss, default: build_cmd_connect: cmd_connect = netdev_build_cmd_connect(netdev, bss, hs, - NULL, vendor_ies, num_vendor_ies); + prev_bssid, vendor_ies, num_vendor_ies); if (!is_offload(hs) && (is_rsn || hs->settings_8021x)) { sm = eapol_sm_new(hs); @@ -3495,8 +3512,52 @@ build_cmd_connect: } } - return netdev_connect_common(netdev, cmd_connect, bss, hs, sm, - event_filter, cb, user_data); + netdev->connect_cmd = cmd_connect; + netdev->event_filter = event_filter; + netdev->connect_cb = cb; + netdev->user_data = user_data; + netdev->handshake = hs; + netdev->sm = sm; + netdev->frequency = bss->frequency; + netdev->cur_rssi = bss->signal_strength / 100; + netdev_rssi_level_init(netdev); + netdev_cqm_rssi_update(netdev); + + handshake_state_set_authenticator_address(hs, bss->addr); + + if (!wiphy_has_ext_feature(netdev->wiphy, + NL80211_EXT_FEATURE_CAN_REPLACE_PTK0)) + handshake_state_set_no_rekey(hs, true); + + wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1, + &connect_work_ops); +} + +int netdev_connect(struct netdev *netdev, struct scan_bss *bss, + struct handshake_state *hs, + const struct iovec *vendor_ies, + size_t num_vendor_ies, + netdev_event_func_t event_filter, + netdev_connect_cb_t cb, void *user_data) +{ + if (!(netdev->ifi_flags & IFF_UP)) + return -ENETDOWN; + + if (netdev->type != NL80211_IFTYPE_STATION && + netdev->type != NL80211_IFTYPE_P2P_CLIENT) + return -ENOTSUP; + + if (netdev->connected || netdev->connect_cmd_id || netdev->work.id) + return -EISCONN; + + if (netdev_handshake_state_setup_connection_type(hs) < 0) + return -ENOTSUP; + + netdev_connect_common(netdev, bss, NULL, hs, vendor_ies, + num_vendor_ies, event_filter, cb, + user_data); + + return 0; } static void disconnect_idle(struct l_idle *idle, void *user_data) @@ -3584,40 +3645,25 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss, netdev_event_func_t event_filter, netdev_connect_cb_t cb, void *user_data) { - struct l_genl_msg *cmd_connect; - struct netdev_handshake_state; struct handshake_state *old_hs; - struct eapol_sm *sm = NULL, *old_sm; - bool is_rsn = hs->supplicant_ie != NULL; - int err; - - if (netdev_handshake_state_setup_connection_type(hs) < 0) - return -ENOTSUP; - - /* TODO: SoftMac SAE/FILS Re-Associations are not suppored yet */ - if (L_WARN_ON(IE_AKM_IS_SAE(hs->akm_suite) || - IE_AKM_IS_FILS(hs->akm_suite))) - return -ENOTSUP; - - cmd_connect = netdev_build_cmd_connect(netdev, target_bss, hs, - orig_bss->addr, NULL, 0); - - if (is_rsn) - sm = eapol_sm_new(hs); + struct eapol_sm *old_sm; old_sm = netdev->sm; old_hs = netdev->handshake; - err = netdev_connect_common(netdev, cmd_connect, target_bss, hs, sm, - event_filter, cb, user_data); - if (err < 0) - return err; - - memcpy(netdev->prev_bssid, orig_bss->addr, ETH_ALEN); + if (netdev_handshake_state_setup_connection_type(hs) < 0) + return -ENOTSUP; netdev->associated = false; netdev->operational = false; netdev->connected = false; + netdev->in_reassoc = true; + + netdev_connect_common(netdev, target_bss, orig_bss, hs, NULL, 0, + event_filter, cb, user_data); + + if (netdev->ap) + memcpy(netdev->ap->prev_bssid, orig_bss->addr, ETH_ALEN); netdev_rssi_polling_update(netdev); @@ -3627,7 +3673,7 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss, if (old_hs) handshake_state_free(old_hs); - return err; + return 0; } static void netdev_join_adhoc_cb(struct l_genl_msg *msg, void *user_data) @@ -3817,17 +3863,33 @@ restore_snonce: MMPDU_STATUS_CODE_UNSPECIFIED); } -static int netdev_ft_tx_associate(struct iovec *ie_iov, size_t iov_len, +static int netdev_ft_tx_associate(struct iovec *ft_iov, size_t n_ft_iov, void *user_data) { struct netdev *netdev = user_data; + struct auth_proto *ap = netdev->ap; + struct handshake_state *hs = netdev->handshake; struct l_genl_msg *msg; + struct iovec iov[64]; + unsigned int n_iov = L_ARRAY_SIZE(iov); + unsigned int c_iov = 0; + enum mpdu_management_subtype subtype = + MPDU_MANAGEMENT_SUBTYPE_REASSOCIATION_REQUEST; msg = netdev_build_cmd_associate_common(netdev); + c_iov = netdev_populate_common_ies(netdev, hs, msg, iov, n_iov, c_iov); + + if (!L_WARN_ON(n_iov - c_iov < n_ft_iov)) { + memcpy(iov + c_iov, ft_iov, sizeof(*ft_iov) * n_ft_iov); + c_iov += n_ft_iov; + } + + mpdu_sort_ies(subtype, iov, c_iov); + l_genl_msg_append_attr(msg, NL80211_ATTR_PREV_BSSID, ETH_ALEN, - netdev->prev_bssid); - l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, ie_iov, iov_len); + ap->prev_bssid); + l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, c_iov); netdev->connect_cmd_id = l_genl_family_send(nl80211, msg, netdev_cmd_ft_reassociate_cb, @@ -3841,7 +3903,7 @@ static int netdev_ft_tx_associate(struct iovec *ie_iov, size_t iov_len, return 0; } -static void prepare_ft(struct netdev *netdev, struct scan_bss *target_bss) +static void prepare_ft(struct netdev *netdev, const struct scan_bss *target_bss) { struct netdev_handshake_state *nhs; @@ -3852,8 +3914,6 @@ static void prepare_ft(struct netdev *netdev, struct scan_bss *target_bss) */ memcpy(netdev->prev_snonce, netdev->handshake->snonce, 32); - memcpy(netdev->prev_bssid, netdev->handshake->aa, 6); - netdev->prev_frequency = netdev->frequency; netdev->frequency = target_bss->frequency; handshake_state_set_authenticator_address(netdev->handshake, @@ -4022,7 +4082,9 @@ static const struct wiphy_radio_work_item_ops ft_work_ops = { .do_work = netdev_ft_work_ready, }; -int netdev_fast_transition(struct netdev *netdev, struct scan_bss *target_bss, +int netdev_fast_transition(struct netdev *netdev, + const struct scan_bss *target_bss, + const struct scan_bss *orig_bss, netdev_connect_cb_t cb) { if (!netdev->operational) @@ -4042,6 +4104,7 @@ int netdev_fast_transition(struct netdev *netdev, struct scan_bss *target_bss, netdev->ap = ft_over_air_sm_new(netdev->handshake, netdev_ft_tx_authenticate, netdev_ft_tx_associate, netdev); + memcpy(netdev->ap->prev_bssid, orig_bss->addr, ETH_ALEN); wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1, &ft_work_ops); @@ -4050,7 +4113,8 @@ int netdev_fast_transition(struct netdev *netdev, struct scan_bss *target_bss, } int netdev_fast_transition_over_ds(struct netdev *netdev, - struct scan_bss *target_bss, + const struct scan_bss *target_bss, + const struct scan_bss *orig_bss, netdev_connect_cb_t cb) { struct netdev_ft_over_ds_info *info; @@ -4081,6 +4145,7 @@ int netdev_fast_transition_over_ds(struct netdev *netdev, netdev->ap = ft_over_ds_sm_new(netdev->handshake, netdev_ft_tx_associate, netdev); + memcpy(netdev->ap->prev_bssid, orig_bss->addr, ETH_ALEN); wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1, &ft_work_ops); @@ -4713,6 +4778,8 @@ static void netdev_channel_switch_event(struct l_genl_msg *msg, l_debug("Channel switch event, frequency: %u", *freq); + netdev->frequency = *freq; + if (!netdev->event_filter) return; @@ -5522,6 +5589,8 @@ static void netdev_newlink_notify(const struct ifinfomsg *ifi, int bytes) char old_name[IFNAMSIZ]; uint8_t old_addr[ETH_ALEN]; struct rtattr *attr; + uint8_t *operstate = NULL; + uint8_t *linkmode = NULL; if (ifi->ifi_family == AF_BRIDGE) { netdev_bridge_port_event(ifi, bytes, true); @@ -5550,12 +5619,36 @@ static void netdev_newlink_notify(const struct ifinfomsg *ifi, int bytes) memcpy(netdev->addr, RTA_DATA(attr), ETH_ALEN); break; + case IFLA_OPERSTATE: + operstate = RTA_DATA(attr); + break; + case IFLA_LINKMODE: + linkmode = RTA_DATA(attr); + break; } } if (!netdev->events_ready) /* Did we send NETDEV_WATCH_EVENT_NEW yet? */ return; + /* + * Sometimes the driver sends the Association / Connect event on the + * nl80211 interface before the driver is ready to accept IF_OPER_UP + * setting on the rtnl interface. This results in our initial + * IF_OPER_UP setting being ignored. In this case the driver will + * send a New Link event with a stale OperState. Detect this case and + * try to re-set IF_OPER_UP. + */ + if (linkmode && *linkmode == 1 && + operstate && *operstate == IF_OPER_DORMANT && + netdev->operational) { + l_debug("Retrying setting OperState to IF_OPER_UP"); + l_rtnl_set_linkmode_and_operstate(rtnl, netdev->index, + IF_LINK_MODE_DORMANT, IF_OPER_UP, + netdev_operstate_cb, + L_UINT_TO_PTR(netdev->index), NULL); + } + new_up = netdev_get_is_up(netdev); /* diff --git a/src/netdev.h b/src/netdev.h @@ -161,12 +161,15 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss, struct scan_bss *orig_bss, struct handshake_state *hs, netdev_event_func_t event_filter, netdev_connect_cb_t cb, void *user_data); -int netdev_fast_transition(struct netdev *netdev, struct scan_bss *target_bss, +int netdev_fast_transition(struct netdev *netdev, + const struct scan_bss *target_bss, + const struct scan_bss *orig_bss, netdev_connect_cb_t cb); int netdev_fast_transition_over_ds_action(struct netdev *netdev, const struct scan_bss *target_bss); int netdev_fast_transition_over_ds(struct netdev *netdev, - struct scan_bss *target_bss, + const struct scan_bss *target_bss, + const struct scan_bss *orig_bss, netdev_connect_cb_t cb); int netdev_preauthenticate(struct netdev *netdev, struct scan_bss *target_bss, netdev_preauthenticate_cb_t cb, diff --git a/src/network.c b/src/network.c @@ -1058,7 +1058,7 @@ static bool match_bss(const void *a, const void *b) return a == b; } -bool network_has_erp_identity(struct network *network) +struct erp_cache_entry *network_get_erp_cache(struct network *network) { struct erp_cache_entry *cache; struct l_settings *settings; @@ -1068,16 +1068,16 @@ bool network_has_erp_identity(struct network *network) settings = network_get_settings(network); if (!settings) - return false; + return NULL; check_id = l_settings_get_string(settings, "Security", "EAP-Identity"); if (!check_id) - return false; + return NULL; cache = erp_cache_get(network_get_ssid(network)); if (!cache) { l_free(check_id); - return false; + return NULL; } identity = erp_cache_entry_get_identity(cache); @@ -1085,17 +1085,19 @@ bool network_has_erp_identity(struct network *network) ret = strcmp(check_id, identity) == 0; l_free(check_id); - erp_cache_put(cache); /* * The settings file must have change out from under us. In this * case we want to remove the ERP entry because it is no longer * valid. */ - if (!ret) + if (!ret) { + erp_cache_put(cache); erp_cache_remove(identity); + return NULL; + } - return ret; + return cache; } const struct l_queue_entry *network_bss_list_get_entries( @@ -1503,35 +1505,11 @@ error: return reply; } -static struct l_dbus_message *network_connect(struct l_dbus *dbus, - struct l_dbus_message *message, - void *user_data) +struct l_dbus_message *__network_connect(struct network *network, + struct scan_bss *bss, + struct l_dbus_message *message) { - struct network *network = user_data; struct station *station = network->station; - struct scan_bss *bss; - - l_debug(""); - - if (network == station_get_connected_network(station)) - /* - * The requested network is already connected, return success. - */ - return l_dbus_message_new_method_return(message); - - if (network->agent_request) - return dbus_error_busy(message); - - /* - * Select the best BSS to use at this time. If we have to query the - * agent this may not be the final choice because BSS visibility can - * change while we wait for the agent. - */ - bss = network_bss_select(network, true); - - /* None of the BSSes is compatible with our stack */ - if (!bss) - return dbus_error_not_supported(message); switch (network_get_security(network)) { case SECURITY_PSK: @@ -1565,6 +1543,39 @@ static struct l_dbus_message *network_connect(struct l_dbus *dbus, } } +static struct l_dbus_message *network_connect(struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct network *network = user_data; + struct station *station = network->station; + struct scan_bss *bss; + + l_debug(""); + + if (network == station_get_connected_network(station)) + /* + * The requested network is already connected, return success. + */ + return l_dbus_message_new_method_return(message); + + if (network->agent_request) + return dbus_error_busy(message); + + /* + * Select the best BSS to use at this time. If we have to query the + * agent this may not be the final choice because BSS visibility can + * change while we wait for the agent. + */ + bss = network_bss_select(network, true); + + /* None of the BSSes is compatible with our stack */ + if (!bss) + return dbus_error_not_supported(message); + + return __network_connect(network, bss, message); +} + /* * Returns an error message in case an error occurs. Otherwise this function * returns NULL and takes a reference to message. Callers should unref @@ -1614,14 +1625,6 @@ void network_blacklist_add(struct network *network, struct scan_bss *bss) l_queue_push_head(network->blacklist, bss); } -const struct iovec *network_get_extra_ies(struct network *network, - size_t *num_elems) -{ - struct scan_bss *bss = network_bss_select(network, false); - - return network_info_get_extra_ies(network->info, bss, num_elems); -} - static bool network_property_get_name(struct l_dbus *dbus, struct l_dbus_message *message, struct l_dbus_message_builder *builder, @@ -1834,6 +1837,9 @@ static void network_unset_hotspot(struct network *network, void *user_data) return; network_set_info(network, NULL); + + l_queue_destroy(network->secrets, eap_secret_info_free); + network->secrets = NULL; } static void emit_known_network_removed(struct station *station, void *user_data) @@ -1852,6 +1858,9 @@ static void emit_known_network_removed(struct station *station, void *user_data) return; network_set_info(network, NULL); + + l_queue_destroy(network->secrets, eap_secret_info_free); + network->secrets = NULL; } connected_network = station_get_connected_network(station); diff --git a/src/network.h b/src/network.h @@ -29,6 +29,7 @@ struct station; struct network; struct scan_bss; struct handshake_state; +struct erp_cache_entry; void network_connected(struct network *network); void network_disconnected(struct network *network); @@ -84,10 +85,11 @@ struct l_dbus_message *network_connect_new_hidden_network( void network_blacklist_add(struct network *network, struct scan_bss *bss); -const struct iovec *network_get_extra_ies(struct network *network, - size_t *num_elems); - -bool network_has_erp_identity(struct network *network); +struct erp_cache_entry *network_get_erp_cache(struct network *network); const struct l_queue_entry *network_bss_list_get_entries( struct network *network); + +struct l_dbus_message *__network_connect(struct network *network, + struct scan_bss *bss, + struct l_dbus_message *message); diff --git a/src/p2p.c b/src/p2p.c @@ -1445,7 +1445,7 @@ static void p2p_netdev_event(struct netdev *netdev, enum netdev_event event, static const char *p2p_ip_to_string(uint32_t addr) { - struct in_addr ia = { .s_addr = L_CPU_TO_BE32(addr) }; + struct in_addr ia = { .s_addr = addr }; return inet_ntoa(ia); } diff --git a/src/station.c b/src/station.c @@ -153,6 +153,24 @@ static bool station_is_autoconnecting(struct station *station) station->state == STATION_STATE_AUTOCONNECT_QUICK; } +static bool station_debug_event(struct station *station, const char *name) +{ + struct l_dbus_message *signal; + + if (!iwd_is_developer_mode()) + return true; + + l_debug("StationDebug.Event(%s)", name); + + signal = l_dbus_message_new_signal(dbus_get_bus(), + netdev_get_path(station->netdev), + IWD_STATION_DEBUG_INTERFACE, "Event"); + + l_dbus_message_set_arguments(signal, "sav", name, 0); + + return l_dbus_send(dbus_get_bus(), signal) != 0; +} + static void station_property_set_scanning(struct station *station, bool scanning) { @@ -288,6 +306,25 @@ static int bss_signal_strength_compare(const void *a, const void *b, void *user) return (bss->signal_strength > new_bss->signal_strength) ? 1 : -1; } +static int station_parse_bss_security(struct station *station, + struct scan_bss *bss, + enum security *security_out) +{ + struct ie_rsn_info info; + int r; + + r = scan_bss_get_rsn_info(bss, &info); + if (r < 0) { + if (r != -ENOENT) + return r; + + *security_out = security_determine(bss->capability, NULL); + } else + *security_out = security_determine(bss->capability, &info); + + return 0; +} + /* * Returns the network object the BSS was added to or NULL if ignored. */ @@ -295,8 +332,6 @@ static struct network *station_add_seen_bss(struct station *station, struct scan_bss *bss) { struct network *network; - struct ie_rsn_info info; - int r; enum security security; const char *path; char ssid[33]; @@ -325,15 +360,8 @@ static struct network *station_add_seen_bss(struct station *station, return NULL; } - memset(&info, 0, sizeof(info)); - r = scan_bss_get_rsn_info(bss, &info); - if (r < 0) { - if (r != -ENOENT) - return NULL; - - security = security_determine(bss->capability, NULL); - } else - security = security_determine(bss->capability, &info); + if (station_parse_bss_security(station, bss, &security) < 0) + return NULL; path = iwd_network_get_path(station, ssid, security); @@ -745,7 +773,7 @@ static int station_build_handshake_rsn(struct handshake_state *hs, { enum security security = network_get_security(network); bool add_mde = false; - bool fils_hint = false; + struct erp_cache_entry *erp_cache = NULL; struct ie_rsn_info bss_info; uint8_t rsne_buf[256]; @@ -766,10 +794,10 @@ static int station_build_handshake_rsn(struct handshake_state *hs, * wiphy may select FILS if supported by the AP. */ if (security == SECURITY_8021X && hs->support_fils) - fils_hint = network_has_erp_identity(network); + erp_cache = network_get_erp_cache(network); info.akm_suites = wiphy_select_akm(wiphy, bss, security, - &bss_info, fils_hint); + &bss_info, erp_cache != NULL); /* * Special case for OWE. With OWE we still need to build up the @@ -850,6 +878,19 @@ build_ie: if (IE_AKM_IS_FT(info.akm_suites)) add_mde = true; + /* + * If FILS was chosen, the ERP cache has been verified to exist. Take + * a reference now so it remains valid (in case of expiration) until + * FILS starts. + */ + if (hs->akm_suite & (IE_RSN_AKM_SUITE_FILS_SHA256 | + IE_RSN_AKM_SUITE_FILS_SHA384 | + IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256 | + IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384)) + hs->erp_cache = erp_cache; + else if (erp_cache) + erp_cache_put(erp_cache); + open_network: if (security == SECURITY_NONE) /* Perform FT association if available */ @@ -869,6 +910,9 @@ open_network: return 0; not_supported: + if (erp_cache) + erp_cache_put(erp_cache); + return -ENOTSUP; } @@ -877,7 +921,10 @@ static struct handshake_state *station_handshake_setup(struct station *station, struct scan_bss *bss) { struct wiphy *wiphy = station->wiphy; + const struct network_info *info = network_get_info(network); struct handshake_state *hs; + const struct iovec *vendor_ies; + size_t iov_elems = 0; hs = netdev_handshake_state_new(station->netdev); @@ -891,16 +938,8 @@ static struct handshake_state *station_handshake_setup(struct station *station, if (network_handshake_setup(network, hs) < 0) goto not_supported; - /* - * If FILS was chosen, the ERP cache has been verified to exist. We - * wait to get it until here because at this point so there are no - * failure paths before fils_sm_new - */ - if (hs->akm_suite & (IE_RSN_AKM_SUITE_FILS_SHA256 | - IE_RSN_AKM_SUITE_FILS_SHA384 | - IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256 | - IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384)) - hs->erp_cache = erp_cache_get(network_get_ssid(network)); + vendor_ies = network_info_get_extra_ies(info, bss, &iov_elems); + handshake_state_set_vendor_ies(hs, vendor_ies, iov_elems); return hs; @@ -1200,6 +1239,11 @@ bool station_set_autoconnect(struct station *station, bool autoconnect) if (station_is_autoconnecting(station) && !autoconnect) station_enter_state(station, STATION_STATE_DISCONNECTED); + if (iwd_is_developer_mode()) + l_dbus_property_changed(dbus_get_bus(), + netdev_get_path(station->netdev), + IWD_STATION_DEBUG_INTERFACE, "AutoConnect"); + return true; } @@ -1729,6 +1773,10 @@ static void station_transition_start(struct station *station, /* Can we use Fast Transition? */ if (station_can_fast_transition(hs, bss)) { + const struct network_info *info = network_get_info(connected); + const struct iovec *vendor_ies; + size_t iov_elems = 0; + /* Rebuild handshake RSN for target AP */ if (station_build_handshake_rsn(hs, station->wiphy, station->connected_network, bss) < 0) { @@ -1737,10 +1785,15 @@ static void station_transition_start(struct station *station, return; } + /* Reset the vendor_ies in case they're different */ + vendor_ies = network_info_get_extra_ies(info, bss, &iov_elems); + handshake_state_set_vendor_ies(hs, vendor_ies, iov_elems); + /* FT-over-DS can be better suited for these situations */ if ((hs->mde[4] & 1) && station->signal_low) { ret = netdev_fast_transition_over_ds(station->netdev, - bss, station_fast_transition_cb); + bss, station->connected_bss, + station_fast_transition_cb); /* No action responses from this BSS, try over air */ if (ret == -ENOENT) goto try_over_air; @@ -1755,6 +1808,7 @@ static void station_transition_start(struct station *station, } else { try_over_air: if (netdev_fast_transition(station->netdev, bss, + station->connected_bss, station_fast_transition_cb) < 0) { station_roam_failed(station); return; @@ -1865,8 +1919,6 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list, while ((bss = l_queue_pop_head(bss_list))) { double rank; - struct ie_rsn_info info; - int r; /* Skip the BSS we are connected to if doing an AP roam */ if (station->ap_directed_roaming && !memcmp(bss->addr, @@ -1879,15 +1931,8 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list, memcmp(bss->ssid, hs->ssid, hs->ssid_len)) goto next; - memset(&info, 0, sizeof(info)); - r = scan_bss_get_rsn_info(bss, &info); - if (r < 0) { - if (r != -ENOENT) - goto next; - - security = security_determine(bss->capability, NULL); - } else - security = security_determine(bss->capability, &info); + if (station_parse_bss_security(station, bss, &security) < 0) + goto next; if (security != orig_security) goto next; @@ -1925,8 +1970,10 @@ next: goto fail_free_bss; /* See if we have anywhere to roam to */ - if (!best_bss || scan_bss_addr_eq(best_bss, station->connected_bss)) + if (!best_bss || scan_bss_addr_eq(best_bss, station->connected_bss)) { + station_debug_event(station, "no-roam-candidates"); goto fail_free_bss; + } bss = network_bss_find_by_addr(network, best_bss->addr); if (bss) { @@ -2555,8 +2602,6 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event, int __station_connect_network(struct station *station, struct network *network, struct scan_bss *bss) { - const struct iovec *extra_ies; - size_t iov_elems = 0; struct handshake_state *hs; int r; @@ -2564,10 +2609,8 @@ int __station_connect_network(struct station *station, struct network *network, if (!hs) return -ENOTSUP; - extra_ies = network_get_extra_ies(network, &iov_elems); - - r = netdev_connect(station->netdev, bss, hs, extra_ies, - iov_elems, station_netdev_event, + r = netdev_connect(station->netdev, bss, hs, NULL, 0, + station_netdev_event, station_connect_cb, station); if (r < 0) { handshake_state_free(hs); @@ -2680,7 +2723,8 @@ void station_connect_network(struct station *station, struct network *network, station_enter_state(station, STATION_STATE_CONNECTING); station->connect_pending = l_dbus_message_ref(message); - station->autoconnect = true; + + station_set_autoconnect(station, true); return; @@ -3034,20 +3078,10 @@ static struct l_dbus_message *station_dbus_get_hidden_access_points( entry; entry = entry->next) { struct scan_bss *bss = entry->data; int16_t signal_strength = bss->signal_strength; - struct ie_rsn_info info; enum security security; - int r; - memset(&info, 0, sizeof(info)); - r = scan_bss_get_rsn_info(bss, &info); - if (r < 0) { - if (r != -ENOENT) - continue; - - security = security_determine(bss->capability, NULL); - } else { - security = security_determine(bss->capability, &info); - } + if (station_parse_bss_security(station, bss, &security) < 0) + continue; l_dbus_message_builder_enter_struct(builder, "sns"); l_dbus_message_builder_append_basic(builder, 's', @@ -3524,6 +3558,7 @@ static struct station *station_create(struct netdev *netdev) #ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); #endif + bool autoconnect = true; station = l_new(struct station, 1); watchlist_init(&station->state_watches, NULL); @@ -3541,8 +3576,6 @@ static struct station *station_create(struct netdev *netdev) l_queue_push_head(station_list, station); - station_set_autoconnect(station, true); - #ifdef HAVE_DBUS l_dbus_object_add_interface(dbus, netdev_get_path(netdev), IWD_STATION_INTERFACE, station); @@ -3555,6 +3588,18 @@ static struct station *station_create(struct netdev *netdev) station_fill_scan_freq_subsets(station); + if (iwd_is_developer_mode()) { +#ifdef HAVE_DBUS + l_dbus_object_add_interface(dbus, + netdev_get_path(station->netdev), + IWD_STATION_DEBUG_INTERFACE, + station); +#endif + autoconnect = false; + } + + station_set_autoconnect(station, autoconnect); + return station; } @@ -3568,6 +3613,10 @@ static void station_free(struct station *station) l_dbus_object_remove_interface(dbus_get_bus(), netdev_get_path(station->netdev), IWD_STATION_DIAGNOSTIC_INTERFACE); + if (iwd_is_developer_mode()) + l_dbus_object_remove_interface(dbus_get_bus(), + netdev_get_path(station->netdev), + IWD_STATION_DEBUG_INTERFACE); if (station->netconfig) { netconfig_destroy(station->netconfig); @@ -3765,6 +3814,9 @@ static struct l_dbus_message *station_force_roam(struct l_dbus *dbus, l_debug("Attempting forced roam to BSS "MAC, MAC_STR(mac)); + /* The various roam routines expect this to be set from scanning */ + station->preparing_roam = true; + station_transition_start(station, target); return l_dbus_message_new_method_return(message); @@ -3773,22 +3825,233 @@ invalid_args: return dbus_error_invalid_args(message); } +static struct network *station_find_network_from_bss(struct station *station, + struct scan_bss *bss) +{ + enum security security; + char ssid[33]; + + memcpy(ssid, bss->ssid, bss->ssid_len); + ssid[bss->ssid_len] = '\0'; + + if (station_parse_bss_security(station, bss, &security) < 0) + return NULL; + + return station_network_find(station, ssid, security); +} + static void station_setup_diagnostic_interface( struct l_dbus_interface *interface) { l_dbus_interface_method(interface, "GetDiagnostics", 0, station_get_diagnostics, "a{sv}", "", "diagnostics"); - - if (iwd_is_developer_mode()) - l_dbus_interface_method(interface, "Roam", 0, - station_force_roam, "", "ay", "mac"); } static void station_destroy_diagnostic_interface(void *user_data) { } +static struct l_dbus_message *station_force_connect_bssid(struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct station *station = user_data; + struct l_queue *bss_list; + struct scan_bss *target; + struct network *network; + struct l_dbus_message_iter iter; + uint8_t *mac; + uint32_t mac_len; + + if (!l_dbus_message_get_arguments(message, "ay", &iter)) + goto invalid_args; + + if (!l_dbus_message_iter_get_fixed_array(&iter, &mac, &mac_len)) + goto invalid_args; + + if (mac_len != 6) + return dbus_error_invalid_args(message); + + bss_list = station_get_bss_list(station); + + target = l_queue_find(bss_list, bss_match_bssid, mac); + if (!target) + return dbus_error_invalid_args(message); + + if (util_ssid_is_hidden(target->ssid_len, target->ssid)) + return dbus_error_not_found(message); + + network = station_find_network_from_bss(station, target); + if (!network) + return dbus_error_invalid_args(message); + + l_debug("Attempting forced connection to BSS "MAC, MAC_STR(mac)); + + return __network_connect(network, target, message); + +invalid_args: + return dbus_error_invalid_args(message); +} + +static void station_debug_scan_triggered(int err, void *user_data) +{ + struct station *station = user_data; + struct l_dbus_message *reply; + + if (err < 0) { + if (station->scan_pending) { + reply = dbus_error_from_errno(err, + station->scan_pending); + dbus_pending_reply(&station->scan_pending, reply); + } + + station_dbus_scan_done(station); + return; + } + + l_debug("debug scan triggered for %s", + netdev_get_name(station->netdev)); + + if (station->scan_pending) { + reply = l_dbus_message_new_method_return(station->scan_pending); + l_dbus_message_set_arguments(reply, ""); + dbus_pending_reply(&station->scan_pending, reply); + } + + station_property_set_scanning(station, true); +} + +static bool station_debug_scan_results(int err, struct l_queue *bss_list, + const struct scan_freq_set *freqs, + void *userdata) +{ + struct station *station = userdata; + bool autoconnect; + + if (err) { + station_dbus_scan_done(station); + return false; + } + + autoconnect = station_is_autoconnecting(station); + station_set_scan_results(station, bss_list, freqs, autoconnect); + + station_dbus_scan_done(station); + + return true; +} + +static struct l_dbus_message *station_debug_scan(struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct station *station = user_data; + struct l_dbus_message_iter iter; + uint16_t *freqs; + uint32_t freqs_len; + struct scan_freq_set *freq_set; + unsigned int i; + + if (station->dbus_scan_id) + return dbus_error_busy(message); + + if (station->state == STATION_STATE_CONNECTING || + station->state == STATION_STATE_CONNECTING_AUTO) + return dbus_error_busy(message); + + if (!l_dbus_message_get_arguments(message, "aq", &iter)) + goto invalid_args; + + if (!l_dbus_message_iter_get_fixed_array(&iter, &freqs, &freqs_len)) + goto invalid_args; + + freq_set = scan_freq_set_new(); + + for (i = 0; i < freqs_len; i++) { + if (!scan_freq_set_add(freq_set, (uint32_t)freqs[i])) { + scan_freq_set_free(freq_set); + goto invalid_args; + } + + l_debug("added frequency %u", freqs[i]); + } + + station->dbus_scan_id = station_scan_trigger(station, freq_set, + station_debug_scan_triggered, + station_debug_scan_results, + NULL); + + scan_freq_set_free(freq_set); + + if (!station->dbus_scan_id) + goto failed; + + station->scan_pending = l_dbus_message_ref(message); + + return NULL; + +failed: + return dbus_error_failed(message); +invalid_args: + return dbus_error_invalid_args(message); +} + +static bool station_property_get_autoconnect(struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_builder *builder, + void *user_data) +{ + struct station *station = user_data; + bool autoconnect; + + autoconnect = station->autoconnect; + + l_dbus_message_builder_append_basic(builder, 'b', &autoconnect); + + return true; +} + +static struct l_dbus_message *station_property_set_autoconnect( + struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_iter *new_value, + l_dbus_property_complete_cb_t complete, + void *user_data) +{ + struct station *station = user_data; + bool autoconnect; + + if (!l_dbus_message_iter_get_variant(new_value, "b", &autoconnect)) + return dbus_error_invalid_args(message); + + l_debug("Setting autoconnect %s", autoconnect ? "true" : "false"); + + station_set_autoconnect(station, autoconnect); + + return l_dbus_message_new_method_return(message); +} + +static void station_setup_debug_interface( + struct l_dbus_interface *interface) +{ + l_dbus_interface_method(interface, "ConnectBssid", 0, + station_force_connect_bssid, "", "ay", + "mac"); + l_dbus_interface_method(interface, "Roam", 0, + station_force_roam, "", "ay", "mac"); + + l_dbus_interface_method(interface, "Scan", 0, + station_debug_scan, "", "aq", + "frequencies"); + + l_dbus_interface_signal(interface, "Event", 0, "sav", "name", "data"); + + l_dbus_interface_property(interface, "AutoConnect", 0, "b", + station_property_get_autoconnect, + station_property_set_autoconnect); +} + static void ap_roam_frame_event(const struct mmpdu_header *hdr, const void *body, size_t body_len, int rssi, void *user_data) @@ -3863,6 +4126,12 @@ static int station_init(void) station_setup_diagnostic_interface, station_destroy_diagnostic_interface, false); + if (iwd_is_developer_mode()) + l_dbus_register_interface(dbus_get_bus(), + IWD_STATION_DEBUG_INTERFACE, + station_setup_debug_interface, + NULL, + false); #endif if (!l_settings_get_uint(iwd_get_config(), "General", @@ -3906,6 +4175,9 @@ static void station_exit(void) #ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_STATION_DIAGNOSTIC_INTERFACE); + if (iwd_is_developer_mode()) + l_dbus_unregister_interface(dbus_get_bus(), + IWD_STATION_DEBUG_INTERFACE); l_dbus_unregister_interface(dbus_get_bus(), IWD_STATION_INTERFACE); #endif netdev_watch_remove(netdev_watch); diff --git a/src/storage.c b/src/storage.c @@ -29,11 +29,13 @@ #include <errno.h> #include <ctype.h> #include <fcntl.h> +#include <stdbool.h> #include <string.h> #include <stdarg.h> #include <stdlib.h> #include <unistd.h> #include <time.h> +#include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> @@ -445,3 +447,19 @@ void storage_known_frequencies_sync(struct l_settings *known_freqs) l_free(known_freq_file_path); } + +bool storage_is_file(const char *filename) +{ + char *path; + struct stat st; + int err; + + path = storage_get_path("%s", filename); + err = stat(path, &st); + l_free(path); + + if (!err && S_ISREG(st.st_mode) != 0) + return true; + + return false; +} diff --git a/src/storage.h b/src/storage.h @@ -32,6 +32,7 @@ ssize_t write_file(const void *buffer, size_t len, bool preserve_times, const char *path_fmt, ...) __attribute__((format(printf, 4, 5))); +bool storage_is_file(const char *filename); bool storage_create_dirs(void); void storage_cleanup_dirs(void); char *storage_get_path(const char *format, ...); diff --git a/test/force-roam b/test/force-roam @@ -9,7 +9,7 @@ if (len(sys.argv) != 3): bus = dbus.SystemBus() device = dbus.Interface(bus.get_object("net.connman.iwd", sys.argv[1]), - "net.connman.iwd.StationDiagnostic") + "net.connman.iwd.StationDebug") mac = sys.argv[2].replace(':', '') diff --git a/tools/hwsim.c b/tools/hwsim.c @@ -124,6 +124,7 @@ struct hwsim_rule { bool destination_any : 1; bool bidirectional : 1; bool drop : 1; + bool enabled : 1; uint32_t frequency; int priority; int signal; @@ -1177,6 +1178,9 @@ static void process_rules(const struct radio_info_rec *src_radio, rule_entry = rule_entry->next) { struct hwsim_rule *rule = rule_entry->data; + if (!rule->enabled) + return; + if (!rule->source_any && !radio_match_addr(src_radio, rule->source) && (!rule->bidirectional || @@ -1432,9 +1436,11 @@ static void frame_delay_callback(struct l_timeout *timeout, void *user_data) else send_frame_destroy(send_info); - l_timeout_remove(timeout); + if (timeout) + l_timeout_remove(timeout); } + /* * Process frames in a similar way to how the kernel built-in hwsim medium * does this, with an additional optimization for unicast frames and @@ -1453,7 +1459,7 @@ static void process_frame(struct hwsim_frame *frame) struct radio_info_rec *radio = entry->data; struct send_frame_info *send_info; bool drop = drop_mcast; - uint32_t delay = HWSIM_DELAY_MIN_MS; + uint32_t delay = 0; if (radio == frame->src_radio) continue; @@ -1495,11 +1501,16 @@ static void process_frame(struct hwsim_frame *frame) send_info->radio = radio; send_info->frame = hwsim_frame_ref(frame); - if (!l_timeout_create_ms(delay, frame_delay_callback, - send_info, NULL)) { - l_error("Error delaying frame, frame will be dropped"); - send_frame_destroy(send_info); - } + if (delay) { + if (!l_timeout_create_ms(delay, frame_delay_callback, + send_info, NULL)) { + l_error("Error delaying frame %ums, " + "frame will be dropped", delay); + send_frame_destroy(send_info); + } + } else + frame_delay_callback(NULL, send_info); + } hwsim_frame_unref(frame); @@ -1995,7 +2006,8 @@ static struct l_dbus_message *rule_add(struct l_dbus *dbus, rule->id = next_rule_id++; rule->source_any = true; rule->destination_any = true; - rule->delay = HWSIM_DELAY_MIN_MS; + rule->delay = 0; + rule->enabled = false; if (!rules) rules = l_queue_new(); @@ -2369,6 +2381,37 @@ invalid_args: return dbus_error_invalid_args(message); } +static bool rule_property_get_enabled(struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_builder *builder, + void *user_data) +{ + struct hwsim_rule *rule = user_data; + bool bval = rule->enabled; + + l_dbus_message_builder_append_basic(builder, 'b', &bval); + + return true; +} + +static struct l_dbus_message *rule_property_set_enabled( + struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_iter *new_value, + l_dbus_property_complete_cb_t complete, + void *user_data) +{ + struct hwsim_rule *rule = user_data; + bool bval; + + if (!l_dbus_message_iter_get_variant(new_value, "b", &bval)) + return dbus_error_invalid_args(message); + + rule->enabled = bval; + + return l_dbus_message_new_method_return(message); +} + static void setup_rule_interface(struct l_dbus_interface *interface) { l_dbus_interface_method(interface, "Remove", 0, rule_remove, "", ""); @@ -2409,6 +2452,10 @@ static void setup_rule_interface(struct l_dbus_interface *interface) L_DBUS_PROPERTY_FLAG_AUTO_EMIT, "ay", rule_property_get_prefix, rule_property_set_prefix); + l_dbus_interface_property(interface, "Enabled", + L_DBUS_PROPERTY_FLAG_AUTO_EMIT, "b", + rule_property_get_enabled, + rule_property_set_enabled); } static void request_name_callback(struct l_dbus *dbus, bool success, diff --git a/tools/test-runner b/tools/test-runner @@ -13,9 +13,11 @@ import time import unittest import importlib import signal +from unittest.result import TestResult import pyroute2 import multiprocessing import re +import traceback from configparser import ConfigParser from prettytable import PrettyTable @@ -46,11 +48,11 @@ TEST_MAX_TIMEOUT = 120 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) -def dbg(*s): +def dbg(*s, **kwargs): ''' Allows prints if stdout has been re-directed ''' - print(*s, file=sys.__stdout__) + print(*s, **kwargs, file=sys.__stdout__) def exit_vm(): if config: @@ -233,7 +235,7 @@ class Process: if not wait and not check: return - self.pid.wait(timeout=5) + Namespace.non_block_wait(self.wait_for_process, 10, 1) self.killed = True self.ret = self.pid.returncode @@ -245,6 +247,13 @@ class Process: if check and self.ret != 0: raise subprocess.CalledProcessError(returncode=self.ret, cmd=self.args) + def wait_for_process(self, timeout): + try: + self.pid.wait(timeout) + return True + except: + return False + def process_io(self, source): data = source.read() @@ -312,12 +321,7 @@ class Process: self.killed = True def wait_for_socket(self, socket, wait): - waited = 0 - while not os.path.exists(socket): - sleep(0.5) - waited += 0.5 - if waited > wait: - raise Exception("Timed out waiting for socket") + Namespace.non_block_wait(os.path.exists, wait, socket) def __str__(self): return str(self.args) + '\n' @@ -428,6 +432,7 @@ class HostapdInstance: def __init__(self, config, radio): self.radio = radio self.config = config + self.cli = None self.intf = radio.create_interface(self.config, 'hostapd') self.intf.set_interface_state('up') @@ -494,6 +499,13 @@ class Hostapd: self.process.wait_for_socket(self.global_ctrl_iface, 30) + for hapd in self.instances: + self.process.wait_for_socket(hapd.intf.ctrl_interface, 30) + + def attach_cli(self): + for hapd in self.instances: + hapd.cli = importlib.import_module('hostapd').HostapdCLI(config=hapd.config) + def _rewrite_config(self, config): ''' Replaces any $ifaceN values with the correct interface @@ -531,7 +543,14 @@ class Hostapd: try: os.remove(self.global_ctrl_iface) except: - dbg("Failed to remove %s" % self.global_ctrl_iface) + print("Failed to remove %s" % self.global_ctrl_iface) + + for hapd in self.instances: + if not hapd.cli: + continue + + hapd.cli._instances[hapd.config] = None + hapd.cli = None self.instances = None @@ -594,8 +613,9 @@ class Namespace: if not env: env = os.environ.copy() - # In case this process needs DBus... - env['DBUS_SYSTEM_BUS_ADDRESS'] = self.dbus_address + if hasattr(self, "dbus_address"): + # In case this process needs DBus... + env['DBUS_SYSTEM_BUS_ADDRESS'] = self.dbus_address p = Process(args, ctx=self, namespace=ns, env=env, **kwargs) @@ -636,7 +656,7 @@ class Namespace: p = self.start_process(['dbus-daemon', '--config-file=%s' % self.dbus_cfg], wait=False, cleanup=self._cleanup_dbus) - p.wait_for_socket(self.dbus_address.split('=')[1], wait=5) + p.wait_for_socket(self.dbus_address.split('=')[1], 5) self._bus = dbus.bus.BusConnection(address_or_type=self.dbus_address) @@ -648,7 +668,7 @@ class Namespace: args.extend(['valgrind', '--leak-check=full', '--track-origins=yes', '--log-file=/tmp/valgrind.log.%p']) - args.extend(['iwd', '-p', iwd_radios]) + args.extend(['iwd', '-p', iwd_radios, '-E']) if self.is_verbose(args[0]): args.append('-d') @@ -694,15 +714,64 @@ class Namespace: return False - def wait_for_dbus_service(self, service): - tries = 0 + @staticmethod + def non_block_wait(func, timeout, *args, exception=True): + ''' + Convenience function for waiting in a non blocking + manor using GLibs context iteration i.e. does not block + the main loop while waiting. + + 'func' will be called at least once and repeatedly until + either it returns success, throws an exception, or the + 'timeout' expires. + + 'timeout' is the ultimate timeout in seconds + + '*args' will be passed to 'func' + + If 'exception' is an Exception type it will be raised. + If 'exception' is True a generic TimeoutError will be raised. + Any other value will not result in an exception. + ''' + # Simple class for signaling the wait timeout + class Bool: + def __init__(self, value): + self.value = value + + def wait_timeout_cb(done): + done.value = True + return False + + mainloop = GLib.MainLoop() + done = Bool(False) + + timeout = GLib.timeout_add_seconds(timeout, wait_timeout_cb, done) + context = mainloop.get_context() + + while True: + context.iteration(may_block=False) + + try: + ret = func(*args) + if ret: + if not done.value: + GLib.source_remove(timeout) + return ret + except Exception as e: + if not done.value: + GLib.source_remove(timeout) + raise e - while not self._bus.name_has_owner(service): - if tries > 200: - raise TimeoutError('DBus service %s did not appear', service) - tries += 1 sleep(0.1) + if done.value == True: + if isinstance(exception, Exception): + raise exception + elif type(exception) == bool and exception: + raise TimeoutError("Timeout on non_block_wait") + else: + return + def __str__(self): ret = 'Namespace: %s\n' % self.name ret += 'Processes:\n' @@ -755,12 +824,13 @@ class TestContext(Namespace): nradios = int(setup['num_radios']) args = ['hwsim'] - if not self.hw_config['SETUP'].get('hwsim_medium', 'yes') in ['yes', '1', 'true']: + if self.hw_config['SETUP'].get('hwsim_medium', 'no') in ['no', '0', 'false']: # register hwsim as medium args.extend(['--no-register']) self.start_process(args) - self.wait_for_dbus_service('net.connman.hwsim') + self.non_block_wait(self._bus.name_has_owner, 20, 'net.connman.hwsim', + exception=TimeoutError('net.connman.hwsim did not appear')) for i in range(nradios): name = 'rad%u' % i @@ -841,6 +911,15 @@ class TestContext(Namespace): radius_config = settings.get('radius_server', None) self.hostapd = Hostapd(self, hapd_radios, hapd_configs, radius_config) + self.hostapd.attach_cli() + + def get_frequencies(self): + frequencies = [] + + for hapd in self.hostapd.instances: + frequencies.append(hapd.cli.frequency) + + return frequencies def start_wpas_interfaces(self): if 'WPA_SUPPLICANT' not in self.hw_config: @@ -1013,15 +1092,17 @@ def build_test_list(args): tests = [test_root + '/' + x for x in full_list[i:] \ if x.startswith('test')] elif os.path.exists(t): - tests.append(t) + if t not in tests: + tests.append(t) elif os.path.exists(path): - tests.append(path) + if path not in tests: + tests.append(path) else: matches = glob(path) if matches == []: raise Exception("Could not find test %s" % t) - tests.extend(matches) + tests.extend(list(set(matches) - set(tests))) return sorted(tests) @@ -1034,31 +1115,121 @@ def start_test(ctx, subtests, rqueue): results queue which is required since this is using multiprocessing. ''' - suite = unittest.TestSuite() + run = 0 + errors = 0 + failures = 0 + skipped = 0 + start = time.time() # # Iterate through each individual python test. # for s in subtests: loader = unittest.TestLoader() - subtest = importlib.import_module(os.path.splitext(s)[0]) - suite.addTests(loader.loadTestsFromModule(subtest)) + module = importlib.import_module(os.path.splitext(s)[0]) + subtest = loader.loadTestsFromModule(module) + + # The test suite is being (ab)used to get a bit more granularity + # with individual tests. The 'normal' way to use unittest is to + # just create a test suite and run them. The problem here is that + # test results are queued and printed at the very end so its + # difficult to know *where* a test failed (python gives a stack + # trace but printing the exception/failure immediately shows + # where in the debug logs something failed). Moreso if there are + # several test functions inside a single python file they run + # as a single test and it is difficult (again) to know where + # something failed. + + # Iterating through each python test file + for test in subtest: + limit_funcs = [] + + if ctx.args.sub_tests: + for i in ctx.args.sub_tests: + if len(i.split('.')) == 2: + limit_funcs.append(i.split('.')[1]) + + # Iterating through individual test functions inside a + # Test() class. Due to the nature of unittest we have + # to jump through some hoops to set up the test class + # only once by turning the enumeration into a list, then + # enumerating (again) to keep track of the index (just + # enumerating the test class doesn't allow len() because + # it is not a list). + tlist = list(enumerate(test)) + for index, t in enumerate(tlist): + # enumerate is returning a tuple, index 1 is our + # actual object. + t = t[1] + + func, file = str(t).split(' ') + # + # TODO: There may be a better way of doing this + # but strigifying the test class gives us a string: + # <function> (<file>.<class>) + # + file = file.strip('()').split('.')[0] + '.py' + + # Create an empty result here in case the test fails + result = TestResult() + + try: + skip = len(limit_funcs) > 0 and func not in limit_funcs + + # Set up class only on first test + if index == 0: + if not skip: + dbg("%s\n\t%s RUNNING" % (file, str(func)), end='') + t.setUpClass() + else: + if not skip: + dbg("\t%s RUNNING" % str(func), end='') + + sys.__stdout__.flush() + + if not skip: + # Run test (setUp/tearDown run automatically) + result = t() + + # Tear down class only on last test + if index == len(tlist) - 1: + t.tearDownClass() + + if skip: + continue + except unittest.SkipTest as e: + result.skipped.append(t) + except Exception as e: + dbg('\n%s threw an uncaught exception:' % func) + traceback.print_exc(file=sys.__stdout__) + + run += result.testsRun + errors += len(result.errors) + failures += len(result.failures) + skipped += len(result.skipped) + + if len(result.skipped) > 0: + dbg(colored(" SKIPPED", "cyan")) + elif run == 0 or len(result.errors) > 0 or len(result.failures) > 0: + dbg(colored(" FAILED", "red")) + for e in result.errors: + dbg(e[1]) + for f in result.failures: + dbg(f[1]) + else: + dbg(colored(" PASSED", "green")) # Prevents future test modules with the same name (e.g. # connection_test.py) from being loaded from the cache - sys.modules.pop(subtest.__name__) + sys.modules.pop(module.__name__) - start = time.time() - runner = unittest.TextTestRunner() - result = runner.run(suite) # # The multiprocessing queue is picky with what objects it will serialize # and send between processes. Because of this we put the important bits # of the result into our own 'SimpleResult' tuple. # - sresult = SimpleResult(run=result.testsRun, failures=len(result.failures), - errors=len(result.errors), skipped=len(result.skipped), - time=time.time() - start) + sresult = SimpleResult(run=run, failures=failures, errors=errors, + skipped=skipped, time=time.time() - start) rqueue.put(sresult) # This may not be required since we are manually popping sys.modules @@ -1070,10 +1241,9 @@ def pre_test(ctx, test, copied): ''' os.chdir(test) - dbg("Starting test %s" % test) + dbg("\nStarting %s" % colored(os.path.basename(test), "white", attrs=['bold'])) if not os.path.exists(test + '/hw.conf'): - print("No hw.conf found for %s" % test) - exit() + raise Exception("No hw.conf found for %s" % test) ctx.hw_config = ConfigParser() ctx.hw_config.read(test + '/hw.conf') @@ -1101,12 +1271,18 @@ def pre_test(ctx, test, copied): # Prune down any subtests if needed if ctx.args.sub_tests: ctx.args.sub_tests = ctx.args.sub_tests.split(',') + + to_run = [x.split('.')[0] for x in ctx.args.sub_tests] pruned = [] for s in subtests: - # Allow test name both with and without the extension - if s in ctx.args.sub_tests or os.path.splitext(s)[0] in ctx.args.sub_tests: - pruned.append(s) + no_ext = s + # Handle <file>.<test function> format + if '.' in s: + no_ext = s.split('.')[0] + + if no_ext in to_run: + pruned.append(no_ext + '.py') subtests = pruned @@ -1120,9 +1296,9 @@ def pre_test(ctx, test, copied): ctx.start_ofono() if ctx.args.log: - ctx.start_process(['iwmon']) + ctx.start_process(['iwmon', '--nowiphy']) elif ctx.args.monitor: - ctx.start_process(['iwmon'], outfile=ctx.args.monitor) + ctx.start_process(['iwmon', '--nowiphy'], outfile=ctx.args.monitor) if ctx.hw_config.has_option('SETUP', 'start_iwd'): start = ctx.hw_config.getboolean('SETUP', 'start_iwd') @@ -1258,8 +1434,8 @@ def run_auto_tests(ctx, args): ctx.results[os.path.basename(test)] = rqueue.get() except Exception as ex: - print(ex) - print("Uncaught exception thrown for %s" % test) + dbg("%s threw an uncaught exception" % test) + traceback.print_exc(file=sys.__stdout__) ctx.results[os.path.basename(test)] = SimpleResult(run=0, failures=0, errors=0, skipped=0, time=0) finally: @@ -1270,10 +1446,6 @@ def run_auto_tests(ctx, args): shutil.rmtree('/tmp/secrets') os.remove('/tmp/phonesim.conf') - # Write out kernel log - if ctx.args.log: - ctx.start_process(["dmesg"], wait=True) - def run_unit_tests(ctx, args): os.chdir(args.testhome + '/unit') units = build_unit_list(args) @@ -1351,6 +1523,9 @@ def run_tests(): shutil.rmtree(f) else: os.remove(f) + + # Start writing out kernel log + config.ctx.start_process(["dmesg", '--follow']) elif args.monitor: parent = os.path.abspath(os.path.join(args.monitor, os.pardir)) mount('mondir', parent, '9p', 0, 'trans=virtio,version=9p2000.L,msize=10240') @@ -1601,7 +1776,7 @@ class Main: rootflags=trans=virtio,msize=1048576,version=9p2000.u \ acpi=off pci=noacpi %s ro \ mac80211_hwsim.radios=0 %s' % (kern_log, options), - '-cpu', 'host', '-smp', str(smp) + '-smp', str(smp) ] # Add two ethernet devices for testing EAD diff --git a/unit/test-mpdu.c b/unit/test-mpdu.c @@ -175,6 +175,44 @@ static void ie_order_test(const void *data) assert(!!mpdu_validate(frame->data, frame->len) == frame->good); } +static void ie_sort_test(const void *data) +{ + static uint8_t ie_fils_session[] = { IE_TYPE_EXTENSION, 1, 4 }; + static uint8_t ie_mde[] = { IE_TYPE_MOBILITY_DOMAIN, 0 }; + static uint8_t ie_ssid[] = { IE_TYPE_SSID, 0 }; + static uint8_t ie_rsn[] = { IE_TYPE_RSN, 0 }; + struct iovec ies[64]; + size_t n_ies = 0; + uint8_t *ie; + + /* Make up some IEs, only the first 3 bytes matter */ + ies[n_ies].iov_base = ie_fils_session; + ies[n_ies++].iov_len = sizeof(ie_fils_session); + + ies[n_ies].iov_base = ie_mde; + ies[n_ies++].iov_len = sizeof(ie_mde); + + ies[n_ies].iov_base = ie_ssid; + ies[n_ies++].iov_len = sizeof(ie_ssid); + + ies[n_ies].iov_base = ie_rsn; + ies[n_ies++].iov_len = sizeof(ie_rsn); + + mpdu_sort_ies(MPDU_MANAGEMENT_SUBTYPE_ASSOCIATION_REQUEST, ies, n_ies); + + ie = ies[0].iov_base; + assert(ie[0] == IE_TYPE_SSID); + + ie = ies[1].iov_base; + assert(ie[0] == IE_TYPE_RSN); + + ie = ies[2].iov_base; + assert(ie[0] == IE_TYPE_MOBILITY_DOMAIN); + + ie = ies[3].iov_base; + assert(ie[0] == IE_TYPE_EXTENSION && ie[2] == 4); +} + int main(int argc, char *argv[]) { l_test_init(&argc, &argv); @@ -192,5 +230,7 @@ int main(int argc, char *argv[]) l_test_add("/IE order/Good (Out of Order IE) 2", ie_order_test, &probe_req_ie_out_of_order2_data); + l_test_add("/IE order/Sorting", ie_sort_test, NULL); + return l_test_run(); }