#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)
{
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;
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);
}
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)
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) {
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;