From: Maneesh Jain Date: Thu, 26 Oct 2017 11:57:35 +0000 (+0530) Subject: Added handling of "AssocStatusCode" signal X-Git-Tag: submit/tizen/20171108.071810~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fconnman.git;a=commitdiff_plain;h=5b04daf30f54e0728d91a65d71e1dc6a47075a11 Added handling of "AssocStatusCode" signal Description : This can be used by application in case AP is denying association with status code Change-Id: I195492be4320032b460b708034f044eec03b71dd Signed-off-by: Maneesh Jain --- diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index f115c5e..a33dab0 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -410,6 +410,8 @@ struct _GSupplicantCallbacks { void (*debug) (const char *str); void (*disconnect_reasoncode)(GSupplicantInterface *interface, int reasoncode); + void (*assoc_status_code)(GSupplicantInterface *interface, + int reasoncode); }; typedef struct _GSupplicantCallbacks GSupplicantCallbacks; diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index f3f2b40..b1232a5 100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -577,6 +577,19 @@ static void callback_disconnect_reason_code(GSupplicantInterface *interface, reason_code); } +static void callback_assoc_status_code(GSupplicantInterface *interface, + int status_code) +{ + if (!callbacks_pointer) + return; + + if (!callbacks_pointer->assoc_status_code) + return; + + callbacks_pointer->assoc_status_code(interface, status_code); + +} + static void remove_group(gpointer data) { GSupplicantGroup *group = data; @@ -2359,6 +2372,12 @@ static void interface_property(const char *key, DBusMessageIter *iter, dbus_message_iter_get_basic(iter, &reason_code); callback_disconnect_reason_code(interface, reason_code); } + } else if (g_strcmp0(key, "AssocStatusCode") == 0) { + int status_code; + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) { + dbus_message_iter_get_basic(iter, &status_code); + callback_assoc_status_code(interface, status_code); + } } else SUPPLICANT_DBG("key %s type %c", key, dbus_message_iter_get_arg_type(iter)); diff --git a/plugins/wifi.c b/plugins/wifi.c index b7e37a1..116fa60 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -71,6 +71,7 @@ #define P2P_LISTEN_PERIOD 500 #define P2P_LISTEN_INTERVAL 2000 + static struct connman_technology *wifi_technology = NULL; static struct connman_technology *p2p_technology = NULL; @@ -134,6 +135,7 @@ struct wifi_data { bool allow_full_scan; #endif int disconnect_code; + int assoc_code; }; #if defined TIZEN_EXT @@ -2785,6 +2787,7 @@ static void interface_state(GSupplicantInterface *interface) connman_network_set_connected(network, true); wifi->disconnect_code = 0; + wifi->assoc_code = 0; break; case G_SUPPLICANT_STATE_DISCONNECTED: @@ -3577,12 +3580,29 @@ static void disconnect_reasoncode(GSupplicantInterface *interface, int reasoncode) { struct wifi_data *wifi = g_supplicant_interface_get_data(interface); - if (wifi != NULL) { wifi->disconnect_code = reasoncode; } } +static void assoc_status_code(GSupplicantInterface *interface, int status_code) +{ + struct wifi_data *wifi = g_supplicant_interface_get_data(interface); + +#if defined TIZEN_EXT + struct connman_network *network; +#endif + + if (wifi != NULL) { + wifi->assoc_code = status_code; + +#if defined TIZEN_EXT + network = wifi->network; + connman_network_set_assoc_status_code(network,status_code); +#endif + + } +} static const GSupplicantCallbacks callbacks = { .system_ready = system_ready, @@ -3607,6 +3627,7 @@ static const GSupplicantCallbacks callbacks = { .network_merged = network_merged, #endif .disconnect_reasoncode = disconnect_reasoncode, + .assoc_status_code = assoc_status_code, .debug = debug, }; diff --git a/src/network.c b/src/network.c index 546479c..08b1319 100755 --- a/src/network.c +++ b/src/network.c @@ -101,6 +101,7 @@ struct connman_network { char *keymgmt_type; bool rsn_mode; int disconnect_reason; + int assoc_status_code; void *wifi_vsie; unsigned int wifi_vsie_len; #endif @@ -2092,6 +2093,26 @@ int connman_network_get_disconnect_reason(struct connman_network *network) return network->wifi.disconnect_reason; } + +int connman_network_set_assoc_status_code(struct connman_network *network, + int assoc_status_code) +{ + + if (network == NULL) + return 0; + + network->wifi.assoc_status_code = assoc_status_code; + return 0; +} + +int connman_network_get_assoc_status_code(struct connman_network *network) +{ + if (network == NULL) + return 0; + + return network->wifi.assoc_status_code; +} + #endif int connman_network_set_nameservers(struct connman_network *network, diff --git a/src/service.c b/src/service.c index 0c9c897..468a327 100755 --- a/src/service.c +++ b/src/service.c @@ -160,6 +160,7 @@ struct connman_service { */ char *keymgmt_type; int disconnect_reason; + int assoc_status_code; #endif #ifdef TIZEN_EXT enum connman_dnsconfig_method dns_config_method_ipv4; @@ -7172,6 +7173,9 @@ static int service_indicate_state(struct connman_service *service) case CONNMAN_SERVICE_STATE_FAILURE: #if defined TIZEN_EXT + + service->assoc_status_code = connman_network_get_assoc_status_code(service->network); + if (service->type == CONNMAN_SERVICE_TYPE_WIFI) service->order = 5; __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);