service: Correctly set 8021X, WEP and PSK passphrases
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 9 Aug 2011 07:59:15 +0000 (10:59 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 9 Aug 2011 10:16:34 +0000 (12:16 +0200)
When returning a passphrase from the Agent API RequestInput method, check
the service security type and set the passphrase accordingly. For WEP and
PSK use __connman_service_set_passphrase() and for 8021X use
__connman_service_set_agent_passphrase(). Print a debug message if the
service security type is none of the three above.

src/service.c

index e88190c..08cbd0b 100644 (file)
@@ -2753,8 +2753,25 @@ static void request_input_cb (struct connman_service *service,
        if (identity != NULL)
                __connman_service_set_agent_identity(service, identity);
 
-       if (passphrase != NULL)
-               __connman_service_set_agent_passphrase(service, passphrase);
+       if (passphrase != NULL) {
+               switch (service->security) {
+               case CONNMAN_SERVICE_SECURITY_WEP:
+               case CONNMAN_SERVICE_SECURITY_PSK:
+                       __connman_service_set_passphrase(service, passphrase);
+                       break;
+               case CONNMAN_SERVICE_SECURITY_8021X:
+                       __connman_service_set_agent_passphrase(service,
+                                                       passphrase);
+                       break;
+               case CONNMAN_SERVICE_SECURITY_UNKNOWN:
+               case CONNMAN_SERVICE_SECURITY_NONE:
+               case CONNMAN_SERVICE_SECURITY_WPA:
+               case CONNMAN_SERVICE_SECURITY_RSN:
+                       DBG("service security '%s' not handled",
+                               security2string(service->security));
+                       break;
+               }
+       }
 
        __connman_service_connect(service);