*/
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <vconf.h>
#include <vconf-keys.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include "log.h"
#include "wifi.h"
#include "neterror.h"
#include "wifi-eap.h"
#include "wifi-wps.h"
+#include "wifi-bssid-scan.h"
+#include "wifi-netlink-scan.h"
#include "wifi-power.h"
#include "wifi-state.h"
#include "wifi-agent.h"
#include "wifi-firmware.h"
-#include "wifi-ssid-scan.h"
#include "wifi-passpoint.h"
#include "wifi-eap-config.h"
#include "wifi-background-scan.h"
+#include "ip-conflict-detect.h"
#include "wifi-config.h"
#include "wifi-tdls.h"
+#include "wifi-key-encryption.h"
+#include "wifi-extension.h"
+
+#define SPRD_CP2_FIRMWARE_PATH "/usr/bin/cp2-downloader"
+#define SPRD_CP2_FIRMWARE_STATE_PATH "/tmp/.wifi-firmware-loaded"
+static int is_wifi_firmware_downloaded = FALSE;
static Wifi *wifi_object = NULL;
static NetConnmanAgent *connman_agent_object = NULL;
if (mac_addr != NULL) {
if (strlen(mac_addr) == 0)
netconfig_set_mac_address_from_file();
- g_free(mac_addr);
+ free(mac_addr);
}
}
g_dbus_connection_call_finish(conn, res, &error);
if (error != NULL) {
ERR("WiFi Connection Error [%s]", error->message);
+ /* No need to emit WiFiConnectFail signal if Connection is
+ * in progress */
+ if (error->code == G_IO_ERROR_TIMED_OUT) {
+ g_error_free(error);
+ DBG("WiFi Connection in Progress");
+ netconfig_gdbus_pending_call_unref();
+ return;
+ }
g_error_free(error);
if (netconfig_dbus_emit_signal(NULL, NETCONFIG_WIFI_PATH,
NETCONFIG_WIFI_INTERFACE, "WiFiConnectFail",
return;
}
+static void _update_wifi_firmware_state(void)
+{
+ int fd;
+ mode_t mode = S_IRGRP | S_IWUSR | S_IXGRP;
+
+ fd = creat(SPRD_CP2_FIRMWARE_STATE_PATH, mode);
+ if (fd >= 0)
+ close(fd);
+ else
+ DBG("Failed to create wifi firmware state file");
+
+ is_wifi_firmware_downloaded = TRUE;
+}
+
+static int _get_wifi_firmware_state(void)
+{
+ if (!is_wifi_firmware_downloaded
+ && access(SPRD_CP2_FIRMWARE_STATE_PATH, F_OK) != 0)
+ is_wifi_firmware_downloaded = FALSE;
+ else
+ is_wifi_firmware_downloaded = TRUE;
+ return is_wifi_firmware_downloaded;
+}
+
+int wifi_firmware_download(void)
+{
+ int rv = 0;
+ const char *path = SPRD_CP2_FIRMWARE_PATH;
+ char *const args[] = { SPRD_CP2_FIRMWARE_PATH, NULL };
+ char *const envs[] = { NULL };
+
+ if (!_get_wifi_firmware_state()) {
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv < 0) {
+ DBG("wifi firmware download fails");
+ return -EIO;
+ }
+ _update_wifi_firmware_state();
+ DBG("wifi firmware download successes");
+ }
+
+ return 0;
+}
+
void wifi_object_create_and_init(void)
{
DBG("Create wifi object.");
G_CALLBACK(handle_get_wifi_state), NULL);
/* WIFI scan */
- g_signal_connect(wifi_object, "handle-request-specific-scan",
- G_CALLBACK(handle_request_specific_scan), NULL);
- g_signal_connect(wifi_object, "handle-request-wps-scan",
- G_CALLBACK(handle_request_wps_scan), NULL);
+ g_signal_connect(wifi_object, "handle-request-bssid-scan",
+ G_CALLBACK(handle_request_bssid_scan), NULL);
+ g_signal_connect(wifi_object, "handle-get-bssid-list",
+ G_CALLBACK(handle_get_bssid_list), NULL);
+ g_signal_connect(wifi_object, "handle-netlink-scan",
+ G_CALLBACK(handle_netlink_scan), NULL);
+
+ /* WPS Connect */
+ g_signal_connect(wifi_object, "handle-request-wps-connect",
+ G_CALLBACK(handle_request_wps_connect), NULL);
+ g_signal_connect(wifi_object, "handle-request-wps-cancel",
+ G_CALLBACK(handle_request_wps_cancel), NULL);
/* WIFI direct */
g_signal_connect(wifi_object, "handle-launch-direct",
g_signal_connect(wifi_object, "handle-delete-eap-config",
G_CALLBACK(handle_delete_eap_config), NULL);
+ /* VSIE methods */
+ g_signal_connect(wifi_object, "handle-add-vsie",
+ G_CALLBACK(handle_add_vsie), NULL);
+ g_signal_connect(wifi_object, "handle-get-vsie",
+ G_CALLBACK(handle_get_vsie), NULL);
+ g_signal_connect(wifi_object, "handle-remove-vsie",
+ G_CALLBACK(handle_remove_vsie), NULL);
+
+ /* IP conflict methods */
+ g_signal_connect(wifi_object, "handle-ip-conflict-set-enable",
+ G_CALLBACK(handle_ip_conflict_set_enable), NULL);
+ g_signal_connect(wifi_object, "handle-is-ip-conflict-detect-enabled",
+ G_CALLBACK(handle_is_ip_conflict_detect_enabled), NULL);
+ g_signal_connect(wifi_object, "handle-set-ip-conflict-period",
+ G_CALLBACK(handle_set_ip_conflict_period), NULL);
+ g_signal_connect(wifi_object, "handle-get-ip-conflict-state",
+ G_CALLBACK(handle_get_ip_conflict_state), NULL);
+ g_signal_connect(wifi_object, "handle-get-ip-conflict-period",
+ G_CALLBACK(handle_get_ip_conflict_period), NULL);
+
/* WIFI configuration */
g_signal_connect(wifi_object, "handle-save-configuration",
G_CALLBACK(handle_save_configuration), NULL);
G_CALLBACK(handle_set_config_field), NULL);
g_signal_connect(wifi_object, "handle-get-config-passphrase",
G_CALLBACK(handle_get_config_passphrase), NULL);
+
/* WIFI EAP configuration */
g_signal_connect(wifi_object, "handle-save-eap-configuration",
G_CALLBACK(handle_save_eap_configuration), NULL);
G_CALLBACK(handle_resume_bgscan), NULL);
g_signal_connect(wifi_object, "handle-pause-bgscan",
G_CALLBACK(handle_pause_bgscan), NULL);
+ g_signal_connect(wifi_object, "handle-reset-bgscan-interval",
+ G_CALLBACK(handle_reset_bgscan_interval), NULL);
+
+ /* Auto Scan Mode */
+ g_signal_connect(wifi_object, "handle-get-autoscan",
+ G_CALLBACK(handle_get_autoscan), NULL);
+ g_signal_connect(wifi_object, "handle-get-autoscanmode",
+ G_CALLBACK(handle_get_autoscanmode), NULL);
+
+ /* Extension API methods */
+ g_signal_connect(wifi_object, "handle-flush-bss",
+ G_CALLBACK(handle_flush_bss), NULL);
/* Passpoint */
g_signal_connect(wifi_object, "handle-set-passpoint",
G_CALLBACK(handle_tdls_disconnect), NULL);
g_signal_connect(wifi_object, "handle-tdls-connected-peer",
G_CALLBACK(handle_tdls_connected_peer), NULL);
+ g_signal_connect(wifi_object, "handle-tdls-discover",
+ G_CALLBACK(handle_tdls_discover), NULL);
+ g_signal_connect(wifi_object, "handle-tdls-connect",
+ G_CALLBACK(handle_tdls_connect), NULL);
+ g_signal_connect(wifi_object, "handle-tdls-channel-switch",
+ G_CALLBACK(handle_tdls_channel_switch), NULL);
+ g_signal_connect(wifi_object, "handle-tdls-cancel-channel-switch",
+ G_CALLBACK(handle_tdls_cancel_channel_switch), NULL);
+
+ /* Passphrase Encryption */
+ g_signal_connect(wifi_object, "handle-encrypt-passphrase",
+ G_CALLBACK(handle_encrypt_passphrase), NULL);
+ g_signal_connect(wifi_object, "handle-decrypt-passphrase",
+ G_CALLBACK(handle_decrypt_passphrase), NULL);
if (!g_dbus_interface_skeleton_export(interface_wifi, connection,
NETCONFIG_WIFI_PATH, NULL)) {