From bac43428b002a99c53d84f9e1f2e1026b03b298a Mon Sep 17 00:00:00 2001 From: Maneesh Jain Date: Fri, 10 Jul 2015 12:30:12 +0530 Subject: [PATCH] Add support of Firmware "Start/Stop" DBus Method This patch allows the P2P framework to control the P2P interface using these two method. 1. "Start" Method: Up the P2P Interface 2. "Stop" Method : Down the P2P interface Change-Id: If95adc2f5a1b4cc6e7c19cc7304f3ead55e7b18f Signed-off-by: Maneesh Jain --- CMakeLists.txt | 5 + include/neterror.h | 40 +----- include/util.h | 3 + include/wifi-firmware.h | 48 +++++++ interfaces/netconfig-iface-wifi.xml | 8 ++ packaging/net-config.spec | 5 +- src/neterror.c | 111 ++++++++++++--- src/utils/util.c | 59 ++++++++ src/wifi-firmware.c | 266 ++++++++++++++++++++++++++++++++++++ src/wifi-indicator.c | 1 + src/wifi-power.c | 1 + src/wifi.c | 1 + 12 files changed, 495 insertions(+), 53 deletions(-) mode change 100644 => 100755 include/neterror.h mode change 100644 => 100755 include/util.h create mode 100755 include/wifi-firmware.h mode change 100644 => 100755 src/neterror.c mode change 100644 => 100755 src/utils/util.c create mode 100755 src/wifi-firmware.c mode change 100644 => 100755 src/wifi-indicator.c mode change 100644 => 100755 src/wifi-power.c mode change 100644 => 100755 src/wifi.c diff --git a/CMakeLists.txt b/CMakeLists.txt index e46193a..7ea1428 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ SET(SRCS src/utils/util.c src/utils/emulator.c src/utils/mdm-private.c + src/wifi-firmware.c ) IF("${CMAKE_BUILD_TYPE}" STREQUAL "") @@ -36,6 +37,10 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") +IF(TIZEN_P2P_ENABLE) + ADD_DEFINITIONS(-DTIZEN_P2P_ENABLE) +ENDIF(TIZEN_P2P_ENABLE) + INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(pkgs REQUIRED glib-2.0 diff --git a/include/neterror.h b/include/neterror.h old mode 100644 new mode 100755 index 91b3484..7502bbf --- a/include/neterror.h +++ b/include/neterror.h @@ -1,7 +1,7 @@ /* * Network Configuration Module * - * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,39 +26,13 @@ extern "C" { #include "glib.h" -G_BEGIN_DECLS +#define NETCONFIG_ERROR_QUARK (netconfig_error_quark()) +#define NETCONFIG_CONNMAN_AGENT_ERROR_QUARK (netconfig_connman_agent_error_quark()) -typedef enum { - NETCONFIG_NO_ERROR = 0x00, - NETCONFIG_ERROR_INTERNAL = 0x01, - NETCONFIG_ERROR_NO_SERVICE = 0x02, - NETCONFIG_ERROR_TRASPORT = 0x03, - NETCONFIG_ERROR_NO_PROFILE = 0x04, - NETCONFIG_ERROR_WRONG_PROFILE = 0x05, - NETCONFIG_ERROR_WIFI_LOAD_INPROGRESS = 0x06, - NETCONFIG_ERROR_WIFI_DRIVER_FAILURE = 0x07, - NETCONFIG_ERROR_SECURITY_RESTRICTED = 0x08, - NETCONFIG_ERROR_FAILED_GET_IMSI = 0x09, - NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH = 0x0A, - NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM = 0x0B, - NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA = 0x0C, - NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY = 0x0D, - NETCONFIG_ERROR_MAX = 0x0E, - NETCONFIG_ERROR_INVALID_PARAMETER = 0x0F, - NETCONFIG_ERROR_PERMISSION_DENIED = 0x10, -} NETCONFIG_ERROR; - -GQuark netconfig_error_quark(void); - -#define NETCONFIG_ERROR_QUARK (netconfig_error_quark()) - -G_END_DECLS - -#ifdef __cplusplus -} -#endif - -void netconfig_error_wifi_load_inprogress(GError **error); +void netconfig_error_inprogress(GError **error); +void netconfig_error_already_exists(GError **error); +void netconfig_error_invalid_parameter(GError **error); +void netconfig_error_permission_denied(GError **error); void netconfig_error_wifi_driver_failed(GError **error); void netconfig_error_security_restricted(GError **error); void netconfig_error_wifi_direct_failed(GError **error); diff --git a/include/util.h b/include/util.h old mode 100644 new mode 100755 index 7bd1b03..997962c --- a/include/util.h +++ b/include/util.h @@ -55,6 +55,9 @@ void netconfig_set_wifi_mac_address(void); void netconfig_add_wifi_found_notification(void); void netconfig_del_wifi_found_notification(void); +gboolean netconfig_interface_up(const char *ifname); +gboolean netconfig_interface_down(const char *ifname); + #ifdef __cplusplus } diff --git a/include/wifi-firmware.h b/include/wifi-firmware.h new file mode 100755 index 0000000..057d328 --- /dev/null +++ b/include/wifi-firmware.h @@ -0,0 +1,48 @@ +/* + * Network Configuration Module + * + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#ifndef __NETCONFIG_WIFI_FIRMWARE_H__ +#define __NETCONFIG_WIFI_FIRMWARE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +enum netconfig_wifi_firmware { + NETCONFIG_WIFI_OFF = 0x00, + NETCONFIG_WIFI_STA = 0x01, + NETCONFIG_WIFI_P2P = 0x02, + NETCONFIG_WIFI_SOFTAP = 0x03, +}; + +int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable); + +gboolean netconfig_iface_wifi_start( + NetconfigWifi *wifi, gchar *device, GError **error); +gboolean netconfig_iface_wifi_stop( + NetconfigWifi *wifi, gchar *device, GError **error); + +#ifdef __cplusplus +} +#endif + +#endif /* __NETCONFIG_WIFI_FIRMWARE_H__ */ diff --git a/interfaces/netconfig-iface-wifi.xml b/interfaces/netconfig-iface-wifi.xml index 8ca646c..90d6f4d 100644 --- a/interfaces/netconfig-iface-wifi.xml +++ b/interfaces/netconfig-iface-wifi.xml @@ -64,4 +64,12 @@ + + + + + + + + diff --git a/packaging/net-config.spec b/packaging/net-config.spec index 7640eaf..080d78f 100644 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -1,6 +1,6 @@ Name: net-config Summary: TIZEN Network Configuration Module -Version: 0.1.90_33 +Version: 0.1.90_34 Release: 1 Group: System/Network License: Apache-2.0 @@ -27,7 +27,8 @@ cp %{SOURCE1001} . %build -%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} +%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DTIZEN_P2P_ENABLE=1 \ make %{?_smp_mflags} diff --git a/src/neterror.c b/src/neterror.c old mode 100644 new mode 100755 index 676760a..f52ec5e --- a/src/neterror.c +++ b/src/neterror.c @@ -1,7 +1,7 @@ /* * Network Configuration Module * - * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,10 +19,35 @@ #include +#include "netdbus.h" #include "neterror.h" #include "netconfig.h" +typedef enum { + NETCONFIG_NO_ERROR = 0x00, + NETCONFIG_ERROR_INTERNAL = 0x01, + NETCONFIG_ERROR_NO_SERVICE = 0x02, + NETCONFIG_ERROR_TRASPORT = 0x03, + NETCONFIG_ERROR_NO_PROFILE = 0x04, + NETCONFIG_ERROR_WRONG_PROFILE = 0x05, + NETCONFIG_ERROR_INPROGRESS = 0x06, + NETCONFIG_ERROR_ALREADYEXISTS = 0x07, + NETCONFIG_ERROR_INVALID_PARAMETER = 0x08, + NETCONFIG_ERROR_PERMISSION_DENIED = 0x09, + NETCONFIG_ERROR_WIFI_DRIVER_FAILURE = 0x0A, + NETCONFIG_ERROR_FAILED_GET_IMSI = 0x0B, + NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH = 0x0C, + NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM = 0x0D, + NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA = 0x0E, + NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY = 0x0F, + NETCONFIG_ERROR_SECURITY_RESTRICTED = 0x10, + NETCONFIG_ERROR_WIFI_LOAD_INPROGRESS = 0x11, + NETCONFIG_ERROR_MAX = 0x12, + +} NETCONFIG_ERROR; + #define NETCONFIG_ERROR_INTERFACE NETCONFIG_SERVICE ".Error" +#define CONNMAN_AGENT_ERROR_INTERFACE "net.connman.Agent.Error" GQuark netconfig_error_quark(void) { @@ -34,68 +59,118 @@ GQuark netconfig_error_quark(void) return quark; } +GQuark netconfig_connman_agent_error_quark(void) +{ + static GQuark quark = 0; + + if (!quark) + quark = g_quark_from_static_string("netconfig_connman_agent_error"); + + return quark; +} void netconfig_error_wifi_load_inprogress(GError **error) { g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_LOAD_INPROGRESS, NETCONFIG_ERROR_INTERFACE ".WifiLoadInprogress"); } -void netconfig_error_wifi_driver_failed(GError **error) + + +void netconfig_error_inprogress(GError **error) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_DRIVER_FAILURE, - NETCONFIG_ERROR_INTERFACE ".WifiDriverFailed"); + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_INPROGRESS, + NETCONFIG_ERROR_INTERFACE ".InProgress"); +} + +void netconfig_error_already_exists(GError **error) +{ + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_ALREADYEXISTS, + NETCONFIG_ERROR_INTERFACE ".AlreadyExists"); } +void netconfig_error_invalid_parameter(GError **error) +{ + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_INVALID_PARAMETER, + NETCONFIG_ERROR_INTERFACE ".InvalidParameter"); +} + +void netconfig_error_permission_denied(GError **error) +{ + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_PERMISSION_DENIED, + NETCONFIG_ERROR_INTERFACE ".PermissionDenied"); +} + + void netconfig_error_security_restricted(GError **error) { g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_SECURITY_RESTRICTED, NETCONFIG_ERROR_INTERFACE ".SecurityRestricted"); } +void netconfig_error_wifi_driver_failed(GError **error) +{ + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_WIFI_DRIVER_FAILURE, + NETCONFIG_ERROR_INTERFACE ".WifiDriverFailed"); +} + void netconfig_error_wifi_direct_failed(GError **error) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_DRIVER_FAILURE, + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_WIFI_DRIVER_FAILURE, NETCONFIG_ERROR_INTERFACE ".WifiDirectFailed"); } void netconfig_error_fail_get_imsi(GError **error) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_FAILED_GET_IMSI, + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_FAILED_GET_IMSI, NETCONFIG_ERROR_INTERFACE".FailGetSimImsi"); } void netconfig_error_fail_req_sim_auth(GError **error) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH, + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH, NETCONFIG_ERROR_INTERFACE".FailReqSimAuth"); } void netconfig_error_fail_req_sim_auth_wrong_param(GError **error) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM, + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM, NETCONFIG_ERROR_INTERFACE".FailReqSimAuthWrongParam"); } void netconfig_error_fail_get_sim_auth_wrong_data(GError **error) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA, + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA, NETCONFIG_ERROR_INTERFACE".FailGetSimAuthWrongData"); } void netconfig_error_fail_get_sim_auth_delay(GError **error) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY, + g_set_error(error, netconfig_error_quark(), + NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY, NETCONFIG_ERROR_INTERFACE".FailGetSimAuthDelay"); } -void netconfig_error_invalid_parameter(GError **error) -{ - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_INVALID_PARAMETER, - NETCONFIG_ERROR_INTERFACE ".InvalidParameter"); -} -void netconfig_error_permission_denied(GError **error) +void netconfig_error_init(void) { - g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_PERMISSION_DENIED, - NETCONFIG_ERROR_INTERFACE ".PermissionDenied"); + /* TODO: register GError domain to make error_name */ + /* + dbus_g_error_domain_register(NETCONFIG_ERROR_QUARK, + NETCONFIG_ERROR_INTERFACE, + code_num_netconfig); + + dbus_g_error_domain_register(NETCONFIG_CONNMAN_AGENT_ERROR_QUARK, + CONNMAN_AGENT_ERROR_INTERFACE, + code_num_connman); + */ } diff --git a/src/utils/util.c b/src/utils/util.c old mode 100644 new mode 100755 index cfcd11d..16db8c8 --- a/src/utils/util.c +++ b/src/utils/util.c @@ -546,3 +546,62 @@ done: close(ctl_sk); } } + +gboolean netconfig_interface_up(const char *ifname) +{ + int fd; + struct ifreq ifr; + + fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + if (fd < 0) + return FALSE; + + memset(&ifr, 0, sizeof(ifr)); + g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { + close(fd); + return FALSE; + } + + ifr.ifr_flags |= (IFF_UP | IFF_DYNAMIC); + if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { + close(fd); + return FALSE; + } + + close(fd); + + INFO("Successfully activated wireless interface"); + return TRUE; +} + +gboolean netconfig_interface_down(const char *ifname) +{ + int fd; + struct ifreq ifr; + + fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + if (fd < 0) + return FALSE; + + memset(&ifr, 0, sizeof(ifr)); + g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + + if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { + close(fd); + return FALSE; + } + + ifr.ifr_flags = (ifr.ifr_flags & ~IFF_UP) | IFF_DYNAMIC; + if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { + close(fd); + return FALSE; + } + + close(fd); + + DBG("Successfully de-activated wireless interface"); + return TRUE; +} + diff --git a/src/wifi-firmware.c b/src/wifi-firmware.c new file mode 100755 index 0000000..621180c --- /dev/null +++ b/src/wifi-firmware.c @@ -0,0 +1,266 @@ +/* + * Network Configuration Module + * + * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include +#include "log.h" +#include "util.h" +#include "netdbus.h" +#include "emulator.h" +#include "neterror.h" +#include "netsupplicant.h" +#include "wifi-firmware.h" +#include "network-statistics.h" + + +#define WLAN_P2P_IFACE_NAME "p2p0" + +static int __netconfig_sta_firmware_start(void) +{ + int rv = 0; + + rv = netconfig_interface_up(WIFI_IFNAME); + if (!rv) + return -EIO; + + INFO("Successfully loaded wireless device driver"); + return 0; +} + +static int __netconfig_sta_firmware_stop(void) +{ + + int rv = 0; + + /* Update statistics before driver remove */ + netconfig_wifi_statistics_update_powered_off(); + + rv = netconfig_interface_down(WIFI_IFNAME); + if (!rv) + return -EIO; + + INFO("Successfully removed wireless device driver"); + return 0; +} + + +static int __netconfig_p2p_firmware_start(void) +{ + +#if defined TIZEN_P2P_ENABLE + int rv = 0; + rv = netconfig_interface_up(WLAN_P2P_IFACE_NAME); + if (!rv) + return -EIO; + + INFO("Successfully up p2p device driver"); + return 0; +#else + INFO("P2P Device is not supported"); + return -ENODEV; +#endif + +} + +static int __netconfig_p2p_firmware_stop(void) +{ + +#if defined TIZEN_P2P_ENABLE + int rv = 0; + rv = netconfig_interface_down(WLAN_P2P_IFACE_NAME); + if (!rv) + return -EIO; + + INFO("Successfully down p2p device driver"); + return 0; +#else + INFO("P2P Device is not supported"); + return -ENODEV; +#endif + +} +static int __netconfig_wifi_firmware_start( + enum netconfig_wifi_firmware type) +{ + + INFO(" %d",type); + if (netconfig_emulator_is_emulated() == TRUE) + return -EIO; + + switch (type) { + case NETCONFIG_WIFI_STA: + return __netconfig_sta_firmware_start(); + case NETCONFIG_WIFI_P2P: + return __netconfig_p2p_firmware_start(); + default: + break; + } + + return -ENXIO; +} + +static int __netconfig_wifi_firmware_stop(enum netconfig_wifi_firmware type) +{ + if (netconfig_emulator_is_emulated() == TRUE) + return -EIO; + + switch (type) { + case NETCONFIG_WIFI_STA: + return __netconfig_sta_firmware_stop(); + case NETCONFIG_WIFI_P2P: + return __netconfig_p2p_firmware_stop(); + default: + break; + } + + return -ENXIO; +} + +int netconfig_wifi_firmware(enum netconfig_wifi_firmware type, gboolean enable) +{ + int err; + static enum netconfig_wifi_firmware current_driver = NETCONFIG_WIFI_OFF; + enum netconfig_wifi_firmware alias = type; + +#if defined WLAN_CONCURRENT_MODE + int flight_mode = 0; + + if (type == NETCONFIG_WIFI_P2P) + alias = NETCONFIG_WIFI_STA; +#endif + + INFO("Wi-Fi current firmware %d (type: %d %s)", current_driver, type, + enable == TRUE ? "enable" : "disable"); + + if (enable == FALSE) { + if (current_driver == NETCONFIG_WIFI_OFF) { + return -EALREADY; + } else if (current_driver == alias) { + +#if defined WLAN_CONCURRENT_MODE + vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode); + + if (flight_mode == 0 && type == NETCONFIG_WIFI_STA && + netconfig_is_wifi_direct_on() == TRUE) { + netconfig_interface_down(WIFI_IFNAME); + + return -EALREADY; + } + + if (type == NETCONFIG_WIFI_P2P && + netconfig_wifi_state_get_technology_state() > + NETCONFIG_WIFI_TECH_OFF) { + netconfig_interface_down(WLAN_P2P_IFACE_NAME); + + return -EALREADY; + } +#endif + err = __netconfig_wifi_firmware_stop(type); + if (err < 0 && err != -EALREADY) + return err; + + current_driver = NETCONFIG_WIFI_OFF; + + return err; + } + + return -EIO; + } + + if (current_driver > NETCONFIG_WIFI_OFF) { + if (current_driver == alias) { + +#if defined WLAN_CONCURRENT_MODE + if (type == NETCONFIG_WIFI_STA) + netconfig_interface_up(WIFI_IFNAME); +#if defined TIZEN_P2P_ENABLE + else if (type == NETCONFIG_WIFI_P2P) + netconfig_interface_up(WLAN_P2P_IFACE_NAME); +#endif +#endif + return -EALREADY; + } + + return -EIO; + } + + err = __netconfig_wifi_firmware_start(type); + if (err < 0) + INFO("Failed to start the Firmware"); + else + current_driver = alias; + + return err; +} + +gboolean netconfig_iface_wifi_start( + NetconfigWifi *wifi, gchar *device, GError **error) +{ + int err; + + g_return_val_if_fail(wifi != NULL, FALSE); + + INFO("Wi-Fi firmware start %s", device != NULL ? device : "null"); + + if (g_strcmp0("p2p", device) == 0) + err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, TRUE); + else if (g_strcmp0("softap", device) == 0) + err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, TRUE); + else + err = -EINVAL; + + if (err < 0) { + if (err == -EALREADY) + netconfig_error_already_exists(error); + else + netconfig_error_wifi_driver_failed(error); + + return FALSE; + } + + return TRUE; +} + +gboolean netconfig_iface_wifi_stop( + NetconfigWifi *wifi, gchar *device, GError **error) +{ + int err; + + g_return_val_if_fail(wifi != NULL, FALSE); + + INFO("Wi-Fi firmware stop %s", device != NULL ? device : "null"); + + if (g_strcmp0("p2p", device) == 0) + err = netconfig_wifi_firmware(NETCONFIG_WIFI_P2P, FALSE); + else if (g_strcmp0("softap", device) == 0) + err = netconfig_wifi_firmware(NETCONFIG_WIFI_SOFTAP, FALSE); + else + err = -EINVAL; + + if (err < 0) { + if (err == -EALREADY) + netconfig_error_already_exists(error); + else + netconfig_error_wifi_driver_failed(error); + + return FALSE; + } + + return TRUE; +} diff --git a/src/wifi-indicator.c b/src/wifi-indicator.c old mode 100644 new mode 100755 index 115e08f..a2a4129 --- a/src/wifi-indicator.c +++ b/src/wifi-indicator.c @@ -17,6 +17,7 @@ * */ + #include #include #include diff --git a/src/wifi-power.c b/src/wifi-power.c old mode 100644 new mode 100755 index db06800..9ba4bdc --- a/src/wifi-power.c +++ b/src/wifi-power.c @@ -38,6 +38,7 @@ #include "mdm-private.h" #include "wifi-agent.h" #include "wifi-eap-config.h" +#include "wifi-firmware.h" #define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh" diff --git a/src/wifi.c b/src/wifi.c old mode 100644 new mode 100755 index 835e8fc..32f3eae --- a/src/wifi.c +++ b/src/wifi.c @@ -36,6 +36,7 @@ #include "wifi-eap-config.h" #include "wifi-background-scan.h" #include "wifi-agent.h" +#include "wifi-firmware.h" #include "netconfig-iface-wifi-glue.h" -- 2.7.4