Implement API to get IPv6 addresses
[platform/core/api/connection.git] / test / connection_test.c
index 569fbe1..7181144 100755 (executable)
 
 #include <tizen_error.h>
 
-#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;}
+#define LOG_RED "\033[0;31m"
+#define LOG_GREEN "\033[0;32m"
+#define LOG_BROWN "\033[0;33m"
+#define LOG_BLUE "\033[0;34m"
+#define LOG_END "\033[0;m"
+
+#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1; }
 
 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
 
@@ -48,7 +54,7 @@ static bool test_get_user_string(const char *msg, char *buf, int buf_size)
                return false;
        }
 
-       buf[rv-1]='\0';
+       buf[rv-1] = '\0';
        return true;
 }
 
@@ -85,6 +91,110 @@ static const char *test_print_state(connection_profile_state_e state)
        }
 }
 
+static const char *test_print_connection_type(connection_type_e type)
+{
+       switch (type) {
+       case CONNECTION_TYPE_DISCONNECTED:
+               return "Disconnected";
+       case CONNECTION_TYPE_WIFI:
+               return "Wifi";
+       case CONNECTION_TYPE_CELLULAR:
+               return "Cellular";
+       case CONNECTION_TYPE_ETHERNET:
+               return "Ethernet";
+       case CONNECTION_TYPE_BT:
+               return "BT";
+       case CONNECTION_TYPE_NET_PROXY:
+               return "Net_Proxy";
+       default:
+               return "Unknown";
+       }
+}
+
+static const char *test_print_cellular_state(connection_cellular_state_e state)
+{
+       switch (state) {
+       case CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE:
+               return "Out of service";
+       case CONNECTION_CELLULAR_STATE_FLIGHT_MODE:
+               return "Flight mode";
+       case CONNECTION_CELLULAR_STATE_ROAMING_OFF:
+               return "Roaming off";
+       case CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE:
+               return "Call only available";
+       case CONNECTION_CELLULAR_STATE_AVAILABLE:
+               return "Available";
+       case CONNECTION_CELLULAR_STATE_CONNECTED:
+               return "Connected";
+       default:
+               return "Unknown";
+       }
+}
+
+static const char *test_print_wifi_state(connection_wifi_state_e state)
+{
+       switch (state) {
+       case CONNECTION_WIFI_STATE_DEACTIVATED:
+               return "Deactivated";
+       case CONNECTION_WIFI_STATE_DISCONNECTED:
+               return "Disconnected";
+       case CONNECTION_WIFI_STATE_CONNECTED:
+               return "Connected";
+       default:
+               return "Unknown";
+       }
+}
+
+static const char *test_print_cellular_service_type(connection_cellular_service_type_e type)
+{
+       switch (type) {
+       case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
+               return "Unknown";
+       case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET:
+               return "Internet";
+       case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
+               return "MMS";
+       case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET:
+               return "Prepaid internet";
+       case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS:
+               return "Prepaid MMS";
+       case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING:
+               return "Tethering";
+       case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION:
+               return "Application";
+       default:
+               return "Unknown";
+       }
+}
+
+static const char* test_print_cellular_auth_type(connection_cellular_auth_type_e type)
+{
+       switch (type) {
+       case CONNECTION_CELLULAR_AUTH_TYPE_PAP:
+               return "PAP";
+       case CONNECTION_CELLULAR_AUTH_TYPE_CHAP:
+               return "CHAP";
+       case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
+       default:
+               return "None";
+       }
+}
+
+static const char* test_print_cellular_pdn_type(connection_cellular_pdn_type_e type)
+{
+       switch (type) {
+       case CONNECTION_CELLULAR_PDN_TYPE_IPV4:
+               return "IPv4";
+       case CONNECTION_CELLULAR_PDN_TYPE_IPV6:
+               return "IPv6";
+       case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6:
+               return "Dual";
+       case CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN:
+       default:
+               return "Unknown";
+       }
+}
+
 static const char *test_print_error(connection_error_e error)
 {
        switch (error) {
@@ -192,9 +302,9 @@ static void test_connection_set_default_callback(connection_error_e result, void
 void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state,
                                                                void* user_data)
 {
-       if(state == CONNECTION_ETHERNET_CABLE_ATTACHED)
+       if (state == CONNECTION_ETHERNET_CABLE_ATTACHED)
                printf("Ethernet Cable Connected\n");
-       else if(state == CONNECTION_ETHERNET_CABLE_DETACHED)
+       else if (state == CONNECTION_ETHERNET_CABLE_DETACHED)
                printf("Ethernet Cable Disconnected\n");
 }
 
@@ -240,28 +350,22 @@ static bool test_get_user_selected_profile(connection_profile_h *profile, bool s
                        return false;
                }
 
-               if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) {
-                       char *essid;
-                       connection_profile_get_wifi_essid(profile_h, &essid);
-                       printf("%d. state:[%s], profile name:%s, essid:%s\n",
-                               profile_count, test_print_state(profile_state),
-                               profile_name, (essid)? essid : "");
-                       g_free(essid);
-
-                       profile_list[profile_count] = profile_h;
-                       profile_count++;
-               } else {
+               printf("%d. state:[%s], profile name:%s", profile_count,
+                               test_print_state(profile_state), profile_name);
+               if (profile_type == CONNECTION_PROFILE_TYPE_CELLULAR) {
                        connection_cellular_service_type_e service_type;
-                       if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
+                       if (connection_profile_get_cellular_service_type(
+                               profile_h, &service_type) !=
+                               CONNECTION_ERROR_NONE)
                                printf("Fail to get cellular service type!\n");
-                       }
 
-                       printf("%d. state:[%s], profile name:%s[%d]\n",
-                               profile_count, test_print_state(profile_state), profile_name, service_type);
-
-                       profile_list[profile_count] = profile_h;
-                       profile_count++;
+                       printf("[%s]",
+                               test_print_cellular_service_type(service_type));
                }
+               printf("\n");
+
+               profile_list[profile_count] = profile_h;
+               profile_count++;
 
                g_free(profile_name);
                if (profile_count >= 100)
@@ -378,6 +482,40 @@ static int test_update_cellular_info(connection_profile_h profile)
                }
        }
 
