From: chleun.moon Date: Thu, 25 May 2017 04:21:03 +0000 (+0900) Subject: Change vpn_setting_test to select vpn provider for connecting X-Git-Tag: submit/tizen/20170612.082510^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c495c1f171cebe92819428ac0b0eb423c32a7a3c;p=platform%2Fcore%2Fapi%2Fvpn-setting.git Change vpn_setting_test to select vpn provider for connecting Change-Id: Ic36b3d1c9bcdb7cde8dadaad44967aaa217ca83c Signed-off-by: cheoleun --- diff --git a/packaging/capi-network-vpn-setting.spec b/packaging/capi-network-vpn-setting.spec index 268e0ad..eac039a 100755 --- a/packaging/capi-network-vpn-setting.spec +++ b/packaging/capi-network-vpn-setting.spec @@ -1,4 +1,4 @@ -%define ipsec_test no +%define ipsec_test yes Name: capi-network-vpn-setting Summary: Default VPN Library diff --git a/src/include/vpn-internal.h b/src/include/vpn-internal.h index 37f1b17..8d30df3 100755 --- a/src/include/vpn-internal.h +++ b/src/include/vpn-internal.h @@ -24,13 +24,7 @@ #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" @@ -43,13 +37,13 @@ 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) diff --git a/test/vpn_test.c b/test/vpn_test.c index 6bfb336..cebf075 100755 --- a/test/vpn_test.c +++ b/test/vpn_test.c @@ -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;