guint Added_sig_id = 0;
guint Updated_sig_id = 0;
guint deleted_sig_id = 0;
-gboolean tethering_disable(Tethering *obj, GDBusMethodInvocation *context);
-gboolean tethering_get_station_info(Tethering *obj,
- GDBusMethodInvocation *context);
-gboolean tethering_get_data_packet_usage(Tethering *obj,
- GDBusMethodInvocation *context);
-gboolean softap_get_station_info(Softap *obj,
- GDBusMethodInvocation *context);
Tethering *_get_tethering_obj(void)
{
return TRUE;
}
-gboolean tethering_disable(Tethering *obj, GDBusMethodInvocation *context)
-{
- int ret = MOBILE_AP_ERROR_NONE;
-
- DBG("+\n");
- g_assert(obj != NULL);
- g_assert(context != NULL);
-
- if (_mobileap_is_disabled()) {
- ERR("Mobile hotspot has not been enabled\n");
- ret = MOBILE_AP_ERROR_NOT_ENABLED;
- tethering_complete_disable(obj, context, MOBILE_AP_DISABLE_CFM, ret);
- return FALSE;
- }
-
- if (_mobileap_get_ipv6_state(MOBILE_AP_STATE_WIFI))
- _disable_wifi_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV6);
- else
- _disable_wifi_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV4);
-
-#ifndef TIZEN_FEATURE_HEADLESS
- if (_mobileap_get_ipv6_state(MOBILE_AP_STATE_BT))
- _disable_bt_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV6);
- else
- _disable_bt_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV4);
-
- _disable_usb_tethering(obj);
-#endif
-
- tethering_complete_disable(obj, context, MOBILE_AP_DISABLE_CFM, ret);
-
- return TRUE;
-}
-
-gboolean tethering_get_station_info(Tethering *obj,
- GDBusMethodInvocation *context)
-{
- DBG("+\n");
-
- GVariant *var = NULL;
-
- g_assert(obj != NULL);
- g_assert(context != NULL);
-
- var = _station_info_foreach();
-
- g_dbus_method_invocation_return_value(context, var);
- g_variant_unref(var);
-
- DBG("-\n");
- return TRUE;
-}
-
-gboolean tethering_get_data_packet_usage(Tethering *obj,
- GDBusMethodInvocation *context)
-{
- char *if_name = NULL;
- unsigned long long wifi_tx_bytes = 0;
- unsigned long long wifi_rx_bytes = 0;
- unsigned long long bt_tx_bytes = 0;
- unsigned long long bt_rx_bytes = 0;
- unsigned long long usb_tx_bytes = 0;
- unsigned long long usb_rx_bytes = 0;
- unsigned long long tx_bytes = 0;
- unsigned long long rx_bytes = 0;
-
- if (_get_network_interface_name(&if_name) == FALSE) {
- tethering_complete_get_data_packet_usage(obj, context,
- MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
- 0ULL, 0ULL);
- return FALSE;
- }
-
- if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI))
- _get_data_usage(WIFI_IF, if_name,
- &wifi_tx_bytes, &wifi_rx_bytes);
-
- if (_mobileap_is_enabled(MOBILE_AP_STATE_BT))
- _get_data_usage(BT_IF_ALL, if_name,
- &bt_tx_bytes, &bt_rx_bytes);
-
- if (_mobileap_is_enabled(MOBILE_AP_STATE_USB))
- _get_data_usage(USB_IF, if_name,
- &usb_tx_bytes, &usb_rx_bytes);
- free(if_name);
-
- tx_bytes = wifi_tx_bytes + bt_tx_bytes + usb_tx_bytes;
- rx_bytes = wifi_rx_bytes + bt_rx_bytes + usb_rx_bytes;
-
- tethering_complete_get_data_packet_usage(obj, context, MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
- tx_bytes, rx_bytes);
-
- return TRUE;
-}
-
-gboolean softap_get_station_info(Softap *obj,
- GDBusMethodInvocation *context)
-{
- DBG("+");
-
- GVariant *var = NULL;
-
- g_assert(obj != NULL);
- g_assert(context != NULL);
-
- var = _station_info_foreach();
-
- g_dbus_method_invocation_return_value(context, var);
- g_variant_unref(var);
-
- DBG("-");
- return TRUE;
-}
-
-gboolean tethering_set_hostapd_tx_power(Tethering *obj,
- GDBusMethodInvocation *context, gint txpower)
-{
- DBG("+\n");
-
- GVariant *var = NULL;
- int result = 0;
-
- g_assert(obj != NULL);
- g_assert(context != NULL);
- result = _set_hostapd_tx_power(txpower);
- var = g_variant_new("(u)", result);
-
- g_dbus_method_invocation_return_value(context, var);
- g_variant_unref(var);
-
- DBG("-\n");
- return TRUE;
-}
-
-gboolean tethering_get_hostapd_tx_power(Tethering *obj,
- GDBusMethodInvocation *context)
-{
- DBG("+\n");
-
- GVariant *var = NULL;
- unsigned int txpower = 0;
-
- g_assert(obj != NULL);
- g_assert(context != NULL);
- txpower = _get_hostapd_tx_power();
- var = g_variant_new("(u)", txpower);
- g_dbus_method_invocation_return_value(context, var);
- g_variant_unref(var);
-
- DBG("-\n");
- return TRUE;
-}
-
-gboolean tethering_push_wps_button(Tethering *obj,
- GDBusMethodInvocation *context)
-{
- mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
-
- DBG("+");
-
-#ifdef TIZEN_FEATURE_WLAN_BOARD_SPRD
- ret = _mh_core_push_wps_button();
-#else
- ret = MOBILE_AP_ERROR_NOT_PERMITTED;
-#endif
-
- tethering_complete_push_wps_button(obj, context, ret);
-
- return TRUE;
-}
-
static void __handle_dnsmasq_dhcp_status_changed_cb(GDBusConnection *connection,
const gchar *sender_name, const gchar *object_path,
const gchar *interface_name, const gchar *signal_name,
#endif
#include "mobileap_common.h"
-#include "mobileap_wifi.h"
+
#include "mobileap_bluetooth.h"
-#include "mobileap_usb.h"
+#include "mobileap_iptables.h"
+#include "mobileap_network.h"
#include "mobileap_notification.h"
+#include "mobileap_usb.h"
+#include "mobileap_wifi.h"
static GSList *station_list = NULL;
dpm_manager_destroy(dpm);
}
#endif
+
+gboolean tethering_disable(Tethering *obj, GDBusMethodInvocation *context)
+{
+ int ret = MOBILE_AP_ERROR_NONE;
+
+ DBG("+");
+ g_assert(obj != NULL);
+ g_assert(context != NULL);
+
+ if (_mobileap_is_disabled()) {
+ ERR("Mobile hotspot has not been enabled\n");
+ ret = MOBILE_AP_ERROR_NOT_ENABLED;
+ tethering_complete_disable(obj, context, MOBILE_AP_DISABLE_CFM, ret);
+ return FALSE;
+ }
+
+ if (_mobileap_get_ipv6_state(MOBILE_AP_STATE_WIFI))
+ _disable_wifi_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV6);
+ else
+ _disable_wifi_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV4);
+
+#ifndef TIZEN_FEATURE_HEADLESS
+ if (_mobileap_get_ipv6_state(MOBILE_AP_STATE_BT))
+ _disable_bt_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV6);
+ else
+ _disable_bt_tethering(obj, MOBILE_AP_ADDRESS_TYPE_IPV4);
+
+ _disable_usb_tethering(obj);
+#endif
+
+ tethering_complete_disable(obj, context, MOBILE_AP_DISABLE_CFM, ret);
+
+ return TRUE;
+}
+
+gboolean tethering_get_station_info(Tethering *obj,
+ GDBusMethodInvocation *context)
+{
+ DBG("+");
+
+ GVariant *var = NULL;
+
+ g_assert(obj != NULL);
+ g_assert(context != NULL);
+
+ var = _station_info_foreach();
+
+ g_dbus_method_invocation_return_value(context, var);
+ g_variant_unref(var);
+
+ DBG("-");
+ return TRUE;
+}
+
+gboolean tethering_get_data_packet_usage(Tethering *obj,
+ GDBusMethodInvocation *context)
+{
+ char *if_name = NULL;
+ unsigned long long wifi_tx_bytes = 0;
+ unsigned long long wifi_rx_bytes = 0;
+ unsigned long long bt_tx_bytes = 0;
+ unsigned long long bt_rx_bytes = 0;
+ unsigned long long usb_tx_bytes = 0;
+ unsigned long long usb_rx_bytes = 0;
+ unsigned long long tx_bytes = 0;
+ unsigned long long rx_bytes = 0;
+
+ if (_get_network_interface_name(&if_name) == FALSE) {
+ tethering_complete_get_data_packet_usage(obj, context,
+ MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
+ 0ULL, 0ULL);
+ return FALSE;
+ }
+
+ if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI))
+ _get_data_usage(WIFI_IF, if_name,
+ &wifi_tx_bytes, &wifi_rx_bytes);
+
+ if (_mobileap_is_enabled(MOBILE_AP_STATE_BT))
+ _get_data_usage(BT_IF_ALL, if_name,
+ &bt_tx_bytes, &bt_rx_bytes);
+
+ if (_mobileap_is_enabled(MOBILE_AP_STATE_USB))
+ _get_data_usage(USB_IF, if_name,
+ &usb_tx_bytes, &usb_rx_bytes);
+ free(if_name);
+
+ tx_bytes = wifi_tx_bytes + bt_tx_bytes + usb_tx_bytes;
+ rx_bytes = wifi_rx_bytes + bt_rx_bytes + usb_rx_bytes;
+
+ tethering_complete_get_data_packet_usage(obj, context, MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
+ tx_bytes, rx_bytes);
+
+ return TRUE;
+}
tethering_complete_disable_wifi_tethering(obj, context,
MOBILE_AP_DISABLE_WIFI_TETHERING_CFM, ret);
- if (ret != MOBILE_AP_ERROR_NONE)
- return FALSE;
-
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_reload_wifi_settings(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_set_mtu(mtu);
-
tethering_complete_set_mtu(obj, context, ret);
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_change_mac(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_change_mac(mac);
-
tethering_complete_change_mac(obj, context, ret);
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_enable_port_forwarding(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_enable_port_forwarding(enable);
-
tethering_complete_enable_port_forwarding(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_add_port_forwarding_rule(Tethering *obj, GDBusMethodInvocation *context,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_add_port_forwarding_rule(ifname, protocol, org_ip, org_port, final_ip, final_port);
-
tethering_complete_add_port_forwarding_rule(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_reset_port_forwarding_rule(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_reset_port_forwarding_rule();
-
tethering_complete_reset_port_forwarding_rule(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_enable_port_filtering(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_enable_port_filtering(enable);
-
tethering_complete_enable_port_filtering(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_add_port_filtering_rule(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_add_port_filtering_rule(port, protocol, allow);
-
tethering_complete_add_port_filtering_rule(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_add_custom_port_filtering_rule(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_add_custom_port_filtering_rule(port1, port2, protocol, allow);
-
tethering_complete_add_custom_port_filtering_rule(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_set_vpn_passthrough_rule(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_set_vpn_passthrough_rule(vpn_type, enable);
-
tethering_complete_set_vpn_passthrough_rule(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_set_wps_pin(Tethering *obj,
ret = MOBILE_AP_ERROR_NOT_PERMITTED;
#endif
- if (obj && context)
- tethering_complete_set_wps_pin(obj, context, ret);
+ tethering_complete_set_wps_pin(obj, context, ret);
+
+#ifdef TIZEN_FEATURE_WLAN_BOARD_SPRD
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
+#else
+ return TRUE;
+#endif
+}
+
+gboolean tethering_push_wps_button(Tethering *obj,
+ GDBusMethodInvocation *context)
+{
+ mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
+
+ DBG("+");
+
+#ifdef TIZEN_FEATURE_WLAN_BOARD_SPRD
+ ret = _mh_core_push_wps_button();
+#else
+ ret = MOBILE_AP_ERROR_NOT_PERMITTED;
+#endif
+
+ tethering_complete_push_wps_button(obj, context, ret);
#ifdef TIZEN_FEATURE_WLAN_BOARD_SPRD
return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
tethering_complete_enable_dhcp(obj, context, ret);
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_dhcp_range(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = _mh_core_execute_dhcp_server(rangestart, rangestop);
-
tethering_complete_dhcp_range(obj, context, ret);
- return TRUE;
+
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_get_wifi_tethering_passphrase(Tethering *obj,
GDBusMethodInvocation *context)
{
+ mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
char passphrase_buf[MOBILE_AP_WIFI_KEY_MAX_LEN + 1] = {0, };
unsigned int len = 0;
- mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = __get_passphrase(passphrase_buf, sizeof(passphrase_buf), &len);
if (ret != MOBILE_AP_ERROR_NONE) {
- tethering_complete_get_wifi_tethering_passphrase(obj, context, NULL, 0, ret);
ERR("__get_passphrase is failed");
- return false;
+ len = 0;
}
- tethering_complete_get_wifi_tethering_passphrase(obj, context, passphrase_buf, len, ret);
+ tethering_complete_get_wifi_tethering_passphrase(obj, context,
+ (len > 0 ? passphrase_buf : NULL), len, ret);
- return true;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean tethering_set_wifi_tethering_passphrase(Tethering *obj,
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
ret = __get_passphrase(old_passphrase, sizeof(old_passphrase), &old_len);
- if (ret == MOBILE_AP_ERROR_NONE && old_len == passphrase_len && !g_strcmp0(old_passphrase, passphrase)) {
- ret = MOBILE_AP_ERROR_NONE;
- tethering_complete_set_wifi_tethering_passphrase(obj, context, ret);
- return true;
- }
+ if (ret == MOBILE_AP_ERROR_NONE &&
+ old_len == passphrase_len &&
+ !g_strcmp0(old_passphrase, passphrase))
+ goto DONE;
+
ret = __set_passphrase(passphrase, passphrase_len);
+
+DONE:
tethering_complete_set_wifi_tethering_passphrase(obj, context, ret);
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
+}
+
+gboolean tethering_set_hostapd_tx_power(Tethering *obj,
+ GDBusMethodInvocation *context, gint txpower)
+{
+ DBG("+");
- return true;
+ GVariant *var = NULL;
+ int result = 0;
+
+ g_assert(obj != NULL);
+ g_assert(context != NULL);
+ result = _set_hostapd_tx_power(txpower);
+ var = g_variant_new("(u)", result);
+
+ g_dbus_method_invocation_return_value(context, var);
+ g_variant_unref(var);
+
+ DBG("-");
+ return TRUE;
+}
+
+gboolean tethering_get_hostapd_tx_power(Tethering *obj,
+ GDBusMethodInvocation *context)
+{
+ DBG("+");
+
+ GVariant *var = NULL;
+ unsigned int txpower = 0;
+
+ g_assert(obj != NULL);
+ g_assert(context != NULL);
+ txpower = _get_hostapd_tx_power();
+ var = g_variant_new("(u)", txpower);
+ g_dbus_method_invocation_return_value(context, var);
+ g_variant_unref(var);
+
+ DBG("-");
+ return TRUE;
}
gboolean softap_enable(Softap *obj, GDBusMethodInvocation *context, GVariant *settings)
softap_emit_soft_ap_off(obj, NULL);
softap_complete_disable(obj, context, ret);
- if (ret != MOBILE_AP_ERROR_NONE)
- return FALSE;
-
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean softap_reload_settings(Softap *obj,
GDBusMethodInvocation *context, GVariant *settings)
{
mobile_ap_error_code_e ret = MOBILE_AP_ERROR_NONE;
- gboolean ret_val = TRUE;
softap_settings_t reload_settings = {"", "", "", "", "", 0, 0, 0, MOBILE_AP_MAX_WIFI_STA, 0, 0};
-
DBG("+");
g_assert(obj != NULL);
ret = _extract_softap_settings(settings, &reload_settings);
if (ret != MOBILE_AP_ERROR_NONE) {
ERR("Failed to get SoftAP settings");
- return FALSE;
+ goto DONE;
}
ret = _reload_softap_settings_for_softap(obj, &reload_settings);
- if (ret != MOBILE_AP_ERROR_NONE) {
+ if (ret != MOBILE_AP_ERROR_NONE)
ERR("_reload_softap_settings is failed\n");
- ret_val = FALSE;
- }
- softap_complete_reload_settings(obj, context, ret);
- return ret_val;
+DONE:
+ softap_complete_reload_settings(obj, context, ret);
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean softap_set_wps_pin(Softap *obj,
softap_complete_set_wps_pin(obj, context, ret);
+#ifdef TIZEN_FEATURE_WLAN_BOARD_SPRD
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
+#else
return TRUE;
+#endif
}
gboolean softap_push_wps_button(Softap *obj, GDBusMethodInvocation *context)
#endif
softap_complete_push_wps_button(obj, context, ret);
+#ifdef TIZEN_FEATURE_WLAN_BOARD_SPRD
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
+#else
return TRUE;
+#endif
}
gboolean softap_enable_dhcp(Softap *obj,
ret = _mh_core_execute_dhcp_server(NULL, NULL);
softap_complete_enable_dhcp(obj, context, ret);
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean softap_disable_dhcp(Softap *obj,
ret = _mh_core_terminate_dhcp_server();
softap_complete_disable_dhcp(obj, context, ret);
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
gboolean softap_enable_dhcp_with_range(Softap *obj,
ret = _mh_core_execute_dhcp_server(rangestart, rangestop);
softap_complete_enable_dhcp_with_range(obj, context, ret);
- return TRUE;
+ return (ret == MOBILE_AP_ERROR_NONE ? TRUE : FALSE);
}
softap_complete_get_dhcp_state(obj, context, state);
return TRUE;
+}
+
+gboolean softap_get_station_info(Softap *obj,
+ GDBusMethodInvocation *context)
+{
+ GVariant *var = NULL;
+
+ g_assert(obj != NULL);
+ g_assert(context != NULL);
+
+ var = _station_info_foreach();
+
+ g_dbus_method_invocation_return_value(context, var);
+ g_variant_unref(var);
+ return (var != NULL ? TRUE : FALSE);
}