Implemented WPS feature 20/82420/1 accepted/tizen/common/20160805.130338 accepted/tizen/ivi/20160809.011153 accepted/tizen/mobile/20160809.011052 accepted/tizen/tv/20160809.011105 accepted/tizen/wearable/20160809.011125 submit/tizen/20160805.043713 submit/tizen/20160805.060940
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 3 Aug 2016 06:49:15 +0000 (15:49 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 3 Aug 2016 07:56:25 +0000 (16:56 +0900)
Change-Id: I868f063f7d97f37881a8ab79b774e365c11df56d
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
include/tethering.h
include/tethering_private.h
packaging/capi-network-tethering.spec
src/tethering.c
test/tethering_test.c

index 905b843e158c7077a82fda65cfab112fee34370d..26cf8f807b478e1ddfba250dc3ce68bd0bac16c8 100644 (file)
@@ -101,6 +101,7 @@ typedef enum
 typedef enum {
     TETHERING_WIFI_SECURITY_TYPE_NONE = 0,  /**< No Security type */
     TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK,  /**< WPA2_PSK */
+       TETHERING_WIFI_SECURITY_TYPE_WPS,  /**< WPA2_PSK */
 } tethering_wifi_security_type_e;
 
 /**
@@ -1320,6 +1321,36 @@ int tethering_wifi_is_port_filtering_enabled(tethering_h tethering, bool* filter
  */
 int tethering_wifi_set_vpn_passthrough_rule(tethering_h tethering, tethering_vpn_passthrough_type_e type, bool enable);
 
+/**
+ * @brief Pushes the WPS button to connect with Wi-Fi Tethering client. (WPS PBC)
+ * @since_tizen 3.0
+ * @remarks The WPS button should be pushed when client tries to connect with Soft AP by using WPS PBC.
+ * @param[in]  tethering  The tethering handle
+ * @return 0 on success, otherwise negative error value
+ * @retval  #TETHERING_ERROR_NONE  Successful
+ * @retval  #TETHERING_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #TETHERING_ERROR_OPERATION_FAILED  Operation failed
+ * @retval  #TETHERING_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval  #TETHERING_ERROR_NOT_SUPPORTED  API is not supported
+ */
+int tethering_wifi_push_wps_button(tethering_h tethering);
+
+/**
+ * @brief Sets the WPS PIN to connect with Wi-Fi Tethering client. (WPS PIN)
+ * @since_tizen 3.0
+ * @remarks The WPS PIN should be inserted when client tries to connect with Soft AP by using WPS PIN.
+ * @param[in]  tethering  The tethering handle
+ * @param[in]  wps_pin  The WPS PIN
+ * @return 0 on success, otherwise negative error value
+ * @retval  #TETHERING_ERROR_NONE  Successful
+ * @retval  #TETHERING_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #TETHERING_ERROR_OPERATION_FAILED  Operation failed
+ * @retval  #TETHERING_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval  #TETHERING_ERROR_NOT_SUPPORTED  API is not supported
+ */
+int tethering_wifi_set_wps_pin(tethering_h tethering, const char *wps_pin);
+
+
 /**
  * @}
  */
index c56723e5dfb2cf6e152722a967ac132dbc6e258e..1f753e80b31578e5ea3b10e35acd729fef1b0952 100644 (file)
@@ -246,6 +246,7 @@ typedef enum {
 #define TETHERING_DEFAULT_SSID "Tizen"
 #define TETHERING_WIFI_SECURITY_TYPE_OPEN_STR          "open"
 #define TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK_STR      "wpa2-psk"
+#define TETHERING_WIFI_SECURITY_TYPE_WPS_STR   "wps"
 #define TETHERING_ERROR_RECOVERY_MAX                   3
 #define SECURITY_TYPE_LEN      32
 #define PSK_ITERATION_COUNT    4096
index b0b41c8c72507dfc0e5c0e076cdda402f61d6452..46d65f9a5a5f2cc9c99db6efbecded838fce8cd7 100644 (file)
@@ -1,6 +1,6 @@
 Name:          capi-network-tethering
 Summary:       Tethering Framework
-Version:       1.0.40
+Version:       1.0.41
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index 4fca45846abb69a3fd165d54b6f6fd6810fb7693..f3780d889db9c8cda1765c6db49d5c393608fc51 100755 (executable)
@@ -163,7 +163,8 @@ static bool __any_tethering_is_enabled(tethering_h tethering)
 static tethering_error_e __set_security_type(const tethering_wifi_security_type_e security_type)
 {
        if (security_type != TETHERING_WIFI_SECURITY_TYPE_NONE &&
-                       security_type != TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK) {
+                       security_type != TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK &&
+                       security_type != TETHERING_WIFI_SECURITY_TYPE_WPS) {
                ERR("Invalid param\n");
                return TETHERING_ERROR_INVALID_PARAMETER;
        }
@@ -687,6 +688,8 @@ static void __handle_security_type_changed(GDBusConnection *connection, const gc
                security_type = TETHERING_WIFI_SECURITY_TYPE_NONE;
        else if (g_strcmp0(buf, TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK_STR) == 0)
                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 {
                SERR("Unknown type : %s\n", buf);
                g_free(buf);
@@ -2594,15 +2597,25 @@ API int tethering_wifi_set_security_type(tethering_h tethering, tethering_wifi_s
 
        __tethering_h *th = (__tethering_h *)tethering;
        tethering_error_e ret = TETHERING_ERROR_NONE;
+       char *sec_str = 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;
+                       break;
+               case TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK:
+                       sec_str = TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK_STR;
+                       break;
+               case TETHERING_WIFI_SECURITY_TYPE_WPS:
+                       sec_str = TETHERING_WIFI_SECURITY_TYPE_WPS_STR;
+                       break;
+               }
+
                __send_dbus_signal(th->client_bus,
-                               SIGNAL_NAME_SECURITY_TYPE_CHANGED,
-                               type == TETHERING_WIFI_SECURITY_TYPE_NONE ?
-                               TETHERING_WIFI_SECURITY_TYPE_OPEN_STR :
-                               TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK_STR);
+                               SIGNAL_NAME_SECURITY_TYPE_CHANGED, sec_str);
        }
        return ret;
 }
@@ -3862,3 +3875,74 @@ API int tethering_wifi_set_vpn_passthrough_rule(tethering_h tethering, tethering
        return TETHERING_ERROR_NONE;
 }
 
+API int tethering_wifi_push_wps_button(tethering_h tethering)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL");
+       __tethering_h *th = (__tethering_h *)tethering;
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GVariant *parameters = NULL;
+       int ret = 0;
+       GError *error = NULL;
+
+       parameters = g_dbus_proxy_call_sync(proxy, "push_wps_button",
+                       NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               return ret;
+       }
+
+       if (parameters != NULL) {
+               g_variant_get(parameters, "(u)", &ret);
+               g_variant_unref(parameters);
+       }
+
+       return TETHERING_ERROR_NONE;
+}
+
+API int tethering_wifi_set_wps_pin(tethering_h tethering, const char *wps_pin)
+{
+       CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE, TETHERING_WIFI_FEATURE);
+
+       _retvm_if(tethering == NULL, TETHERING_ERROR_INVALID_PARAMETER,
+                       "parameter(tethering) is NULL");
+       __tethering_h *th = (__tethering_h *)tethering;
+       GDBusProxy *proxy = th->client_bus_proxy;
+       GVariant *parameters = NULL;
+       int ret = 0;
+       GError *error = NULL;
+
+       parameters = g_dbus_proxy_call_sync(proxy, "set_wps_pin",
+                       g_variant_new("(s)", wps_pin), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (error) {
+               ERR("g_dbus_proxy_call_sync failed because  %s\n", error->message);
+
+               if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
+                       ret = TETHERING_ERROR_PERMISSION_DENIED;
+               else
+                       ret = TETHERING_ERROR_OPERATION_FAILED;
+
+               g_error_free(error);
+               return ret;
+       }
+
+       if (parameters != NULL) {
+               g_variant_get(parameters, "(u)", &ret);
+               g_variant_unref(parameters);
+       }
+
+       return TETHERING_ERROR_NONE;
+}
+
+
index 3d69e1c2e8e8bf3933db30e3aa87707b38d05b59..3ec2b7a6f5259d412a5859c9ec144c1ea9b23558 100755 (executable)
@@ -388,9 +388,25 @@ static bool __clients_foreach_cb(tethering_client_h client, void *data)
 
 static void __security_type_changed_cb(tethering_wifi_security_type_e changed_type, void *user_data)
 {
-       g_print("Wi-Fi Tethering Security type is changed to [%s]\n",
-                       changed_type == TETHERING_WIFI_SECURITY_TYPE_NONE ?
-                       "open" : "wpa2-psk");
+
+       char *sec_str = NULL;
+
+       switch (changed_type) {
+       case TETHERING_WIFI_SECURITY_TYPE_NONE:
+               sec_str = "open";
+               break;
+       case TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK:
+               sec_str = "wpa2-psk";
+               break;
+       case TETHERING_WIFI_SECURITY_TYPE_WPS:
+               sec_str = "wps";
+               break;
+       default:
+               sec_str = "unknown";
+               break;
+       }
+       g_print("Wi-Fi Tethering Security type is changed to [%s]\n", sec_str);
+
        return;
 }
 
@@ -455,6 +471,7 @@ static void __print_wifi_tethering_setting(tethering_h th)
 {
        char *ssid = NULL;
        char *passphrase = NULL;
+       char *sec_str = NULL;
        bool visibility = false;
        bool mac_filter = 0;
        bool forwarding_enabled = false;
@@ -488,11 +505,23 @@ static void __print_wifi_tethering_setting(tethering_h th)
        error = tethering_wifi_get_security_type(th, &security_type);
        if (error != TETHERING_ERROR_NONE)
                __is_err(error);
-       else
-               g_print("\t** WiFi tethering security_type : %s\n",
-                               security_type ==
-                               TETHERING_WIFI_SECURITY_TYPE_NONE ?
-                               "open" : "wpa2-psk");
+       else {
+               switch (security_type) {
+               case TETHERING_WIFI_SECURITY_TYPE_NONE:
+                       sec_str = "open";
+                       break;
+               case TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK:
+                       sec_str = "wpa2-psk";
+                       break;
+               case TETHERING_WIFI_SECURITY_TYPE_WPS:
+                       sec_str = "wps";
+                       break;
+               default:
+                       sec_str = "unknown";
+                       break;
+               }
+               g_print("\t** WiFi tethering security_type : %s\n", sec_str);
+       }
 
        error = tethering_wifi_get_mode(th, &hw_mode);
        if (error != TETHERING_ERROR_NONE)
@@ -721,7 +750,7 @@ static int test_tethering_wifi_set_security_type(void)
        int ret;
        int security_type;
 
-       printf("Input security type for Wi-Fi tethering (0:NONE, 1:WPA2_PSK)");
+       printf("Input security type for Wi-Fi tethering (0:NONE, 1:WPA2_PSK, 2:WPS)");
        ret = scanf("%9d", &security_type);
        if (ret < 0) {
                printf("scanf is failed!!\n");
@@ -974,7 +1003,7 @@ static int test_tethering_wifi_get_txpower(void)
                printf("Fail to get txpower!!\n");
                return -1;
        }
-       g_print("tethering_hostapd_get_txpower received [%d]\n",txpower);
+       g_print("tethering_hostapd_get_txpower received [%d]\n", txpower);
        return 1;
 }
 
@@ -1055,7 +1084,7 @@ static int test_tethering_wifi_enable_port_forwarding(void)
        printf("Wi-Fi tethring port forwarding(0:disable 1:enable): ");
        ret = scanf("%d", &enable);
 
-       ret =tethering_wifi_enable_port_forwarding(th, enable);
+       ret = tethering_wifi_enable_port_forwarding(th, enable);
        if (__is_err(ret) == true) {
                printf("Fail to enable port forwarding!\n");
                return -1;
@@ -1127,7 +1156,7 @@ static int test_tethering_wifi_enable_port_filtering(void)
        printf("Wi-Fi tethring port filtering(0:disable 1:enable): ");
        ret = scanf("%d", &enable);
 
-       ret =tethering_wifi_enable_port_filtering(th, enable);
+       ret = tethering_wifi_enable_port_filtering(th, enable);
        if (__is_err(ret) == true) {
                printf("Fail to enable port filtering!\n");
                return -1;
@@ -1228,6 +1257,36 @@ static int test_tethering_wifi_set_vpn_passthrough_rule(void)
        return 1;
 }
 
+static int test_tethering_wifi_push_wps_button(void)
+{
+       int ret = 0;
+
+       ret = tethering_wifi_push_wps_button(th);
+       if (__is_err(ret) == true) {
+               printf("Fail to get port filtering rule!\n");
+               return -1;
+       }
+
+       return 1;
+}
+
+static int test_tethering_wifi_set_wps_pin(void)
+{
+       int ret = 0;
+       char wps_pin[128];
+
+       printf("Input WPS PIN: ");
+       ret = scanf("%127s", wps_pin);
+
+       ret = tethering_wifi_set_wps_pin(th, wps_pin);
+       if (__is_err(ret) == true) {
+               printf("Fail to get port filtering rule!\n");
+               return -1;
+       }
+
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -1296,6 +1355,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("D       - Get port filtering rule\n");
                printf("E       - Get custom port filtering rule\n");
                printf("F       - Set vpn passthrough rule\n");
+               printf("G       - Push WPS button\n");
+               printf("H       - Set WPS PIN\n");
                printf("0       - \n");
                printf("ENTER  - Show options menu.......\n");
        }
@@ -1409,6 +1470,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'F':
                rv = test_tethering_wifi_set_vpn_passthrough_rule();
                break;
+       case 'G':
+               rv = test_tethering_wifi_push_wps_button();
+               break;
+       case 'H':
+               rv = test_tethering_wifi_set_wps_pin();
+               break;
        }
 
        if (rv == 1)