+       if (test_get_user_int("Input PdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
+               switch (input_int) {
+               case 1:
+                       rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
+                       break;
+               case 2:
+                       rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
+                       break;
+               case 3:
+                       rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
+                       break;
+               }
+
+               if (rv != CONNECTION_ERROR_NONE)
+                       return -1;
+       }
+
+       if (test_get_user_int("Input RoamPdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
+               switch (input_int) {
+               case 1:
+                       rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
+                       break;
+               case 2:
+                       rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
+                       break;
+               case 3:
+                       rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
+                       break;
+               }
+
+               if (rv != CONNECTION_ERROR_NONE)
+                       return -1;
+       }
+
        return 1;
 }
 
@@ -395,9 +533,35 @@ static int test_update_wifi_info(connection_profile_h profile)
        return 1;
 }
 
+static int test_update_dns_info(connection_profile_h profile,
+               connection_address_family_e address_family)
+{
+       int rv = 0;
+       char input_str[100] = {0,};
+       if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
+               rv = connection_profile_set_dns_address(profile,
+                               1,
+                               address_family,
+                               input_str);
+               if (rv != CONNECTION_ERROR_NONE)
+                       return -1;
+
+               if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
+                       rv = connection_profile_set_dns_address(profile,
+                                       2,
+                                       address_family,
+                                       input_str);
+                       if (rv != CONNECTION_ERROR_NONE)
+                               return -1;
+               }
+       }
+       return 1;
+}
+
 static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
 {
        int rv = 0;
+       int input_int = 0;
        char input_str[100] = {0,};
 
        if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
@@ -416,32 +580,25 @@ static int test_update_ip_info(connection_profile_h profile, connection_address_
                        return -1;
        }
 
-       if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
-               rv = connection_profile_set_gateway_address(profile,
+       if (test_get_user_int("Input Prefix Length - (Enter for skip) :", &input_int)) {
+               rv = connection_profile_set_prefix_length(profile,
                                                        address_family,
-                                                       input_str);
+                                                       input_int);
                if (rv != CONNECTION_ERROR_NONE)
                        return -1;
        }
 
-       if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
-               rv = connection_profile_set_dns_address(profile,
-                                                       1,
+       if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
+               rv = connection_profile_set_gateway_address(profile,
                                                        address_family,
                                                        input_str);
                if (rv != CONNECTION_ERROR_NONE)
                        return -1;
-
-               if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
-                       rv = connection_profile_set_dns_address(profile,
-                                                               2,
-                                                               address_family,
-                                                               input_str);
-                       if (rv != CONNECTION_ERROR_NONE)
-                               return -1;
-               }
        }
 
