From: Maneesh Jain Date: Thu, 16 Feb 2017 11:34:14 +0000 (+0530) Subject: [tizen 4.0]: Add support of Disconnect Reason Event Handler X-Git-Tag: accepted/tizen/common/20170303.090745^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fconnman.git;a=commitdiff_plain;h=2e8645c8115381bd1b76876f8a4a7b31640cc239 [tizen 4.0]: Add support of Disconnect Reason Event Handler Description: Merged the following upstream patch and modified the connMan accordingly. http://git.kernel.org/cgit/network/connman/connman.git/commit/?id=6245582d0dc9a3f47a6880dabf437ee7c351caef Change-Id: Id90b6d83849c62c2842c038aec516354a2b74060 Signed-off-by: Maneesh Jain --- diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index ffd07b2..fe693cd 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -293,7 +293,6 @@ int g_supplicant_interface_disconnect(GSupplicantInterface *interface, #if defined TIZEN_EXT int g_supplicant_interface_remove_network(GSupplicantInterface *interface); -int g_supplicant_interface_get_disconnect_reason(GSupplicantInterface *interface); #endif int g_supplicant_interface_set_apscan(GSupplicantInterface *interface, unsigned int ap_scan); @@ -407,6 +406,8 @@ struct _GSupplicantCallbacks { GSupplicantPeerState state); void (*peer_request) (GSupplicantPeer *peer); void (*debug) (const char *str); + void (*disconnect_reasoncode)(GSupplicantInterface *interface, + int reasoncode); }; typedef struct _GSupplicantCallbacks GSupplicantCallbacks; diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index c596619..50b0e67 100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -559,6 +559,20 @@ static void callback_peer_request(GSupplicantPeer *peer) callbacks_pointer->peer_request(peer); } +static void callback_disconnect_reason_code(GSupplicantInterface *interface, + int reason_code) +{ + if (!callbacks_pointer) + return; + + if (!callbacks_pointer->disconnect_reasoncode) + return; + + if (reason_code != 0) + callbacks_pointer->disconnect_reasoncode(interface, + reason_code); +} + static void remove_group(gpointer data) { GSupplicantGroup *group = data; @@ -2288,17 +2302,12 @@ static void interface_property(const char *key, DBusMessageIter *iter, } else if (g_strcmp0(key, "Networks") == 0) { supplicant_dbus_array_foreach(iter, interface_network_added, interface); -#if defined TIZEN_EXT } else if (g_strcmp0(key, "DisconnectReason") == 0) { - int disconnect_reason = 0; - - dbus_message_iter_get_basic(iter, &disconnect_reason); - interface->disconnect_reason = disconnect_reason; - - SUPPLICANT_DBG("disconnect reason (%d)", - interface->disconnect_reason); - -#endif + int reason_code; + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) { + dbus_message_iter_get_basic(iter, &reason_code); + callback_disconnect_reason_code(interface, reason_code); + } } else SUPPLICANT_DBG("key %s type %c", key, dbus_message_iter_get_arg_type(iter)); @@ -5705,23 +5714,6 @@ int g_supplicant_interface_remove_network(GSupplicantInterface *interface) return network_remove(data); } - -int g_supplicant_interface_get_disconnect_reason(GSupplicantInterface *interface) -{ - int reason_code = 0; - - SUPPLICANT_DBG(""); - - if (interface == NULL) - return -EINVAL; - - if (system_available == FALSE) - return -EFAULT; - - reason_code = interface->disconnect_reason; - - return reason_code; -} #endif static const char *g_supplicant_rule0 = "type=signal," diff --git a/plugins/wifi.c b/plugins/wifi.c index 84d0708..7b416fc 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -134,7 +134,6 @@ struct wifi_data { bool allow_full_scan; #endif int disconnect_code; - }; #if defined TIZEN_EXT @@ -2638,6 +2637,7 @@ static void interface_state(GSupplicantInterface *interface) break; connman_network_set_connected(network, true); + wifi->disconnect_code = 0; break; case G_SUPPLICANT_STATE_DISCONNECTED: @@ -2663,10 +2663,6 @@ static void interface_state(GSupplicantInterface *interface) network, wifi)) break; -#if defined TIZEN_EXT - wifi->disconnect_code = g_supplicant_interface_get_disconnect_reason(wifi->interface); - DBG("Disconnect Reason code %d", wifi->disconnect_code); -#endif /* See table 8-36 Reason codes in IEEE Std 802.11 */ switch (wifi->disconnect_code) { case 1: /* Unspecified reason */ @@ -3402,6 +3398,17 @@ static void debug(const char *str) connman_debug("%s", str); } +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 const GSupplicantCallbacks callbacks = { .system_ready = system_ready, .system_killed = system_killed, @@ -3424,6 +3431,7 @@ static const GSupplicantCallbacks callbacks = { .system_power_off = system_power_off, .network_merged = network_merged, #endif + .disconnect_reasoncode = disconnect_reasoncode, .debug = debug, }; diff --git a/src/service.c b/src/service.c index f561170..e4de9e1 100755 --- a/src/service.c +++ b/src/service.c @@ -2867,7 +2867,7 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited, append_ethernet, service); connman_dbus_dict_append_basic(dict, "DisconnectReason", - DBUS_TYPE_INT32, &service->disconnect_reason); + DBUS_TYPE_UINT32, &service->disconnect_reason); break; #endif