INCLUDE_DIRECTORIES(${INCLUDE_DIR} ${CMAKE_SOURCE_DIR})
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED gio-2.0 gio-unix-2.0 dbus-1 dlog deviced vconf notification capi-network-connection capi-network-bluetooth appcore-common capi-network-wifi capi-network-wifi-direct alarm-service appsvc libcrypto key-manager libtzplatform-config)
+pkg_check_modules(pkgs REQUIRED gio-2.0 gio-unix-2.0 dbus-1 dlog deviced vconf notification capi-network-connection capi-network-bluetooth syspopup-caller
+ appcore-common capi-network-wifi capi-network-wifi-direct alarm-service appsvc libcrypto key-manager libtzplatform-config)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
#include <glib.h>
#include <gio/gio.h>
+#include "mobileap.h"
#include "mobileap_softap.h"
#include <mobileap-agent-server-stub.h>
+#define DPM_POLICY_WIFI_TETHERING "wifi-hotspot"
+#define DPM_POLICY_USB_TETHERING "usb-tethering"
+#define DPM_POLICY_BT_TETHERING "bluetooth-tethering"
+
gint _slist_find_station_by_interface(gconstpointer a, gconstpointer b);
gint _slist_find_station_by_mac(gconstpointer a, gconstpointer b);
gint _slist_find_station_by_ip_addr(gconstpointer a, gconstpointer b);
int _flush_ip_address(const char *interface);
int _execute_command(const char *cmd);
int _get_tethering_type_from_ip(const char *ip, mobile_ap_type_e *type);
+
+/* DPM */
+gboolean tethering_change_policy(Tethering *obj, GDBusMethodInvocation *context, gchar *name, gboolean state, void *user_data);
+int _is_allowed(mobile_ap_type_e type);
+
Tethering *_get_tethering_obj(void);
Softap *_get_softap_obj(void);
+
#endif /* __MOBILEAP_COMMON_H__ */
#include "mobileap.h"
+#define NETPOPUP "net-popup"
#define MH_NOTI_STR_MAX 50
#define MH_NOTI_PATH_MAX 256
-
#define MH_NOTI_ICON_PATH tzplatform_mkpath(TZ_SYS_RO_UG, "/res/images/ug-setting-mobileap-efl")
#define MH_NOTI_ICON_BT "noti_tethering_bluetooth.png"
#define MH_NOTI_ICON_GENERAL "noti_tethering_general.png"
int _delete_connected_noti(void);
void _create_tethering_active_noti(void);
void _create_bt_tethering_active_noti(void);
+void _create_security_restriction_noti(mobile_ap_type_e type);
#endif
<method name="hostapd_get_txpower">
<arg type="u" name="result" direction="out"/>
</method>
+
+ <method name="change_policy">
+ <arg type="s" name="name" direction="in"/>
+ <arg type="b" name="state" direction="in"/>
+ <arg type="u" name="result" direction="out"/>
+ </method>
<!-- Signal (D-Bus) definitions -->
<signal name="net_closed">
</signal>
g_context = context;
+ if (!_is_allowed(MOBILE_AP_TYPE_BT)) {
+ DBG("DPM policy restricts BT tethering\n");
+ ret = MOBILE_AP_ERROR_NOT_PERMITTED;
+ _create_security_restriction_noti(MOBILE_AP_TYPE_BT);
+ goto DONE;
+ }
+
_block_device_sleep();
ret = __init_bt(obj);
#include <dbus/dbus.h>
-#include "mobileap_notification.h"
#include "mobileap_common.h"
+#include "mobileap_wifi.h"
+#include "mobileap_bluetooth.h"
+#include "mobileap_usb.h"
+#include "mobileap_notification.h"
static GSList *station_list = NULL;
+static bool allow_wifi_tethering = true;
+static bool allow_bt_tethering = true;
+static bool allow_usb_tethering = true;
gint _slist_find_station_by_interface(gconstpointer a, gconstpointer b)
{
return MOBILE_AP_ERROR_INVALID_PARAM;
}
+
+gboolean tethering_change_policy(Tethering *obj, GDBusMethodInvocation *context, gchar *name, gboolean state, void *user_data)
+{
+ bool allowed = false;
+ int mobileap_state = VCONFKEY_MOBILE_HOTSPOT_MODE_NONE;
+
+ DBG("%s dpm policy is %d", name, state);
+ if (state)
+ allowed = true;
+
+ if (!strcmp(name, DPM_POLICY_WIFI_TETHERING)) {
+ vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &mobileap_state);
+ if (!allowed && (mobileap_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)) {
+ _create_security_restriction_noti(MOBILE_AP_TYPE_WIFI);
+ _disable_wifi_tethering(obj);
+ tethering_emit_wifi_off(obj, NULL);
+ }
+ allow_wifi_tethering = allowed;
+ } else if (!strcmp(name, DPM_POLICY_USB_TETHERING)) {
+ vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &mobileap_state);
+ if (!allowed && (mobileap_state & VCONFKEY_MOBILE_HOTSPOT_MODE_USB)) {
+ _create_security_restriction_noti(MOBILE_AP_TYPE_USB);
+ _disable_usb_tethering(obj);
+ tethering_emit_usb_off(obj, NULL);
+ }
+ allow_usb_tethering = allowed;
+ } else if (!strcmp(name, DPM_POLICY_BT_TETHERING)) {
+ vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &mobileap_state);
+ if (!allowed && (mobileap_state & VCONFKEY_MOBILE_HOTSPOT_MODE_BT)) {
+ _create_security_restriction_noti(MOBILE_AP_TYPE_BT);
+ _disable_bt_tethering(obj);
+ tethering_emit_bluetooth_off(obj, NULL);
+ }
+ allow_bt_tethering = allowed;
+ }
+
+ tethering_complete_change_policy(obj, context, MOBILE_AP_ERROR_NONE);
+
+ return TRUE;
+}
+
+int _is_allowed(mobile_ap_type_e type)
+{
+ bool allowed = false;
+
+ switch (type) {
+ case MOBILE_AP_TYPE_WIFI:
+ allowed = allow_wifi_tethering;
+ break;
+ case MOBILE_AP_TYPE_USB:
+ allowed = allow_usb_tethering;
+ break;
+ case MOBILE_AP_TYPE_BT:
+ allowed = allow_bt_tethering;
+ break;
+ default:
+ break;
+ }
+
+ return allowed;
+}
g_signal_connect(tethering_obj, "handle-dhcp-range",
G_CALLBACK(tethering_dhcp_range), NULL);
+ /* DPM */
+ g_signal_connect(tethering_obj, "handle-change-policy",
+ G_CALLBACK(tethering_change_policy), NULL);
+
g_signal_connect(softap_obj, "handle-enable",
G_CALLBACK(softap_enable), NULL);
g_signal_connect(softap_obj, "handle-disable",
}
return 0;
}
+
int main(int argc, char **argv)
{
int ret = 0;
#include <notification_text_domain.h>
#include <notification_internal.h>
#include <bluetooth.h>
+#include <bundle.h>
#include <bundle_internal.h>
+#include <syspopup_caller.h>
#ifndef TIZEN_TV
#include <appsvc.h>
#endif
return;
}
+
+void _create_security_restriction_noti(mobile_ap_type_e type)
+{
+ bundle *b = NULL;
+ char restricted_type[MAX_BUF_SIZE] = {0, };
+ int ret;
+
+ switch (type) {
+ case MOBILE_AP_TYPE_WIFI:
+ g_strlcpy(restricted_type, "wifi tethering", MAX_BUF_SIZE - 1);
+ break;
+ case MOBILE_AP_TYPE_USB:
+ g_strlcpy(restricted_type, "usb tethering", MAX_BUF_SIZE - 1);
+ break;
+ case MOBILE_AP_TYPE_BT:
+ g_strlcpy(restricted_type, "bt tethering", MAX_BUF_SIZE - 1);
+ break;
+ default:
+ ERR("Invalid type.\n");
+ return;
+ }
+
+ b = bundle_create();
+
+ bundle_add(b, "_SYSPOPUP_TYPE_", "toast_popup");
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "security restriction");
+ bundle_add(b, "_RESTRICTED_TYPE_", restricted_type);
+
+ DBG("Launch security restriction alert network popup");
+ ret = syspopup_launch(NETPOPUP, b);
+ if (ret < 0)
+ ERR("Fail to launch syspopup");
+
+ bundle_free(b);
+
+ return;
+}
g_context = context;
+ if (!_is_allowed(MOBILE_AP_TYPE_USB)) {
+ DBG("DPM policy restricts USB tethering\n");
+ ret = MOBILE_AP_ERROR_NOT_PERMITTED;
+ _create_security_restriction_noti(MOBILE_AP_TYPE_USB);
+ goto DONE;
+ }
+
ret = _enable_usb_tethering(obj);
if (ret != MOBILE_AP_ERROR_NONE) {
ERR("_enable_usb_tethering() is failed : %d\n", ret);
}
g_context = context;
+ if (!_is_allowed(MOBILE_AP_TYPE_WIFI)) {
+ DBG("DPM policy restricts Wi-Fi tethering\n");
+ ret = MOBILE_AP_ERROR_NOT_PERMITTED;
+ _create_security_restriction_noti(MOBILE_AP_TYPE_WIFI);
+ goto DONE;
+ }
+
wifi_settings.ssid = g_strdup(ssid);
if (security_type == SOFTAP_SECURITY_TYPE_WPA2_PSK) {
wifi_settings.key = g_strdup(key);