From: Tomasz Bursztyka Date: Wed, 10 Oct 2012 08:18:45 +0000 (+0300) Subject: gsupplicant: Add a new state according to 'interface_disabled' X-Git-Tag: 1.9~41 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fconnman.git;a=commitdiff_plain;h=583b1a120a8b5b11654c389144d9f7f96c4cfe35 gsupplicant: Add a new state according to 'interface_disabled' When soft rfkill is on, wpa_supplicant sets the interface disabled and sends a state named 'interface_disabled'. Taking this information into account fixes the following issue: - disable wifi (user setting) and hard rfkill it - then un-hard rfkill it, whereafter rfkill states (soft/hard) will go like this: * from 1/1 to 0/0 * from 0/0 to 1/0 when 0/0 occurs, connman will request to enable wifi The problem with this is that enabling wifi takes quite some time and in between ConnMan will soft block wifi to disable it (according to previous user setting). Thus it will request to disable wifi but since enabling is still going on, this request won't do anything. Meanwhile wpa_supplicant will also catch the soft rfkill event and wpa_supplicant will set the state to 'interface_disabled', but since it's not handled properly by ConnMan, the wifi_enable() callback will be called and the function will assume wifi got enabled. --- diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 4e0118d..790cfed 100644 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -95,6 +95,7 @@ typedef enum { typedef enum { G_SUPPLICANT_STATE_UNKNOWN, + G_SUPPLICANT_STATE_DISABLED, G_SUPPLICANT_STATE_DISCONNECTED, G_SUPPLICANT_STATE_INACTIVE, G_SUPPLICANT_STATE_SCANNING, diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index be42958..477106b 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -287,6 +287,8 @@ static GSupplicantState string2state(const char *state) if (g_str_equal(state, "unknown") == TRUE) return G_SUPPLICANT_STATE_UNKNOWN; + else if (g_str_equal(state, "interface_disabled") == TRUE) + return G_SUPPLICANT_STATE_DISABLED; else if (g_str_equal(state, "disconnected") == TRUE) return G_SUPPLICANT_STATE_DISCONNECTED; else if (g_str_equal(state, "inactive") == TRUE) @@ -1681,7 +1683,6 @@ static void interface_property(const char *key, DBusMessageIter *iter, debug_strvalmap("Mode capability", mode_capa_map, interface->mode_capa); - interface->ready = TRUE; callback_interface_added(interface); return; } @@ -1698,6 +1699,10 @@ static void interface_property(const char *key, DBusMessageIter *iter, interface->state = string2state(str); callback_interface_state(interface); } + if (interface->state == G_SUPPLICANT_STATE_DISABLED) + interface->ready = FALSE; + else + interface->ready = TRUE; SUPPLICANT_DBG("state %s (%d)", str, interface->state); } else if (g_strcmp0(key, "Scanning") == 0) { @@ -2857,6 +2862,7 @@ int g_supplicant_interface_scan(GSupplicantInterface *interface, case G_SUPPLICANT_STATE_GROUP_HANDSHAKE: return -EBUSY; case G_SUPPLICANT_STATE_UNKNOWN: + case G_SUPPLICANT_STATE_DISABLED: case G_SUPPLICANT_STATE_DISCONNECTED: case G_SUPPLICANT_STATE_INACTIVE: case G_SUPPLICANT_STATE_SCANNING: diff --git a/plugins/wifi.c b/plugins/wifi.c index 2d81f80..2984de0 100644 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -1328,6 +1328,7 @@ static connman_bool_t is_idle(struct wifi_data *wifi) switch (wifi->state) { case G_SUPPLICANT_STATE_UNKNOWN: + case G_SUPPLICANT_STATE_DISABLED: case G_SUPPLICANT_STATE_DISCONNECTED: case G_SUPPLICANT_STATE_INACTIVE: case G_SUPPLICANT_STATE_SCANNING: @@ -1357,6 +1358,7 @@ static connman_bool_t is_idle_wps(GSupplicantInterface *interface, * actually means that we are idling. */ switch (wifi->state) { case G_SUPPLICANT_STATE_UNKNOWN: + case G_SUPPLICANT_STATE_DISABLED: case G_SUPPLICANT_STATE_DISCONNECTED: case G_SUPPLICANT_STATE_INACTIVE: case G_SUPPLICANT_STATE_SCANNING: @@ -1527,6 +1529,7 @@ static void interface_state(GSupplicantInterface *interface) break; case G_SUPPLICANT_STATE_UNKNOWN: + case G_SUPPLICANT_STATE_DISABLED: case G_SUPPLICANT_STATE_ASSOCIATED: case G_SUPPLICANT_STATE_4WAY_HANDSHAKE: case G_SUPPLICANT_STATE_GROUP_HANDSHAKE: