* @brief Enumeration for the cause of disabling the tethering.
* @since_tizen 2.3
*/
-typedef enum
-{
+typedef enum {
TETHERING_DISABLED_BY_USB_DISCONNECTION = 0, /**< Disabled due to usb disconnection */
TETHERING_DISABLED_BY_FLIGHT_MODE, /**< Disabled due to flight mode */
TETHERING_DISABLED_BY_LOW_BATTERY, /**< Disabled due to low battery */
*/
typedef enum {
TETHERING_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address type */
+ TETHERING_ADDRESS_FAMILY_IPV6 = 1, /**< IPV6 Address type (Since 4.0) */
} tethering_address_family_e;
/**
int tethering_disable(tethering_h tethering, tethering_type_e type);
/**
+ * @brief Enables the IPv6 tethering, asynchronously.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/tethering.admin
+ * @remarks It supports Wi-Fi tethering and BT tethering only.
+ * @param[in] tethering The tethering handle
+ * @param[in] type The tethering type
+ * @return 0 on success, otherwise negative error value
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post tethering_enabled_cb() will be invoked.
+ * @see tethering_is_enabled()
+ * @see tethering_ipv6_disable()
+ */
+int tethering_ipv6_enable(tethering_h tethering, tethering_type_e type);
+
+/**
+ * @brief Disables the IPv6 tethering, asynchronously.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/tethering.admin
+ * @remarks It supports Wi-Fi tethering and BT tethering only.
+ * @param[in] tethering The tethering handle
+ * @param[in] type The tethering type
+ * @return 0 on success, otherwise negative error value
+ * @retval #TETHERING_ERROR_NONE Successful
+ * @retval #TETHERING_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post tethering_disabled_cb() will be invoked.
+ * @see tethering_is_enabled()
+ * @see tethering_ipv6_enable()
+ */
+int tethering_ipv6_disable(tethering_h tethering, tethering_type_e type);
+
+/**
* @brief Checks whether the tethering is enabled or not.
* @since_tizen 2.3
* @privlevel platform
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE node PUBLIC
- "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
- "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
-
-<node>
- <interface name="org.tizen.tethering">
-
- <!-- Method definitions -->
-
- <method name="disable">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="enable_wifi_tethering">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="s" name="ssid" direction="in"/>
- <arg type="s" name="key" direction="in"/>
- <arg type="i" name="visibility" direction="in"/>
- <arg type="i" name="security" direction="in"/>
- <arg type="u" name="type" direction="out"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="disable_wifi_tethering">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="enable_bt_tethering">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="disable_bt_tethering">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="enable_usb_tethering">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="disable_usb_tethering">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="reload_wifi_settings">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="s" name="ssid" direction="in"/>
- <arg type="s" name="key" direction="in"/>
- <arg type="i" name="visibility" direction="in"/>
- <arg type="i" name="security" direction="in"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="get_station_info">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="a(usssu)" name="station" direction="out"/>
- </method>
-
- <method name="get_data_packet_usage">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="type" direction="out"/>
- <arg type="t" name="rx_data" direction="out"/>
- <arg type="t" name="tx_data" direction="out"/>
- </method>
- <method name="hostapd_set_txpower">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="txpower" direction="in"/>
- <arg type="u" name="result" direction="out"/>
- </method>
-
- <method name="hostapd_get_txpower">
- <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="u" name="result" direction="out"/>
- </method>
- <!-- Signal (D-Bus) definitions -->
- <signal name="net_closed">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="sta_connected">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="sta_disconnected">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="wifi_on">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="wifi_off">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="usb_on">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="usb_off">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="bluetooth_on">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="bluetooth_off">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="no_data_timeout">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="low_batt_mode">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- <signal name="flight_mode">
- <arg type="s" name="arg1" direction="out"/>
- </signal>
-
- </interface>
-</node>
#define TETHERING_USB_FEATURE "http://tizen.org/feature/network.tethering.usb"
#define TETHERING_WIFI_FEATURE "http://tizen.org/feature/network.tethering.wifi"
-typedef enum
-{
+typedef enum {
TETHERING_SUPPORTED_FEATURE,
TETHERING_SUPPORTED_FEATURE_WIFI,
TETHERING_SUPPORTED_FEATURE_BT,
#define CHECK_FEATURE_SUPPORTED(...) \
do { \
int rv = _tethering_check_feature_supported(__VA_ARGS__, NULL); \
- if(rv != TETHERING_ERROR_NONE) { \
+ if (rv != TETHERING_ERROR_NONE) { \
return rv; \
} \
} while (0)
* Common configuration
*/
#define TETHERING_TYPE_MAX 5 /**< All, USB, Wi-Fi, BT, Wi-Fi AP */
-#define TETHERING_STR_INFO_LEN 20 /**< length of the ip or mac address */
+#define TETHERING_STR_INFO_LEN 40 /**< length of the ip or mac address */
/**
* Mobile AP error code
Name: capi-network-tethering
Summary: Tethering Framework
-Version: 1.0.45
+Version: 1.0.46
Release: 1
Group: System/Network
License: Apache-2.0
err = TETHERING_ERROR_PERMISSION_DENIED;
break;
//LCOV_EXCL_STOP
- default :
+ default:
ERR("Not defined error : %d\n", agent_error);
err = TETHERING_ERROR_OPERATION_FAILED;
break;
INFO("ssid: %s security: %d mode: %s channel: %d visibility: %s\n",
set->ssid, set->sec_type, set->mode, set->channel,
- (set->visibility)?"true":"false");
+ (set->visibility) ? "true" : "false");
INFO("-\n");
return TETHERING_ERROR_NONE;
}
sigs[E_SIGNAL_WIFI_TETHER_ON].sig_id);
g_dbus_proxy_call(proxy, "enable_wifi_tethering",
- g_variant_new("(sssiiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.max_connected, set.sec_type),
+ g_variant_new("(sssiiiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.max_connected, set.sec_type, TETHERING_ADDRESS_FAMILY_IPV4),
G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
(GAsyncReadyCallback) __wifi_enabled_cfm_cb, (gpointer)tethering);
break;
return TETHERING_ERROR_NONE;
}
+API int tethering_ipv6_enable(tethering_h tethering, tethering_type_e type)
+{
+ DBG("+ type : %d\n", type);
+ CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+ if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE);
+ else if (type == TETHERING_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+ else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE);
+
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+ GDBusProxy *proxy = th->client_bus_proxy;
+ GDBusConnection *connection = th->client_bus;
+ int ret = 0;
+
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_INFINITE);
+
+ if (__check_precondition(type) == FALSE) {
+ //LCOV_EXCL_START
+ DBG("-\n");
+ return TETHERING_ERROR_OPERATION_FAILED;
+ //LCOV_EXCL_STOP
+ }
+
+ switch (type) {
+ //LCOV_EXCL_START
+ case TETHERING_TYPE_WIFI: {
+ _softap_settings_t set = {"", "", "", 0, false, false, 0, 0};
+
+ ret = __prepare_wifi_settings(tethering, &set);
+ if (ret != TETHERING_ERROR_NONE) {
+ ERR("softap settings initialization failed\n");
+ DBG("-\n");
+ return TETHERING_ERROR_OPERATION_FAILED;
+ }
+ g_dbus_connection_signal_unsubscribe(connection,
+ sigs[E_SIGNAL_WIFI_TETHER_ON].sig_id);
+ g_dbus_proxy_call(proxy, "enable_wifi_tethering",
+ g_variant_new("(sssiiiiii)", set.ssid, set.key, set.mode, set.channel, set.visibility, set.mac_filter, set.max_connected, set.sec_type, TETHERING_ADDRESS_FAMILY_IPV6),
+ G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+ (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_CALL_FLAGS_NONE, -1, th->cancellable,
+ (GAsyncReadyCallback) __bt_enabled_cfm_cb, (gpointer)tethering);
+
+ break;
+ }
+
+ default: {
+ ERR("Unknown type : %d\n", type);
+
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
+
+ DBG("-\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ g_dbus_proxy_set_default_timeout(proxy, DBUS_TIMEOUT_USE_DEFAULT);
+ DBG("-\n");
+ return TETHERING_ERROR_NONE;
+}
+
+API int tethering_ipv6_disable(tethering_h tethering, tethering_type_e type)
+{
+ DBG("+ type : %d\n", type);
+ CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
+ if (type == TETHERING_TYPE_USB) CHECK_FEATURE_SUPPORTED(TETHERING_USB_FEATURE);
+ else if (type == TETHERING_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(TETHERING_WIFI_FEATURE);
+ else if (type == TETHERING_TYPE_BT) CHECK_FEATURE_SUPPORTED(TETHERING_BT_FEATURE);
+
+ _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+ "parameter(tethering) is NULL\n");
+
+ __tethering_h *th = (__tethering_h *)tethering;
+ GDBusProxy *proxy = th->client_bus_proxy;
+ GDBusConnection *connection = th->client_bus;
+
+ switch (type) {
+ case TETHERING_TYPE_WIFI:
+ DBG("Disable wifi tethering..");
+ g_dbus_connection_signal_unsubscribe(connection,
+ sigs[E_SIGNAL_WIFI_TETHER_OFF].sig_id);
+
+ g_dbus_proxy_call(proxy, "disable_wifi_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_BT:
+ g_dbus_connection_signal_unsubscribe(connection,
+ sigs[E_SIGNAL_BT_TETHER_OFF].sig_id);
+
+ g_dbus_proxy_call(proxy, "disable_bt_tethering",
+ g_variant_new("(i)", TETHERING_ADDRESS_FAMILY_IPV6), G_DBUS_CALL_FLAGS_NONE, -1, th->cancellable,
+ (GAsyncReadyCallback) __disabled_cfm_cb, (gpointer)tethering);
+ break;
+
+ default:
+ ERR("Not supported tethering type [%d]\n", type);
+ DBG("-\n");
+ return TETHERING_ERROR_INVALID_PARAMETER;
+ }
+ DBG("-\n");
+ return TETHERING_ERROR_NONE;
+}
/**
* @internal
* @brief Disables the tethering, asynchronously.
ERR("Not supported type : %d\n", type);
break;
}
- INFO("- enabled: %s\n",(is_on & vconf_type)? "true" : "false");
+ INFO("- enabled: %s\n", (is_on & vconf_type) ? "true" : "false");
return is_on & vconf_type ? true : false;
}
err_msg = "Resource is busy";
break;
+ case TETHERING_ERROR_NOT_PERMITTED:
+ err_msg = "Operation is not permitted";
+ break;
+
default:
err_msg = "This should not be happened";
break;
char *interface = NULL;
char *mac_address = NULL;
char *ip_address = NULL;
+ char *ip6_address = NULL;
char *gateway_address = NULL;
+ char *gateway6_address = NULL;
char *subnet_mask = NULL;
+ char *prefix = NULL;
if (tethering_is_enabled(th, type) == FALSE) {
g_print("%s is not enabled\n",
tethering_get_mac_address(th, type, &mac_address);
tethering_get_ip_address(th, type, TETHERING_ADDRESS_FAMILY_IPV4,
&ip_address);
+ tethering_get_ip_address(th, type, TETHERING_ADDRESS_FAMILY_IPV6,
+ &ip6_address);
tethering_get_gateway_address(th, type, TETHERING_ADDRESS_FAMILY_IPV4,
&gateway_address);
+ tethering_get_gateway_address(th, type, TETHERING_ADDRESS_FAMILY_IPV6,
+ &gateway6_address);
tethering_get_subnet_mask(th, type, TETHERING_ADDRESS_FAMILY_IPV4,
&subnet_mask);
+ tethering_get_subnet_mask(th, type, TETHERING_ADDRESS_FAMILY_IPV6,
+ &prefix);
g_print("interface name : %s\n", interface);
g_print("mac address : %s\n", mac_address);
- g_print("ip address : %s\n", ip_address);
+ g_print("IPv4 address : %s\n", ip_address);
+ g_print("IPv6 address : %s\n", ip6_address);
g_print("gateway address: %s\n", gateway_address);
+ g_print("IPv6 gateway address: %s\n", gateway6_address);
g_print("subnet mask : %s\n", subnet_mask);
+ g_print("IPv6 prefix : %s\n", prefix);
if (interface)
free(interface);
free(mac_address);
if (ip_address)
free(ip_address);
+ if (ip6_address)
+ free(ip6_address);
if (gateway_address)
free(gateway_address);
if (subnet_mask)
free(subnet_mask);
+ if (gateway6_address)
+ free(gateway6_address);
+ if (prefix)
+ free(prefix);
return;
}
{
int ret = TETHERING_ERROR_NONE;
tethering_type_e type;
+ int address_type = 0;
+
+ printf("IPv4: 0, IPv6: 1\n");
+ ret = scanf("%d", &address_type);
if (!__get_tethering_type(&type))
return -1;
- ret = tethering_enable(th, type);
+ if (address_type)
+ ret = tethering_ipv6_enable(th, type);
+ else
+ ret = tethering_enable(th, type);
+
if (__is_err(ret) == true) {
printf("Fail to enable tethering\n");
return -1;
{
int ret = TETHERING_ERROR_NONE;
tethering_type_e type;
+ int address_type = 0;
+
+ printf("IPv4: 0, IPv6: 1\n");
+ ret = scanf("%d", &address_type);
if (!__get_tethering_type(&type))
return -1;
- ret = tethering_disable(th, type);
+ if (address_type)
+ ret = tethering_ipv6_disable(th, type);
+ else
+ ret = tethering_disable(th, type);
+
if (__is_err(ret) == true) {
printf("Fail to disable tethering\n");
return -1;