X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=plugins%2Fsupplicant.c;h=69e79eb2261800a23f208c761752b33236c885f5;hb=6e84765a8dda6c0cb5f13fbaf7bdecf9016c8de4;hp=ce56e8fdfcc0fc134faa50af29f409526b14164a;hpb=7af7e16c45130925cd95a560a8b47977ac238f03;p=connman diff --git a/plugins/supplicant.c b/plugins/supplicant.c index ce56e8f..69e79eb 100644 --- a/plugins/supplicant.c +++ b/plugins/supplicant.c @@ -279,6 +279,12 @@ static int add_interface(struct supplicant_task *task) return -EIO; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + return -EIO; + } + dbus_pending_call_set_notify(call, add_interface_reply, task, NULL); dbus_message_unref(message); @@ -349,6 +355,12 @@ static int create_interface(struct supplicant_task *task) return -EIO; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + return -EIO; + } + dbus_pending_call_set_notify(call, get_interface_reply, task, NULL); dbus_message_unref(message); @@ -369,6 +381,8 @@ static void remove_interface_reply(DBusPendingCall *call, void *user_data) connman_device_unref(task->device); + inet_ifdown(task->ifindex); + free_task(task); dbus_message_unref(reply); @@ -401,6 +415,12 @@ static int remove_interface(struct supplicant_task *task) return -EIO; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + return -EIO; + } + dbus_pending_call_set_notify(call, remove_interface_reply, task, NULL); dbus_message_unref(message); @@ -783,23 +803,30 @@ static int initiate_scan(struct supplicant_task *task) return 0; } -static char *build_group(const unsigned char *ssid, unsigned int ssid_len, +static char *build_group(const char *addr, + const unsigned char *ssid, unsigned int ssid_len, const char *mode, const char *security) { GString *str; unsigned int i; - if (ssid_len < 1) - return NULL; + if (ssid_len > 0 && ssid[0] != '\0') { + str = g_string_sized_new((ssid_len * 2) + 24); + if (str == NULL) + return NULL; - str = g_string_sized_new((ssid_len * 2) + 24); - if (str == NULL) - return NULL; + for (i = 0; i < ssid_len; i++) + g_string_append_printf(str, "%02x", ssid[i]); + } else { + if (addr == NULL) + return NULL; - g_string_append_printf(str, "wifi_"); + str = g_string_sized_new(15 + 24); + if (str == NULL) + return NULL; - for (i = 0; i < ssid_len; i++) - g_string_append_printf(str, "%02x", ssid[i]); + g_string_append_printf(str, "hidden_%s", addr); + } g_string_append_printf(str, "_%s_%s", mode, security); @@ -838,7 +865,7 @@ static void extract_addr(DBusMessageIter *value, if (result->path == NULL) return; - snprintf(result->path, 18, "%02X_%02X_%02X_%02X_%02X_%02X", + snprintf(result->path, 18, "%02x%02x%02x%02x%02x%02x", eth->ether_addr_octet[0], eth->ether_addr_octet[1], eth->ether_addr_octet[2], @@ -1037,7 +1064,8 @@ static void properties_reply(DBusPendingCall *call, void *user_data) mode = (result.adhoc == TRUE) ? "adhoc" : "managed"; - group = build_group(result.ssid, result.ssid_len, mode, security); + group = build_group(result.path, result.ssid, result.ssid_len, + mode, security); network = connman_device_get_network(task->device, result.path); if (network == NULL) { @@ -1131,6 +1159,12 @@ static void get_properties(struct supplicant_task *task) goto noscan; } + if (call == NULL) { + connman_error("D-Bus connection not available"); + dbus_message_unref(message); + goto noscan; + } + dbus_pending_call_set_notify(call, properties_reply, task, NULL); dbus_message_unref(message); @@ -1222,6 +1256,11 @@ static void scan_results_available(struct supplicant_task *task) if (task->noscan == FALSE) connman_device_set_scanning(task->device, TRUE); + if (call == NULL) { + connman_error("D-Bus connection not available"); + goto done; + } + dbus_pending_call_set_notify(call, scan_results_reply, task, NULL); done: @@ -1314,7 +1353,11 @@ static void state_change(struct supplicant_task *task, DBusMessage *msg) connman_network_set_connected(task->network, FALSE); connman_device_set_scanning(task->device, FALSE); break; + case WPA_ASSOCIATING: + connman_network_set_associating(task->network, TRUE); + break; default: + connman_network_set_associating(task->network, FALSE); break; } } @@ -1471,6 +1514,8 @@ int supplicant_connect(struct connman_network *network) enable_network(task); + connman_network_set_associating(task->network, TRUE); + return 0; }