X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fsignal-handler.c;h=4fe67ad328540f444c8264af1b3f931651233b52;hb=refs%2Fchanges%2F51%2F179351%2F1;hp=4c7ec98ea9ca3ee785b7543b5530b6f47fe5d148;hpb=2f71d55788918230848803d21c6f1cdf39b095b4;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git diff --git a/src/signal-handler.c b/src/signal-handler.c index 4c7ec98..4fe67ad 100755 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -27,6 +28,7 @@ #include "netdbus.h" #include "neterror.h" #include "wifi-wps.h" +#include "wifi-bssid-scan.h" #include "wifi-agent.h" #include "wifi-power.h" #include "wifi-state.h" @@ -34,12 +36,11 @@ #include "network-state.h" #include "cellular-state.h" #include "signal-handler.h" -#include "wifi-ssid-scan.h" #include "wifi-background-scan.h" #include "wifi-tdls.h" - -#if defined TIZEN_DEBUG_DISABLE -#include "wifi-dump.h" +#include "ip-conflict-detect.h" +#if defined TIZEN_DEBUG_ENABLE +#include "network-dump.h" #endif #define DBUS_SERVICE_DBUS "org.freedesktop.DBus" @@ -53,12 +54,18 @@ #define SIGNAL_TDLS_CONNECTED "TDLSConnected" #define SIGNAL_TDLS_DISCONNECTED "TDLSDisconnected" #define SIGNAL_TDLS_PEER_FOUND "TDLSPeerFound" + +#define SIGNAL_WPS_CONNECTED "WPSConnected" +#define SIGNAL_WPS_EVENT "Event" +#define SIGNAL_WPS_CREDENTIALS "Credentials" + #define CONNMAN_SIGNAL_SERVICES_CHANGED "ServicesChanged" #define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged" #define CONNMAN_SIGNAL_NAME_CHANGED "NameOwnerChanged" #define MAX_SIG_LEN 64 -#define TOTAL_CONN_SIGNALS 4 +#define TOTAL_CONN_SIGNALS 5 +#define MAX_SOCKET_OPEN_RETRY 5 typedef enum { SIG_INTERFACE_REMOVED = 0, @@ -87,7 +94,9 @@ static const char supplicant_signals[SIG_MAX][MAX_SIG_LEN] = { }; static int supp_subscription_ids[SIG_MAX] = {0}; +#if defined TIZEN_DEBUG_ENABLE static int dumpservice_subscription_id = 0; +#endif typedef void (*supplicant_signal_cb)(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, @@ -96,6 +105,92 @@ typedef void (*connman_signal_cb)(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data); +static void __netconfig_extract_ipv4_signal_data(GVariant *dictionary, + const gchar *profile) +{ + gchar *key = NULL; + const gchar *value = NULL; + GVariant *var = NULL; + GVariantIter iter; + GVariantBuilder *builder; + GVariant *params; + + g_variant_iter_init(&iter, dictionary); + while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) { + if (g_strcmp0(key, "Address") == 0) { + g_variant_get(var, "&s", &value); + char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP); + + DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, + value); + if (g_strcmp0(old_ip, value) != 0) { + builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + + if (value != NULL) { + vconf_set_str(VCONFKEY_NETWORK_IP, value); + g_variant_builder_add(builder, "{sv}", "IPv4Address", + g_variant_new_string(value)); + } else if (old_ip != NULL && strlen(old_ip) > 0) { + vconf_set_str(VCONFKEY_NETWORK_IP, ""); + g_variant_builder_add(builder, "{sv}", "IPv4Address", + g_variant_new_string("")); + } + + params = g_variant_new("(@a{sv})", + g_variant_builder_end(builder)); + + netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH, + NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged", + params); + } + free(old_ip); + } + } +} + +static void __netconfig_extract_ipv6_signal_data(GVariant *dictionary, + const gchar *profile) +{ + gchar *key = NULL; + const gchar *value = NULL; + GVariant *var = NULL; + GVariantIter iter; + GVariantBuilder *builder; + GVariant *params; + + g_variant_iter_init(&iter, dictionary); + while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) { + if (g_strcmp0(key, "Address") == 0) { + g_variant_get(var, "&s", &value); + char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6); + + DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, + value); + if (g_strcmp0(old_ip6, value) != 0) { + builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + + if (value != NULL) { + vconf_set_str(VCONFKEY_NETWORK_IP6, value); + g_variant_builder_add(builder, "{sv}", "IPv6Address", + g_variant_new_string(value)); + } else if (old_ip6 != NULL && strlen(old_ip6) > 0) { + vconf_set_str(VCONFKEY_NETWORK_IP6, ""); + g_variant_builder_add(builder, "{sv}", "IPv6Address", + g_variant_new_string("")); + } + + params = g_variant_new("(@a{sv})", + g_variant_builder_end(builder)); + + netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH, + NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged", + params); + } + free(old_ip6); + } + } +} + static void _technology_signal_cb(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) @@ -112,19 +207,17 @@ static void _technology_signal_cb(GDBusConnection *conn, if (g_strcmp0(key, "Powered") == 0) { /* Power state */ value = g_variant_get_boolean(var); - if (value == TRUE) { + if (value == TRUE) wifi_state_update_power_state(TRUE); - } else { + else wifi_state_update_power_state(FALSE); - } } else if (g_strcmp0(key, "Connected") == 0) { /* Connection state */ value = g_variant_get_boolean(var); - if (value == TRUE) { + if (value == TRUE) wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_CONNECTED); - } else { + else wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_POWERED); - } } else if (g_strcmp0(key, "Tethering") == 0) { /* Tethering state */ wifi_state_set_tech_state(NETCONFIG_WIFI_TECH_TETHERED); @@ -138,13 +231,16 @@ static void _technology_signal_cb(GDBusConnection *conn, static void _service_signal_cb(GDBusConnection *conn, const gchar *name, const gchar *path, - const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) + const gchar *interface, const gchar *sig, + GVariant *param, gpointer user_data) { gchar *sigvalue = NULL; gchar *property; GVariant *variant = NULL, *var; GVariantIter *iter; const gchar *value = NULL; + struct sock_data *sd = NULL; + int idx = 0; if (path == NULL || param == NULL) goto done; @@ -153,24 +249,41 @@ static void _service_signal_cb(GDBusConnection *conn, if (sigvalue == NULL) goto done; - if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0) { + if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0) goto done; - } if (g_strcmp0(sigvalue, "State") == 0) { g_variant_get(variant, "s", &property); - DBG("[%s] %s", property, path); + DBG("[%s] %s", property, path); + if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) { + if (g_strcmp0(property, "ready") == 0) { + for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) { + sd = start_ip_conflict_mon(); + if (sd != NULL) + break; + } + } else if (g_strcmp0(property, "online") == 0) { + // do nothing + } else { + stop_ip_conflict_mon(); + } + } + if (netconfig_is_wifi_profile(path) == TRUE) { int wifi_state = 0; - vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state); - if (wifi_state == VCONFKEY_WIFI_OFF) + netconfig_vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state); + if (wifi_state == VCONFKEY_WIFI_OFF) { + g_free(property); goto done; + } if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) { - if (wifi_state >= VCONFKEY_WIFI_CONNECTED) + if (wifi_state >= VCONFKEY_WIFI_CONNECTED) { + g_free(property); goto done; + } netconfig_update_default_profile(path); @@ -184,11 +297,14 @@ static void _service_signal_cb(GDBusConnection *conn, wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE); else wifi_state_set_service_state(NETCONFIG_WIFI_IDLE); + g_free(property); goto done; } - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); @@ -204,11 +320,14 @@ static void _service_signal_cb(GDBusConnection *conn, wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION); else wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION); + g_free(property); goto done; } - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); @@ -221,12 +340,11 @@ static void _service_signal_cb(GDBusConnection *conn, } else { if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) { if (netconfig_get_default_profile() == NULL) { - if(!netconfig_is_cellular_profile(path)) { + if (!netconfig_is_cellular_profile(path)) netconfig_update_default_profile(path); - } else { - if (netconfig_is_cellular_internet_profile(path)) { + else { + if (netconfig_is_cellular_internet_profile(path)) netconfig_update_default_profile(path); - } } } @@ -234,29 +352,38 @@ static void _service_signal_cb(GDBusConnection *conn, cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE); } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) { - if (netconfig_get_default_profile() == NULL) + if (netconfig_get_default_profile() == NULL) { + g_free(property); goto done; + } if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path)) cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE); - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); - } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) { - if (netconfig_get_default_profile() == NULL) + } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) { + if (netconfig_get_default_profile() == NULL) { + g_free(property); goto done; + } if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path)) cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING); - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); } } + g_free(property); } else if (g_strcmp0(sigvalue, "Proxy") == 0) { if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0) goto done; @@ -266,9 +393,13 @@ static void _service_signal_cb(GDBusConnection *conn, g_variant_get(variant, "a{sv}", &iter); while (g_variant_iter_loop(iter, "{sv}", &property, &var)) { + GVariantBuilder *builder; + GVariant *sig_params; if (g_strcmp0(property, "Servers") == 0) { GVariantIter *iter_sub = NULL; + builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + g_variant_get(var, "as", &iter_sub); g_variant_iter_loop(iter_sub, "s", &value); g_variant_iter_free(iter_sub); @@ -276,6 +407,16 @@ static void _service_signal_cb(GDBusConnection *conn, DBG("Proxy - [%s]", value); vconf_set_str(VCONFKEY_NETWORK_PROXY, value); + g_variant_builder_add(builder, "{sv}", "ProxyAddress", + g_variant_new_string(value)); + + sig_params = g_variant_new("(@a{sv})", + g_variant_builder_end(builder)); + + netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH, + NETCONFIG_NETWORK_INTERFACE, "NetworkConfigChanged", + sig_params); + g_free(property); g_variant_unref(var); break; @@ -283,8 +424,20 @@ static void _service_signal_cb(GDBusConnection *conn, value = g_variant_get_string(var, NULL); DBG("Method - [%s]", value); - if (g_strcmp0(value, "direct") == 0) + if (g_strcmp0(value, "direct") == 0) { + builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}")); + vconf_set_str(VCONFKEY_NETWORK_PROXY, ""); + g_variant_builder_add(builder, "{sv}", "ProxyAddress", + g_variant_new_string("")); + + sig_params = g_variant_new("(@a{sv})", + g_variant_builder_end(builder)); + + netconfig_dbus_emit_signal(NULL, NETCONFIG_NETWORK_PATH, + NETCONFIG_NETWORK_INTERFACE, + "NetworkConfigChanged", sig_params); + } g_free(property); g_variant_unref(var); @@ -293,9 +446,14 @@ static void _service_signal_cb(GDBusConnection *conn, } g_variant_iter_free(iter); + } else if (g_strcmp0(sigvalue, "IPv4") == 0) { + __netconfig_extract_ipv4_signal_data(variant, path); + } else if (g_strcmp0(sigvalue, "IPv6") == 0) { + __netconfig_extract_ipv6_signal_data(variant, path); } else if (g_strcmp0(sigvalue, "Error") == 0) { g_variant_get(variant, "s", &property); INFO("[%s] Property : %s", sigvalue, property); + g_free(property); } done: if (sigvalue) @@ -362,7 +520,7 @@ static void _services_changed_cb(GDBusConnection *conn, const gchar *name, is_cell_internet_prof = netconfig_is_cellular_internet_profile( service_path); if (service_path != NULL) { - while (g_variant_iter_loop(next, "{sv}", &property, + while (next && g_variant_iter_loop(next, "{sv}", &property, &variant)) { if (g_strcmp0(property, "State") == 0) { g_variant_get(variant, "s", &value); @@ -372,11 +530,12 @@ static void _services_changed_cb(GDBusConnection *conn, const gchar *name, g_strcmp0(value, "online") != 0) { g_free(property); + g_free(value); g_variant_unref(variant); break; } - if(!is_cell_prof) + if (!is_cell_prof) netconfig_update_default_profile( service_path); else if (is_cell_internet_prof) { @@ -391,18 +550,22 @@ static void _services_changed_cb(GDBusConnection *conn, const gchar *name, cellular_state_set_service_state( NETCONFIG_CELLULAR_ONLINE); g_free(property); + g_free(value); g_variant_unref(variant); break; } } } } + + g_variant_iter_free(added); + if (next) g_variant_iter_free(next); - if (added) - g_variant_iter_free(added); + if (removed) g_variant_iter_free(removed); + return; } @@ -411,8 +574,8 @@ static void _supplicant_interface_removed(GDBusConnection *conn, const gchar *sig, GVariant *param, gpointer user_data) { DBG("Interface removed handling!"); - if (netconfig_wifi_is_wps_enabled() == TRUE) - netconfig_wifi_wps_signal_scanaborted(); + if (netconfig_wifi_is_bssid_scan_started() == TRUE) + netconfig_wifi_bssid_signal_scanaborted(); return; } @@ -422,9 +585,10 @@ static void _supplicant_properties_changed(GDBusConnection *conn, const gchar *sig, GVariant *param, gpointer user_data) { DBG("Properties changed handling!"); - gchar *key; - GVariantIter *iter; - GVariant *variant; + gchar *key = NULL; + const gchar *state = NULL; + GVariantIter *iter = NULL; + GVariant *variant = NULL; gboolean scanning = FALSE; if (param == NULL) @@ -434,12 +598,42 @@ static void _supplicant_properties_changed(GDBusConnection *conn, while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) { if (g_strcmp0(key, "Scanning") == 0) { scanning = g_variant_get_boolean(variant); + DBG("setting scanning %s", scanning ? "TRUE" : "FALSE"); if (scanning == TRUE) netconfig_wifi_set_scanning(TRUE); + else + netconfig_wifi_set_scanning(FALSE); + + g_variant_unref(variant); + g_free(key); + variant = NULL; + key = NULL; + break; + } else if (g_strcmp0(key, "State") == 0) { + state = g_variant_get_string(variant, NULL); + if (state != NULL) + ERR("Supplicant state : %s", state); + + g_variant_unref(variant); + g_free(key); + variant = NULL; + key = NULL; + break; + } else if (g_strcmp0(key, "DisconnectReason") == 0) { + int reason = g_variant_get_int32(variant); + ERR("Supplicant DisconnReason : %d", reason); g_variant_unref(variant); g_free(key); + variant = NULL; + key = NULL; break; + } else { + gchar *value; + value = g_variant_print(variant, TRUE); + DBG("Supplicant %s : %s", key, value); + + g_free(value); } } @@ -453,10 +647,7 @@ static void _supplicant_bss_added(GDBusConnection *conn, const gchar *sig, GVariant *param, gpointer user_data) { DBG("BSS added handling!"); - if (wifi_ssid_scan_get_state() == TRUE) - wifi_ssid_scan_add_bss(param); - else - wifi_state_set_bss_found(TRUE); + wifi_state_set_bss_found(TRUE); return; } @@ -468,18 +659,13 @@ static void _supplicant_scan_done(GDBusConnection *conn, DBG("Scan Done handling!"); netconfig_wifi_set_scanning(FALSE); - if (netconfig_wifi_is_wps_enabled() == TRUE) { - netconfig_wifi_wps_signal_scandone(); + if (netconfig_wifi_is_bssid_scan_started() == TRUE) { + netconfig_wifi_bssid_signal_scandone(); if (wifi_state_get_technology_state() < NETCONFIG_WIFI_TECH_POWERED) return; } - if (netconfig_wifi_get_bgscan_state() != TRUE) { - if (wifi_ssid_scan_get_state() == TRUE) - wifi_ssid_scan_emit_scan_completed(); - else - wifi_ssid_scan(NULL); - } else { + if (netconfig_wifi_get_bgscan_state() == TRUE) { if (wifi_state_get_technology_state() >= NETCONFIG_WIFI_TECH_POWERED) netconfig_wifi_bgscan_start(FALSE); @@ -497,9 +683,14 @@ static void _supplicant_driver_hanged(GDBusConnection *conn, DBG("Driver Hanged handling!"); ERR("Critical. Wi-Fi firmware crashed"); +#if !defined TIZEN_WEARABLE + netconfig_send_message_to_net_popup("Wi-Fi Error", + "Wi-Fi Driver Hanged. Please get log dump and report", "popup", NULL); +#endif wifi_power_recover_firmware(); return; + } static void _supplicant_session_overlapped(GDBusConnection *conn, @@ -509,19 +700,41 @@ static void _supplicant_session_overlapped(GDBusConnection *conn, DBG("Driver session overlapped handling!"); ERR("WPS PBC SESSION OVERLAPPED"); #if defined TIZEN_WEARABLE - wc_launch_syspopup(WC_POPUP_TYPE_SESSION_OVERLAPPED); + return; #else netconfig_send_message_to_net_popup("WPS Error", "wps session overlapped", "popup", NULL); #endif } +#if defined TIZEN_DEBUG_ENABLE +static void __netconfig_dumpservice_handler(GDBusConnection *conn, + const gchar *name, const gchar *path, const gchar *interface, + const gchar *sig, GVariant *param, gpointer user_data) +{ + int mode; + gchar *signal_path = NULL; + + if (param == NULL) + return; + + g_variant_get(param, "(is)", &mode, &signal_path); + DBG("Path: %s and mode: %d", signal_path, mode); + + netconfig_dump_log(signal_path); + if (signal_path) + g_free(signal_path); + + return; +} +#endif + static void _supplicant_tdls_connected(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) { - ERR("Received TDLS Connected Signal"); - netconfig_wifi_tlds_connected_event(param); + DBG("Received TDLS Connected Signal"); + netconfig_wifi_tdls_connected_event(param); return; } @@ -530,8 +743,8 @@ static void _supplicant_tdls_disconnected(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) { - ERR("Received TDLS Disconnected Signal"); - netconfig_wifi_tlds_disconnected_event(param); + DBG("Received TDLS Disconnected Signal"); + netconfig_wifi_tdls_disconnected_event(param); return; } @@ -540,7 +753,204 @@ static void _supplicant_tdls_peer_found(GDBusConnection *conn, const gchar *name, const gchar *path, const gchar *interface, const gchar *sig, GVariant *param, gpointer user_data) { - ERR("Received TDLS Peer Found Signal"); + DBG("Received TDLS Peer Found Signal"); + netconfig_wifi_tdls_peer_found_event(param); + return; +} + +static void _supplicant_wifi_wps_connected(GVariant *param) +{ + gchar *key; + char ssid[32] = {0, }; + gchar *name; + GVariantIter *iter; + GVariant *variant; + int config_error = 0; + int error_indication = 0; + gsize ssid_len = 0; + + if (param == NULL) { + ERR("Param is NULL"); + return; + } + + g_variant_get(param, "(sa{sv})", &name, &iter); + INFO("wps Result: %s", name); + while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) { + INFO("wps Key is %s", key); + if (g_strcmp0(key, "SSID") == 0) { + const char *t_key = NULL; + t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar)); + INFO("wps ssid_len is %d ", ssid_len); + if (t_key == NULL) { + g_free(key); + g_variant_unref(variant); + ERR("WPS PBC Connection Failed"); + goto error; + } + if (ssid_len > 0 && ssid_len <= 32) { + memcpy(ssid, t_key, ssid_len); + } else { + memset(ssid, 0, sizeof(ssid)); + ssid_len = 0; + } + INFO("WPS PBC Connection completed with AP %s", ssid); + netconfig_wifi_notify_wps_completed(ssid, ssid_len); + } + } + + g_variant_iter_free(iter); + g_free(name); + return; + +error: + g_variant_iter_free(iter); + g_free(name); + error_indication = WPS_EI_OPERATION_FAILED; + config_error = WPS_CFG_NO_ERROR; + ERR("Error Occured! Notifying Fail Event"); + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); + +} + +static void _supplicant_wifi_wps_event(GVariant *param) +{ + gchar *key; + gchar *name; + GVariantIter *iter; + GVariant *variant; + gint32 config_error = 0; + gint32 error_indication = 0; + + if (param == NULL) { + ERR("Param is NULL"); + return; + } + + g_variant_get(param, "(sa{sv})", &name, &iter); + INFO("Event Result: %s", name); + if (g_strcmp0(name, "fail") == 0) { + while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) { + if (key == NULL) + goto error; + INFO("Key is %s", key); + if (g_strcmp0(key, "config_error") == 0) { + config_error = g_variant_get_int32(variant); + ERR("Config Error %d", config_error); + } else if (g_strcmp0(key, "error_indication") == 0) { + error_indication = g_variant_get_int32(variant); + ERR("Error Indication %d", error_indication); + } + } + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); + } + + g_variant_iter_free(iter); + g_free(name); + return; + +error: + g_variant_iter_free(iter); + g_free(name); + error_indication = WPS_EI_OPERATION_FAILED; + config_error = WPS_CFG_NO_ERROR; + ERR("Error Occured! Notifying Fail Event"); + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); +} + +static void _supplicant_wifi_wps_credentials(GVariant *param) +{ + gchar *key; + char ssid[32] = {0, }; + char wps_key[100] = {0, }; + GVariantIter *iter; + GVariant *variant; + int config_error = 0; + int error_indication = 0; + gsize ssid_len = 0; + + if (param == NULL) { + ERR("Param is NULL"); + return; + } + + g_variant_get(param, "(a{sv})", &iter); + while (g_variant_iter_loop(iter, "{sv}", &key, &variant)) { + if (key == NULL) + goto error; + INFO("wps Key is %s", key); + if (g_strcmp0(key, "Key") == 0) { + gsize key_len = 0; + const char *t_key = NULL; + key_len = g_variant_get_size(variant); + + INFO("wps password len %d ", key_len); + if (key_len > 0) { + t_key = g_variant_get_fixed_array(variant, &key_len, sizeof(guchar)); + if (!t_key) { + g_free(key); + g_variant_unref(variant); + goto error; + } + strncpy(wps_key, t_key, key_len); + wps_key[key_len] = '\0'; + INFO("WPS Key in process credentials %s", wps_key); + } else + SLOGI("WPS AP Security ->Open"); + } else if (g_strcmp0(key, "SSID") == 0) { + const char *t_key = NULL; + t_key = g_variant_get_fixed_array(variant, &ssid_len, sizeof(guchar)); + INFO("wps ssid_len is %d ", ssid_len); + if (!t_key) { + g_free(key); + g_variant_unref(variant); + goto error; + } + if (ssid_len > 0 && ssid_len <= 32) { + memcpy(ssid, t_key, ssid_len); + } else { + memset(ssid, 0, sizeof(ssid)); + ssid_len = 0; + } + INFO("SSID in process credentials %s", ssid); + } + } + + g_variant_iter_free(iter); + +#if 0 + /* + * Notify WPS Credentials only when requested through WPS PBC + * In case of WPS PIN connman will take care of notification + */ + if (netconfig_get_wps_field() == TRUE) +#endif + netconfig_wifi_notify_wps_credentials(ssid, ssid_len, wps_key); + return; + +error: + g_variant_iter_free(iter); + error_indication = WPS_EI_OPERATION_FAILED; + config_error = WPS_CFG_NO_ERROR; + ERR("Error Occured! Notifying Fail Event"); + netconfig_wifi_notify_wps_fail_event(config_error, error_indication); +} + +static void __netconfig_wps_signal_filter_handler(GDBusConnection *conn, + const gchar *name, const gchar *path, const gchar *interface, + const gchar *sig, GVariant *param, gpointer user_data) +{ + if (g_strcmp0(sig, SIGNAL_WPS_CREDENTIALS) == 0) { + INFO("Received wps CREDENTIALS Signal from Supplicant"); + _supplicant_wifi_wps_credentials(param); + } else if (g_strcmp0(sig, SIGNAL_WPS_EVENT) == 0) { + INFO("Received wps EVENT Signal from Supplicant"); + _supplicant_wifi_wps_event(param); + } else if (g_strcmp0(sig, SIGNAL_WPS_CONNECTED) == 0) { + INFO("Received WPSConnected Signal from Supplicant"); + _supplicant_wifi_wps_connected(param); + } + return; } @@ -556,27 +966,6 @@ static supplicant_signal_cb supplicant_cbs[SIG_MAX] = { _supplicant_tdls_peer_found }; -#if defined TIZEN_DEBUG_DISABLE -static void __netconfig_dumpservice_handler(GDBusConnection *conn, - const gchar *name, const gchar *path, const gchar *interface, - const gchar *sig, GVariant *param, gpointer user_data) -{ - int mode; - gchar *signal_path = NULL; - - if (param == NULL) - return; - - g_variant_get(param, "(io)", &mode, &signal_path); - DBG("Path: %s and mode: %d", signal_path, mode); - netconfig_dump_log(path); - if (signal_path) - g_free(signal_path); - - return; -} -#endif - void register_gdbus_signal(void) { GDBusConnection *connection = NULL; @@ -641,6 +1030,20 @@ void register_gdbus_signal(void) INFO("Successfully register connman DBus signal filters"); + conn_subscription_ids[4] = g_dbus_connection_signal_subscribe( + connection, + SUPPLICANT_SERVICE, + SUPPLICANT_INTERFACE ".Interface.WPS", + NULL, + NULL, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + __netconfig_wps_signal_filter_handler, + NULL, + NULL); + + INFO("Successfully register Supplicant WPS DBus signal filters"); + for (sig = SIG_INTERFACE_REMOVED; sig < SIG_MAX; sig++) { /* * For SIG_INTERFACE_REMOVED INTERFACE_ADDED @@ -663,13 +1066,9 @@ void register_gdbus_signal(void) INFO("Successfully register Supplicant DBus signal filters"); -#if defined TIZEN_DEBUG_DISABLE +#if defined TIZEN_DEBUG_ENABLE dumpservice_subscription_id = g_dbus_connection_signal_subscribe( connection, - /* - * Sender => For testing purpose made NULL - *WPA_SUPPLICANT, - */ NULL, DUMP_SERVICE_INTERFACE, DUMP_SIGNAL, @@ -680,8 +1079,9 @@ void register_gdbus_signal(void) NULL, NULL); - INFO("Successfully register Dumpservice DBus signal filter"); + INFO("Successfully registered Dumpservice DBus signal filter"); #endif + /* In case ConnMan precedes this signal register, * net-config should update the default connected profile. */ @@ -713,6 +1113,8 @@ void deregister_gdbus_signal(void) } } +#if defined TIZEN_DEBUG_ENABLE g_dbus_connection_signal_unsubscribe(connection, dumpservice_subscription_id); +#endif }