libtzplatform-config
libnl-3.0
libnl-genl-3.0
+ hal-api-wifi
${P2P_REQUIRED_PKGS}
${WEARABLE_REQUIRED_PKGS}
)
int netconfig_vconf_get_int(const char * key, int *value);
int netconfig_vconf_get_bool(const char * key, int *value);
char* netconfig_get_env(const char *key);
+void netconfig_set_mac_address_to_vconf(const char *def_mac);
void netconfig_set_mac_address_from_file(void);
char *netconfig_get_mac_address_from_file(const char *ifname);
+char *netconfig_get_default_ifname_from_file(void);
int netconfig_freq_to_channel(int freq);
int netconfig_get_operating_class(int freq);
void __netconfig_pop_wifi_connected_poppup(const char *ssid);
NETCONFIG_WIFI_P2P = 0x02,
NETCONFIG_WIFI_SOFTAP = 0x03,
};
-
+int netconfig_wifi_firmware_get_mac(const char *interface_name, char **mac);
int netconfig_wifi_firmware(enum netconfig_wifi_firmware type,
const char *interface_name, gboolean enable);
#define WIFI_CERT_STORAGEDIR "/var/lib/wifi/cert"
#define CONNMAN_STORAGEDIR "/var/lib/connman"
+void wifi_set_default_mac(char *def_mac);
+int wifi_check_systemd_service(void);
void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
gpointer user_data);
BuildRequires: pkgconfig(key-manager)
BuildRequires: pkgconfig(libnl-3.0)
BuildRequires: pkgconfig(libnl-genl-3.0)
+BuildRequires: pkgconfig(hal-api-wifi)
Requires: vconf
Requires: connman
Requires: systemd
SmackProcessLabel=System
ExecStart=/usr/bin/net-config
Restart=on-failure
-Capabilities=cap_dac_override,cap_net_admin,cap_net_raw=i
+Capabilities=cap_dac_override,cap_net_admin,cap_net_raw,cap_sys_module=i
SecureBits=keep-caps
[Install]
BusName=net.netconfig
RemainAfterExit=yes
ExecStart=/usr/bin/net-config
-Capabilities=cap_dac_override,cap_net_admin,cap_net_raw=i
+Capabilities=cap_dac_override,cap_net_admin,cap_net_raw,cap_sys_module=i
SecureBits=keep-caps
[Install]
#include "network-statistics.h"
#include "network-dump.h"
#include "ethernet.h"
+#include "wifi-firmware.h"
static GMainLoop *main_loop = NULL;
{
int ret;
int check_ethernet_monitor_timer = 0;
+ char *ifname = NULL;
+ char *wifi_def_mac = NULL;
umask(0077);
g_type_init();
#endif
+ /* Backward compatibility:
+ * Execute only when the old style hal architecture is not running
+ */
+ if (!wifi_check_systemd_service()) {
+ ifname = netconfig_get_default_ifname_from_file();
+
+ if (ifname && netconfig_wifi_firmware_get_mac(ifname, &wifi_def_mac) == 0)
+ wifi_set_default_mac(wifi_def_mac);
+
+ g_free(ifname);
+ }
+
main_loop = g_main_loop_new(NULL, FALSE);
if (main_loop == NULL) {
ERR("Couldn't create GMainLoop\n");
check_dump_state_and_start();
#endif
- if (TIZEN_WLAN_BOARD_SPRD)
+ /* Backward compatibility:
+ * Execute only when the old style hal architecture is running
+ */
+ if (TIZEN_WLAN_BOARD_SPRD && wifi_check_systemd_service())
wifi_firmware_download();
/*In case no emulator, set the ETH0 Mac address*/
#define TELEPHONY_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-telephony.so"
#define STC_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-stc.so"
#define BATTERY_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-battery.so"
+#define CONNMAN_MAINFILE "/etc/connman/main.conf"
+#define CONNMAN_WIFI_DEF_IFNAME "DefaultWifiInterface"
static gboolean netconfig_device_picker_test = FALSE;
static int mdnsd_ref_count = 0;
return value;
}
+void netconfig_set_mac_address_to_vconf(const char *def_mac)
+{
+ int mac_len = 0;
+
+ mac_len = strlen(def_mac);
+ if (mac_len < 17) {
+ ERR("def_mac is empty");
+ return;
+ }
+
+ netconfig_set_vconf_str(VCONFKEY_WIFI_BSSID_ADDRESS, def_mac, TRUE);
+}
+
void netconfig_set_mac_address_from_file(void)
{
FILE *file = NULL;
return g_strdup(mac_str);
}
+char *netconfig_get_default_ifname_from_file(void)
+{
+ GKeyFile *keyfile = NULL;
+
+ keyfile = netconfig_keyfile_load(CONNMAN_MAINFILE);
+ if (keyfile == NULL) {
+ ERR("keyfile[%s] is NULL", CONNMAN_MAINFILE);
+ return NULL;
+ }
+
+ char *str = g_key_file_get_string(keyfile, "General",
+ CONNMAN_WIFI_DEF_IFNAME, NULL);
+ g_key_file_free(keyfile);
+
+ if (!str)
+ return NULL;
+
+ if (*str == '\0') {
+ g_free(str);
+ return NULL;
+ }
+
+ g_strchomp(str);
+
+ if (strlen(str) >= IFNAMSIZ) {
+ g_free(str);
+ return NULL;
+ }
+
+ DBG("ifname[%s]", str);
+ return str;
+}
+
int netconfig_freq_to_channel(int freq)
{
if (freq < 2412 || freq > 5825 ||
#include <vconf-keys.h>
#include <stdio.h>
#include <fcntl.h>
+#include <hal-wifi.h>
#include "log.h"
#include "util.h"
#include "wifi-firmware.h"
#include "network-statistics.h"
-#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
-
#define QUAD_CPUS_COUNT 4
#define TEMP_BUFFER_LEN 100
#define WIFI_MAC_ADD_PATH "/sys/class/net/wlan0/address"
static int __netconfig_sta_firmware_start(const char *interface_name)
{
int rv = 0;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "start", (char *)interface_name, NULL };
- char *const envs[] = { NULL };
- rv = netconfig_execute_file(path, args, envs);
- if (rv < 0)
+ rv = hal_wifi_get_backend();
+ if (rv < 0) {
+ DBG("hal_wifi_get_backend() failed, ret: %d", rv);
return -EIO;
+ }
+
+ rv = hal_wifi_sta_start(interface_name);
+ if (rv < 0) {
+ DBG("hal_wifi_sta_start() failed, ret: %d", rv);
+ return -EIO;
+ }
rv = netconfig_interface_up(interface_name);
if (rv != TRUE)
static int __netconfig_sta_firmware_stop(const char *interface_name)
{
int rv = 0;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "stop", (char *)interface_name, NULL };
- char *const envs[] = { NULL };
rv = netconfig_interface_down(interface_name);
if (rv != TRUE)
return -EIO;
- rv = netconfig_execute_file(path, args, envs);
- if (rv < 0)
+ rv = hal_wifi_get_backend();
+ if (rv < 0) {
+ DBG("hal_wifi_get_backend() failed, ret: %d", rv);
return -EIO;
+ }
+
+ rv = hal_wifi_stop(interface_name);
+ if (rv < 0) {
+ DBG("hal_wifi_stop() failed, ret: %d", rv);
+ netconfig_interface_up(interface_name);
+ return -EIO;
+ }
DBG("Successfully removed wireless device driver");
return 0;
return -ENODEV;
int rv = 0;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "p2p", (char *)interface_name, NULL };
- char *const envs[] = { NULL };
- rv = netconfig_execute_file(path, args, envs);
- if (rv < 0)
+ rv = hal_wifi_get_backend();
+ if (rv < 0) {
+ DBG("hal_wifi_get_backend() failed, ret: %d", rv);
return -EIO;
+ }
+
+ rv = hal_wifi_p2p_start(interface_name);
+ if (rv < 0) {
+ DBG("hal_wifi_p2p_start() failed, ret: %d", rv);
+ return -EIO;
+ }
#if defined TIZEN_WLAN_USE_P2P_INTERFACE
rv = netconfig_interface_up(interface_name);
return -ENODEV;
int rv = 0;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "stop", (char *)interface_name, NULL };
- char *const envs[] = { NULL };
rv = netconfig_interface_down(interface_name);
if (rv != TRUE)
return -EIO;
- rv = netconfig_execute_file(path, args, envs);
- if (rv < 0)
+ rv = hal_wifi_get_backend();
+ if (rv < 0) {
+ DBG("hal_wifi_get_backend() failed, ret: %d", rv);
return -EIO;
+ }
+
+ rv = hal_wifi_stop(interface_name);
+ if (rv < 0) {
+ DBG("hal_wifi_stop() failed, ret: %d", rv);
+ netconfig_interface_up(interface_name);
+ return -EIO;
+ }
DBG("Successfully removed p2p device driver");
return 0;
return -ENODEV;
int rv = 0;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "softap", (char *)interface_name, NULL };
- char *const envs[] = { NULL };
- rv = netconfig_execute_file(path, args, envs);
- if (rv < 0)
+ rv = hal_wifi_get_backend();
+ if (rv < 0) {
+ DBG("hal_wifi_get_backend() failed, ret: %d", rv);
return -EIO;
+ }
+
+ rv = hal_wifi_softap_start(interface_name);
+ if (rv < 0) {
+ DBG("hal_wifi_softap_start() failed, ret: %d", rv);
+ return -EIO;
+ }
if (netconfig_interface_up(interface_name) == FALSE)
return -EIO;
return -ENODEV;
int rv = 0;
- const char *path = WLAN_DRIVER_SCRIPT;
- char *const args[] = { "/usr/bin/wlan.sh", "stop", (char *)interface_name, NULL };
- char *const envs[] = { NULL };
rv = netconfig_interface_down(interface_name);
if (rv != TRUE)
return -EIO;
- rv = netconfig_execute_file(path, args, envs);
- if (rv < 0)
+ rv = hal_wifi_get_backend();
+ if (rv < 0) {
+ DBG("hal_wifi_get_backend() failed, ret: %d", rv);
return -EIO;
+ }
+
+ rv = hal_wifi_stop(interface_name);
+ if (rv < 0) {
+ DBG("hal_wifi_stop() failed, ret: %d", rv);
+ netconfig_interface_up(interface_name);
+ return -EIO;
+ }
DBG("Successfully removed softap device driver");
return 0;
return 0;
}
+int netconfig_wifi_firmware_get_mac(const char *interface_name, char **mac)
+{
+ int rv = 0;
+
+ rv = hal_wifi_get_backend();
+ if (rv < 0) {
+ DBG("hal_wifi_get_backend() failed, ret: %d", rv);
+ return -EIO;
+ }
+
+ rv = hal_wifi_get_mac(interface_name, mac);
+ if (rv < 0) {
+ DBG("hal_wifi_get_mac() failed, ret: %d", rv);
+ return -EIO;
+ }
+
+ DBG("Successfully loaded default wifi mac address: %s", *mac);
+ return 0;
+}
+
int netconfig_wifi_firmware(enum netconfig_wifi_firmware type,
const char *interface_name, gboolean enable)
{
#include "wifi-extension.h"
#include "wifi-dpp.h"
-#define SPRD_CP2_FIRMWARE_PATH "/usr/bin/cp2-downloader"
+#define SPRD_CP2_FIRMWARE_PATH "/hal/bin/cp2-downloader"
#define SPRD_CP2_FIRMWARE_STATE_PATH "/tmp/.wifi-firmware-loaded"
+#define WIFI_SYSTEMD_SERVICE_PATH "/usr/lib/systemd/system/wifi-ready.service"
static int is_wifi_firmware_downloaded = FALSE;
static Wifi *wifi_object = NULL;
static NetConnmanAgent *connman_agent_object = NULL;
static WifiFirmware *wififirmware_object = NULL;
+static char *wifi_def_mac = NULL;
Wifi *get_wifi_object(void){
return wifi_object;
gchar *mac_addr = NULL;
mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
- if (mac_addr != NULL) {
- if (strlen(mac_addr) == 0)
+ if (mac_addr == NULL || strlen(mac_addr) == 0) {
+ if (wifi_def_mac)
+ netconfig_set_mac_address_to_vconf(wifi_def_mac);
+ else
netconfig_set_mac_address_from_file();
- free(mac_addr);
}
+
+ g_free(mac_addr);
+}
+
+void wifi_set_default_mac(char *def_mac)
+{
+ if (!def_mac)
+ return;
+
+ if (wifi_def_mac)
+ g_free(wifi_def_mac);
+
+ wifi_def_mac = def_mac;
+}
+
+int wifi_check_systemd_service(void)
+{
+ if (access(WIFI_SYSTEMD_SERVICE_PATH, F_OK ) != -1 )
+ return 1;
+ else
+ return 0;
}
void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
wifi_power_deinitialize();
wifi_state_deinitialize();
+
+ g_free(wifi_def_mac);
}