#include <gsupplicant/gsupplicant.h>
+#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"
#if defined TIZEN_EXT
#define WIFI_EAP_FAST_PAC_FILE "/var/lib/wifi/wifi.pac" /* path of Pac file for EAP-FAST */
+#define RSSI_LEVEL_2_5G -77
+#define RSSI_LEVEL_2_24G -75
#endif
static struct connman_technology *wifi_technology = NULL;
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;
/* On error, let's recall scan_callback, which will cleanup */
return scan_callback(ret, interface, user_data);
}
- }
+ } else
+ wifi->allow_full_scan = false;
#endif
scanning = connman_device_get_scanning(device, CONNMAN_SERVICE_TYPE_WIFI);
return;
}
-#endif
+#else
/*
* On the contrary, if BackgroundScanning is disabled, update autoscan
wifi->autoscan = parse_autoscan_params(AUTOSCAN_SINGLE);
break;
}
+#endif
}
static void finalize_interface_creation(struct wifi_data *wifi)
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);
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,
g_sequence_free(latest_list);
g_key_file_free(keyfile);
g_free(ssid);
+#if defined TIZEN_EXT
+ g_strfreev(services);
+#endif
return -ENOMEM;
}
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
.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,
static int network_probe(struct connman_network *network)
{
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("network %p", network);
return 0;
DBG("network %p result %d", network, result);
#if defined TIZEN_EXT
- char *ifname = g_supplicant_interface_get_ifname(interface);
+ const char *ifname = g_supplicant_interface_get_ifname(interface);
set_connman_bssid(RESET_BSSID, NULL, ifname);
for (list = iface_list; list; list = list->next) {
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;
}
static void signalpoll_callback(int result, int maxspeed, int strength,
- void *user_data)
+ int snr, void *user_data)
{
struct connman_network *network = user_data;
+ uint16_t freq = connman_network_get_frequency(network);
if (result != 0) {
DBG("Failed to get maxspeed from signalpoll !");
if (strength > 100)
strength = 100;
- DBG("maxspeed = %d, strength = %d", maxspeed, strength);
+ DBG("maxspeed = %d, strength = %d, snr = %d", maxspeed, strength, snr);
connman_network_set_strength(network, (uint8_t)strength);
connman_network_set_maxspeed(network, maxspeed);
set_connection_mode(network, maxspeed);
connman_network_unref(network);
+
+ /* If SNR is less than 20 or RSSI level is less than 3,
+ * scan for BSS transition is started.
+ * */
+ if (connman_setting_get_bool("WifiRoamingScan") == false)
+ return;
+
+ if (snr < 20 && snr != 0)
+ goto scan;
+ else if (freq > 4900 && strength <= RSSI_LEVEL_2_5G)
+ goto scan;
+ else if (freq <= 4900 && strength <= RSSI_LEVEL_2_24G)
+ goto scan;
+
+ return;
+
+scan:
+ throw_wifi_scan(connman_network_get_device(network), scan_callback);
}
static int network_signalpoll(struct wifi_data *wifi)
if (ret < 0) {
DBG("Fail to get max speed !!");
wifi->automaxspeed_timeout = 0;
- connman_network_unref(wifi->network);
+
+ if (wifi->network)
+ connman_network_unref(wifi->network);
return FALSE;
}
#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) {
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);
mode = g_supplicant_network_get_mode(supplicant_network);
identifier = g_supplicant_network_get_identifier(supplicant_network);
-
+#if defined TIZEN_EXT
+ if (!simplified_log)
+#endif
DBG("%s", identifier);
if (!g_strcmp0(mode, "adhoc"))
name = g_supplicant_network_get_name(network);
#if defined TIZEN_EXT
- DBG("name %s property %s", name, property);
+ if (!simplified_log)
+ DBG("name %s property %s", name, property);
#else
DBG("name %s", name);
#endif
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,
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);
}