X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Fconnection_test.c;h=087ce68a0d7de02d6843fe20859d984f87e0517e;hb=47d6150437cba7fe5a3925990ef46c0226a65971;hp=71811446766bfd4d674416e0108fbb9797305633;hpb=ef1bc028fa1fb0c0a7eab20254a727bdfcd82c30;p=platform%2Fcore%2Fapi%2Fconnection.git diff --git a/test/connection_test.c b/test/connection_test.c index 7181144..087ce68 100755 --- a/test/connection_test.c +++ b/test/connection_test.c @@ -859,6 +859,8 @@ static void test_print_network_info(connection_profile_h profile, connection_add char *ip = NULL; char *subnet = NULL; char *gateway = NULL; + char *dhcp_server = NULL; + int dhcp_lease_duration = 0; char *dns1 = NULL; char *dns2 = NULL; char *proxy = NULL; @@ -893,6 +895,19 @@ static void test_print_network_info(connection_profile_h profile, connection_add g_free(gateway); } + if (connection_profile_get_dhcp_server_address(profile, address_family, &dhcp_server) != CONNECTION_ERROR_NONE) + printf("Fail to get DHCP Server address!\n"); + else { + printf("DHCP Server : %s\n", dhcp_server); + g_free(dhcp_server); + } + + if (connection_profile_get_dhcp_lease_duration(profile, address_family, &dhcp_lease_duration) != CONNECTION_ERROR_NONE) + printf("Fail to get DHCP lease duration!\n"); + else { + printf("DHCP lease duration : %d\n", dhcp_lease_duration); + } + if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE) printf("Fail to get subnet mask!\n"); else { @@ -1804,6 +1819,147 @@ int test_remove_route_ipv6(void) return 1; } +int test_add_route_entry(void) +{ + char ip_addr[100] = {0}; + char gateway[100] = {0}; + char if_name[40] = {0}; + int input; + bool input_rv; + int rv = 0; + + input_rv = test_get_user_int("Input Address type to get" + "(1:IPV4, 2:IPV6):", &input); + + if (input_rv == false) { + printf("Invalid input!!\n"); + return -1; + } + + switch (input) { + case 1: + if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false) + return -1; + + if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false) + return -1; + + if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false) + return -1; + + g_strstrip(ip_addr); + g_strstrip(gateway); + g_strstrip(if_name); + rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway); + if (rv != CONNECTION_ERROR_NONE) { + printf("Fail to get add new route [%d]\n", rv); + return -1; + } + printf("Add Route successfully\n"); + break; + + case 2: + if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false) + return -1; + + if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false) + return -1; + + if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false) + return -1; + + g_strstrip(ip_addr); + g_strstrip(gateway); + g_strstrip(if_name); + rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway); + if (rv != CONNECTION_ERROR_NONE) { + printf("Fail to get add new route [%d]\n", rv); + return -1; + } + printf("Add Route successfully\n"); + break; + + default: + printf("Wrong IP address family!!\n"); + return -1; + + } + + return 1; + +} + +int test_remove_route_entry(void) +{ + char ip_addr[100] = {0}; + char gateway[100] = {0}; + char if_name[40] = {0}; + int input; + bool input_rv; + int rv = 0; + + input_rv = test_get_user_int("Input Address type to get" + "(1:IPV4, 2:IPV6):", &input); + + if (input_rv == false) { + printf("Invalid input!!\n"); + return -1; + } + + switch (input) { + case 1: + if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false) + return -1; + + if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false) + return -1; + + if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false) + return -1; + + g_strstrip(ip_addr); + g_strstrip(gateway); + g_strstrip(if_name); + rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway); + if (rv != CONNECTION_ERROR_NONE) { + printf("Fail to remove the route [%s]\n", test_print_error(rv)); + return -1; + } + printf("Remove Route successfully\n"); + + break; + + case 2: + if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false) + return -1; + + if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false) + return -1; + + if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false) + return -1; + + g_strstrip(ip_addr); + g_strstrip(gateway); + g_strstrip(if_name); + rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway); + if (rv != CONNECTION_ERROR_NONE) { + printf("Fail to remove the route [%d]\n", rv); + return -1; + } + printf("Remove Route successfully\n"); + break; + + default: + printf("Wrong IP address family!!\n"); + return -1; + + } + + return 1; + +} + int test_get_bt_state(void) { int rv = 0; @@ -2022,7 +2178,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("x - Get ethernet cable state\n"); printf("B - Add IPv6 new route\n"); printf("C - Remove IPv6 route\n"); - printf("D - Get IPv6 address\n"); + printf("D - Add new route entry\n"); + printf("E - Remove route entry\n"); + printf("F - Get all IPv6 address\n"); printf(LOG_RED "0 - Exit \n" LOG_END); printf("ENTER - Show options menu.......\n"); } @@ -2134,6 +2292,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) rv = test_remove_route_ipv6(); break; case 'D': + rv = test_add_route_entry(); + break; + case 'E': + rv = test_remove_route_entry(); + break; + case 'F': rv = test_foreach_ipv6_address(); break; }