X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fwifi.c;h=821681627f51c690a6d1c070fa6d95ee2baad9b8;hb=e2aacb30e612fed1db0ab4a35b922b55d52e90ae;hp=6672f0dd7bfbcf53fffe804f9ef6f6b5a6d2ffb8;hpb=92632d79d49dd50e5a162b2cb78ca53a75d570e2;p=platform%2Fupstream%2Fconnman.git diff --git a/plugins/wifi.c b/plugins/wifi.c index 6672f0d..8216816 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -59,11 +59,13 @@ #include +#include "src/shared/util.h" + #define CLEANUP_TIMEOUT 8 /* in seconds */ #define INACTIVE_TIMEOUT 12 /* in seconds */ #define FAVORITE_MAXIMUM_RETRIES 2 -#define BGSCAN_DEFAULT "simple:30:-45:300" +#define BGSCAN_DEFAULT "simple:30:-65:300" #define AUTOSCAN_EXPONENTIAL "exponential:3:300" #define AUTOSCAN_SINGLE "single:3" @@ -173,6 +175,9 @@ struct wifi_data { bool allow_full_scan; unsigned int automaxspeed_timeout; GSupplicantScanParams *hidden_scan_params; + unsigned int mac_policy; + unsigned int preassoc_mac_policy; + unsigned int mac_lifetime; #endif int disconnect_code; int assoc_code; @@ -2406,7 +2411,7 @@ static void setup_autoscan(struct wifi_data *wifi) return; } -#endif +#else /* * On the contrary, if BackgroundScanning is disabled, update autoscan @@ -2430,6 +2435,7 @@ static void setup_autoscan(struct wifi_data *wifi) wifi->autoscan = parse_autoscan_params(AUTOSCAN_SINGLE); break; } +#endif } static void finalize_interface_creation(struct wifi_data *wifi) @@ -2493,6 +2499,11 @@ static int wifi_enable(struct connman_device *device) interface = connman_inet_ifname(index); ret = g_supplicant_interface_create(interface, driver, NULL, +#ifdef TIZEN_EXT + connman_device_get_mac_policy(device), + connman_device_get_preassoc_mac_policy(device), + connman_device_get_random_mac_lifetime(device), +#endif /* TIZEN_EXT */ interface_create_callback, wifi); g_free(interface); @@ -2618,7 +2629,7 @@ static int get_latest_connections(int max_ssids, g_key_file_free(keyfile); continue; } - g_time_val_from_iso8601(str, &modified); + util_iso8601_to_timeval(str, &modified); g_free(str); ssid = g_key_file_get_string(keyfile, @@ -2632,6 +2643,9 @@ static int get_latest_connections(int max_ssids, g_sequence_free(latest_list); g_key_file_free(keyfile); g_free(ssid); +#if defined TIZEN_EXT + g_strfreev(services); +#endif return -ENOMEM; } @@ -2954,6 +2968,99 @@ static int wifi_specific_scan(enum connman_service_type type, return ret; } + +static void wifi_mac_policy_callback(int result, + unsigned int policy, + void *user_data) +{ + struct connman_device *device = user_data; + + if (result == 0) + connman_device_mac_policy_notify(device, result, policy); + + connman_device_unref(device); +} + +int wifi_set_mac_policy(struct connman_device *device, unsigned int policy) +{ + struct wifi_data *wifi = connman_device_get_data(device); + int ret; + + if (!wifi) + return -EINVAL; + + connman_device_ref(device); + + ret = g_supplicant_interface_set_mac_policy(wifi->interface, + wifi_mac_policy_callback, + policy, device); + if (ret != 0) + connman_device_unref(device); + + return ret; +} + +static void wifi_preassoc_mac_policy_callback(int result, + unsigned int policy, + void *user_data) +{ + struct connman_device *device = user_data; + + if (result == 0) + connman_device_preassoc_mac_policy_notify(device, result, policy); + + connman_device_unref(device); +} + +int wifi_set_preassoc_mac_policy(struct connman_device *device, unsigned int policy) +{ + struct wifi_data *wifi = connman_device_get_data(device); + int ret; + + if (!wifi) + return -EINVAL; + + connman_device_ref(device); + + ret = g_supplicant_interface_set_preassoc_mac_policy(wifi->interface, + wifi_preassoc_mac_policy_callback, + policy, device); + if (ret != 0) + connman_device_unref(device); + + return ret; +} + +static void wifi_random_mac_lifetime_callback(int result, + unsigned int lifetime, + void *user_data) +{ + struct connman_device *device = user_data; + + if (result == 0) + connman_device_random_mac_lifetime_notify(device, result, lifetime); + + connman_device_unref(device); +} + +int wifi_set_random_mac_lifetime(struct connman_device *device, unsigned int lifetime) +{ + struct wifi_data *wifi = connman_device_get_data(device); + int ret; + + if (!wifi) + return -EINVAL; + + connman_device_ref(device); + + ret = g_supplicant_interface_set_random_mac_lifetime(wifi->interface, + wifi_random_mac_lifetime_callback, + lifetime, device); + if (ret != 0) + connman_device_unref(device); + + return ret; +} #endif #if defined TIZEN_EXT_WIFI_MESH @@ -3329,6 +3436,9 @@ static struct connman_device_driver wifi_ng_driver = { .set_regdom = wifi_set_regdom, #if defined TIZEN_EXT .specific_scan = wifi_specific_scan, + .set_mac_policy = wifi_set_mac_policy, + .set_preassoc_mac_policy = wifi_set_preassoc_mac_policy, + .set_random_mac_lifetime = wifi_set_random_mac_lifetime, #endif #if defined TIZEN_EXT_WIFI_MESH .abort_scan = mesh_abort_scan, @@ -3707,7 +3817,7 @@ found: return; } - if (wifi->network != wifi->pending_network) + if (wifi->network && wifi->network != wifi->pending_network) connman_network_set_connected(wifi->network, false); wifi->network = NULL; @@ -4349,9 +4459,9 @@ static void interface_state(GSupplicantInterface *interface) #if defined TIZEN_EXT if (handle_assoc_status_code(interface, wifi)) { - GSList *bssid_list = (GSList *)connman_network_get_bssid_list(network); const char *group = connman_network_get_group(network); GSupplicantNetwork *supplicant_network; + GSList *bssid_list = NULL; guint bssid_length = 0; if (group) { @@ -4363,6 +4473,7 @@ static void interface_state(GSupplicantInterface *interface) g_supplicant_network_update_assoc_reject(interface, supplicant_network); } + bssid_list = (GSList *)connman_network_get_bssid_list(network); if (bssid_list) bssid_length = g_slist_length(bssid_list); @@ -5137,6 +5248,8 @@ static void network_changed(GSupplicantNetwork *network, const char *property) need_save = connman_device_set_last_connected_ident(wifi->device, service_ident); if (need_save) connman_device_save_last_connected(wifi->device); + + g_free(service_ident); } connman_network_set_last_connected_bssid(connman_network, @@ -5847,6 +5960,9 @@ static void sta_remove_callback(int result, info->wifi->interface = NULL; g_supplicant_interface_create(info->ifname, driver, info->wifi->bridge, +#ifdef TIZEN_EXT + 0, 0, 60, +#endif /* TIZEN_EXT */ ap_create_callback, info); }