* limitations under the License.
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dbus/dbus.h>
#include <gio/gio.h>
#include <vconf.h>
-#include <openssl/evp.h>
-#include <openssl/sha.h>
#include <ckmc/ckmc-manager.h>
#include <tzplatform_config.h>
#include "tethering_private.h"
static void __send_dbus_signal(GDBusConnection *conn, const char *signal_name, const char *arg)
{
if (conn == NULL || signal_name == NULL)
- return; //LCOV_EXCL_LINE
+ return;
GVariant *message = NULL;
GError *error = NULL;
g_dbus_connection_emit_signal(conn, NULL, TETHERING_SERVICE_OBJECT_PATH,
TETHERING_SERVICE_INTERFACE, signal_name, message, &error);
if (error) {
- ERR("g_dbus_connection_emit_signal is failed because %s\n", error->message); //LCOV_EXCL_LINE
- g_error_free(error); //LCOV_EXCL_LINE
+ ERR("g_dbus_connection_emit_signal is failed because %s\n", error->message);
+ g_error_free(error);
}
- g_variant_unref(message);
}
static bool __any_tethering_is_enabled(tethering_h tethering)
{
if (tethering_is_enabled(tethering, TETHERING_TYPE_USB) ||
tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) ||
- tethering_is_enabled(tethering, TETHERING_TYPE_BT))
+ tethering_is_enabled(tethering, TETHERING_TYPE_BT) ||
+ tethering_is_enabled(tethering, TETHERING_TYPE_P2P))
return true;
return false;
{
if (security_type != TETHERING_WIFI_SECURITY_TYPE_NONE &&
security_type != TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK &&
- security_type != TETHERING_WIFI_SECURITY_TYPE_WPS) {
+ security_type != TETHERING_WIFI_SECURITY_TYPE_WPS &&
+ security_type != TETHERING_WIFI_SECURITY_TYPE_SAE) {
ERR("Invalid param\n");
return TETHERING_ERROR_INVALID_PARAMETER;
}
err = TETHERING_ERROR_NONE;
break;
- //LCOV_EXCL_START
case MOBILE_AP_ERROR_RESOURCE:
err = TETHERING_ERROR_OUT_OF_MEMORY;
break;
- //LCOV_EXCL_STOP
case MOBILE_AP_ERROR_INTERNAL:
err = TETHERING_ERROR_OPERATION_FAILED;
err = TETHERING_ERROR_OPERATION_FAILED;
break;
- //LCOV_EXCL_START
case MOBILE_AP_ERROR_NOT_PERMITTED:
err = TETHERING_ERROR_NOT_PERMITTED;
break;
case MOBILE_AP_ERROR_PERMISSION_DENIED:
err = TETHERING_ERROR_PERMISSION_DENIED;
break;
- //LCOV_EXCL_STOP
default:
ERR("Not defined error : %d\n", agent_error);
err = TETHERING_ERROR_OPERATION_FAILED;
return err;
}
-//LCOV_EXCL_START
static void __handle_dhcp(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data)
type = TETHERING_TYPE_WIFI;
else if (ap_type == MOBILE_AP_TYPE_BT)
type = TETHERING_TYPE_BT;
+ else if (ap_type == MOBILE_AP_TYPE_P2P)
+ type = TETHERING_TYPE_P2P;
else {
ERR("Not supported tethering type [%d]\n", ap_type);
goto DONE;
g_free(name);
DBG("-\n");
}
-//LCOV_EXCL_STOP
-//LCOV_EXCL_START
static void __handle_net_closed(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data)
DBG("-\n");
}
-//LCOV_EXCL_STOP
static void __handle_wifi_tether_on(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
DBG("-\n");
}
-//LCOV_EXCL_START
static void __handle_usb_tether_on(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data)
g_free(buf);
DBG("-\n");
}
-//LCOV_EXCL_STOP
static void __handle_bt_tether_on(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
DBG("-\n");
}
-//LCOV_EXCL_START
static void __handle_no_data_timeout(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
GVariant *parameters, gpointer user_data)
}
DBG("-\n");
}
-//LCOV_EXCL_STOP
static void __handle_security_type_changed(GDBusConnection *connection, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name, const gchar *signal_name,
security_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
else if (g_strcmp0(buf, TETHERING_WIFI_SECURITY_TYPE_WPS_STR) == 0)
security_type = TETHERING_WIFI_SECURITY_TYPE_WPS;
+ else if (g_strcmp0(buf, TETHERING_WIFI_SECURITY_TYPE_SAE_STR) == 0)
+ security_type = TETHERING_WIFI_SECURITY_TYPE_SAE;
else {
SERR("Unknown type : %s\n", buf);
g_free(buf);
g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
if (g_error) {
- //LCOV_EXCL_START
ERR("DBus error [%s]\n", g_error->message);
if (g_error->code == G_DBUS_ERROR_NO_REPLY &&
++retry < TETHERING_ERROR_RECOVERY_MAX) {
else
error = TETHERING_ERROR_OPERATION_FAILED;
g_error_free(g_error);
- //LCOV_EXCL_STOP
} else {
g_variant_get(g_var, "(u)", &info);
error = __get_error(info);
g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
if (g_error) {
- //LCOV_EXCL_START
ERR("DBus error [%s]\n", g_error->message);
if (g_error->code == G_DBUS_ERROR_NO_REPLY &&
++retry < TETHERING_ERROR_RECOVERY_MAX) {
else
error = TETHERING_ERROR_OPERATION_FAILED;
g_error_free(g_error);
- //LCOV_EXCL_STOP
} else {
g_variant_get(g_var, "(u)", &info);
g_variant_unref(g_var);
DBG("-\n");
}
-//LCOV_EXCL_START
static void __usb_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
gpointer user_data)
{
ecb(error, TETHERING_TYPE_USB, true, data);
DBG("-\n");
}
-//LCOV_EXCL_STOP
static void __p2p_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
gpointer user_data)
g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
if (g_error) {
- //LCOV_EXCL_START
ERR("DBus error [%s]\n", g_error->message);
g_error_free(g_error);
return;
- //LCOV_EXCL_STOP
}
g_variant_get(g_var, "(uu)", &event_type, &info);
INFO("cfm event : %d info : %d\n", event_type, info);
dcb(error, type, code, data);
break;
- //LCOV_EXCL_START
case MOBILE_AP_DISABLE_USB_TETHERING_CFM:
sigs[E_SIGNAL_USB_TETHER_OFF].sig_id = g_dbus_connection_signal_subscribe(th->client_bus,
NULL, TETHERING_SERVICE_INTERFACE, sigs[E_SIGNAL_USB_TETHER_OFF].name,
if (dcb)
dcb(error, type, code, data);
break;
- //LCOV_EXCL_STOP
case MOBILE_AP_DISABLE_P2P_TETHERING_CFM:
type = TETHERING_TYPE_P2P;
g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
if (g_error) {
- //LCOV_EXCL_START
ERR("DBus fail [%s]\n", g_error->message);
if (g_error->code == G_DBUS_ERROR_ACCESS_DENIED)
tethering_error = TETHERING_ERROR_PERMISSION_DENIED;
tethering_error = TETHERING_ERROR_OPERATION_FAILED;
flag = true;
- //LCOV_EXCL_STOP
}
if (th->data_usage_cb == NULL) {
ERR("There is no data_usage_cb\n");
GVariant *g_var;
guint info;
__tethering_h *th = (__tethering_h *)user_data;
- tethering_error_e tethering_error;
+ tethering_error_e tethering_error = TETHERING_ERROR_NONE;
g_var = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
if (g_error) {
else
tethering_error = TETHERING_ERROR_OPERATION_FAILED;
g_error_free(g_error);
+ } else {
+ g_variant_get(g_var, "(u)", &info);
+ if (tethering_error == TETHERING_ERROR_NONE)
+ tethering_error = __get_error(info);
+ g_variant_unref(g_var);
}
+
if (th->settings_reloaded_cb == NULL) {
DBG("There is no settings_reloaded_cb\n-\n");
return;
}
- g_variant_get(g_var, "(u)", &info);
- tethering_error = __get_error(info);
- g_variant_unref(g_var);
th->settings_reloaded_cb(tethering_error,
th->settings_reloaded_user_data);
_retvm_if(buf == NULL, false, "parameter(buf) is NULL\n");
switch (type) {
- //LCOV_EXCL_START
case TETHERING_TYPE_USB:
g_strlcpy(buf, TETHERING_USB_IF, len);
break;
- //LCOV_EXCL_STOP
case TETHERING_TYPE_WIFI:
g_strlcpy(buf, TETHERING_WIFI_IF, len);
break;
-
case TETHERING_TYPE_BT:
g_strlcpy(buf, TETHERING_BT_IF, len);
break;
-
default:
ERR("Not supported type : %d\n", type);
return false;
case TETHERING_TYPE_USB:
g_strlcpy(buf, TETHERING_USB_GATEWAY, len);
break;
-
case TETHERING_TYPE_WIFI:
g_strlcpy(buf, TETHERING_WIFI_GATEWAY, len);
break;
-
case TETHERING_TYPE_BT:
g_strlcpy(buf, TETHERING_BT_GATEWAY, len);
break;
-
default:
ERR("Not supported type : %d\n", type);
return false;
static int __get_common_ssid(char *ssid, unsigned int size)
{
if (ssid == NULL) {
- ERR("ssid is null\n"); //LCOV_EXCL_LINE
+ ERR("ssid is null\n");
return TETHERING_ERROR_INVALID_PARAMETER;
}
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (error) {
- //LCOV_EXCL_START
ERR("g_dbus_proxy_call_sync failed because %s\n", error->message);
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
g_error_free(error);
return ret;
- //LCOV_EXCL_STOP
}
if (parameters != NULL) {
g_variant_get(parameters, "(siu)", &passphrase, &len, &ret);
+ g_strlcpy(set->key, passphrase, sizeof(set->key) - 1);
+ g_free(passphrase);
g_variant_unref(parameters);
}
-
- g_strlcpy(set->key, passphrase, sizeof(set->key));
}
INFO("ssid: %s security: %d mode: %s channel: %d visibility: %s\n",
static bool __check_precondition(tethering_type_e type)
{
- int dnet_state = 0;
+ int dnet_status = 0;
int cellular_state = 0;
- int wifi_state = 0;
/* data network through cellular */
vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &cellular_state);
return TRUE;
}
-#ifdef TIZEN_TV_EXT
- /* data network through ethernet */
- vconf_get_int(VCONFKEY_NETWORK_STATUS, &dnet_state);
- if (dnet_state == VCONFKEY_NETWORK_ETHERNET) {
- INFO("Data Network is connected");
- return TRUE;
- }
-#else
- vconf_get_int(VCONFKEY_DNET_STATE, &dnet_state);
- if (dnet_state > VCONFKEY_DNET_OFF) {
- INFO("Data Network is connected");
+ /* data network status */
+ vconf_get_int(VCONFKEY_NETWORK_STATUS, &dnet_status);
+ if ((dnet_status == VCONFKEY_NETWORK_WIFI
+ && type != TETHERING_TYPE_WIFI)
+ || dnet_status == VCONFKEY_NETWORK_ETHERNET)
return TRUE;
- }
-#endif/*TIZEN_TV_EXT*/
-
- /* data network through wifi */
- if (type != TETHERING_TYPE_WIFI) {
- vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
- if (wifi_state > VCONFKEY_WIFI_UNCONNECTED) {
- INFO("Wi-Fi is connected!");
- return TRUE;
- }
- }
ERR("Network is not available!");
return FALSE;
th->sec_type = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK;
th->visibility = true;
th->mac_filter = false;
- th->channel = 6;
+ th->channel = TETHERING_WIFI_CHANNEL;
th->mode_type = TETHERING_WIFI_MODE_TYPE_G;
th->wifi_max_connected = TETHERING_WIFI_MAX_STA;
if (__generate_initial_passphrase(th->passphrase,
sizeof(th->passphrase)) == 0) {
- ERR("random passphrase generation failed\n"); //LCOV_EXCL_LINE
+ ERR("random passphrase generation failed\n");
free(th);
return TETHERING_ERROR_OPERATION_FAILED;
}
if (__get_common_ssid(ssid, sizeof(ssid)) != TETHERING_ERROR_NONE) {
- ERR("common ssid get failed\n"); //LCOV_EXCL_LINE
+ ERR("common ssid get failed\n");
free(th);
return TETHERING_ERROR_OPERATION_FAILED;
}
GCancellable *cancellable = g_cancellable_new();
th->client_bus = g_bus_get_sync(DBUS_BUS_SYSTEM, cancellable, &error);
if (error) {
- //LCOV_EXCL_START
ERR("Couldn't connect to the System bus[%s]", error->message);
g_error_free(error);
g_cancellable_cancel(cancellable);
g_object_unref(cancellable);
free(th);
return TETHERING_ERROR_OPERATION_FAILED;
- //LCOV_EXCL_STOP
}
th->cancellable = cancellable;
NULL, TETHERING_SERVICE_NAME, TETHERING_SERVICE_OBJECT_PATH,
TETHERING_SERVICE_INTERFACE, th->cancellable, &error);
if (!th->client_bus_proxy) {
- //LCOV_EXCL_START
if (error)
ERR("Couldn't create the proxy object because of %s\n", error->message);
g_cancellable_cancel(th->cancellable);
g_object_unref(th->client_bus);
free(th);
return TETHERING_ERROR_OPERATION_FAILED;
- //LCOV_EXCL_STOP
}
__connect_signals((tethering_h)th);
*tethering = (tethering_h)th;
_tethering_add_handle(th);
- INFO("Tethering Handle : 0x%X\n", th);
+ INFO("Tethering Handle : %p\n", th);
INFO("-\n");
return TETHERING_ERROR_NONE;
}
__tethering_h *th = (__tethering_h *)tethering;
- INFO("Tethering Handle : 0x%X\n", th);
+ INFO("Tethering Handle : %p\n", th);
__disconnect_signals(tethering);
+ _tethering_remove_handle(th);
if (th->ssid)
free(th->ssid);
g_object_unref(th->client_bus);
memset(th, 0x00, sizeof(__tethering_h));
- _tethering_remove_handle(th);
free(th);
INFO("-\n");
g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_INFINITE);
if (__check_precondition(type) == FALSE) {
- //LCOV_EXCL_START
INFO("-\n");
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
return TETHERING_ERROR_OPERATION_FAILED;
- //LCOV_EXCL_STOP
}
switch (type) {
- //LCOV_EXCL_START
case TETHERING_TYPE_USB:
g_dbus_connection_signal_unsubscribe(connection,
sigs[E_SIGNAL_USB_TETHER_ON].sig_id);
- g_dbus_proxy_call(proxy, "enable_usb_tethering", NULL,
+ g_dbus_proxy_call(proxy, "enable_usb_tethering",
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __usb_enabled_cfm_cb, (gpointer)tethering);
break;
- //LCOV_EXCL_STOP
case TETHERING_TYPE_WIFI: {
_softap_settings_t set = {"", "", "", 0, false};
ret = __prepare_wifi_settings(tethering, &p2p_set);
if (ret != TETHERING_ERROR_NONE) {
ERR("p2p settings initialization failed\n");
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
DBG("-\n");
return TETHERING_ERROR_OPERATION_FAILED;
}
ret = __prepare_wifi_settings(tethering, &set);
if (ret != TETHERING_ERROR_NONE) {
ERR("softap settings initialization failed\n");
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
return TETHERING_ERROR_OPERATION_FAILED;
}
g_dbus_connection_signal_unsubscribe(connection,
sigs[E_SIGNAL_USB_TETHER_ON].sig_id);
- g_dbus_proxy_call(proxy, "enable_usb_tethering", NULL,
+ g_dbus_proxy_call(proxy, "enable_usb_tethering",
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __usb_enabled_cfm_cb, (gpointer)tethering);
G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __bt_enabled_cfm_cb, (gpointer)tethering);
break;
- //LCOV_EXCL_STOP
}
default:
ERR("Unknown type : %d\n", type);
g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_INFINITE);
if (__check_precondition(type) == FALSE) {
- //LCOV_EXCL_START
DBG("-\n");
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
return TETHERING_ERROR_OPERATION_FAILED;
- //LCOV_EXCL_STOP
}
switch (type) {
- //LCOV_EXCL_START
+ case TETHERING_TYPE_USB: {
+ g_dbus_connection_signal_unsubscribe(connection,
+ sigs[E_SIGNAL_USB_TETHER_ON].sig_id);
+
+ g_dbus_proxy_call(proxy, "enable_usb_tethering",
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6),
+ G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+ (GAsyncReadyCallback) __usb_enabled_cfm_cb, (gpointer)tethering);
+ break;
+ }
+
case TETHERING_TYPE_WIFI: {
_softap_settings_t set = {"", "", "", 0, false, false, 0, 0};
if (ret != TETHERING_ERROR_NONE) {
ERR("softap settings initialization failed\n");
DBG("-\n");
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
return TETHERING_ERROR_OPERATION_FAILED;
}
g_dbus_connection_signal_unsubscribe(connection,
(GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
break;
}
+
case TETHERING_TYPE_BT: {
g_dbus_connection_signal_unsubscribe(connection,
sigs[E_SIGNAL_BT_TETHER_ON].sig_id);
- /* For TEST */
- g_dbus_proxy_call(proxy, "enable_bt_tethering", g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6),
+ g_dbus_proxy_call(proxy, "enable_bt_tethering",
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6),
G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __bt_enabled_cfm_cb, (gpointer)tethering);
GDBusConnection *connection = th->client_bus;
switch (type) {
+ case TETHERING_TYPE_USB:
+ g_dbus_connection_signal_unsubscribe(connection,
+ sigs[E_SIGNAL_USB_TETHER_OFF].sig_id);
+
+ g_dbus_proxy_call(proxy, "disable_usb_tethering",
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6),
+ G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+ (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
+ break;
+
case TETHERING_TYPE_WIFI:
DBG("Disable wifi tethering..");
g_dbus_connection_signal_unsubscribe(connection,
G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
break;
+
case TETHERING_TYPE_BT:
g_dbus_connection_signal_unsubscribe(connection,
sigs[E_SIGNAL_BT_TETHER_OFF].sig_id);
sigs[E_SIGNAL_USB_TETHER_OFF].sig_id);
g_dbus_proxy_call(proxy, "disable_usb_tethering",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
+ G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
break;
sigs[E_SIGNAL_USB_TETHER_OFF].sig_id);
g_dbus_proxy_call(proxy, "disable_usb_tethering",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV4),
+ G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
g_dbus_connection_signal_unsubscribe(connection,
result = g_dbus_proxy_call_sync(th->client_bus_proxy, "get_station_info",
NULL, G_DBUS_CALL_FLAGS_NONE,
-1, th->cancellable, &error);
- if (error)
+
+ if (error) {
ERR("g_dbus_proxy_call_sync is failed and error is %s\n", error->message);
+ g_error_free(error);
+ return TETHERING_ERROR_OPERATION_FAILED;
+ }
+
g_variant_get(result, "(a(a{sv}))", &outer_iter);
while (g_variant_iter_loop(outer_iter, "(@a{sv})", &station)) {
g_variant_get(station, "a{sv}", &inner_iter);
client.interface = TETHERING_TYPE_WIFI;
else if (interface == MOBILE_AP_TYPE_BT)
client.interface = TETHERING_TYPE_BT;
+ else if (interface == MOBILE_AP_TYPE_P2P)
+ client.interface = TETHERING_TYPE_P2P;
else {
ERR("Invalid interface\n");
g_free(key);
g_free(hostname);
g_free(ip);
g_free(mac);
+
+ hostname = NULL;
+ ip = NULL;
+ mac = NULL;
+
g_variant_iter_free(inner_iter);
if (callback((tethering_client_h)&client, user_data) == false) {
DBG("iteration is stopped\n");
g_free(client.hostname);
+ client.hostname = NULL;
g_variant_iter_free(outer_iter);
- g_variant_unref(station);
g_variant_unref(result);
DBG("-\n");
return TETHERING_ERROR_OPERATION_FAILED;
}
g_free(client.hostname);
+ client.hostname = NULL;
}
g_variant_iter_free(outer_iter);
- g_variant_unref(station);
g_variant_unref(result);
DBG("-\n");
return TETHERING_ERROR_NONE;
}
/* TETHERING_TYPE_ALL */
- for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_BT; ti++) {
+ for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
th->changed_cb[ti] = callback;
th->changed_user_data[ti] = user_data;
}
}
/* TETHERING_TYPE_ALL */
- for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_BT; ti++) {
+ for (ti = TETHERING_TYPE_USB; ti <= TETHERING_TYPE_P2P; ti++) {
th->changed_cb[ti] = NULL;
th->changed_user_data[ti] = NULL;
}
ret = __set_security_type(type);
if (ret == TETHERING_ERROR_NONE) {
-
switch (type) {
case TETHERING_WIFI_SECURITY_TYPE_NONE:
sec_str = TETHERING_WIFI_SECURITY_TYPE_OPEN_STR;
case TETHERING_WIFI_SECURITY_TYPE_WPS:
sec_str = TETHERING_WIFI_SECURITY_TYPE_WPS_STR;
break;
+ case TETHERING_WIFI_SECURITY_TYPE_SAE:
+ sec_str = TETHERING_WIFI_SECURITY_TYPE_SAE_STR;
+ break;
}
__send_dbus_signal(th->client_bus,
CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
_retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(type) is NULL\n");
ret = __set_visible(visible);
if (ret == TETHERING_ERROR_NONE) {
-
__send_dbus_signal(th->client_bus,
SIGNAL_NAME_SSID_VISIBILITY_CHANGED,
visible ? SIGNAL_MSG_SSID_VISIBLE :
CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
_retvm_if(visible == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(visible) is NULL\n");
g_variant_new("(s)", passphrase), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (error) {
- //LCOV_EXCL_START
ERR("g_dbus_proxy_call_sync failed because %s\n", error->message);
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
g_error_free(error);
return ret;
- //LCOV_EXCL_STOP
}
g_variant_get(parameters, "(u)", &ret);
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (error) {
- //LCOV_EXCL_START
ERR("g_dbus_proxy_call_sync failed because %s\n", error->message);
if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
g_error_free(error);
return ret;
- //LCOV_EXCL_STOP
}
if (parameters != NULL) {
bool mac_exist = false;
char *p_mac = NULL;
- p_mac = strdup(mac);
- if (p_mac == NULL) {
- ERR("strdup failed\n");
- return TETHERING_ERROR_OUT_OF_MEMORY;
- }
-
fp = fopen(filepath, "a+");
if (!fp) {
ERR("fopen is failed\n");
}
if (!mac_exist) {
+ p_mac = strdup(mac);
+ if (p_mac == NULL) {
+ ERR("strdup failed\n");
+ fclose(fp);
+ return TETHERING_ERROR_OUT_OF_MEMORY;
+ }
+
fprintf(fp, "%s\n", mac);
if ((strcmp(filepath, ALLOWED_LIST) == 0))
allowed_list = g_slist_append(allowed_list, p_mac);
else if ((strcmp(filepath, BLOCKED_LIST) == 0))
blocked_list = g_slist_append(blocked_list, p_mac);
+ else
+ free(p_mac);
}
fclose(fp);
fclose(fp);
fclose(fp1);
- if ((strcmp(filepath, ALLOWED_LIST) == 0))
- rename(TEMP_LIST, ALLOWED_LIST);
- else if ((strcmp(filepath, BLOCKED_LIST) == 0))
- rename(TEMP_LIST, BLOCKED_LIST);
+ if ((strcmp(filepath, ALLOWED_LIST) == 0)) {
+ if (rename(TEMP_LIST, ALLOWED_LIST) != 0) {
+ ERR("rename is failed (%s -> %s)", TEMP_LIST, ALLOWED_LIST);
+ return TETHERING_ERROR_OPERATION_FAILED;
+ }
+ } else if ((strcmp(filepath, BLOCKED_LIST) == 0)) {
+ if (rename(TEMP_LIST, BLOCKED_LIST) != 0) {
+ ERR("rename is failed (%s -> %s)", TEMP_LIST, BLOCKED_LIST);
+ return TETHERING_ERROR_OPERATION_FAILED;
+ }
+ }
return TETHERING_ERROR_NONE;
}
_retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(tethering) is NULL\n");
+ _retvm_if(txpower == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(txpower) is NULL\n");
_retvm_if(tethering_is_enabled(tethering, TETHERING_TYPE_WIFI) == false,
TETHERING_ERROR_NOT_ENABLED,
"tethering type[%d] is not enabled\n", TETHERING_TYPE_WIFI);
_retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(tethering) is NULL\n");
+ _retvm_if(ifname == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(ifname) is NULL\n");
_retvm_if(protocol == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(protocol) is NULL\n");
+ _retvm_if(org_ip == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(org_ip) is NULL\n");
+ _retvm_if(final_ip == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(final_ip) is NULL\n");
GVariant *parameters;
GError *error = NULL;
return TETHERING_ERROR_NONE;
}
-API int tethering_wifi_is_port_forwarding_enabled(tethering_h tethering, bool* forwarding_enabled)
+API int tethering_wifi_is_port_forwarding_enabled(tethering_h tethering, bool *forwarding_enabled)
{
CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
GVariant *parameters;
GError *error = NULL;
guint result;
- char cmd[MAX_BUF_SIZE] = { 0, };
char *list = NULL;
+ int ret;
__tethering_h *th = (__tethering_h *)tethering;
g_variant_unref(parameters);
if (allow)
- snprintf(cmd, sizeof(cmd), "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_ACCEPT);
+ ret = asprintf(&list, "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_ACCEPT);
else
- snprintf(cmd, sizeof(cmd), "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_DROP);
+ ret = asprintf(&list, "%s "FILTERING_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port, ACTION_DROP);
- DBG("cmd:%s", cmd);
-
- list = strdup(cmd);
- if (list == NULL) {
- ERR("strdup failed\n");
+ if (ret == -1 || list == NULL) {
+ ERR("asprintf failed\n");
return TETHERING_ERROR_OUT_OF_MEMORY;
}
+ DBG("cmd:%s", list);
+
port_filtering = g_slist_append(port_filtering, list);
return TETHERING_ERROR_NONE;
GVariant *parameters;
GError *error = NULL;
guint result;
- char cmd[MAX_BUF_SIZE] = { 0, };
char *list = NULL;
+ int ret;
__tethering_h *th = (__tethering_h *)tethering;
g_variant_unref(parameters);
if (allow)
- snprintf(cmd, sizeof(cmd), "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_ACCEPT);
+ ret = asprintf(&list, "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_ACCEPT);
else
- snprintf(cmd, sizeof(cmd), "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_DROP);
+ ret = asprintf(&list, "%s "FILTERING_MULTIPORT_RULE_STR, IPTABLES, TABLE_FILTER, TETH_FILTER_FW, protocol, port1, port2, ACTION_DROP);
- DBG("cmd:%s", cmd);
-
- list = strdup(cmd);
- if (list == NULL) {
- ERR("strdup failed\n");
+ if (ret == -1 || list == NULL) {
+ ERR("asprintf failed\n");
return TETHERING_ERROR_OUT_OF_MEMORY;
}
+ DBG("cmd:%s", list);
+
custom_port_filtering = g_slist_append(custom_port_filtering, list);
return TETHERING_ERROR_NONE;
return TETHERING_ERROR_NONE;
}
-API int tethering_wifi_is_port_filtering_enabled(tethering_h tethering, bool* filtering_enabled)
+API int tethering_wifi_is_port_filtering_enabled(tethering_h tethering, bool *filtering_enabled)
{
CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
_retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
"parameter(tethering) is NULL");
+ _retvm_if(wps_pin == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(wps_pin) is NULL");
+
__tethering_h *th = (__tethering_h *)tethering;
GDBusProxy *proxy = th->client_bus_proxy;
GVariant *parameters = NULL;