+ DBG("base %d - limit %d", base, limit);
+ autoscan->base = base;
+ autoscan->limit = limit;
+
+ return autoscan;
+}
+
+static void setup_autoscan(struct wifi_data *wifi)
+{
+ if (wifi->autoscan == NULL)
+ wifi->autoscan = parse_autoscan_params(AUTOSCAN_DEFAULT);
+
+ start_autoscan(wifi->device);
+}
+
+static void interface_create_callback(int result,
+ GSupplicantInterface *interface,
+ void *user_data)
+{
+ struct wifi_data *wifi = user_data;
+
+ DBG("result %d ifname %s, wifi %p", result,
+ g_supplicant_interface_get_ifname(interface),
+ wifi);
+
+ if (result < 0 || wifi == NULL)
+ return;
+
+ wifi->interface = interface;
+ g_supplicant_interface_set_data(interface, wifi);
+
+ if (g_supplicant_interface_get_ready(interface) == FALSE)
+ return;
+
+ DBG("interface is ready wifi %p tethering %d", wifi, wifi->tethering);
+
+ if (wifi->device == NULL) {
+ connman_error("WiFi device not set");
+ return;
+ }
+
+ connman_device_set_powered(wifi->device, TRUE);
+
+ if (connman_setting_get_bool("BackgroundScanning") == FALSE)
+ return;
+
+ /* Setting up automatic scanning */
+ setup_autoscan(wifi);
+}
+
+static int wifi_enable(struct connman_device *device)
+{
+ struct wifi_data *wifi = connman_device_get_data(device);
+ const char *interface = connman_device_get_string(device, "Interface");
+ const char *driver = connman_option_get_string("wifi");
+ int ret;
+
+ DBG("device %p %p", device, wifi);
+
+ ret = g_supplicant_interface_create(interface, driver, NULL,
+ interface_create_callback,
+ wifi);
+ if (ret < 0)
+ return ret;
+
+ return -EINPROGRESS;
+}
+
+static int wifi_disable(struct connman_device *device)
+{
+ struct wifi_data *wifi = connman_device_get_data(device);
+ int ret;
+
+ DBG("device %p", device);
+
+ wifi->connected = FALSE;
+ wifi->disconnecting = FALSE;
+
+ if (wifi->pending_network != NULL)
+ wifi->pending_network = NULL;
+
+ stop_autoscan(device);
+
+ /* In case of a user scan, device is still referenced */
+ if (connman_device_get_scanning(device) == TRUE) {
+ connman_device_set_scanning(device, FALSE);
+ connman_device_unref(wifi->device);
+ }
+
+ remove_networks(device, wifi);
+
+ ret = g_supplicant_interface_remove(wifi->interface, NULL, NULL);
+ if (ret < 0)
+ return ret;
+
+ return -EINPROGRESS;