From 50944289c6f40c9961bf2a69d0986dd8aca11704 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 1 Apr 2013 19:38:21 +0200 Subject: [PATCH] Use the wpa_supplicant to join open networks if it is running. We need to make sure that the wpa_supplicant knows about our intention even when joining an open network, as it otherwise might interfere. Since leaving a network is not synchronous and the wpa_supplicant is already running in that case anyway, this seems easier and more reliable. If the wpa_supplicant is not already running we still join ourselves. --- src/servers/net/NetServer.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index 6a33f5151f..e24e70dada 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -1113,24 +1113,26 @@ NetServer::_JoinNetwork(const BMessage& message, const char* name) } } - if (!askForConfig - && network.authentication_mode == B_NETWORK_AUTHENTICATION_NONE) { - // we join the network ourselves - status_t status = set_80211(deviceName, IEEE80211_IOC_SSID, - network.name, strlen(network.name)); - if (status != B_OK) { - fprintf(stderr, "%s: joining SSID failed: %s\n", name, - strerror(status)); - return status; - } - - return B_OK; - } - - // Join via wpa_supplicant + // We always try to join via the wpa_supplicant. Even if we could join + // ourselves, we need to make sure that the wpa_supplicant knows about + // our intention, as otherwise it would interfere with it. BMessenger wpaSupplicant(kWPASupplicantSignature); if (!wpaSupplicant.IsValid()) { + // The wpa_supplicant isn't running yet, we may join ourselves. + if (!askForConfig + && network.authentication_mode == B_NETWORK_AUTHENTICATION_NONE) { + // We can join this network ourselves. + status_t status = set_80211(deviceName, IEEE80211_IOC_SSID, + network.name, strlen(network.name)); + if (status != B_OK) { + fprintf(stderr, "%s: joining SSID failed: %s\n", name, + strerror(status)); + return status; + } + } + + // We need the supplicant, try to launch it. status_t status = be_roster->Launch(kWPASupplicantSignature); if (status != B_OK && status != B_ALREADY_RUNNING) return status;