Bug 786438 - Handle WEP authentication fail. r=mrbkap
authorChuck Lee <chulee@mozilla.com>
Tue, 06 Nov 2012 14:08:46 +0800
changeset 112622 c25c93664add2f141ab81c04911b6d1aa13cf351
parent 112621 539bb6ca633ab494d229dcc3c33ea88350bb8bbe
child 112623 931d42b011330696421fd1e996ed0044f34e1f0d
push id23833
push useremorley@mozilla.com
push dateThu, 08 Nov 2012 10:20:57 +0000
treeherdermozilla-central@e0d7b394462b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs786438
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 786438 - Handle WEP authentication fail. r=mrbkap
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -809,16 +809,27 @@ var WifiManager = (function() {
      "COMPLETED", "DORMANT", "UNINITIALIZED"];
 
   var driverEventMap = { STOPPED: "driverstopped", STARTED: "driverstarted", HANGED: "driverhung" };
 
   // handle events sent to us by the event worker
   function handleEvent(event) {
     debug("Event coming in: " + event);
     if (event.indexOf("CTRL-EVENT-") !== 0 && event.indexOf("WPS") !== 0) {
+      // Handle connection fail exception on WEP-128, while password length
+      // is not 5 nor 13 bytes.
+      if (event.indexOf("Association request to the driver failed") !== -1) {
+        notify("passwordmaybeincorrect");
+        if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
+          notify("disconnected");
+          manager.authenticationFailuresCount = 0;
+        }
+        return true;
+      }
+
       if (event.indexOf("WPA:") == 0 &&
           event.indexOf("pre-shared key may be incorrect") != -1) {
         notify("passwordmaybeincorrect");
       }
 
       // This is ugly, but we need to grab the SSID here. While we're at it,
       // we grab the BSSID as well.
       var match = /Trying to associate with ([^ ]+) \(SSID='([^']+)' freq=\d+ MHz\)/.exec(event);
@@ -886,16 +897,25 @@ var WifiManager = (function() {
       manager.connectionInfo.ssid = null;
       manager.connectionInfo.id = -1;
       if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
         notify("disconnected", {BSSID: bssid});
         manager.authenticationFailuresCount = 0;
       }
       return true;
     }
+    // Association reject is triggered mostly on incorrect WEP key.
+    if (eventData.indexOf("CTRL-EVENT-ASSOC-REJECT") === 0) {
+      notify("passwordmaybeincorrect");
+      if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
+        notify("disconnected");
+        manager.authenticationFailuresCount = 0;
+      }
+      return true;
+    }
     if (eventData.indexOf("CTRL-EVENT-CONNECTED") === 0) {
       // Format: CTRL-EVENT-CONNECTED - Connection to 00:1e:58:ec:d5:6d completed (reauth) [id=1 id_str=]
       var bssid = eventData.split(" ")[4];
       var id = eventData.substr(eventData.indexOf("id=")).split(" ")[0];
 
       // Don't call onconnected if we ignored this state change (since we were
       // already connected).
       if (notifyStateChange({ state: "CONNECTED", BSSID: bssid, id: id }))