[haiku-commits] r42774 - haiku/trunk/src/servers/net

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 28 Sep 2011 02:21:32 +0200 (CEST)

Author: mmlr
Date: 2011-09-28 02:21:32 +0200 (Wed, 28 Sep 2011)
New Revision: 42774
Changeset: https://dev.haiku-os.org/changeset/42774

Modified:
   haiku/trunk/src/servers/net/NetServer.cpp
Log:
* Fill out the wireless network join request as detailed as possible, but don't
  fail when encountering missing information (like the password). This gives the
  supplicant an opportunity to ask for the required information as needed.
* Remove (currently broken) WEP support from the net_server. It will be
  delegated to the supplicant as well, as that one already handles all the
  key/password conversion.

In the absence of a supplicant the net_server can therefore only join open
networks now. It will also only attempt that if it is sure that the network in
question is actually an open network (by means of scan results or explicit
configuration) and will otherwise delegate the join request.


Modified: haiku/trunk/src/servers/net/NetServer.cpp
===================================================================
--- haiku/trunk/src/servers/net/NetServer.cpp   2011-09-27 21:34:28 UTC (rev 
42773)
+++ haiku/trunk/src/servers/net/NetServer.cpp   2011-09-28 00:21:32 UTC (rev 
42774)
@@ -151,22 +151,6 @@
 }
 
 
-static int32
-translate_wep_key(const char*& buffer, char* key)
-{
-       memset(key, 0, IEEE80211_KEYBUF_SIZE);
-
-       // TODO: support possibility to set them all
-       if (buffer[0] != '\0') {
-               int32 length = strlcpy(key, buffer, IEEE80211_KEYBUF_SIZE);
-               buffer += length;
-               return length;
-       }
-
-       return 0;
-}
-
-
 // #pragma mark - exported functions
 
 
@@ -982,6 +966,8 @@
        // Get network
        BNetworkDevice device(deviceName);
        wireless_network network;
+
+       bool askForConfig = false;
        if ((address.Family() != AF_LINK
                        || device.GetNetwork(address, network) != B_OK)
                && device.GetNetwork(name, network) != B_OK) {
@@ -993,12 +979,14 @@
                network.cipher = 0;
                network.group_cipher = 0;
                network.key_mode = 0;
+               askForConfig = true;
        }
 
        const char* string;
        if (message.FindString("authentication", &string) == B_OK
                || (found && networkMessage.FindString("authentication", 
&string)
                                == B_OK)) {
+               askForConfig = false;
                if (!strcasecmp(string, "wpa2")) {
                        network.authentication_mode = 
B_NETWORK_AUTHENTICATION_WPA2;
                        network.key_mode = B_KEY_MODE_IEEE802_1X;
@@ -1011,20 +999,14 @@
                        network.authentication_mode = 
B_NETWORK_AUTHENTICATION_WEP;
                        network.key_mode = B_KEY_MODE_NONE;
                        network.cipher = network.group_cipher = 
B_NETWORK_CIPHER_WEP_40;
-               } else if (strcasecmp(string, "none") && strcasecmp(string, 
"open"))
+               } else if (strcasecmp(string, "none") && strcasecmp(string, 
"open")) {
                        fprintf(stderr, "%s: invalid authentication mode.\n", 
name);
+                       askForConfig = true;
+               }
        }
 
-       // TODO: if password is still NULL, ask password manager once we have 
one
-       // TODO: remove the clear text settings password once we have
-
-       if (password == NULL
-               && network.authentication_mode > B_NETWORK_AUTHENTICATION_NONE)
-               return B_NOT_ALLOWED;
-
-       // Join the specified network with the specified authentication method
-
-       if (network.authentication_mode < B_NETWORK_AUTHENTICATION_WPA) {
+       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));
@@ -1034,39 +1016,6 @@
                        return status;
                }
 
-               if (network.authentication_mode == 
B_NETWORK_AUTHENTICATION_WEP) {
-                       status = set_80211(deviceName, IEEE80211_IOC_WEP, NULL, 
0,
-                               IEEE80211_WEP_ON);
-                       if (status != B_OK) {
-                               fprintf(stderr, "%s: turning on WEP failed: 
%s\n", name,
-                                       strerror(status));
-                               return status;
-                       }
-
-                       const char* buffer = password;
-
-                       // set key
-                       for (int32 i = 0; i < 4; i++) {
-                               char key[IEEE80211_KEYBUF_SIZE];
-                               int32 keyLength = translate_wep_key(buffer, 
key);
-                               status = set_80211(deviceName, 
IEEE80211_IOC_WEPKEY, key,
-                                       keyLength);
-                               if (status != B_OK)
-                                       break;
-                       }
-
-                       if (status == B_OK) {
-                               status = set_80211(deviceName, 
IEEE80211_IOC_WEPKEY, NULL, 0,
-                                       0);
-                       }
-
-                       if (status != B_OK) {
-                               fprintf(stderr, "%s: setting WEP keys failed: 
%s\n", name,
-                                       strerror(status));
-                               return status;
-                       }
-               }
-
                return B_OK;
        }
 
@@ -1084,6 +1033,12 @@
                status = join.AddString("name", network.name);
        if (status == B_OK)
                status = join.AddFlat("address", &network.address);
+       if (status == B_OK && !askForConfig)
+               status = join.AddUInt32("authentication", 
network.authentication_mode);
+       if (status == B_OK && password != NULL)
+               status = join.AddString("password", password);
+       if (status != B_OK)
+               return status;
 
        BMessenger wpaSupplicant(kWPASupplicantSignature);
        BMessage reply;


Other related posts:

  • » [haiku-commits] r42774 - haiku/trunk/src/servers/net - mmlr