PROJECT(net-config C)
SET(PACKAGE ${PROJECT_NAME})
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(BINDIR "${PREFIX}/sbin")
+SET(BINDIR "${PREFIX}/bin")
SET(DATADIR "${PREFIX}/share")
SET(LIBDIR "${PREFIX}/${LIB_PATH}")
SET(INTERFACES "${CMAKE_SOURCE_DIR}/interfaces")
src/network-statistics.c
src/dbus/netsupplicant.c
src/wifi-background-scan.c
- src/wifi-tel-intf.c
src/wifi-config.c
)
IF(TIZEN_P2P_ENABLE)
ADD_DEFINITIONS(-DTIZEN_P2P_ENABLE)
- SET(P2P_REQUIRED_PKGS "capi-network-wifi-direct")
ENDIF(TIZEN_P2P_ENABLE)
IF(TIZEN_TETHERING_ENABLE)
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(pkgs REQUIRED
dlog
- tapi
vconf
gio-2.0
glib-2.0
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${PCAP_LIB} "-ldl")
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/config/security-network-config.conf DESTINATION /usr/lib/tmpfiles.d/)
ADD_SUBDIRECTORY(plugin/headed)
+ADD_SUBDIRECTORY(plugin/telephony)
--- /dev/null
+z /sys/module/dhd/parameters/firmware_path 0660 root network_fw -
+z /sys/module/dhd/parameters/nvram_path 0660 root network_fw -
#include <gio/gio.h>
#include <glib-object.h>
+#ifndef EXPORT_SYM
+#define EXPORT_SYM __attribute__((__visibility__("default")))
+#endif
+
#define NETCONFIG_ERROR_QUARK (netconfig_error_quark())
#define NETCONFIG_CONNMAN_AGENT_ERROR_QUARK (netconfig_connman_agent_error_quark())
#endif
#include <glib.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+
+#include "neterror.h"
#define NETCONFIG_ADD_FOUND_AP_NOTI "add_found_ap_noti"
#define NETCONFIG_DEL_FOUND_AP_NOTI "del_found_ap_noti"
#define NETCONFIG_ADD_PORTAL_NOTI "add_portal_noti"
#define NETCONFIG_DEL_PORTAL_NOTI "del_portal_noti"
+struct wifi_authentication_data {
+ int auth_result;
+ int resp_length;
+ int authentication_key_length;
+ int cipher_length;
+ int integrity_length;
+ char *resp_data;
+ char *authentication_key;
+ char *cipher_data;
+ char *integrity_data;
+};
+
struct netconfig_headed_plugin_t {
void(*pop_device_picker) (void);
gboolean(*send_notification_to_net_popup) (const char *, const char *);
void(*pop_wifi_connected_poppup) (const char *);
};
+struct netconfig_telephony_plugin_t {
+ void(*get_telephony_network_type) (int *svctype, int *pstype);
+ gboolean(*wifi_get_sim_imsi) (void *wifi, GDBusMethodInvocation *context);
+ netconfig_error_e(*wifi_req_aka_auth) (GArray *rand_data, GArray *autn_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+ gboolean(*wifi_req_sim_auth) (GArray *rand_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+ gboolean(*tapi_check_sim_state) (void);
+ gboolean(*wifi_get_aka_authdata) (void *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+ gboolean(*wifi_get_sim_authdata) (void *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+};
+
typedef enum {
SYS_EVT_NETWORK_STATUS = 0,
SYS_EVT_WIFI_STATE = 1,
EVAL_WIFI_OFF = 27,
} sys_evt_t;
+void netconfig_complete_get_sim_imsi(void *wifi, GDBusMethodInvocation *context, char *imsi);
+void netconfig_complete_get_aka_auth(void *wifi, GDBusMethodInvocation *context, GArray *array);
+void netconfig_complete_get_sim_auth(void *wifi, GDBusMethodInvocation *context, GArray *array);
+void netconfig_wifi_power_on();
+
#ifdef __cplusplus
}
#endif
int netconfig_vconf_get_bool(const char * key, int *value);
char* netconfig_get_env(const char *key);
void netconfig_set_mac_address_from_file(void);
-
void __netconfig_pop_wifi_connected_poppup(const char *ssid);
+
+void netconfig_get_telephony_network_type(int *svctype, int *pstype);
+gboolean __netconfig_wifi_get_sim_imsi(Wifi *wifi, GDBusMethodInvocation *context);
+netconfig_error_e __netconfig_wifi_req_aka_auth(GArray *rand_data, GArray *autn_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+gboolean __netconfig_wifi_req_sim_auth(GArray *rand_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+gboolean netconfig_tapi_check_sim_state(void);
+gboolean __netconfig_wifi_get_aka_authdata(Wifi *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+gboolean __netconfig_wifi_get_sim_authdata(Wifi *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data);
+
void netconfig_plugin_init();
void netconfig_plugin_deinit();
gboolean netconfig_get_headed_plugin_flag();
+gboolean netconfig_get_telephony_plugin_flag();
#ifdef __cplusplus
}
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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.
- * 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_TEL_INTF_H__
-#define __NETCONFIG_WIFI_TEL_INTF_H__
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-#include <ITapiSim.h>
-#include <TapiUtility.h>
-#include "wifi.h"
-
-TapiHandle * netconfig_tel_init(void);
-void netconfig_tel_deinit(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NETCONFIG_WIFI_TEL_INTERFACE_H__ */
-
Name: net-config
Summary: TIZEN Network Configuration service
-Version: 1.1.110
+Version: 1.1.112
Release: 2
Group: System/Network
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(tapi)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-system-info)
-BuildRequires: pkgconfig(capi-network-wifi-direct)
BuildRequires: pkgconfig(capi-vpnsvc)
BuildRequires: cmake
BuildRequires: pkgconfig(sqlite3)
%description plugin-headed
TIZEN Network Configuration service extension for headed profile.
+%package plugin-telephony
+Summary: net-config extension for telephony FW
+BuildRequires: pkgconfig(tapi)
+Requires: %{name} = %{version}-%{release}
+%description plugin-telephony
+TIZEN Network Configuration service extension for telephony FW.
+
%prep
%setup -q
chsmack -a 'System::Shared' %{TZ_SYS_ETC}/resolv.conf
#Network logs
-#mkdir -p /opt/usr/data/network
-#chmod 755 /opt/usr/data/network
+mkdir -p /opt/usr/data/network
+chmod 755 /opt/usr/data/network
+chown network_fw:network_fw /opt/usr/data/network
#chsmack -a 'System' /opt/usr/data/network
#Add net-config.service to systemd extra default dependency ignore list
%files
%manifest net-config.manifest
-%attr(500,root,root) %{_sbindir}/*
-%attr(644,root,root) %{_sysconfdir}/resolv.conf
-%attr(644,root,root) %{TZ_SYS_ETC}/resolv.conf
-%attr(644,root,root) /usr/share/upgrade/data/resolv.conf
-%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
+%attr(500,network_fw,network_fw) %{_bindir}/*
+%attr(644,network_fw,network_fw) %{_sysconfdir}/resolv.conf
+%attr(644,network_fw,network_fw) %{TZ_SYS_ETC}/resolv.conf
+%attr(644,network_fw,network_fw) /usr/share/upgrade/data/resolv.conf
+%attr(644,network_fw,network_fw) %{_datadir}/dbus-1/system-services/*
#DBus DAC
-%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/*
-%attr(644,root,root) %{_libdir}/systemd/system/net-config.service
-%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/net-config.service
+%attr(644,network_fw,network_fw) %{_sysconfdir}/dbus-1/system.d/*
+%attr(644,network_fw,network_fw) %{_libdir}/systemd/system/net-config.service
+%attr(644,network_fw,network_fw) %{_libdir}/systemd/system/multi-user.target.wants/net-config.service
%if "%{?_lib}" == "lib64"
-%attr(644,root,root) %{_unitdir}/net-config.service
-%attr(644,root,root) %{_unitdir}/multi-user.target.wants/net-config.service
+%attr(644,network_fw,network_fw) %{_unitdir}/net-config.service
+%attr(644,network_fw,network_fw) %{_unitdir}/multi-user.target.wants/net-config.service
%endif
%license LICENSE
%if 0%{?model_build_feature_wlan_wearable} == 1
-%attr(700,root,root) /usr/system/RestoreDir/softreset/network_softreset.sh
+%attr(700,network_fw,network_fw) /usr/system/RestoreDir/softreset/network_softreset.sh
%endif
%{upgrade_script_path}/500.netconfig_upgrade.sh
mv %{_unitdir}/net-config.service.tv %{_unitdir}/net-config.service
%endif
%files profile_tv
-%attr(644,root,root) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
-%attr(644,root,root) %{_libdir}/systemd/system/net-config.service.tv
+%attr(644,network_fw,network_fw) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+%attr(644,network_fw,network_fw) %{_libdir}/systemd/system/net-config.service.tv
%if "%{?_lib}" == "lib64"
-%attr(644,root,root) %{_unitdir}/net-config.service.tv
+%attr(644,network_fw,network_fw) %{_unitdir}/net-config.service.tv
%endif
%files plugin-headed
%manifest net-config.manifest
-%attr(500,root,root) %{_libdir}/net-config-plugin-headed.so
+%attr(500,network_fw,network_fw) %{_libdir}/net-config-plugin-headed.so
+%attr(644,network_fw,network_fw) /usr/lib/tmpfiles.d/security-network-config.conf
+
+%files plugin-telephony
+%manifest net-config.manifest
+%attr(500,network_fw,network_fw) %{_libdir}/net-config-plugin-telephony.so
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(net-config-plugin-telephony C)
+
+IF(TIZEN_WEARABLE)
+ ADD_DEFINITIONS(-DTIZEN_WEARABLE)
+ENDIF(TIZEN_WEARABLE)
+
+ADD_DEFINITIONS(-DUSE_NETCONFIG_LOG)
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(pkgs_telephony REQUIRED
+ dlog
+ vconf
+ gio-2.0
+ gio-unix-2.0
+ glib-2.0
+ tapi
+ )
+
+FOREACH(flag ${pkgs_telephony_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+# INCLUDE_DIRECTORIES(SRCS include)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(SRCS_TELEPHONY
+ telephony.c
+ )
+
+# library build
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS_TELEPHONY})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_telephony_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME})
+
+# install
+INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${LIBDIR})
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2017 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 <errno.h>
+#include <vconf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <arpa/inet.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <vconf-keys.h>
+#include <ITapiSim.h>
+#include <TapiUtility.h>
+
+#include "plugin.h"
+
+#ifdef USE_NETCONFIG_LOG
+#include "log.h"
+#else
+#include <dlog.h>
+
+#define NETCONFIG_TAG "NETCONFIG"
+#define __LOG(level, format, arg...) \
+ do { \
+ SLOG(level, NETCONFIG_TAG, format, ## arg); \
+ } while (0)
+
+#define DBG(format, arg...) __LOG(LOG_DEBUG, format, ## arg)
+#define ERR(format, arg...) __LOG(LOG_ERROR, format, ## arg)
+#endif
+
+#define TAPI_HANDLE_MAX 2
+
+/* #define SIM_SLOT_DUAL 2 */
+#define SIM_SLOT_SINGLE 1
+
+#define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE "db/telephony/dualsim/default_data_service"
+/*
+#define DEFAULT_DATA_SERVICE_SIM1 0
+#define DEFAULT_DATA_SERVICE_SIM2 1
+*/
+#define SIM_RAND_DATA_LEN 16
+#define SIM_AUTH_MAX_RESP_DATA_LEN 128
+#define SIM_AUTH_SRES_LEN 4
+#define SIM_AUTH_KC_LEN 8
+
+#define AKA_RAND_DATA_LEN 16
+#define AKA_AUTN_DATA_LEN 16
+#define AKA_AUTH_RES_MAX_LEN 16
+#define AKA_AUTH_RES_MIN_LEN 4
+#define AKA_AUTH_CK_LEN 16
+#define AKA_AUTH_IK_LEN 16
+
+static TapiHandle *tapi_handle_dual[TAPI_HANDLE_MAX+1];
+static TapiHandle *tapi_handle = NULL;
+struct wifi_authentication_data **wifi_authdata_p = NULL;
+
+#define wifi_authdata (*wifi_authdata_p)
+
+static int _check_current_sim()
+{
+#if defined TIZEN_WEARABLE
+ return -1;
+#else
+ int current_sim = 0;
+ int sim_slot_count = 0;
+
+ if ((vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT_COUNT, &sim_slot_count) != 0)
+ || sim_slot_count == SIM_SLOT_SINGLE) {
+ ERR("failed to get sim slot count (%d)", sim_slot_count);
+ return -1;
+ }
+
+ if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, ¤t_sim) != 0) {
+ ERR("failed to get default data service = %d\n", current_sim);
+ return 0;
+ }
+
+ DBG("default data service [SIM%d]", current_sim);
+ return current_sim;
+#endif
+}
+
+static TapiHandle * netconfig_tel_init(void)
+{
+ char **cp_list = NULL;
+ int current_sim = _check_current_sim();
+
+ if (current_sim < 0) {
+ if (tapi_handle == NULL) {
+ tapi_handle = tel_init(NULL);
+ if (tapi_handle == NULL)
+ ERR("tel_init() Failed - modem %d", current_sim);
+ }
+ return tapi_handle;
+ } else {
+ if (tapi_handle_dual[current_sim] == NULL) {
+ cp_list = tel_get_cp_name_list();
+ if (!cp_list) {
+ ERR("tel_get_cp_name_list() Failed");
+ return NULL;
+ }
+
+ tapi_handle_dual[current_sim] = tel_init(cp_list[current_sim]);
+ if (tapi_handle_dual[current_sim] == NULL)
+ ERR("tel_init() Failed - modem %d", current_sim);
+
+ g_strfreev(cp_list);
+ }
+ return tapi_handle_dual[current_sim];
+ }
+}
+
+static void netconfig_tel_deinit(void)
+{
+ int current_sim = _check_current_sim();
+
+ if (current_sim < 0) {
+ if (tapi_handle)
+ tel_deinit(tapi_handle);
+
+ tapi_handle = NULL;
+ } else {
+ unsigned int i = 0;
+ while (tapi_handle_dual[i]) {
+ tel_deinit(tapi_handle_dual[i]);
+ tapi_handle_dual[i] = NULL;
+ i++;
+ }
+ }
+}
+
+void telephony_get_network_type(int *svctype, int *pstype)
+{
+ TapiHandle *tapi_handle = NULL;
+ int telephony_svctype = 0, telephony_pstype = 0;
+
+ tapi_handle = (TapiHandle *)netconfig_tel_init();
+
+ if (NULL != tapi_handle) {
+ tel_get_property_int(tapi_handle,
+ TAPI_PROP_NETWORK_SERVICE_TYPE,
+ &telephony_svctype);
+ tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_PS_TYPE,
+ &telephony_pstype);
+ netconfig_tel_deinit();
+ }
+
+ *svctype = telephony_svctype;
+ *pstype = telephony_pstype;
+}
+
+gboolean telephony_wifi_get_sim_imsi(void *wifi, GDBusMethodInvocation *context)
+{
+ int ret;
+ TapiHandle *handle;
+ TelSimImsiInfo_t imsi_info;
+ char *imsi;
+
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ ERR("tapi_init failed");
+ netconfig_error_fail_get_imsi(context);
+ return FALSE;
+ }
+
+ ERR("before tel_get_sim_imsi");
+ ret = tel_get_sim_imsi(handle, &imsi_info);
+ ERR("after tel_get_sim_imsi");
+ if (ret != TAPI_API_SUCCESS) {
+ ERR("Failed tel_get_sim_imsi() : [%d]", ret);
+ netconfig_error_fail_get_imsi(context);
+ return FALSE;
+ }
+
+ imsi = g_strdup_printf("%s%s%s", imsi_info.szMcc,
+ imsi_info.szMnc, imsi_info.szMsin);
+
+ netconfig_complete_get_sim_imsi(wifi, context, imsi);
+ g_free(imsi);
+
+ return TRUE;
+}
+
+static void *__telephony_wifi_free_wifi_authdata(
+ struct wifi_authentication_data *data)
+{
+ if (data != NULL) {
+ if (data->resp_data)
+ g_free(data->resp_data);
+ if (data->authentication_key)
+ g_free(data->authentication_key);
+ if (data->cipher_data)
+ g_free(data->cipher_data);
+ if (data->integrity_data)
+ g_free(data->integrity_data);
+
+ g_free(data);
+ data = NULL;
+ }
+
+ return NULL;
+}
+
+static void __telephony_response_aka_authentication(TapiHandle *handle,
+ int result, void *data, void *user_data)
+{
+ if (wifi_authdata != NULL)
+ wifi_authdata = __telephony_wifi_free_wifi_authdata(wifi_authdata);
+
+ wifi_authdata = g_try_new0(struct wifi_authentication_data, 1);
+
+ if (wifi_authdata == NULL) {
+ ERR("Out of Memory!");
+ return;
+ }
+
+ TelSimAuthenticationResponse_t *auth_resp =
+ (TelSimAuthenticationResponse_t *) data;
+ if (auth_resp == NULL) {
+ ERR("the auth response is NULL");
+
+ wifi_authdata->auth_result = -1;
+ return;
+ } else
+ wifi_authdata->auth_result = auth_resp->auth_result;
+
+ if (auth_resp->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
+ wifi_authdata->resp_length = auth_resp->resp_length;
+ wifi_authdata->cipher_length = auth_resp->cipher_length;
+ wifi_authdata->integrity_length = auth_resp->integrity_length;
+
+ if (wifi_authdata->resp_data != NULL)
+ g_free(wifi_authdata->resp_data);
+
+ wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
+
+ if (wifi_authdata->cipher_data != NULL)
+ g_free(wifi_authdata->cipher_data);
+
+ wifi_authdata->cipher_data = g_strdup(auth_resp->cipher_data);
+
+ if (wifi_authdata->integrity_data != NULL)
+ g_free(wifi_authdata->integrity_data);
+
+ wifi_authdata->integrity_data = g_strdup(auth_resp->integrity_data);
+ } else {
+ ERR("the result error for aka auth : [%d]", auth_resp->auth_result);
+
+ if (auth_resp->auth_result == TAPI_SIM_AUTH_SQN_FAILURE ||
+ auth_resp->auth_result == TAPI_SIM_AUTH_SYNCH_FAILURE) {
+ wifi_authdata->resp_length = auth_resp->resp_length;
+
+ if (wifi_authdata->resp_data != NULL)
+ g_free(wifi_authdata->resp_data);
+
+ wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
+ }
+ }
+}
+
+netconfig_error_e telephony_wifi_req_aka_auth(GArray *rand_data, GArray *autn_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ int i;
+ int ret;
+ TapiHandle *handle;
+ TelSimAuthenticationData_t auth_data;
+
+ if (!wifi_authdata_p)
+ wifi_authdata_p = data;
+
+ if (rand_data == NULL || autn_data == NULL)
+ return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH;
+
+ if (rand_data->len != AKA_RAND_DATA_LEN) {
+ ERR("wrong rand data len : [%d]", rand_data->len);
+
+ return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
+ }
+
+ if (autn_data->len != AKA_AUTN_DATA_LEN) {
+ ERR("wrong autn data len : [%d]", autn_data->len);
+
+ return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
+ }
+
+ if ((ret = g_array_get_element_size(rand_data)) != 1) {
+ ERR("wrong rand data size : [%d]", ret);
+
+ return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
+ }
+
+ if ((ret = g_array_get_element_size(autn_data)) != 1) {
+ ERR("wrong autn data size : [%d]", ret);
+
+ return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
+ }
+
+ memset(&auth_data, 0, sizeof(auth_data));
+
+ auth_data.auth_type = TAPI_SIM_AUTH_TYPE_3G;
+ auth_data.rand_length = AKA_RAND_DATA_LEN;
+ auth_data.autn_length = AKA_AUTN_DATA_LEN;
+
+ for (i = 0; i < rand_data->len; i++)
+ auth_data.rand_data[i] = g_array_index(rand_data, guint8, i);
+
+ for (i = 0; i < autn_data->len; i++)
+ auth_data.autn_data[i] = g_array_index(autn_data, guint8, i);
+
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL)
+ return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH;
+
+ ret = tel_req_sim_authentication(handle, &auth_data,
+ __telephony_response_aka_authentication, NULL);
+
+ if (ret != TAPI_API_SUCCESS) {
+ ERR("Failed tel_req_sim_authentication() : [%d]", ret);
+
+ return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH;
+ }
+ return NETCONFIG_NO_ERROR;
+}
+
+static void telephony_response_sim_authentication(TapiHandle *handle,
+ int result, void *data, void *user_data)
+{
+ if (wifi_authdata != NULL)
+ wifi_authdata = __telephony_wifi_free_wifi_authdata(wifi_authdata);
+
+ wifi_authdata = g_try_new0(struct wifi_authentication_data, 1);
+
+ if (wifi_authdata == NULL) {
+ ERR("Out of Memory!");
+ return;
+ }
+
+ TelSimAuthenticationResponse_t *auth_resp =
+ (TelSimAuthenticationResponse_t *) data;
+ if (auth_resp == NULL) {
+ ERR("the auth response is NULL");
+
+ wifi_authdata->auth_result = -1;
+ return;
+ } else
+ wifi_authdata->auth_result = auth_resp->auth_result;
+
+ if (auth_resp->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
+ wifi_authdata->resp_length = auth_resp->resp_length;
+ wifi_authdata->authentication_key_length =
+ auth_resp->authentication_key_length;
+
+ if (wifi_authdata->resp_data != NULL)
+ g_free(wifi_authdata->resp_data);
+
+ wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
+
+ if (wifi_authdata->authentication_key != NULL)
+ g_free(wifi_authdata->authentication_key);
+
+ wifi_authdata->authentication_key = g_strdup(auth_resp->authentication_key);
+ } else {
+ ERR("the result error for sim auth : [%d]", auth_resp->auth_result);
+
+ wifi_authdata->resp_length = 0;
+ wifi_authdata->authentication_key_length = 0;
+ }
+}
+
+gboolean telephony_wifi_req_sim_auth(GArray *rand_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ int i;
+ int ret;
+ TapiHandle *handle;
+ TelSimAuthenticationData_t auth_data;
+
+ if (!wifi_authdata_p)
+ wifi_authdata_p = data;
+
+ if (rand_data == NULL)
+ return FALSE;
+
+ if (rand_data->len != SIM_RAND_DATA_LEN) {
+ ERR("wrong rand data len : [%d]", rand_data->len);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
+ return FALSE;
+ }
+
+ if ((ret = g_array_get_element_size(rand_data)) != 1) {
+ ERR("wrong rand data size : [%d]", ret);
+
+ netconfig_error_fail_req_sim_auth_wrong_param(context);
+ return FALSE;
+ }
+
+ memset(&auth_data, 0, sizeof(auth_data));
+
+ auth_data.auth_type = TAPI_SIM_AUTH_TYPE_GSM;
+ auth_data.rand_length = SIM_RAND_DATA_LEN;
+
+ for (i = 0; i < rand_data->len; i++)
+ auth_data.rand_data[i] = g_array_index(rand_data, guint8, i);
+
+ handle = (TapiHandle *)netconfig_tel_init();
+ if (handle == NULL) {
+ netconfig_error_fail_req_sim_auth(context);
+ return FALSE;
+ }
+
+ ret = tel_req_sim_authentication(handle,
+ &auth_data, telephony_response_sim_authentication, NULL);
+ if (ret != TAPI_API_SUCCESS) {
+ ERR("Failed tel_req_sim_authentication() : [%d]", ret);
+
+ netconfig_error_fail_req_sim_auth(context);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void telephony_noti_sim_status_cb(TapiHandle *handle, const char *noti_id,
+ void *data, void *user_data)
+{
+ TelSimCardStatus_t *status = data;
+
+ if (*status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+ DBG("Turn Wi-Fi on automatically");
+
+ netconfig_wifi_power_on();
+ netconfig_tel_deinit();
+ }
+}
+
+gboolean telephony_tapi_check_sim_state(void)
+{
+ int ret, card_changed;
+ TelSimCardStatus_t status = TAPI_SIM_STATUS_UNKNOWN;
+ TapiHandle *tapi_handle = NULL;
+
+ tapi_handle = (TapiHandle *)netconfig_tel_init();
+ if (tapi_handle == NULL) {
+ ERR("Failed to tapi init");
+ return FALSE;
+ }
+
+ ret = tel_get_sim_init_info(tapi_handle, &status, &card_changed);
+ if (ret != TAPI_API_SUCCESS) {
+ ERR("tel_get_sim_init_info() Failed : [%d]", ret);
+ netconfig_tel_deinit();
+ return FALSE;
+ }
+
+ switch (status) {
+ case TAPI_SIM_STATUS_UNKNOWN:
+ case TAPI_SIM_STATUS_CARD_ERROR:
+ case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
+ case TAPI_SIM_STATUS_CARD_BLOCKED:
+ case TAPI_SIM_STATUS_SIM_INIT_COMPLETED:
+ break;
+ case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_INITIALIZING:
+ case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
+ case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
+ tel_register_noti_event(tapi_handle, TAPI_NOTI_SIM_STATUS,
+ telephony_noti_sim_status_cb, NULL);
+ return FALSE;
+ default:
+ ERR("not defined status(%d)", status);
+ break;
+ }
+
+ netconfig_tel_deinit();
+
+ return TRUE;
+}
+
+static void __telephony_wifi_clean_authentication(void)
+{
+ netconfig_tel_deinit();
+
+ wifi_authdata = __telephony_wifi_free_wifi_authdata(wifi_authdata);
+}
+
+gboolean telephony_wifi_get_aka_authdata(void *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ GArray *array = NULL;
+ guchar res_len;
+
+ if (!wifi_authdata_p)
+ wifi_authdata_p = data;
+
+ if (wifi_authdata == NULL) {
+ DBG("the status error : no response yet");
+ netconfig_error_fail_get_sim_auth_delay(context);
+ return FALSE;
+ }
+
+ switch (wifi_authdata->auth_result) {
+ case TAPI_SIM_AUTH_NO_ERROR:
+ break;
+
+ case TAPI_SIM_AUTH_SQN_FAILURE:
+ case TAPI_SIM_AUTH_SYNCH_FAILURE:
+ array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ wifi_authdata->resp_length+1);
+ res_len = (guchar)((wifi_authdata->resp_length-1) & 0xff);
+
+ g_array_append_vals(array, &res_len, 1);
+ g_array_append_vals(array, wifi_authdata->resp_data,
+ wifi_authdata->resp_length);
+
+ netconfig_complete_get_aka_auth(wifi, context, array);
+ g_array_free(array, TRUE);
+
+ __telephony_wifi_clean_authentication();
+
+ return TRUE;
+
+ default:
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __telephony_wifi_clean_authentication();
+ return FALSE;
+ }
+
+ if ((wifi_authdata->resp_length >= AKA_AUTH_RES_MIN_LEN ||
+ wifi_authdata->resp_length <= AKA_AUTH_RES_MAX_LEN) &&
+ wifi_authdata->cipher_length == AKA_AUTH_CK_LEN &&
+ wifi_authdata->integrity_length == AKA_AUTH_IK_LEN) {
+ array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ wifi_authdata->resp_length+AKA_AUTH_CK_LEN+AKA_AUTH_IK_LEN+1);
+
+ res_len = (guchar)((wifi_authdata->resp_length-1) & 0xff);
+ g_array_append_vals(array, &res_len, 1);
+ g_array_append_vals(array, wifi_authdata->resp_data,
+ wifi_authdata->resp_length);
+ g_array_append_vals(array, wifi_authdata->cipher_data,
+ AKA_AUTH_CK_LEN);
+ g_array_append_vals(array, wifi_authdata->integrity_data,
+ AKA_AUTH_IK_LEN);
+ } else {
+ ERR("auth data length is wrong, res = [%d], Kc = [%d], Ki = [%d]",
+ wifi_authdata->resp_length, wifi_authdata->cipher_length,
+ wifi_authdata->integrity_length);
+
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __telephony_wifi_clean_authentication();
+ return FALSE;
+ }
+
+ netconfig_complete_get_aka_auth(wifi, context, array);
+ g_array_free(array, TRUE);
+ __telephony_wifi_clean_authentication();
+
+ return TRUE;
+}
+
+gboolean telephony_wifi_get_sim_authdata(void *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ GArray *array = NULL;
+
+ if (!wifi_authdata_p)
+ wifi_authdata_p = data;
+
+ if (wifi_authdata == NULL) {
+ DBG("the status error : no response yet");
+ netconfig_error_fail_get_sim_auth_delay(context);
+ return FALSE;
+ }
+
+ if (wifi_authdata->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
+ if (wifi_authdata->resp_length == SIM_AUTH_SRES_LEN &&
+ wifi_authdata->authentication_key_length == SIM_AUTH_KC_LEN) {
+ array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
+ SIM_AUTH_SRES_LEN+SIM_AUTH_KC_LEN);
+ g_array_append_vals(array, wifi_authdata->resp_data,
+ SIM_AUTH_SRES_LEN);
+ g_array_append_vals(array, wifi_authdata->authentication_key,
+ SIM_AUTH_KC_LEN);
+ } else {
+ ERR("auth data length is wrong, SRES = [%d], Kc = [%d]",
+ wifi_authdata->resp_length,
+ wifi_authdata->authentication_key_length);
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __telephony_wifi_clean_authentication();
+ return FALSE;
+ }
+ } else {
+ ERR("failed auth result = [%d]", wifi_authdata->auth_result);
+ netconfig_error_fail_get_sim_auth_wrong_data(context);
+ __telephony_wifi_clean_authentication();
+ return FALSE;
+ }
+
+ netconfig_complete_get_sim_auth(wifi, context, array);
+ g_array_free(array, TRUE);
+ __telephony_wifi_clean_authentication();
+ return TRUE;
+}
+
+
+extern struct netconfig_telephony_plugin_t netconfig_telephony_plugin
+ __attribute__ ((visibility("default")));
+struct netconfig_telephony_plugin_t netconfig_telephony_plugin = {
+ telephony_get_network_type,
+ telephony_wifi_get_sim_imsi,
+ telephony_wifi_req_aka_auth,
+ telephony_wifi_req_sim_auth,
+ telephony_tapi_check_sim_state,
+ telephony_wifi_get_aka_authdata,
+ telephony_wifi_get_sim_authdata
+};
+
<allow own="net.netconfig"/>
<allow send_destination="net.netconfig"/>
</policy>
+ <policy user="network_fw">
+ <allow own="net.netconfig"/>
+ <allow send_destination="net.netconfig"/>
+ </policy>
<policy context="default">
<check send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="AddRoute" privilege="http://tizen.org/privilege/network.set" />
<check send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="RemoveRoute" privilege="http://tizen.org/privilege/network.set" />
[Service]
Type=forking
+User=network_fw
+Group=network_fw
SmackProcessLabel=System
-ExecStart=/usr/sbin/net-config
+ExecStart=/usr/bin/net-config
Restart=on-failure
-CapabilityBoundingSet=~CAP_MAC_ADMIN
-CapabilityBoundingSet=~CAP_MAC_OVERRIDE
+Capabilities=cap_net_admin,cap_net_raw=i
+SecureBits=keep-caps
[Install]
WantedBy=multi-user.target
[Service]
Type=dbus
+User=network_fw
+Group=network_fw
BusName=net.netconfig
RemainAfterExit=yes
-ExecStartPre=-/usr/sbin/net-config.service
-ExecStart=/usr/sbin/net-config
-CapabilityBoundingSet=~CAP_MAC_ADMIN
-CapabilityBoundingSet=~CAP_MAC_OVERRIDE
+ExecStartPre=-/usr/bin/net-config.service
+ExecStart=/usr/bin/net-config
+Capabilities=cap_net_admin,cap_net_raw=i
+SecureBits=keep-caps
[Install]
WantedBy=multi-user.target
[D-BUS Service]
Name=net.netconfig
-Exec=/usr/sbin/net-config
-User=root
+Exec=/usr/bin/net-config
+User=network_fw
+Group=network_fw
Name=net.netconfig
Exec=/bin/false
SystemdService=net-config.service
-User=root
+User=network_fw
+Group=network_fw
NETCONFIG_ERROR_INTERFACE ".WifiDirectFailed");
}
-void netconfig_error_fail_get_imsi(GDBusMethodInvocation *context)
+EXPORT_SYM void netconfig_error_fail_get_imsi(GDBusMethodInvocation *context)
{
ERR("dbus method return error");
g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_INTERFACE".FailGetSimImsi");
}
-void netconfig_error_fail_req_sim_auth(GDBusMethodInvocation *context)
+EXPORT_SYM void netconfig_error_fail_req_sim_auth(GDBusMethodInvocation *context)
{
ERR("dbus method return error");
g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_INTERFACE".FailReqSimAuth");
}
-void netconfig_error_fail_req_sim_auth_wrong_param(GDBusMethodInvocation *context)
+EXPORT_SYM void netconfig_error_fail_req_sim_auth_wrong_param(GDBusMethodInvocation *context)
{
ERR("dbus method return error");
g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_INTERFACE".FailReqSimAuthWrongParam");
}
-void netconfig_error_fail_get_sim_auth_wrong_data(GDBusMethodInvocation *context)
+EXPORT_SYM void netconfig_error_fail_get_sim_auth_wrong_data(GDBusMethodInvocation *context)
{
ERR("dbus method return error");
g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
NETCONFIG_ERROR_INTERFACE".FailGetSimAuthWrongData");
}
-void netconfig_error_fail_get_sim_auth_delay(GDBusMethodInvocation *context)
+EXPORT_SYM void netconfig_error_fail_get_sim_auth_delay(GDBusMethodInvocation *context)
{
ERR("dbus method return error");
g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
-#include <ITapiSim.h>
-#include <TapiUtility.h>
#include "log.h"
#include "util.h"
#include "network-dpm.h"
#include "network-monitor.h"
#include "netsupplicant.h"
-#include "wifi-tel-intf.h"
#include "generated-code.h"
/* Define TCP buffer sizes for various networks */
rmax_size = NET_TCP_BUFFERSIZE_WIFI_RMEM_MAX;
wmax_size = NET_TCP_BUFFERSIZE_WIFI_WMEM_MAX;
} else if (netconfig_is_cellular_profile(profile) == TRUE) {
- TapiHandle *tapi_handle = NULL;
int telephony_svctype = 0, telephony_pstype = 0;
- tapi_handle = (TapiHandle *)netconfig_tel_init();
- if (NULL != tapi_handle) {
- tel_get_property_int(tapi_handle,
- TAPI_PROP_NETWORK_SERVICE_TYPE,
- &telephony_svctype);
- tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_PS_TYPE,
- &telephony_pstype);
- netconfig_tel_deinit();
- }
-
+ netconfig_get_telephony_network_type(&telephony_svctype, &telephony_pstype);
DBG("Default cellular %d, %d", telephony_svctype, telephony_pstype);
switch (telephony_pstype) {
/* default profile is NULL and new connected profile is NULL */
if (!profile) {
- profile = __netconfig_get_default_profile();
+ char *tmp_profile = __netconfig_get_default_profile();
- if (profile && netconfig_is_cellular_profile(profile) &&
- !netconfig_is_cellular_internet_profile(profile)) {
+ if (tmp_profile && netconfig_is_cellular_profile(tmp_profile) &&
+ !netconfig_is_cellular_internet_profile(tmp_profile)) {
DBG("not a default cellular profile");
- profile = NULL;
+ g_free(tmp_profile);
+ tmp_profile = NULL;
}
- if (!profile) {
+ if (!tmp_profile) {
__netconfig_update_default_connection_info();
return;
}
+
+ netconfig_default_connection_info.profile = g_strdup(tmp_profile);
+ __netconfig_get_default_connection_info(tmp_profile);
+ __netconfig_update_default_connection_info();
+ g_free(tmp_profile);
+ return;
}
netconfig_default_connection_info.profile = g_strdup(profile);
__netconfig_get_default_connection_info(profile);
__netconfig_update_default_connection_info();
-
}
void netconfig_update_default(void)
while (g_variant_iter_loop(next, "{sv}", &key1, &variant)) {
if (g_strcmp0(key1, "Interface") == 0) {
value = g_variant_get_string(variant, NULL);
- if (ifname)
- g_free(ifname);
ifname = g_strdup(value);
+ g_free(key1);
+ g_variant_unref(variant);
+ break;
}
}
}
g_variant_iter_init(&iter, dictionary);
while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
if (g_strcmp0(key, "Address") == 0) {
- value = g_variant_get_string(var, NULL);
+ g_variant_get(var, "&s", &value);
char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
DBG("Old IPv4.Address [%s] Received new IPv4.Address [%s]", old_ip, value);
g_variant_iter_init(&iter, dictionary);
while (g_variant_iter_loop(&iter, "{sv}", &key, &var)) {
if (g_strcmp0(key, "Address") == 0) {
- value = g_variant_get_string(var, NULL);
+ g_variant_get(var, "&s", &value);
char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6);
DBG("Old IPv6.Address [%s] Received new IPv6.Address [%s]", old_ip6, value);
#include <tzplatform_config.h>
#include "log.h"
+#include "neterror.h"
-#define LOG_FILE_PATH "/var/log/netconfig.log"
+#define LOG_FILE_PATH "/opt/usr/data/network/netconfig.log"
#define MAX_LOG_SIZE 1 * 1024 * 1024
#define MAX_LOG_COUNT 1
strftime(strtime, size, "%m/%d %H:%M:%S", local_ptm);
}
-void netconfig_log(const char *format, ...)
+EXPORT_SYM void netconfig_log(const char *format, ...)
{
va_list ap;
int log_size = 0;
va_end(ap);
}
-void log_cleanup(void)
+EXPORT_SYM void log_cleanup(void)
{
if (log_file == NULL)
return;
#define MAC_ADDRESS_FILEPATH "/sys/class/net/wlan0/address"
#define MAC_ADDRESS_MAX_LEN 18
#define HEADED_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-headed.so"
+#define TELEPHONY_PLUGIN_FILEPATH "/usr/lib/net-config-plugin-telephony.so"
static gboolean netconfig_device_picker_test = FALSE;
static int mdnsd_ref_count = 0;
} dnssd_conn_destroy_data;
static gboolean netconfig_plugin_headed_enabled = FALSE;
+static gboolean netconfig_plugin_telephony_enabled = FALSE;
static void *handle_headed;
+static void *handle_telephony;
static struct netconfig_headed_plugin_t *headed_plugin;
+static struct netconfig_telephony_plugin_t *telephony_plugin;
GKeyFile *netconfig_keyfile_load(const char *pathname)
{
}
data = g_try_malloc0(sizeof(dnssd_conn_destroy_data));
+
+ if (data == NULL) {
+ ERR("Out of Memory!");
+ return;
+ }
+
data->conn_name = g_strdup(name);
data->conn_id = g_dbus_connection_signal_subscribe(connection,
headed_plugin->pop_wifi_connected_poppup(ssid);
}
+void netconfig_get_telephony_network_type(int *svctype, int *pstype)
+{
+ if (!netconfig_plugin_telephony_enabled)
+ return;
+
+ if (!telephony_plugin)
+ return;
+
+ telephony_plugin->get_telephony_network_type(svctype, pstype);
+}
+
+gboolean __netconfig_wifi_get_sim_imsi(Wifi *wifi, GDBusMethodInvocation *context)
+{
+ if (!netconfig_plugin_telephony_enabled)
+ return FALSE;
+
+ if (!telephony_plugin)
+ return FALSE;
+
+ return telephony_plugin->wifi_get_sim_imsi(wifi, context);
+}
+
+netconfig_error_e __netconfig_wifi_req_aka_auth(GArray *rand_data, GArray *autn_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ if (!netconfig_plugin_telephony_enabled)
+ return NETCONFIG_ERROR_INTERNAL;
+
+ if (!telephony_plugin)
+ return NETCONFIG_ERROR_INTERNAL;
+
+ return telephony_plugin->wifi_req_aka_auth(rand_data, autn_data, context, data);
+}
+
+gboolean __netconfig_wifi_req_sim_auth(GArray *rand_data,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ if (!netconfig_plugin_telephony_enabled)
+ return FALSE;
+
+ if (!telephony_plugin)
+ return FALSE;
+
+ return telephony_plugin->wifi_req_sim_auth(rand_data, context, data);
+}
+
+gboolean netconfig_tapi_check_sim_state(void)
+{
+ if (!netconfig_plugin_telephony_enabled)
+ return FALSE;
+
+ if (!telephony_plugin)
+ return FALSE;
+
+ return telephony_plugin->tapi_check_sim_state();
+}
+
+gboolean __netconfig_wifi_get_aka_authdata(Wifi *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ if (!netconfig_plugin_telephony_enabled)
+ return FALSE;
+
+ if (!telephony_plugin)
+ return FALSE;
+
+ return telephony_plugin->wifi_get_aka_authdata(wifi, context, data);
+}
+
+gboolean __netconfig_wifi_get_sim_authdata(Wifi *wifi,
+ GDBusMethodInvocation *context, struct wifi_authentication_data **data)
+{
+ if (!netconfig_plugin_telephony_enabled)
+ return FALSE;
+
+ if (!telephony_plugin)
+ return FALSE;
+
+ return telephony_plugin->wifi_get_sim_authdata(wifi, context, data);
+}
+
void netconfig_set_vconf_int(const char * key, int value)
{
int ret = 0;
handle_headed = dlopen(HEADED_PLUGIN_FILEPATH, RTLD_NOW);
if (!handle_headed) {
ERR("Can't load %s: %s", HEADED_PLUGIN_FILEPATH, dlerror());
- return;
+ } else {
+ headed_plugin = dlsym(handle_headed, "netconfig_headed_plugin");
+ if (!headed_plugin) {
+ ERR("Can't load symbol: %s", dlerror());
+ dlclose(handle_headed);
+ } else {
+ netconfig_plugin_headed_enabled = TRUE;
+ }
}
- headed_plugin = dlsym(handle_headed, "netconfig_headed_plugin");
- if (!headed_plugin) {
- ERR("Can't load symbol: %s", dlerror());
- dlclose(handle_headed);
- return;
+ handle_telephony = dlopen(TELEPHONY_PLUGIN_FILEPATH, RTLD_NOW);
+ if (!handle_telephony) {
+ ERR("Can't load %s: %s", TELEPHONY_PLUGIN_FILEPATH, dlerror());
+ } else {
+ telephony_plugin = dlsym(handle_telephony, "netconfig_telephony_plugin");
+ if (!telephony_plugin) {
+ ERR("Can't load symbol: %s", dlerror());
+ dlclose(handle_telephony);
+ } else {
+ netconfig_plugin_telephony_enabled = TRUE;
+ }
}
-
- netconfig_plugin_headed_enabled = TRUE;
}
void netconfig_plugin_deinit()
{
- if (!netconfig_plugin_headed_enabled)
- return;
+ if (netconfig_plugin_headed_enabled) {
+ netconfig_plugin_headed_enabled = FALSE;
+ dlclose(handle_headed);
+ }
- netconfig_plugin_headed_enabled = FALSE;
- dlclose(handle_headed);
+ if (netconfig_plugin_telephony_enabled) {
+ netconfig_plugin_telephony_enabled = FALSE;
+ dlclose(handle_telephony);
+ }
}
gboolean netconfig_get_headed_plugin_flag()
return netconfig_plugin_headed_enabled;
}
+gboolean netconfig_get_telephony_plugin_flag()
+{
+ return netconfig_plugin_telephony_enabled;
+}
+
#include "util.h"
#include "netdbus.h"
#include "neterror.h"
-#include "wifi-tel-intf.h"
#include "network-state.h"
#include "wifi-eap.h"
+#include "wifi-power.h"
-#define SIM_RAND_DATA_LEN 16
-#define SIM_AUTH_MAX_RESP_DATA_LEN 128
-#define SIM_AUTH_SRES_LEN 4
-#define SIM_AUTH_KC_LEN 8
-
-#define AKA_RAND_DATA_LEN 16
-#define AKA_AUTN_DATA_LEN 16
-#define AKA_AUTH_RES_MAX_LEN 16
-#define AKA_AUTH_RES_MIN_LEN 4
-#define AKA_AUTH_CK_LEN 16
-#define AKA_AUTH_IK_LEN 16
-
-struct wifii_authentication_data {
- int auth_result;
- int resp_length;
- int authentication_key_length;
- int cipher_length;
- int integrity_length;
- char *resp_data;
- char *authentication_key;
- char *cipher_data;
- char *integrity_data;
-};
-
-static struct wifii_authentication_data *wifi_authdata;
-
-static void *__netconfig_wifi_free_wifi_authdata(
- struct wifii_authentication_data *data)
-{
- if (data != NULL) {
- if (data->resp_data)
- g_free(data->resp_data);
- if (data->authentication_key)
- g_free(data->authentication_key);
- if (data->cipher_data)
- g_free(data->cipher_data);
- if (data->integrity_data)
- g_free(data->integrity_data);
-
- g_free(data);
- data = NULL;
- }
-
- return NULL;
-}
-
-static void __netconfig_wifi_clean_authentication(void)
-{
- netconfig_tel_deinit();
-
- wifi_authdata = __netconfig_wifi_free_wifi_authdata(wifi_authdata);
-}
-
-static gboolean __netconfig_wifi_get_sim_imsi(Wifi *wifi,
- GDBusMethodInvocation *context)
-{
- int ret;
- TapiHandle *handle;
- TelSimImsiInfo_t imsi_info;
- char *imsi;
-
- handle = (TapiHandle *)netconfig_tel_init();
- if (handle == NULL) {
- ERR("tapi_init failed");
- netconfig_error_fail_get_imsi(context);
- return FALSE;
- }
-
- ERR("before tel_get_sim_imsi");
- ret = tel_get_sim_imsi(handle, &imsi_info);
- ERR("after tel_get_sim_imsi");
- if (ret != TAPI_API_SUCCESS) {
- ERR("Failed tel_get_sim_imsi() : [%d]", ret);
- netconfig_error_fail_get_imsi(context);
- return FALSE;
- }
-
- imsi = g_strdup_printf("%s%s%s", imsi_info.szMcc,
- imsi_info.szMnc, imsi_info.szMsin);
-
- wifi_complete_get_sim_imsi(wifi, context, imsi);
- g_free(imsi);
-
- return TRUE;
-}
-
-void __netconfig_response_sim_authentication(TapiHandle *handle,
- int result, void *data, void *user_data)
-{
- if (wifi_authdata != NULL)
- wifi_authdata = __netconfig_wifi_free_wifi_authdata(wifi_authdata);
-
- wifi_authdata = g_try_new0(struct wifii_authentication_data, 1);
-
- TelSimAuthenticationResponse_t *auth_resp =
- (TelSimAuthenticationResponse_t *) data;
- if (auth_resp == NULL) {
- ERR("the auth response is NULL");
-
- wifi_authdata->auth_result = -1;
- return;
- } else
- wifi_authdata->auth_result = auth_resp->auth_result;
-
- if (auth_resp->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
- wifi_authdata->resp_length = auth_resp->resp_length;
- wifi_authdata->authentication_key_length =
- auth_resp->authentication_key_length;
-
- if (wifi_authdata->resp_data != NULL)
- g_free(wifi_authdata->resp_data);
-
- wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
-
- if (wifi_authdata->authentication_key != NULL)
- g_free(wifi_authdata->authentication_key);
-
- wifi_authdata->authentication_key =
- g_strdup(auth_resp->authentication_key);
- } else {
- ERR("the result error for sim auth : [%d]", auth_resp->auth_result);
-
- wifi_authdata->resp_length = 0;
- wifi_authdata->authentication_key_length = 0;
- }
-}
-
-void __netconfig_response_aka_authentication(TapiHandle *handle,
- int result, void *data, void *user_data)
-{
- if (wifi_authdata != NULL)
- wifi_authdata = __netconfig_wifi_free_wifi_authdata(wifi_authdata);
-
- wifi_authdata = g_try_new0(struct wifii_authentication_data, 1);
-
- TelSimAuthenticationResponse_t *auth_resp =
- (TelSimAuthenticationResponse_t *) data;
- if (auth_resp == NULL) {
- ERR("the auth response is NULL");
-
- wifi_authdata->auth_result = -1;
- return;
- } else
- wifi_authdata->auth_result = auth_resp->auth_result;
-
- if (auth_resp->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
- wifi_authdata->resp_length = auth_resp->resp_length;
- wifi_authdata->cipher_length = auth_resp->cipher_length;
- wifi_authdata->integrity_length = auth_resp->integrity_length;
-
- if (wifi_authdata->resp_data != NULL)
- g_free(wifi_authdata->resp_data);
-
- wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
-
- if (wifi_authdata->cipher_data != NULL)
- g_free(wifi_authdata->cipher_data);
-
- wifi_authdata->cipher_data = g_strdup(auth_resp->cipher_data);
-
- if (wifi_authdata->integrity_data != NULL)
- g_free(wifi_authdata->integrity_data);
-
- wifi_authdata->integrity_data = g_strdup(auth_resp->integrity_data);
- } else {
- ERR("the result error for aka auth : [%d]", auth_resp->auth_result);
-
- if (auth_resp->auth_result == TAPI_SIM_AUTH_SQN_FAILURE ||
- auth_resp->auth_result == TAPI_SIM_AUTH_SYNCH_FAILURE) {
- wifi_authdata->resp_length = auth_resp->resp_length;
-
- if (wifi_authdata->resp_data != NULL)
- g_free(wifi_authdata->resp_data);
-
- wifi_authdata->resp_data = g_strdup(auth_resp->resp_data);
- }
- }
-}
-
-static gboolean __netconfig_wifi_req_sim_auth(GArray *rand_data,
- GDBusMethodInvocation *context)
-{
- int i;
- int ret;
- TapiHandle *handle;
- TelSimAuthenticationData_t auth_data;
-
- if (rand_data == NULL)
- return FALSE;
-
- if (rand_data->len != SIM_RAND_DATA_LEN) {
- ERR("wrong rand data len : [%d]", rand_data->len);
-
- netconfig_error_fail_req_sim_auth_wrong_param(context);
- return FALSE;
- }
-
- if ((ret = g_array_get_element_size(rand_data)) != 1) {
- ERR("wrong rand data size : [%d]", ret);
-
- netconfig_error_fail_req_sim_auth_wrong_param(context);
- return FALSE;
- }
-
- memset(&auth_data, 0, sizeof(auth_data));
-
- auth_data.auth_type = TAPI_SIM_AUTH_TYPE_GSM;
- auth_data.rand_length = SIM_RAND_DATA_LEN;
-
- for (i = 0; i < rand_data->len; i++)
- auth_data.rand_data[i] = g_array_index(rand_data, guint8, i);
-
- handle = (TapiHandle *)netconfig_tel_init();
- if (handle == NULL) {
- netconfig_error_fail_req_sim_auth(context);
- return FALSE;
- }
-
- ret = tel_req_sim_authentication(handle,
- &auth_data, __netconfig_response_sim_authentication, NULL);
- if (ret != TAPI_API_SUCCESS) {
- ERR("Failed tel_req_sim_authentication() : [%d]", ret);
-
- netconfig_error_fail_req_sim_auth(context);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static netconfig_error_e __netconfig_wifi_req_aka_auth(
- GArray *rand_data, GArray *autn_data, GDBusMethodInvocation *context)
-{
- int i;
- int ret;
- TapiHandle *handle;
- TelSimAuthenticationData_t auth_data;
-
- if (rand_data == NULL || autn_data == NULL)
- return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH;
-
- if (rand_data->len != AKA_RAND_DATA_LEN) {
- ERR("wrong rand data len : [%d]", rand_data->len);
-
- return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
- }
-
- if (autn_data->len != AKA_AUTN_DATA_LEN) {
- ERR("wrong autn data len : [%d]", autn_data->len);
-
- return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
- }
-
- if ((ret = g_array_get_element_size(rand_data)) != 1) {
- ERR("wrong rand data size : [%d]", ret);
-
- return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
- }
-
- if ((ret = g_array_get_element_size(autn_data)) != 1) {
- ERR("wrong autn data size : [%d]", ret);
-
- return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM;
- }
-
- memset(&auth_data, 0, sizeof(auth_data));
-
- auth_data.auth_type = TAPI_SIM_AUTH_TYPE_3G;
- auth_data.rand_length = AKA_RAND_DATA_LEN;
- auth_data.autn_length = AKA_AUTN_DATA_LEN;
-
- for (i = 0; i < rand_data->len; i++)
- auth_data.rand_data[i] = g_array_index(rand_data, guint8, i);
-
- for (i = 0; i < autn_data->len; i++)
- auth_data.autn_data[i] = g_array_index(autn_data, guint8, i);
-
- handle = (TapiHandle *)netconfig_tel_init();
- if (handle == NULL)
- return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH;
-
- ret = tel_req_sim_authentication(handle, &auth_data,
- __netconfig_response_aka_authentication, NULL);
-
- if (ret != TAPI_API_SUCCESS) {
- ERR("Failed tel_req_sim_authentication() : [%d]", ret);
-
- return NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH;
- }
- return NETCONFIG_NO_ERROR;
-}
-
-static gboolean __netconfig_wifi_get_sim_authdata(Wifi *wifi,
- GDBusMethodInvocation *context)
-{
- GArray *array = NULL;
-
- if (wifi_authdata == NULL) {
- DBG("the status error : no response yet");
- netconfig_error_fail_get_sim_auth_delay(context);
- return FALSE;
- }
-
- if (wifi_authdata->auth_result == TAPI_SIM_AUTH_NO_ERROR) {
- if (wifi_authdata->resp_length == SIM_AUTH_SRES_LEN &&
- wifi_authdata->authentication_key_length == SIM_AUTH_KC_LEN) {
- array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
- SIM_AUTH_SRES_LEN+SIM_AUTH_KC_LEN);
- g_array_append_vals(array, wifi_authdata->resp_data,
- SIM_AUTH_SRES_LEN);
- g_array_append_vals(array, wifi_authdata->authentication_key,
- SIM_AUTH_KC_LEN);
- } else {
- ERR("auth data length is wrong, SRES = [%d], Kc = [%d]",
- wifi_authdata->resp_length,
- wifi_authdata->authentication_key_length);
- netconfig_error_fail_get_sim_auth_wrong_data(context);
- __netconfig_wifi_clean_authentication();
- return FALSE;
- }
- } else {
- ERR("failed auth result = [%d]", wifi_authdata->auth_result);
- netconfig_error_fail_get_sim_auth_wrong_data(context);
- __netconfig_wifi_clean_authentication();
- return FALSE;
- }
-
- wifi_complete_get_sim_auth(wifi, context, array->data);
- g_array_free(array, TRUE);
- __netconfig_wifi_clean_authentication();
- return TRUE;
-}
-
-static gboolean __netconfig_wifi_get_aka_authdata(Wifi *wifi, GDBusMethodInvocation *context)
-{
- GArray *array = NULL;
- guchar res_len;
-
- if (wifi_authdata == NULL) {
- DBG("the status error : no response yet");
- netconfig_error_fail_get_sim_auth_delay(context);
- return FALSE;
- }
-
- switch (wifi_authdata->auth_result) {
- case TAPI_SIM_AUTH_NO_ERROR:
- break;
-
- case TAPI_SIM_AUTH_SQN_FAILURE:
- case TAPI_SIM_AUTH_SYNCH_FAILURE:
- array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
- wifi_authdata->resp_length+1);
- res_len = (guchar)((wifi_authdata->resp_length-1) & 0xff);
-
- g_array_append_vals(array, &res_len, 1);
- g_array_append_vals(array, wifi_authdata->resp_data,
- wifi_authdata->resp_length);
-
- wifi_complete_get_aka_auth(wifi, context, array->data);
- g_array_free(array, TRUE);
-
- __netconfig_wifi_clean_authentication();
-
- return TRUE;
-
- default:
- netconfig_error_fail_get_sim_auth_wrong_data(context);
- __netconfig_wifi_clean_authentication();
- return FALSE;
- }
-
- if ((wifi_authdata->resp_length >= AKA_AUTH_RES_MIN_LEN ||
- wifi_authdata->resp_length <= AKA_AUTH_RES_MAX_LEN) &&
- wifi_authdata->cipher_length == AKA_AUTH_CK_LEN &&
- wifi_authdata->integrity_length == AKA_AUTH_IK_LEN) {
- array = g_array_sized_new(FALSE, FALSE, sizeof(guchar),
- wifi_authdata->resp_length+AKA_AUTH_CK_LEN+AKA_AUTH_IK_LEN+1);
-
- res_len = (guchar)((wifi_authdata->resp_length-1) & 0xff);
- g_array_append_vals(array, &res_len, 1);
- g_array_append_vals(array, wifi_authdata->resp_data,
- wifi_authdata->resp_length);
- g_array_append_vals(array, wifi_authdata->cipher_data,
- AKA_AUTH_CK_LEN);
- g_array_append_vals(array, wifi_authdata->integrity_data,
- AKA_AUTH_IK_LEN);
- } else {
- ERR("auth data length is wrong, res = [%d], Kc = [%d], Ki = [%d]",
- wifi_authdata->resp_length, wifi_authdata->cipher_length,
- wifi_authdata->integrity_length);
-
- netconfig_error_fail_get_sim_auth_wrong_data(context);
- __netconfig_wifi_clean_authentication();
- return FALSE;
- }
-
- wifi_complete_get_aka_auth(wifi, context, array->data);
- g_array_free(array, TRUE);
- __netconfig_wifi_clean_authentication();
-
- return TRUE;
-}
+static struct wifi_authentication_data *wifi_authdata;
gboolean handle_get_sim_imsi(Wifi *wifi, GDBusMethodInvocation *context)
{
g_free(out_auth_data);
rand_data_garray->len = length;
- result = __netconfig_wifi_req_sim_auth(rand_data_garray, context);
+ result = __netconfig_wifi_req_sim_auth(rand_data_garray, context, &wifi_authdata);
g_array_free(rand_data_garray, FALSE);
if (result)
g_free(out_auth_data);
autn_data_garray->len = length;
- ret = __netconfig_wifi_req_aka_auth(rand_data_garray, autn_data_garray, context);
+ ret = __netconfig_wifi_req_aka_auth(rand_data_garray, autn_data_garray, context, &wifi_authdata);
if (ret == NETCONFIG_NO_ERROR) {
result = TRUE;
wifi_complete_req_aka_auth(wifi, context, result);
g_return_val_if_fail(wifi != NULL, FALSE);
- ret = __netconfig_wifi_get_sim_authdata(wifi, context);
+ ret = __netconfig_wifi_get_sim_authdata(wifi, context, &wifi_authdata);
return ret;
}
g_return_val_if_fail(wifi != NULL, FALSE);
- ret = __netconfig_wifi_get_aka_authdata(wifi, context);
+ ret = __netconfig_wifi_get_aka_authdata(wifi, context, &wifi_authdata);
return ret;
}
+
+EXPORT_SYM void netconfig_complete_get_sim_imsi(void *wifi, GDBusMethodInvocation *context, char *imsi)
+{
+ wifi_complete_get_sim_imsi((Wifi*)wifi, context, imsi);
+}
+
+EXPORT_SYM void netconfig_complete_get_aka_auth(void *wifi, GDBusMethodInvocation *context, GArray *array)
+{
+ wifi_complete_get_aka_auth((Wifi*)wifi, context, array->data);
+}
+
+EXPORT_SYM void netconfig_complete_get_sim_auth(void *wifi, GDBusMethodInvocation *context, GArray *array)
+{
+ wifi_complete_get_sim_auth((Wifi*)wifi, context, array->data);
+}
+
+EXPORT_SYM void netconfig_wifi_power_on()
+{
+#if defined TIZEN_WEARABLE
+ wifi_power_on_wearable(TRUE);
+#else
+ wifi_power_on();
+#endif
+}
#include <errno.h>
#include <vconf.h>
#include <vconf-keys.h>
-#include <ITapiSim.h>
-#include <TapiUtility.h>
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <tzplatform_config.h>
-#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
-#include <wifi-direct.h>
-#endif
-
#include "log.h"
#include "util.h"
#include "netdbus.h"
#include "wifi-wps.h"
#include "wifi-power.h"
#include "wifi-state.h"
-#include "wifi-tel-intf.h"
#include "netsupplicant.h"
#include "network-state.h"
#include "network-dpm.h"
#include "wifi-background-scan.h"
-#define WLAN_SUPPLICANT_SCRIPT "/usr/sbin/wpa_supp.sh"
-#define P2P_SUPPLICANT_SCRIPT "/usr/sbin/p2p_supp.sh"
+#define WLAN_SUPPLICANT_SCRIPT "/usr/bin/wpa_supp.sh"
+#define P2P_SUPPLICANT_SCRIPT "/usr/bin/p2p_supp.sh"
#define VCONF_WIFI_OFF_STATE_BY_AIRPLANE "file/private/wifi/wifi_off_by_airplane"
#define VCONF_WIFI_OFF_STATE_BY_RESTRICTED "file/private/wifi/wifi_off_by_restricted"
{
int rv = 0;
const char *path = WLAN_SUPPLICANT_SCRIPT;
- char *const args_enable[] = { "/usr/sbin/wpa_supp.sh", "start", NULL };
- char *const args_disable[] = { "/usr/sbin/wpa_supp.sh", "stop", NULL };
+ char *const args_enable[] = { "/usr/bin/wpa_supp.sh", "start", NULL };
+ char *const args_disable[] = { "/usr/bin/wpa_supp.sh", "stop", NULL };
char *const envs[] = { NULL };
static gboolean enabled = FALSE;
return 0;
}
-#if defined TIZEN_P2P_ENABLE && defined WLAN_CONCURRENT_MODE
-static int __netconfig_p2p_supplicant(gboolean enable)
-{
- int rv = 0;
- const char *path = P2P_SUPPLICANT_SCRIPT;
- char *const args_enable[] = { P2P_SUPPLICANT_SCRIPT, "start", NULL };
- char *const args_disable[] = { P2P_SUPPLICANT_SCRIPT, "stop", NULL };
- char *const envs[] = { NULL };
-
- if (enable == TRUE)
- rv = netconfig_execute_file(path, args_enable, envs);
- else
- rv = netconfig_execute_file(path, args_disable, envs);
- if (rv < 0)
- return -EIO;
-
- DBG("p2p_supplicant %s", enable == TRUE ? "started" : "stopped");
-
- return 0;
-}
-#endif
-
void netconfig_wifi_recover_firmware(void)
{
wifi_firmware_recovery_mode = TRUE;
wifi_power_off();
}
-#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
-static void __netconfig_wifi_direct_state_cb(int error_code, wifi_direct_device_state_e device_state, void *user_data)
-{
- int err;
-
- wifi_direct_unset_device_state_changed_cb();
- wifi_direct_deinitialize();
-
- if (device_state == WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) {
- err = wifi_power_on();
- if (err < 0) {
- if (err == -EALREADY)
- wifi_state_update_power_state(TRUE);
- else
- wifi_state_emit_power_failed();
- }
- }
-}
-
-static gboolean __netconfig_wifi_direct_power_off(void)
-{
- DBG("Wi-Fi direct is turning off");
-
- if (wifi_direct_initialize() < 0)
- return FALSE;
-
- if (wifi_direct_set_device_state_changed_cb(__netconfig_wifi_direct_state_cb, NULL) < 0)
- return FALSE;
-
- if (wifi_direct_deactivate() < 0)
- return FALSE;
-
- return TRUE;
-}
-#endif
-
static int _load_driver_and_supplicant(void)
{
int err = 0;
prev_state = new_state;
}
-static void _tapi_noti_sim_status_cb(TapiHandle *handle, const char *noti_id,
- void *data, void *user_data)
-{
- TelSimCardStatus_t *status = data;
-
- if (*status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
- DBG("Turn Wi-Fi on automatically");
-#if defined TIZEN_WEARABLE
- wifi_power_on_wearable(TRUE);
-#else
- wifi_power_on();
-#endif
- netconfig_tel_deinit();
- }
-}
-
-static gboolean netconfig_tapi_check_sim_state(void)
-{
- int ret, card_changed;
- TelSimCardStatus_t status = TAPI_SIM_STATUS_UNKNOWN;
- TapiHandle *tapi_handle = NULL;
-
- tapi_handle = (TapiHandle *)netconfig_tel_init();
- if (tapi_handle == NULL) {
- ERR("Failed to tapi init");
- return FALSE;
- }
-
- ret = tel_get_sim_init_info(tapi_handle, &status, &card_changed);
- if (ret != TAPI_API_SUCCESS) {
- ERR("tel_get_sim_init_info() Failed : [%d]", ret);
- netconfig_tel_deinit();
- return FALSE;
- }
-
- switch (status) {
- case TAPI_SIM_STATUS_UNKNOWN:
- case TAPI_SIM_STATUS_CARD_ERROR:
- case TAPI_SIM_STATUS_CARD_NOT_PRESENT:
- case TAPI_SIM_STATUS_CARD_BLOCKED:
- case TAPI_SIM_STATUS_SIM_INIT_COMPLETED:
- break;
- case TAPI_SIM_STATUS_SIM_PIN_REQUIRED:
- case TAPI_SIM_STATUS_SIM_INITIALIZING:
- case TAPI_SIM_STATUS_SIM_PUK_REQUIRED:
- case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED:
- case TAPI_SIM_STATUS_SIM_NCK_REQUIRED:
- case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED:
- case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED:
- case TAPI_SIM_STATUS_SIM_CCK_REQUIRED:
- tel_register_noti_event(tapi_handle, TAPI_NOTI_SIM_STATUS,
- _tapi_noti_sim_status_cb, NULL);
- return FALSE;
- default:
- ERR("not defined status(%d)", status);
- break;
- }
-
- netconfig_tel_deinit();
-
- return TRUE;
-}
-
static void __netconfig_telephony_ready_changed_cb(keynode_t * node, void *data)
{
int telephony_ready = 0;
return -EBUSY;
}
-#if defined TIZEN_P2P_ENABLE && !defined WLAN_CONCURRENT_MODE
- if (netconfig_is_wifi_direct_on() == TRUE) {
- if (__netconfig_wifi_direct_power_off() == TRUE)
- return -EINPROGRESS;
- else {
- ERR("Failed to turn Wi-Fi direct off");
- return -EBUSY;
- }
- }
-#endif
-
err = wifi_power_driver_and_supplicant(TRUE);
if (err < 0 && err != -EALREADY)
return err;
+++ /dev/null
-/*
- * Network Configuration Module
- *
- * 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.
- * 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 <vconf.h>
-
-#include "log.h"
-#include "wifi-tel-intf.h"
-
-#define TAPI_HANDLE_MAX 2
-
-#define SIM_SLOT_DUAL 2
-#define SIM_SLOT_SINGLE 1
-
-#define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE "db/telephony/dualsim/default_data_service"
-#define DEFAULT_DATA_SERVICE_SIM1 0
-#define DEFAULT_DATA_SERVICE_SIM2 1
-
-static TapiHandle *tapi_handle_dual[TAPI_HANDLE_MAX+1];
-static TapiHandle *tapi_handle = NULL;
-
-static int _check_current_sim()
-{
-#if defined TIZEN_WEARABLE
- return -1;
-#else
- int current_sim = 0;
- int sim_slot_count = 0;
-
- if ((vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT_COUNT, &sim_slot_count) != 0)
- || sim_slot_count == SIM_SLOT_SINGLE) {
- ERR("failed to get sim slot count (%d)", sim_slot_count);
- return -1;
- }
-
- if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, ¤t_sim) != 0) {
- ERR("failed to get default data service = %d\n", current_sim);
- return 0;
- }
-
- DBG("default data service [SIM%d]", current_sim);
- return current_sim;
-#endif
-}
-
-TapiHandle * netconfig_tel_init(void)
-{
- char **cp_list = NULL;
- int current_sim = _check_current_sim();
-
- if (current_sim < 0) {
- if (tapi_handle == NULL) {
- tapi_handle = tel_init(NULL);
- if (tapi_handle == NULL)
- ERR("tel_init() Failed - modem %d", current_sim);
- }
- return tapi_handle;
- } else {
- if (tapi_handle_dual[current_sim] == NULL) {
- cp_list = tel_get_cp_name_list();
- if (!cp_list) {
- ERR("tel_get_cp_name_list() Failed");
- return NULL;
- }
-
- tapi_handle_dual[current_sim] = tel_init(cp_list[current_sim]);
- if (tapi_handle_dual[current_sim] == NULL)
- ERR("tel_init() Failed - modem %d", current_sim);
-
- g_strfreev(cp_list);
- }
- return tapi_handle_dual[current_sim];
- }
-}
-
-void netconfig_tel_deinit(void)
-{
- int current_sim = _check_current_sim();
-
- if (current_sim < 0) {
- if (tapi_handle)
- tel_deinit(tapi_handle);
-
- tapi_handle = NULL;
- } else {
- unsigned int i = 0;
- while (tapi_handle_dual[i]) {
- tel_deinit(tapi_handle_dual[i]);
- tapi_handle_dual[i] = NULL;
- i++;
- }
- }
-}
-