diff --git a/repos/dde_linux/README b/repos/dde_linux/README
index e2b5ac08f1..0d27793ddd 100644
--- a/repos/dde_linux/README
+++ b/repos/dde_linux/README
@@ -164,12 +164,24 @@ Valid state values are 'connected', 'disconnected', 'connecting' and
'disconnecting'.
In return, the wifi_drv get its configuration via a ROM module. This ROM
-module contains the selected accesspoint. To connect to a accesspoint
-a report like the following is used:
+module contains the configuration for the selected accesspoint.
+To connect to an open accesspoint a configuration like the following is used:
-!
+!
-To disconnect from an accesspoint, a empty report is sent:
+If the network is protected by, e.g., WPA/WPA2, the protection type as well
+as the the pre-shared key have to be specified:
+
+!
+
+If a network consists of several different access points and a particular one
+should be used it can be selected by specifing its BSSID in a 'bssid'
+attribute.
+
+Of all attributes only the 'ssid' attribute is mandatory, all others are
+optional and should only be used when needed.
+
+To disconnect from an accesspoint, a empty configuration is sent:
!
diff --git a/repos/dde_linux/src/drivers/wifi/main.cc b/repos/dde_linux/src/drivers/wifi/main.cc
index ffa213018c..0ad545760e 100644
--- a/repos/dde_linux/src/drivers/wifi/main.cc
+++ b/repos/dde_linux/src/drivers/wifi/main.cc
@@ -18,6 +18,7 @@
#include
#include
#include
+#include
/* local includes */
#include "wpa.h"
@@ -72,7 +73,7 @@ namespace {
static int generate_wpa_supplicant_conf(char const **p, Genode::size_t *len, char const *ssid,
char const *bssid, bool protection = false, char const *psk = 0)
{
- static char const *start_fmt = "network={\n";
+ static char const *start_fmt = "network={\n\tscan_ssid=1\n";
static char const *ssid_fmt = "\tssid=\"%s\"\n";
static char const *bssid_fmt = "\tbssid=%s\n";
static char const *prot_fmt = "\tkey_mgmt=%s\n";
@@ -139,7 +140,9 @@ struct Wlan_configration
*/
void _update_configuration()
{
- Genode::Lock::Guard guard(update_lock);
+ using namespace Genode;
+
+ Lock::Guard guard(update_lock);
config_rom.update();
@@ -153,15 +156,13 @@ struct Wlan_configration
return;
}
- Genode::Xml_node node(config_rom.local_addr(), config_rom.size());
+ Xml_node node(config_rom.local_addr(), config_rom.size());
/**
- * Since is empty we also generate a dummy
- * configuration.
+ * Since is empty or missing an ssid attribute
+ * we also generate a dummy configuration.
*/
- bool use_ssid = node.has_attribute("ssid");
- bool use_bssid = node.has_attribute("bssid");
- if (!use_ssid && !use_bssid) {
+ if (!node.has_attribute("ssid")) {
_active_dummy_configuration();
return;
}
@@ -169,35 +170,41 @@ struct Wlan_configration
/**
* Try to generate a valid configuration.
*/
- enum { MAX_SSID_LENGTH = 32,
- BSSID_LENGTH = 12 + 5,
- MIN_PSK_LENGTH = 8,
- MAX_PSK_LENGTH = 63 };
+ enum { MAX_SSID_LENGTH = 32 + 1,
+ BSSID_LENGTH = 12 + 5 + 1,
+ PROT_LENGTH = 7 + 1,
+ MIN_PSK_LENGTH = 8,
+ MAX_PSK_LENGTH = 63 + 1};
- char ssid[MAX_SSID_LENGTH + 1] = { 0 };
- if (use_ssid)
- node.attribute("ssid").value(ssid, sizeof(ssid));
+ String ssid;
+ node.attribute("ssid").value(&ssid);
- char bssid[BSSID_LENGTH + 1] = { 0 };
+ bool use_bssid = node.has_attribute("bssid");
+ String bssid;
if (use_bssid)
- node.attribute("bssid").value(bssid, sizeof(bssid));
+ node.attribute("bssid").value(&bssid);
- bool use_protection = node.has_attribute("protection");
+ bool use_protection = false;
+ if (node.has_attribute("protection")) {
+ String prot;
+ node.attribute("protection").value(&prot);
+ use_protection = (prot == "WPA-PSK");
+ }
- char psk[MAX_PSK_LENGTH + 1] = { 0 };
+ String psk;
if (use_protection && node.has_attribute("psk"))
- node.attribute("psk").value(psk, sizeof(psk));
+ node.attribute("psk").value(&psk);
/* psk must be between 8 and 63 characters long */
- if (use_protection && (Genode::strlen(psk) < MIN_PSK_LENGTH)) {
+ if (use_protection && (psk.length() < MIN_PSK_LENGTH)) {
+ PERR("error: given psk is too short");
_active_dummy_configuration();
return;
}
- if (generate_wpa_supplicant_conf(&buffer, &size,
- use_ssid ? ssid : 0,
- use_bssid ? bssid : 0,
- use_protection, psk) == 0)
+ if (generate_wpa_supplicant_conf(&buffer, &size, ssid.string(),
+ use_bssid ? bssid.string() : 0,
+ use_protection, psk.string()) == 0)
_activate_configuration();
}