From e0874baa8fbddcdecd1920f3f494ae2ee53b931d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Mon, 7 Oct 2024 17:35:14 +0200 Subject: [PATCH] driver/wifi: remove auto_connect attribute This commit does away with controlling the join-intent via an attribute but couples it to the existence of a '' node. With this change all '' nodes within the configuration are always unconditionally considered for joining. Issue #5356. --- repos/dde_linux/run/wifi_config.inc | 11 ++--- repos/dde_linux/src/driver/wifi/README | 19 +++---- repos/dde_linux/src/driver/wifi/manager.h | 60 ++++++++++------------- repos/pc/run/pc_wifi.run | 6 +-- 4 files changed, 41 insertions(+), 55 deletions(-) diff --git a/repos/dde_linux/run/wifi_config.inc b/repos/dde_linux/run/wifi_config.inc index 7ed87aec03..b3a4dcf643 100644 --- a/repos/dde_linux/run/wifi_config.inc +++ b/repos/dde_linux/run/wifi_config.inc @@ -31,15 +31,15 @@ proc wifi_verbose { } { # You may script your tests with this function in the dynamic_rom config below. # The syntax for the networks parameter is # -# { ssid protection passphrase auto_connect explicit_scan } +# { ssid protection passphrase explicit_scan } # # Example dynamic_rom config: # -# { -# } [wifi_config 5 no [list "net1 WPA2 net1_psk yes no" "net2 WPA2 net2_psk yes no"]] { +# { +# } [wifi_config 5 no [list "net1 WPA2 net1_psk no" "net2 WPA2 net2_psk no"]] { # -# -# } [wifi_config 5 no [list "net1 WPA2 net1_psk yes no" "net2 WPA2 net2_psk yes yes"]] { +# +# } [wifi_config 5 no [list "net1 WPA2 net1_psk no" "net2 WPA2 net2_psk yes"]] { # } # @@ -62,7 +62,6 @@ proc wifi_config { scan_interval update_quality_interval rfkill networks } { append config " ssid=\"[lindex $n 0]\"" append config " protection=\"[lindex $n 1]\"" append config " passphrase=\"[lindex $n 2]\"" - append config " auto_connect=\"[lindex $n 3]\"" append config "/>\n" } append config "\n" diff --git a/repos/dde_linux/src/driver/wifi/README b/repos/dde_linux/src/driver/wifi/README index 05f4044922..2350231d90 100644 --- a/repos/dde_linux/src/driver/wifi/README +++ b/repos/dde_linux/src/driver/wifi/README @@ -117,9 +117,10 @@ node features the following attributes. * :verbose: allows for logging of diagnostic messages generated by the managing portion of the driver. The default is 'false'. -Besides those attributes the '' node can host one or -more '' nodes. Such a node describes the parameters of -a network and has the following attributes. +Besides those attributes the '' node can host '' +nodes. Such a node describes the parameters of a network and its +existence implies the intent to join the network. It has the following +attributes. * :ssid: sets the name of the network. @@ -140,17 +141,12 @@ a network and has the following attributes. * :passphrase: sets the PSK that is required should the network be protected. -* :auto_connect: allows for joining a network automatically. The - default value is 'true'. When more than one network is configured - with enabled 'auto_connect' the driver will try to select the best - one it gets a response from. - - Note: If configured auto-connect networks overlap in locality, the - driver might switch dynamically between the networks. - Of all attributes solely the 'ssid' attribute is mandatory and all others are optional. They should be used when needed only. +Note: If configured networks overlap in locality, the driver might + switch dynamically between these networks. + To scan for a hidden network a '' node must by added. It contains the following mandatory attribute. @@ -165,7 +161,6 @@ while the second one is hidden but should show up in the scan results. ! ! ! ! diff --git a/repos/dde_linux/src/driver/wifi/manager.h b/repos/dde_linux/src/driver/wifi/manager.h index 7f9aa0d058..75e55a510f 100644 --- a/repos/dde_linux/src/driver/wifi/manager.h +++ b/repos/dde_linux/src/driver/wifi/manager.h @@ -161,11 +161,6 @@ struct Accesspoint : Interface Pass pass { }; unsigned quality { 0 }; - /* - * Internal configuration fields - */ - bool auto_connect { false }; - static Accesspoint from_xml(Xml_node const &node) { Accesspoint ap { }; @@ -173,9 +168,8 @@ struct Accesspoint : Interface ap.ssid = node.attribute_value("ssid", Accesspoint::Ssid()); ap.bssid = node.attribute_value("bssid", Accesspoint::Bssid()); - ap.pass = node.attribute_value("passphrase", Accesspoint::Pass("")); - ap.prot = node.attribute_value("protection", Accesspoint::Prot("NONE")); - ap.auto_connect = node.attribute_value("auto_connect", true); + ap.pass = node.attribute_value("passphrase", Accesspoint::Pass("")); + ap.prot = node.attribute_value("protection", Accesspoint::Prot("NONE")); return ap; } @@ -216,8 +210,7 @@ struct Accesspoint : Interface "BSSID: '", bssid, "'", " " "protection: ", prot, " " "id: ", id, " " - "quality: ", quality, " " - "auto_connect: ", auto_connect); + "quality: ", quality); } bool wpa() const { return prot != "NONE"; } @@ -228,17 +221,15 @@ struct Accesspoint : Interface { bool const update = ((Accesspoint::valid(other.bssid) && other.bssid != bssid) || pass != other.pass - || prot != other.prot - || auto_connect != other.auto_connect); + || prot != other.prot); if (!update) return false; if (Accesspoint::valid(other.bssid)) bssid = other.bssid; - pass = other.pass; - prot = other.prot; - auto_connect = other.auto_connect; + pass = other.pass; + prot = other.prot; return true; } }; @@ -488,11 +479,8 @@ struct Add_network_cmd : Action _state = State::FILL_NETWORK_PSK; break; case State::FILL_NETWORK_PSK: - if (_accesspoint.auto_connect) { - ctrl_cmd(_msg, Cmd("ENABLE_NETWORK ", _accesspoint.id)); - _state = State::ENABLE_NETWORK; - } else - _state = State::COMPLETE; + ctrl_cmd(_msg, Cmd("ENABLE_NETWORK ", _accesspoint.id)); + _state = State::ENABLE_NETWORK; break; case State::ENABLE_NETWORK: _state = State::COMPLETE; @@ -643,12 +631,12 @@ struct Remove_network_cmd : Action /* * Action for updating a network * - * For now only the PSK is updated and depending on the - * auto_connect configuration the network will also be - * enabled to allow for auto-join after the alteration. + * For now only the PSK is updated. */ struct Update_network_cmd : Action { + enum class Op : unsigned { + UPDATE_ALL, DISABLE_ONLY }; enum class State : unsigned { INIT, UPDATE_NETWORK_PSK, DISABLE_NETWORK, ENABLE_NETWORK, COMPLETE @@ -656,13 +644,17 @@ struct Update_network_cmd : Action Ctrl_msg_buffer &_msg; Accesspoint _accesspoint; State _state; + Op _op; - Update_network_cmd(Ctrl_msg_buffer &msg, Accesspoint const &ap) + Update_network_cmd(Ctrl_msg_buffer &msg, + Accesspoint const &ap, + Op op = Op::UPDATE_ALL) : Action { Command::UPDATE }, _msg { msg }, _accesspoint { ap }, - _state { State::INIT } + _state { State::INIT }, + _op { op } { } void print(Output &out) const override @@ -685,12 +677,11 @@ struct Update_network_cmd : Action _state = State::DISABLE_NETWORK; break; case State::DISABLE_NETWORK: - if (_accesspoint.auto_connect) { + if (_op != Op::DISABLE_ONLY) { ctrl_cmd(_msg, Cmd("ENABLE_NETWORK ", _accesspoint.id)); _state = State::ENABLE_NETWORK; - } else { + } else _state = State::COMPLETE; - } break; case State::ENABLE_NETWORK: _state = State::COMPLETE; @@ -1867,12 +1858,12 @@ struct Wifi::Manager : Wifi::Rfkill_notification_handler Join_state _join { }; - bool _single_autoconnect() const + bool _single_network() const { unsigned count = 0; _network_list.for_each([&] (Network const &network) { network.with_accesspoint([&] (Accesspoint const &ap) { - count += ap.auto_connect; }); }); + ++count; }); }); return count == 1; } @@ -1929,7 +1920,7 @@ struct Wifi::Manager : Wifi::Rfkill_notification_handler * as we do not have the available accesspoints at hand to compare * that. */ - if ((_join.state == Join_state::State::CONNECTING) && _single_autoconnect()) { + if ((_join.state == Join_state::State::CONNECTING) && _single_network()) { /* * Ignore the event for a while as it may happen that hidden @@ -1997,10 +1988,11 @@ struct Wifi::Manager : Wifi::Rfkill_notification_handler * again. At this point intervention by the management * component is needed. */ - ap.auto_connect = false; _queue_action(*new (_actions_alloc) - Update_network_cmd(_msg, ap), _config.verbose); + Update_network_cmd(_msg, ap, + Update_network_cmd::Op::DISABLE_ONLY), + _config.verbose); }); }); } else @@ -2102,7 +2094,7 @@ struct Wifi::Manager : Wifi::Rfkill_notification_handler Remove_network_cmd(_msg, added_ap.id), _config.verbose); } else - if (handled && _single_autoconnect()) + if (handled && _single_network()) /* * To accomodate a management component that only deals * with one network, e.g. the sculpt_manager, generate a diff --git a/repos/pc/run/pc_wifi.run b/repos/pc/run/pc_wifi.run index f46281beb8..2ada3eaa53 100644 --- a/repos/pc/run/pc_wifi.run +++ b/repos/pc/run/pc_wifi.run @@ -179,15 +179,15 @@ append config { -} [wifi_config 5 10 no [list "[wifi_ssid] [wifi_wpa] [wifi_psk] yes no "]] { +} [wifi_config 5 10 no [list "[wifi_ssid] [wifi_wpa] [wifi_psk] no"]] { -} [wifi_config 5 10 yes [list "[wifi_ssid] [wifi_wpa] [wifi_psk] yes no "]] { +} [wifi_config 5 10 yes [list "[wifi_ssid] [wifi_wpa] [wifi_psk] no"]] { -} [wifi_config 5 10 no [list "[wifi_ssid] [wifi_wpa] [wifi_psk] yes no "]] { +} [wifi_config 5 10 no [list "[wifi_ssid] [wifi_wpa] [wifi_psk] no"]] {