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.
This commit is contained in:
Michael Lotz 2013-04-01 19:38:21 +02:00
parent 0ef15eb6b9
commit 50944289c6

View File

@ -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;