service: Filter Adding WPS to the Security Array
authorGrant Erickson <marathon96@gmail.com>
Mon, 5 Sep 2011 05:31:34 +0000 (07:31 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 12 Sep 2011 09:40:48 +0000 (11:40 +0200)
Some access points incorrectly advertise WPS even when they are
configured as open (i.e. no security), so filter adding WPS to the
security array appropriately.

src/service.c

index 65255d1..03afb39 100644 (file)
@@ -1310,10 +1310,27 @@ static void append_security(DBusMessageIter *iter, void *user_data)
                dbus_message_iter_append_basic(iter,
                                DBUS_TYPE_STRING, &str);
 
-       str = "wps";
-       if (service->wps == TRUE)
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
+       /*
+        * Some access points incorrectly advertise WPS even when they
+        * are configured as open or no security, so filter
+        * appropriately.
+        */
+       if (service->wps == TRUE) {
+               switch (service->security) {
+               case CONNMAN_SERVICE_SECURITY_PSK:
+               case CONNMAN_SERVICE_SECURITY_WPA:
+               case CONNMAN_SERVICE_SECURITY_RSN:
+                       str = "wps";
+                       dbus_message_iter_append_basic(iter,
+                               DBUS_TYPE_STRING, &str);
+                       break;
+               case CONNMAN_SERVICE_SECURITY_UNKNOWN:
+               case CONNMAN_SERVICE_SECURITY_NONE:
+               case CONNMAN_SERVICE_SECURITY_WEP:
+               case CONNMAN_SERVICE_SECURITY_8021X:
+                       break;
+               }
+       }
 }
 
 static void append_ethernet(DBusMessageIter *iter, void *user_data)