ap: update Scanning property when AP starts
PATCH v2 1/6 ap: update Scanning property when AP starts
This wasn't being updated meaning the property is missing until a scan is issued over DBus.
Rather than duplicate all the property changed calls they were all factored out into a helper function.
--- src/ap.c | 55 +++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 30 deletions(-)
src/ap.c +25 -30
@@ -3672,6 +3672,28 @@ struct ap_if_data {struct l_dbus_message *pending; }; +static void ap_properties_changed (struct ap_if_data *ap_if) +{ +l_dbus_property_changed (dbus_get_bus (), +netdev_get_path (ap_if->netdev), +IWD_AP_INTERFACE ,"Started" ); +l_dbus_property_changed (dbus_get_bus (), +netdev_get_path (ap_if->netdev), +IWD_AP_INTERFACE ,"Name" ); +l_dbus_property_changed (dbus_get_bus (), +netdev_get_path (ap_if->netdev), +IWD_AP_INTERFACE ,"Frequency" ); +l_dbus_property_changed (dbus_get_bus (), +netdev_get_path (ap_if->netdev), +IWD_AP_INTERFACE ,"PairwiseCiphers" ); +l_dbus_property_changed (dbus_get_bus (), +netdev_get_path (ap_if->netdev), +IWD_AP_INTERFACE ,"GroupCipher" ); +l_dbus_property_changed (dbus_get_bus (), +netdev_get_path (ap_if->netdev), +IWD_AP_INTERFACE ,"Scanning" ); +} +static void ap_if_event_func (enum ap_event_type type,const void *event_data,void *user_data) {
@@ -3703,21 +3725,8 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data, reply =l_dbus_message_new_method_return (ap_if->pending);dbus_pending_reply (&ap_if->pending, reply); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"Started" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"Name" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"Frequency" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"PairwiseCiphers" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"GroupCipher" ); + +ap_properties_changed (ap_if); l_rtnl_set_linkmode_and_operstate(rtnl, netdev_get_ifindex(ap_if->netdev),
@@ -3730,21 +3739,7 @@ static void ap_if_event_func(enum ap_event_type type, const void *event_data,netdev_get_path (ap_if->netdev), IWD_AP_DIAGNOSTIC_INTERFACE); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"Started" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"Name" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"Frequency" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"PairwiseCiphers" ); -l_dbus_property_changed (dbus_get_bus (), -netdev_get_path (ap_if->netdev), -IWD_AP_INTERFACE ,"GroupCipher" ); +ap_properties_changed (ap_if); l_rtnl_set_linkmode_and_operstate(rtnl, netdev_get_ifindex(ap_if->netdev),
Signature · 1 line
2.34.3
PATCH v2 2/6 auto-t: iwd.py: allow certain APIs to be used in AP mode
AP mode implements a few DBus methods/properties which are named the same as station: Scan, Scanning, and GetOrderedNetworks. Allow the Device object to work with these in AP mode by calling the correct method if the Mode is 'ap'.
--- autotests/util/iwd.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
autotests/util/iwd.py +16 -8
@@ -521,13 +521,16 @@ class Device(IWDDBusAbstract): def scanning(self): ''' Reflects whether the device is currently scanning - for networks. net.connman.iwd.Network objects are - updated when this property goes from true to false. + for networks. For station devices net.connman.iwd.Network + objects are updated when this property goes from true to false @rtype: boolean ''' - props = self._station_properties() - return bool(props['Scanning']) + if self._properties['Mode'] == 'station': + props = self._station_properties() + return bool(props['Scanning']) + else: + return bool(self._ap.scanning) @property def autoconnect(self):
@@ -544,12 +547,14 @@ class Device(IWDDBusAbstract): Possible exception: BusyEx FailedEx ''' - self._iface.Scan(dbus_interface=IWD_STATION_INTERFACE, + if self._properties['Mode'] == 'station': + self._iface.Scan(dbus_interface=IWD_STATION_INTERFACE, reply_handler=self._success, error_handler=self._failure) - - if wait: - self._wait_for_async_op() + if wait: + self._wait_for_async_op() + else: + self._ap.scan() def disconnect(self): '''Disconnect from the network
@@ -576,6 +581,9 @@ class Device(IWDDBusAbstract): groups the maximum relative signal-strength is the main sorting factor. ''' + if self._properties['Mode'] == 'ap': + return self._ap.get_ordered_networks() + ordered_networks = [] if not full_scan: for bus_obj in self._station.GetOrderedNetworks():
Signature · 1 line
2.34.3
PATCH v2 3/6 auto-t: add test for scanning in AP mode
In reply to James Prestwood--- autotests/testAP/scan_test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 autotests/testAP/scan_test.py
autotests/testAP/scan_test.py new file +20 -0
@@ -0,0 +1,20 @@ +#! /usr/bin/python3 + +import unittest + +from iwd import IWD + +class Test(unittest.TestCase): + def test_ap_scan(self): + wd = IWD(True) + + dev = wd.list_devices(1)[0] + + dev.start_ap('TestAP2', 'Password2') + + dev.scan() + + networks = dev.get_ordered_networks() + + self.assertTrue(len(networks) == 1) + self.assertTrue(networks[0]['Name'] == 'TestAP1')
Signature · 1 line
2.34.3
PATCH v2 4/6 ap: change PairwiseCiphers to string array
In reply to James PrestwoodA comma separated list as a string was ok for pure display purposes but if any processing needed to be done on these values by external consumers it really makes more sense to use a DBus array.
--- src/ap.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
src/ap.c +19 -14
@@ -3154,11 +3154,10 @@ static enum ie_rsn_cipher_suite ap_string_to_cipher(const char *str)return 0 ; } -static char *ap_ciphers_to_string (uint16_t ciphers) +static char **ap_ciphers_to_strv (uint16_t ciphers) {uint16_t i;char **list =l_strv_new (); -char *ret;for (i =0 ; i <16 ; i++) {if (!(ciphers & (1 << i)))
@@ -3168,9 +3167,7 @@ static char *ap_ciphers_to_string(uint16_t ciphers) ie_rsn_cipher_suite_to_string(1 << i)); } - ret =l_strjoinv (list,',' ); -l_strv_free (list); -return ret; +return list; } static int ap_load_config(struct ap_state *ap, const struct l_settings *config,
@@ -4096,15 +4093,22 @@ static bool ap_dbus_property_get_pairwise(struct l_dbus *dbus, void *user_data) {struct ap_if_data *ap_if = user_data; -char *list; +char **ciphers; +size_t i;if (!ap_if->ap || !ap_if->ap->started)return false; - list =ap_ciphers_to_string (ap_if->ap->ciphers); + ciphers =ap_ciphers_to_strv (ap_if->ap->ciphers); + +l_dbus_message_builder_enter_array (builder,"s" ); + +for (i =0 ; ciphers[i]; i++) +l_dbus_message_builder_append_basic (builder,'s' , ciphers[i]); + +l_dbus_message_builder_leave_array (builder); -l_dbus_message_builder_append_basic (builder,'s' , list); -l_free (list); +l_strv_free (ciphers);return true; }
@@ -4115,15 +4119,16 @@ static bool ap_dbus_property_get_group(struct l_dbus *dbus, void *user_data) {struct ap_if_data *ap_if = user_data; -char *cipher; +char **cipher;if (!ap_if->ap || !ap_if->ap->started)return false; - cipher =ap_ciphers_to_string (ap_if->ap->group_cipher); + cipher =ap_ciphers_to_strv (ap_if->ap->group_cipher); -l_dbus_message_builder_append_basic (builder,'s' , cipher); -l_free (cipher); +/* Group cipher will only ever be a single value */ +l_dbus_message_builder_append_basic (builder,'s' , cipher[0 ]); +l_strv_free (cipher);return true; }
@@ -4149,7 +4154,7 @@ static void ap_setup_interface(struct l_dbus_interface *interface) ap_dbus_property_get_scanning, NULL);l_dbus_interface_property (interface,"Frequency" ,0 ,"u" , ap_dbus_property_get_freq,NULL ); -l_dbus_interface_property (interface,"PairwiseCiphers" ,0 ,"s" , +l_dbus_interface_property (interface,"PairwiseCiphers" ,0 ,"as" , ap_dbus_property_get_pairwise,NULL );l_dbus_interface_property (interface,"GroupCipher" ,0 ,"s" , ap_dbus_property_get_group,NULL );
Signature · 1 line
2.34.3
PATCH v2 5/6 auto-t: update test to work with PairwiseCiphers array
In reply to James Prestwood--- autotests/testAP-no-support/connection_test.py | 2 +- autotests/testAP/connection_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
autotests/testAP-no-support/connection_test.py +1 -1
@@ -27,7 +27,7 @@ class Test(unittest.TestCase): dev_ap.start_ap('TestAP2', 'Password2') self.assertTrue(dev_ap.group_cipher == 'TKIP') - self.assertTrue(dev_ap.pairwise_ciphers == 'TKIP') + self.assertIn('TKIP', dev_ap.pairwise_ciphers) ordered_network = dev_sta.get_ordered_network('TestAP2')
autotests/testAP/connection_test.py +1 -1
@@ -60,7 +60,7 @@ class Test(unittest.TestCase): dev1.start_ap('TestAP2') self.assertTrue(dev1.group_cipher == group) - self.assertTrue(dev1.pairwise_ciphers == pairwise) + self.assertIn(pairwise, dev1.pairwise_ciphers) try: validate(wd, dev2, dev1, 'TestAP2', 'Password2', ip_checks=False)
Signature · 1 line
2.34.3
PATCH v2 6/6 doc: document AP properties PairwiseCiphers/GroupCipher
In reply to James Prestwood--- doc/access-point-api.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+)
doc/access-point-api.txt +12 -0
@@ -71,3 +71,15 @@ Properties boolean Started [readonly] uint32 Frequency [readonly, optional] The frequency that the Access Point is operating on. + + array{string} PairwiseCiphers [readonly, optional] + + List of pairwise ciphers the access point supports. + The same format as setting a list of ciphers for an AP + profile, i.e. TKIP, CCMP-128, GCMP-128, CCMP-256 etc. + + string GroupCipher [readonly, optional] + + The group cipher suite the access point is using. + Possible values are the same as what could be included + in the PairwiseCiphers list.
Signature · 1 line
2.34.3
Hi James,
Quoted 9 lines · James Prestwood
This wasn't being updated meaning the property is missing until a scan is issued over DBus.
Rather than duplicate all the property changed calls they were all factored out into a helper function.
--- src/ap.c | 55 +++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 30 deletions(-)
All applied, thanks.
Regards,
-Denis