+       if (test_update_dns_info(profile, address_family) < 0)
+               return -1;
+
        return 1;
 }
 
@@ -492,21 +649,48 @@ static int test_update_proxy_info(connection_profile_h profile, connection_addre
        return 1;
 }
 
+
+
 static int test_update_network_info(connection_profile_h profile)
 {
        int rv = 0;
        int input_int = 0;
+       int dns_input = 0;
        int address_family = 0;
 
        test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
 
-       if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)"
+       if (test_get_user_int("Input IPv4/IPv6 Address Type (DHCP:1, Static:2, Auto:3)"
                                " - (Enter for skip) :", &input_int)) {
                switch (input_int) {
                case 1:
                        rv = connection_profile_set_ip_config_type(profile,
-                                                                  address_family,
-                                                                  CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+                                       address_family,
+                                       CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+                       if (test_get_user_int("Input DNS Address Type (Static:1, DHCP:2)"
+                                               " - (Enter for skip) :", &dns_input)) {
+                               switch (dns_input) {
+                               case CONNECTION_DNS_CONFIG_TYPE_STATIC:
+                                       rv = connection_profile_set_dns_config_type(
+                                                       profile,
+                                                       address_family,
+                                                       CONNECTION_DNS_CONFIG_TYPE_STATIC);
+                                       if (rv != CONNECTION_ERROR_NONE)
+                                               return -1;
+                                       if (test_update_dns_info(profile,
+                                                               address_family) == -1)
+                                               return -1;
+                                       break;
+                               case CONNECTION_DNS_CONFIG_TYPE_DYNAMIC:
+                                       rv = connection_profile_set_dns_config_type(
+                                                       profile,
+                                                       address_family,
+                                                       CONNECTION_DNS_CONFIG_TYPE_DYNAMIC);
+                                       if (rv != CONNECTION_ERROR_NONE)
+                                               return -1;
+                                       break;
+                               }
+                       }
                        break;
                case 2:
                        rv = connection_profile_set_ip_config_type(profile,
@@ -521,6 +705,11 @@ static int test_update_network_info(connection_profile_h profile)
                        if (test_update_proxy_info(profile, address_family) == -1)
                                return -1;
                        break;
+               case 3:
+                       rv = connection_profile_set_ip_config_type(profile,
+                                                               address_family,
+                                                               CONNECTION_IP_CONFIG_TYPE_AUTO);
+                       break;
                default:
                        return -1;
                }
@@ -536,6 +725,8 @@ static int test_update_network_info(connection_profile_h profile)
 static void test_print_cellular_info(connection_profile_h profile)
 {
        connection_cellular_service_type_e service_type;
+       connection_cellular_pdn_type_e pdn_type;
+       connection_cellular_pdn_type_e roam_pdn_type;
        char *apn = NULL;
        connection_cellular_auth_type_e auth_type;
        char *user_name = NULL;
@@ -548,7 +739,17 @@ static void test_print_cellular_info(connection_profile_h profile)
        if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
                printf("Fail to get cellular service type!\n");
        else
-               printf("Cellular service type : %d\n", service_type);
+               printf("Cellular service type : %s\n", test_print_cellular_service_type(service_type));
+
+       if (connection_profile_get_cellular_pdn_type(profile, &pdn_type) != CONNECTION_ERROR_NONE)
+               printf("Fail to get cellular pdn type!\n");
+       else
+               printf("Cellular pdn type : %s\n", test_print_cellular_pdn_type(pdn_type));
+
+       if (connection_profile_get_cellular_roam_pdn_type(profile, &roam_pdn_type) != CONNECTION_ERROR_NONE)
+               printf("Fail to get cellular roam pdn type!\n");
+       else
+               printf("Cellular roam pdn type : %s\n", test_print_cellular_pdn_type(roam_pdn_type));
 
        if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
                printf("Fail to get cellular APN!\n");
@@ -560,7 +761,7 @@ static void test_print_cellular_info(connection_profile_h profile)
        if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
                printf("Fail to get auth info!\n");
        else {
-               printf("Cellular auth type : %d\n", auth_type);
+               printf("Cellular auth type : %s\n", test_print_cellular_auth_type(auth_type));
                printf("Cellular user_name : %s\n", user_name);
                printf("Cellular password : %s\n", password);
                g_free(user_name);
@@ -655,14 +856,16 @@ static void test_print_wifi_info(connection_profile_h profile)
 static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
 {
        char *interface_name = NULL;
-       connection_ip_config_type_e ip_type;
        char *ip = NULL;
        char *subnet = NULL;
        char *gateway = NULL;
        char *dns1 = NULL;
        char *dns2 = NULL;
-       connection_proxy_type_e proxy_type;
        char *proxy = NULL;
+       int prefix_len;
+       connection_ip_config_type_e ip_type;
+       connection_proxy_type_e proxy_type;
+       connection_dns_config_type_e dns_type;
 
        if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
                printf("Fail to get interface name!\n");
@@ -683,6 +886,13 @@ static void test_print_network_info(connection_profile_h profile, connection_add
                g_free(ip);
        }
 
+       if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
+               printf("Fail to get gateway!\n");
+       else {
+               printf("Gateway : %s\n", gateway);
+               g_free(gateway);
+       }
+
        if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
                printf("Fail to get subnet mask!\n");
        else {
@@ -690,12 +900,15 @@ static void test_print_network_info(connection_profile_h profile, connection_add
                g_free(subnet);
        }
 
-       if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
-               printf("Fail to get gateway!\n");
-       else {
-               printf("Gateway : %s\n", gateway);
-               g_free(gateway);
-       }
+       if (connection_profile_get_prefix_length(profile, address_family, &prefix_len) != CONNECTION_ERROR_NONE)
+               printf("Fail to get prefix length!\n");
+       else
+               printf("Prefix length : %d\n", prefix_len);
+
+       if (connection_profile_get_dns_config_type(profile, address_family, &dns_type) != CONNECTION_ERROR_NONE)
+               printf("Fail to get DNS configuration type!\n");
+       else
+               printf("DNS configuration type : %d\n", dns_type);
 
        if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
                printf("Fail to get DNS1!\n");
@@ -790,7 +1003,8 @@ int test_get_network_state(void)
                return -1;
        }
 
-       printf("Retval = [%s] network connection state [%d]\n", test_print_error(rv), net_state);
+       printf("Retval = [%s] network connection state [%s]\n",
+               test_print_error(rv), test_print_connection_type(net_state));
 
        return 1;
 }
@@ -807,7 +1021,8 @@ int test_get_cellular_state(void)
                return -1;
        }
 
-       printf("Retval = [%s] Cellular state [%d]\n", test_print_error(rv), cellular_state);
+       printf("Retval = [%s] Cellular state [%s]\n",
+               test_print_error(rv), test_print_cellular_state(cellular_state));
 
        return 1;
 }
@@ -824,7 +1039,8 @@ int test_get_wifi_state(void)
                return -1;
        }
 
-       printf("Retval = [%s] WiFi state [%d]\n", test_print_error(rv), wifi_state);
+       printf("Retval = [%s] WiFi state [%s]\n",
+               test_print_error(rv), test_print_wifi_state(wifi_state));
 
        return 1;
 }
@@ -849,16 +1065,16 @@ int test_get_current_proxy(void)
 int test_get_current_ip(void)
 {
        char *ip_addr = NULL;
-       int input;
-       bool rv;
+       int input;
+       bool rv;
 
-       rv = test_get_user_int("Input Address type to get"
-                       "(1:IPV4, 2:IPV6):", &input);
+       rv = test_get_user_int("Input Address type to get"
+               "(1:IPV4, 2:IPV6):", &input);
 
-       if (rv == false) {
-               printf("Invalid input!!\n");
-               return -1;
-       }
+       if (rv == false) {
+               printf("Invalid input!!\n");
+               return -1;
+       }
 
        switch (input) {
        case 1:
@@ -894,9 +1110,9 @@ int test_get_call_statistics_info(void)
        connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
        printf("last recv data size [%lld]\n", rv);
        connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
-       printf("last sent data size [%lld]\n",rv );
+       printf("last sent data size [%lld]\n", rv);
        connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
-       printf("total received data size [%lld]\n",rv );
+       printf("total received data size [%lld]\n", rv);
        connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
        printf("total sent data size [%lld]\n", rv);
 
@@ -910,9 +1126,9 @@ int test_get_wifi_call_statistics_info(void)
        connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
        printf("WiFi last recv data size [%lld]\n", rv);
        connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
-       printf("WiFi last sent data size [%lld]\n",rv );
+       printf("WiFi last sent data size [%lld]\n", rv);
        connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
-       printf("WiFi total received data size [%lld]\n",rv );
+       printf("WiFi total received data size [%lld]\n", rv);
        connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
        printf("WiFi total sent data size [%lld]\n", rv);
 
@@ -1258,6 +1474,7 @@ int test_get_profile_info(void)
 {
        connection_profile_type_e prof_type;
        connection_profile_state_e profile_state;
+       connection_profile_state_e profile_ipv6_state;
        connection_profile_h profile;
        char *profile_name = NULL;
        int address_family = 0;
@@ -1275,11 +1492,18 @@ int test_get_profile_info(void)
        }
 
        if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
-               printf("Fail to get profile state\n");
+               printf("Fail to get profile IPv4 state\n");
                return -1;
        } else
                printf("Profile State : %s\n", test_print_state(profile_state));
 
+       if (connection_profile_get_ipv6_state(profile, &profile_ipv6_state) != CONNECTION_ERROR_NONE) {
+               printf("Fail to get profile IPv6 state\n");
+               return -1;
+       } else
+               printf("Profile IPv6 State : %s\n", test_print_state(profile_ipv6_state));
+
+
        if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
                return -1;
 
@@ -1686,24 +1910,59 @@ int test_reset_profile(void)
                return -1;
        }
 
-       if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) {
+       if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE)
+               return -1;
+
+       return 1;
+}
+
+static bool test_get_ipv6_address_callback(char *ipv6_address, void* user_data)
+{
+       printf("IPv6 Address : %s\n", ipv6_address);
+       return true;
+}
+
+int test_foreach_ipv6_address(void)
+{
+       int rv = 0;
+       int type;
+       connection_type_e conn_type;
+
+       test_get_user_int("Input Connection Type(1: WiFi 2: Ethernet) :", &type);
+
+       switch (type) {
+       case 1:
+               conn_type = CONNECTION_TYPE_WIFI;
+               break;
+       case 2:
+               conn_type = CONNECTION_TYPE_ETHERNET;
+               break;
+       default:
+               printf("Wrong number!!\n");
+               return -1;
+       }
+
+       rv = connection_foreach_ipv6_address(connection, conn_type, test_get_ipv6_address_callback, NULL);
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Fail to get IPv6 address\n");
                return -1;
        }
 
        return 1;
 }
 
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
-       mainloop = g_main_loop_new (NULL, FALSE);
+       mainloop = g_main_loop_new(NULL, FALSE);
 
        GIOChannel *channel = g_io_channel_unix_new(0);
