summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@nokia.com>2011-02-04 13:14:19 (GMT)
committerSamuel Ortiz <sameo@linux.intel.com>2011-02-07 23:58:47 (GMT)
commitc280448c625ebd29e9718807c8774215c87e0382 (patch)
tree4d8bfffd4da4eeaa3cc2dd63fa5682fdf26099d7 /gsupplicant
parent29873834009a4e88efc151104dfac3975ddeba81 (diff)
downloadconnman-c280448c625ebd29e9718807c8774215c87e0382.zip
connman-c280448c625ebd29e9718807c8774215c87e0382.tar.gz
connman-c280448c625ebd29e9718807c8774215c87e0382.tar.bz2
gsupplicant: Report AddNetwork and SelectNetwork errors to caller
Call interface_connect_data callback when an error is reported for wpa_supplicant AddNetwork and SelectNetwork method calls. In the case of WPA-PSK or WEP key being incorrectly formatted, set the callback result to -ENOKEY.
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/supplicant.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 7a3fd4c..2c3e5dd 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2410,6 +2410,24 @@ int g_supplicant_interface_scan(GSupplicantInterface *interface,
interface_scan_params, interface_scan_result, data);
}
+static int parse_supplicant_error(DBusMessageIter *iter)
+{
+ int err = -ECANCELED;
+ char *key;
+
+ while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(iter, &key);
+ if (strncmp(key, "psk", 4) == 0 ||
+ strncmp(key, "wep_key", 7) == 0) {
+ err = -ENOKEY;
+ break;
+ }
+ dbus_message_iter_next(iter);
+ }
+
+ return err;
+}
+
static void interface_select_network_result(const char *error,
DBusMessageIter *iter, void *user_data)
{
@@ -2419,8 +2437,10 @@ static void interface_select_network_result(const char *error,
SUPPLICANT_DBG("");
err = 0;
- if (error != NULL)
- err = -EIO;
+ if (error != NULL) {
+ SUPPLICANT_DBG("SelectNetwork error %s", error);
+ err = parse_supplicant_error(iter);
+ }
if (data->callback != NULL)
data->callback(err, data->interface, data->user_data);
@@ -2445,6 +2465,7 @@ static void interface_add_network_result(const char *error,
struct interface_connect_data *data = user_data;
GSupplicantInterface *interface = data->interface;
const char *path;
+ int err;
if (error != NULL)
goto error;
@@ -2466,6 +2487,11 @@ static void interface_add_network_result(const char *error,
return;
error:
+ SUPPLICANT_DBG("AddNetwork error %s", error);
+ err = parse_supplicant_error(iter);
+ if (data->callback != NULL)
+ data->callback(err, data->interface, data->user_data);
+
g_free(interface->network_path);
interface->network_path = NULL;
g_free(data->ssid);