Change vpn_setting_test to select vpn provider for connecting 00/131000/1 ipsec
authorchleun.moon <chleun.moon@samsung.com>
Thu, 25 May 2017 04:21:03 +0000 (13:21 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Thu, 25 May 2017 04:21:12 +0000 (13:21 +0900)
Change-Id: Ic36b3d1c9bcdb7cde8dadaad44967aaa217ca83c
Signed-off-by: cheoleun <chleun.moon@samsung.com>
packaging/capi-network-vpn-setting.spec
src/include/vpn-internal.h
test/vpn_test.c

index 268e0ad..eac039a 100755 (executable)
@@ -1,4 +1,4 @@
-%define ipsec_test no
+%define ipsec_test yes
 
 Name:       capi-network-vpn-setting
 Summary:    Default VPN Library
index 37f1b17..8d30df3 100755 (executable)
 
 #include "vpn.h"
 #include "common.h"
-
-#define LOGI(fmt, arg...) printf("%s:%d %s() " fmt "\n",  \
-                               __FILE__, __LINE__, __func__, ## arg)
-#define LOGW(fmt, arg...) printf("warning %s:%d %s() " fmt "\n", \
-                               __FILE__, __LINE__, __func__, ## arg)
-#define LOGE(fmt, arg...) printf("error %s:%d %s() " fmt "\n", \
-                               __FILE__, __LINE__, __func__, ## arg)
+#include "dlog.h"
 
 #undef LOG_TAG
 #define LOG_TAG "CAPI_NETWORK_VPN"
        do { \
                switch (log_level) { \
                case VPN_ERROR: \
-                       LOGE(format, ## args); \
+                       SLOGE(format, ## args); \
                        break; \
                case VPN_WARN: \
-                       LOGW(format, ## args); \
+                       SLOGW(format, ## args); \
                        break; \
                default: \
-                       LOGI(format, ## args); \
+                       SLOGI(format, ## args); \
                } \
        } while (0)
 
index 6bfb336..cebf075 100755 (executable)
@@ -270,9 +270,6 @@ static void _test_get_vpn_handle(vpn_h *handle_ptr)
 {
        assert(handle_ptr != NULL);
 
-       char name_str[128] = { 0 };
-       char host_str[128] = { 0 };
-       char domain_str[128] = { 0 };
        const char *name = NULL;
        const char *type = NULL;
        const char *host = NULL;
@@ -280,8 +277,11 @@ static void _test_get_vpn_handle(vpn_h *handle_ptr)
 
        GList *iter;
        GList *handles = vpn_get_vpn_handle_list();
+       int index = 1;
+       int num;
        for (iter = handles; iter != NULL; iter = iter->next) {
-               printf("\n Handle = %p\n", iter->data);
+               printf(" \n%d)\n", index++);
+               printf(" Handle = %p\n", iter->data);
                vpn_get_vpn_info_name(iter->data, &name);
                vpn_get_vpn_info_type(iter->data, &type);
                vpn_get_vpn_info_host(iter->data, &host);
@@ -293,20 +293,27 @@ static void _test_get_vpn_handle(vpn_h *handle_ptr)
        }
 
        printf("==================================\n");
-       printf(" Please ENTER Name: ");
-       if (scanf(" %127s", name_str) < 0)
+       printf(" Please ENTER Number: ");
+       if (scanf(" %d", &num) < 0)
                printf("Error in Reading Host String\n");
 
-       printf("==================================\n");
-       printf(" Please ENTER Host: ");
-       if (scanf(" %127s", host_str) < 0)
-               printf("Error in Reading Host String\n");
-
-       printf(" Please ENTER Domain: ");
-       if (scanf(" %127s", domain_str) < 0)
-               printf("Error in Reading Domain String\n");
+       if (num < index) {
+               int i = 1;
+               for (iter = handles; iter != NULL; iter = iter->next) {
+                       if (i == num) {
+                               vpn_get_vpn_info_name(iter->data, &name);
+                               vpn_get_vpn_info_type(iter->data, &type);
+                               vpn_get_vpn_info_host(iter->data, &host);
+                               vpn_get_vpn_info_domain(iter->data, &domain);
+                               vpn_get_vpn_handle(name, host, domain, handle_ptr);
+                               break;
+                       }
+                       i++;
+               }
+       }
+       else
+               printf("Error\n");
 
-       vpn_get_vpn_handle(name_str, host_str, domain_str, handle_ptr);
 }
 
 static void _test_get_user_input(char *buf, char *what)
@@ -588,7 +595,7 @@ static int __test_deinit()
        int i = 0;
 
        for (i = 0; i < IPSEC_KVS_MAX; i++)
-               g_free(ipsec_setting_kvs[i].value)
+               g_free(ipsec_setting_kvs[i].value);
 
        rv = vpn_settings_deinit();
        if (rv != VPN_ERROR_NONE) {
@@ -773,9 +780,12 @@ static int __set_vpn_settings_ipsec_kvs()
        int rv = 0;
        int i = 0;
        for (i = 0; i < IPSEC_KVS_MAX; i++) {
-               if(ipsec_setting_kvs[i].value)
+               if (ipsec_setting_kvs[i].value) {
+                       if (i == IPSEC_RIGHT_ADDRS) 
+                               rv = vpn_settings_set_host(ipsec_setting_kvs[i].value);
                        rv = vpn_settings_set_specific(ipsec_setting_kvs[i].key, ipsec_setting_kvs[i].value);
-               if(rv != VPN_ERROR_NONE)
+               }
+               if (rv != VPN_ERROR_NONE)
                        break;
        }
        return rv;