service: WPS connection logic
authorTomasz Bursztyka <tomasz.bursztyka@nokia.com>
Wed, 26 Jan 2011 08:09:42 +0000 (10:09 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 27 Jan 2011 11:55:08 +0000 (12:55 +0100)
src/service.c

index fa10bc26a24f67878cd76eccce1debd500a4ba16..7743ae9ded5cd7e8dd747cd928cfc8fcd1bb01b3 100644 (file)
@@ -2316,9 +2316,12 @@ static void request_input_cb (struct connman_service *service,
 {
        DBG ("RequestInput return, %p", service);
 
-       if (passphrase == NULL)
+       if (passphrase == NULL && service->wps == FALSE)
                return;
-       __connman_service_set_passphrase(service, passphrase);
+
+       if (passphrase != NULL)
+               __connman_service_set_passphrase(service, passphrase);
+
        __connman_service_connect(service);
 }
 
@@ -3296,7 +3299,8 @@ static connman_bool_t prepare_network(struct connman_service *service)
                                                        &ssid_len) == NULL)
                        return FALSE;
 
-               connman_network_set_string(service->network,
+               if (service->passphrase != NULL)
+                       connman_network_set_string(service->network,
                                "WiFi.Passphrase", service->passphrase);
                break;
        case CONNMAN_NETWORK_TYPE_ETHERNET:
@@ -3380,8 +3384,16 @@ static int service_connect(struct connman_service *service)
                case CONNMAN_SERVICE_SECURITY_PSK:
                case CONNMAN_SERVICE_SECURITY_WPA:
                case CONNMAN_SERVICE_SECURITY_RSN:
-                       if (service->passphrase == NULL)
-                               return -ENOKEY;
+                       if (service->passphrase == NULL) {
+                               if (service->network == NULL)
+                                       return -EOPNOTSUPP;
+
+                               if (service->wps == FALSE ||
+                                       connman_network_get_bool(
+                                                       service->network,
+                                                       "WiFi.UseWPS") == FALSE)
+                                       return -ENOKEY;
+                       }
                        break;
                case CONNMAN_SERVICE_SECURITY_8021X:
                        break;