-       g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread,NULL );
+       g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
 
        printf("Test Thread created...\n");
 
-       g_main_loop_run (mainloop);
+       g_main_loop_run(mainloop);
 
        return 0;
 }
@@ -1728,42 +1987,43 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        if (*a == '\n' || *a == '\r') {
                printf("\n\n Network Connection API Test App\n\n");
                printf("Options..\n");
-               printf("1       - Create Handle and set callbacks\n");
-               printf("2       - Destroy Handle(unset callbacks automatically)\n");
-               printf("3       - Get network state\n");
-               printf("4       - Get cellular state (please insert SIM Card)\n");
-               printf("5       - Get wifi state (please turn on WiFi)\n");
-               printf("6       - Get current proxy address \n");
-               printf("7       - Get current Ip address\n");
-               printf("8       - Get cellular data call statistics\n");
-               printf("9       - Get WiFi data call statistics\n");
-               printf("a       - Get Profile list\n");
-               printf("b       - Get Connected Profile list\n");
-               printf("c       - Get Current profile\n");
-               printf("d       - Open connection with profile\n");
-               printf("e       - Get default cellular service by type\n");
-               printf("f       - Set default cellular service by type\n");
-               printf("g       - Close connection with profile\n");
-               printf("h       - Add profile(Cellular and Wifi only)\n");
-               printf("i       - Remove profile(Cellular:delete, WiFi:forgot)\n");
-               printf("j       - Update profile\n");
-               printf("k       - Get profile info\n");
-               printf("l       - Refresh profile info\n");
-               printf("m       - Set state changed callback\n");
-               printf("n       - Unset state changed callback\n");
-               printf("o       - Reset cellular data call statistics\n");
-               printf("p       - Reset WiFi data call statistics\n");
-               printf("q       - Add new route\n");
-               printf("r       - Remove a route\n");
-               printf("s       - Get Bluetooth state\n");
-               printf("t       - Get profile id\n");
-               printf("u       - Reset profile\n");
-               printf("v       - Get all cellular default profiles\n");
-               printf("w       - Get mac address\n");
-               printf("x       - Get ethernet cable state\n");
-               printf("B       - Add IPv6 new route\n");
-               printf("C       - Remove IPv6 route\n");
-               printf("0       - Exit \n");
+               printf(LOG_GREEN "1   - Create Handle and set callbacks\n" LOG_END);
+               printf("2   - Destroy Handle(unset callbacks automatically)\n");
+               printf(LOG_GREEN "3   - Get network state\n" LOG_END);
+               printf(LOG_GREEN "4   - Get cellular state (please insert SIM Card)\n" LOG_END);
+               printf(LOG_GREEN "5   - Get wifi state (please turn on WiFi)\n" LOG_END);
+               printf("6   - Get current proxy address \n");
+               printf("7   - Get current Ip address\n");
+               printf("8   - Get cellular data call statistics\n");
+               printf("9   - Get WiFi data call statistics\n");
+               printf(LOG_GREEN "a   - Get Profile list\n" LOG_END);
+               printf(LOG_GREEN "b   - Get Connected Profile list\n" LOG_END);
+               printf(LOG_GREEN "c   - Get Current profile\n" LOG_END);
+               printf("d   - Open connection with profile\n");
+               printf("e   - Get default cellular service by type\n");
+               printf("f   - Set default cellular service by type\n");
+               printf("g   - Close connection with profile\n");
+               printf("h   - Add profile(Cellular and Wifi only)\n");
+               printf("i   - Remove profile(Cellular:delete, WiFi:forgot)\n");
+               printf("j   - Update profile\n");
+               printf("k   - Get profile info\n");
+               printf("l   - Refresh profile info\n");
+               printf("m   - Set state changed callback\n");
+               printf("n   - Unset state changed callback\n");
+               printf("o   - Reset cellular data call statistics\n");
+               printf("p   - Reset WiFi data call statistics\n");
+               printf("q   - Add new route\n");
+               printf("r   - Remove a route\n");
+               printf("s   - Get Bluetooth state\n");
+               printf("t   - Get profile id\n");
+               printf("u   - Reset profile\n");
+               printf("v   - Get all cellular default profiles\n");
+               printf("w   - Get mac address\n");
+               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(LOG_RED "0   - Exit \n" LOG_END);
                printf("ENTER   - Show options menu.......\n");
        }
 
@@ -1873,6 +2133,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'C':
                rv = test_remove_route_ipv6();
                break;
+       case 'D':
+               rv = test_foreach_ipv6_address();
+               break;
        }
 
        if (rv == 1)