2 * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include "net_connection.h"
25 #include <tizen_error.h>
27 #define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;}
29 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
31 connection_h connection = NULL;
32 static GSList *state_cb_list = NULL;
35 static bool test_get_user_string(const char *msg, char *buf, int buf_size)
37 if (msg == NULL || buf == NULL || buf_size < 2)
42 memset(buf, 0, buf_size);
43 rv = read(0, buf, buf_size - 1);
45 if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
55 static bool test_get_user_int(const char *msg, int *num)
57 if (msg == NULL || num == NULL)
63 rv = read(0, buf, 32);
65 if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
72 static const char *test_print_state(connection_profile_state_e state)
75 case CONNECTION_PROFILE_STATE_DISCONNECTED:
76 return "Disconnected";
77 case CONNECTION_PROFILE_STATE_ASSOCIATION:
79 case CONNECTION_PROFILE_STATE_CONFIGURATION:
80 return "Configuration";
81 case CONNECTION_PROFILE_STATE_CONNECTED:
88 static const char *test_print_error(connection_error_e error)
91 case CONNECTION_ERROR_NONE:
92 return "CONNECTION_ERROR_NONE";
93 case CONNECTION_ERROR_INVALID_PARAMETER:
94 return "CONNECTION_ERROR_INVALID_PARAMETER";
95 case CONNECTION_ERROR_OUT_OF_MEMORY:
96 return "CONNECTION_ERROR_OUT_OF_MEMORY";
97 case CONNECTION_ERROR_INVALID_OPERATION:
98 return "CONNECTION_ERROR_INVALID_OPERATION";
99 case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
100 return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
101 case CONNECTION_ERROR_OPERATION_FAILED:
102 return "CONNECTION_ERROR_OPERATION_FAILED";
103 case CONNECTION_ERROR_ITERATOR_END:
104 return "CONNECTION_ERROR_ITERATOR_END";
105 case CONNECTION_ERROR_NO_CONNECTION:
106 return "CONNECTION_ERROR_NO_CONNECTION";
107 case CONNECTION_ERROR_NOW_IN_PROGRESS:
108 return "CONNECTION_ERROR_NOW_IN_PROGRESS";
109 case CONNECTION_ERROR_ALREADY_EXISTS:
110 return "CONNECTION_ERROR_ALREADY_EXISTS";
111 case CONNECTION_ERROR_OPERATION_ABORTED:
112 return "CONNECTION_ERROR_OPERATION_ABORTED";
113 case CONNECTION_ERROR_DHCP_FAILED:
114 return "CONNECTION_ERROR_DHCP_FAILED";
115 case CONNECTION_ERROR_INVALID_KEY:
116 return "CONNECTION_ERROR_INVALID_KEY";
117 case CONNECTION_ERROR_NO_REPLY:
118 return "CONNECTION_ERROR_NO_REPLY";
119 case CONNECTION_ERROR_PERMISSION_DENIED:
120 return "CONNECTION_ERROR_PERMISSION_DENIED";
121 case CONNECTION_ERROR_NOT_SUPPORTED:
122 return "CONNECTION_ERROR_NOT_SUPPORTED";
124 return "CONNECTION_ERROR_UNKNOWN";
128 static void test_type_changed_callback(connection_type_e type, void* user_data)
130 printf("Type changed callback, connection type : %d\n", type);
133 static void test_ip_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
135 printf("IP changed callback, IPv4 address : %s, IPv6 address : %s\n",
136 ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
139 static void test_proxy_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
141 printf("Proxy changed callback, IPv4 address : %s, IPv6 address : %s\n",
142 ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
145 static void test_profile_state_callback(connection_profile_state_e state, void* user_data)
148 connection_profile_h profile = user_data;
153 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE)
156 printf("[%s] : %s\n", test_print_state(state), profile_name);
157 g_free(profile_name);
160 static void test_connection_opened_callback(connection_error_e result, void* user_data)
162 if (result == CONNECTION_ERROR_NONE)
163 printf("Connection open Succeeded\n");
165 printf("Connection open Failed, err : %d\n", result);
168 static void test_connection_closed_callback(connection_error_e result, void* user_data)
170 if (result == CONNECTION_ERROR_NONE)
171 printf("Connection close Succeeded\n");
173 printf("Connection close Failed, err : %d\n", result);
176 static void test_connection_reset_profile_callback(connection_error_e result, void* user_data)
178 if (result == CONNECTION_ERROR_NONE)
179 printf("Reset profile Succeeded\n");
181 printf("Reset profile Failed, err : [%s]\n", test_print_error(result));
184 static void test_connection_set_default_callback(connection_error_e result, void* user_data)
186 if (result == CONNECTION_ERROR_NONE)
187 printf("Default profile setting Succeeded\n");
189 printf("Default profile setting Failed, err : %d\n", result);
192 void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state,
195 if(state == CONNECTION_ETHERNET_CABLE_ATTACHED)
196 printf("Ethernet Cable Connected\n");
197 else if(state == CONNECTION_ETHERNET_CABLE_DETACHED)
198 printf("Ethernet Cable Disconnected\n");
201 static bool test_get_user_selected_profile(connection_profile_h *profile, bool select)
206 connection_profile_type_e profile_type;
207 connection_profile_state_e profile_state;
208 connection_profile_iterator_h profile_iter;
209 connection_profile_h profile_h;
211 connection_profile_h profile_list[100] = {0,};
212 int profile_count = 0;
214 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
215 if (rv != CONNECTION_ERROR_NONE) {
216 printf("Fail to get profile iterator [%d]\n", rv);
220 while (connection_profile_iterator_has_next(profile_iter)) {
221 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
222 printf("Fail to get profile handle\n");
226 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
227 printf("Fail to get profile name\n");
231 if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) {
232 printf("Fail to get profile type\n");
233 g_free(profile_name);
237 if (connection_profile_get_state(profile_h, &profile_state) != CONNECTION_ERROR_NONE) {
238 printf("Fail to get profile state\n");
239 g_free(profile_name);
243 if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) {
245 connection_profile_get_wifi_essid(profile_h, &essid);
246 printf("%d. state:[%s], profile name:%s, essid:%s\n",
247 profile_count, test_print_state(profile_state),
248 profile_name, (essid)? essid : "");
251 profile_list[profile_count] = profile_h;
254 printf("%d. state:[%s], profile name : %s\n",
255 profile_count, test_print_state(profile_state), profile_name);
257 profile_list[profile_count] = profile_h;
261 g_free(profile_name);
262 if (profile_count >= 100)
269 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
270 input >= profile_count ||
272 printf("Wrong number!!\n");
277 *profile = profile_list[input];
282 static int test_update_cellular_info(connection_profile_h profile)
285 char input_str1[100] = {0,};
286 char input_str2[100] = {0,};
290 if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, "
291 "Prepaid MMS:4, Tethering:5, Application:6)"
292 " - (Enter for skip) :", &input_int)) {
295 rv = connection_profile_set_cellular_service_type(profile,
296 CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
299 rv = connection_profile_set_cellular_service_type(profile,
300 CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
303 rv = connection_profile_set_cellular_service_type(profile,
304 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET);
307 rv = connection_profile_set_cellular_service_type(profile,
308 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS);
311 rv = connection_profile_set_cellular_service_type(profile,
312 CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING);
315 rv = connection_profile_set_cellular_service_type(profile,
316 CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
322 if (rv != CONNECTION_ERROR_NONE)
327 if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) {
328 rv = connection_profile_set_cellular_apn(profile, input_str1);
329 if (rv != CONNECTION_ERROR_NONE)
333 if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
334 rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
335 if (rv != CONNECTION_ERROR_NONE)
339 if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) {
340 rv = connection_profile_set_cellular_home_url(profile, input_str1);
341 if (rv != CONNECTION_ERROR_NONE)
345 if (test_get_user_int("Input AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) {
348 rv = connection_profile_set_cellular_auth_info(profile,
349 CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", "");
350 if (rv != CONNECTION_ERROR_NONE)
355 type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
358 if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
360 if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false)
362 if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
365 rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
366 if (rv != CONNECTION_ERROR_NONE)
374 static int test_update_wifi_info(connection_profile_h profile)
377 char input_str[100] = {0,};
379 if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) {
380 rv = connection_profile_set_wifi_passphrase(profile, input_str);
381 if (rv != CONNECTION_ERROR_NONE)
388 static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
391 char input_str[100] = {0,};
393 if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
394 rv = connection_profile_set_ip_address(profile,
397 if (rv != CONNECTION_ERROR_NONE)
401 if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
402 rv = connection_profile_set_subnet_mask(profile,
405 if (rv != CONNECTION_ERROR_NONE)
409 if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
410 rv = connection_profile_set_gateway_address(profile,
413 if (rv != CONNECTION_ERROR_NONE)
417 if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
418 rv = connection_profile_set_dns_address(profile,
422 if (rv != CONNECTION_ERROR_NONE)
425 if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
426 rv = connection_profile_set_dns_address(profile,
430 if (rv != CONNECTION_ERROR_NONE)
438 static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
442 char input_str[100] = {0,};
444 if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)"
445 " - (Enter for skip) :", &input_int)) {
448 rv = connection_profile_set_proxy_type(profile,
449 CONNECTION_PROXY_TYPE_DIRECT);
451 if (rv != CONNECTION_ERROR_NONE)
456 rv = connection_profile_set_proxy_type(profile,
457 CONNECTION_PROXY_TYPE_AUTO);
460 rv = connection_profile_set_proxy_type(profile,
461 CONNECTION_PROXY_TYPE_MANUAL);
467 if (rv != CONNECTION_ERROR_NONE)
470 if (test_get_user_string("Input auto Proxy URL or Proxy address"
471 " - (Enter for skip) :", input_str, 100)) {
472 rv = connection_profile_set_proxy_address(profile,
475 if (rv != CONNECTION_ERROR_NONE)
485 static int test_update_network_info(connection_profile_h profile)
491 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
493 if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)"
494 " - (Enter for skip) :", &input_int)) {
497 rv = connection_profile_set_ip_config_type(profile,
499 CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
502 rv = connection_profile_set_ip_config_type(profile,
504 CONNECTION_IP_CONFIG_TYPE_STATIC);
505 if (rv != CONNECTION_ERROR_NONE)
508 if (test_update_ip_info(profile, address_family) == -1)
511 if (test_update_proxy_info(profile, address_family) == -1)
518 if (rv != CONNECTION_ERROR_NONE)
526 static void test_print_cellular_info(connection_profile_h profile)
528 connection_cellular_network_type_e network_type;
529 connection_cellular_service_type_e service_type;
531 connection_cellular_auth_type_e auth_type;
532 char *user_name = NULL;
533 char *password = NULL;
534 char *home_url = NULL;
535 bool roaming = false;
537 bool editable = false;
539 if (connection_profile_get_cellular_network_type(profile, &network_type) != CONNECTION_ERROR_NONE)
540 printf("Fail to get cellular network type!\n");
542 printf("Cellular network type : %d\n", network_type);
544 if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
545 printf("Fail to get cellular service type!\n");
547 printf("Cellular service type : %d\n", service_type);
549 if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
550 printf("Fail to get cellular APN!\n");
552 printf("Cellular APN : %s\n", apn);
556 if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
557 printf("Fail to get auth info!\n");
559 printf("Cellular auth type : %d\n", auth_type);
560 printf("Cellular user_name : %s\n", user_name);
561 printf("Cellular password : %s\n", password);
566 if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE)
567 printf("Fail to get cellular home url!\n");
569 printf("Cellular home url : %s\n", home_url);
573 if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
574 printf("Fail to get cellular is roaming!\n");
576 printf("Cellular roaming : %s\n", roaming ? "true" : "false");
578 if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE)
579 printf("Fail to get cellular hidden state!\n");
581 printf("Cellular hidden : %s\n", hidden ? "true" : "false");
583 if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE)
584 printf("Fail to get cellular editing state!\n");
586 printf("Cellular editable : %s\n", editable ? "true" : "false");
589 static void test_print_wifi_info(connection_profile_h profile)
596 connection_wifi_security_type_e security_type;
597 connection_wifi_encryption_type_e encryption_type;
598 bool pass_required = false;
599 bool wps_supported = false;
601 if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
602 printf("Fail to get Wi-Fi essid!\n");
604 printf("Wi-Fi essid : %s\n", essid);
608 if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
609 printf("Fail to get Wi-Fi bssid!\n");
611 printf("Wi-Fi bssid : %s\n", bssid);
615 if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
616 printf("Fail to get Wi-Fi rssi!\n");
618 printf("Wi-Fi rssi : %d\n", rssi);
620 if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
621 printf("Fail to get Wi-Fi frequency!\n");
623 printf("Wi-Fi frequency : %d\n", frequency);
625 if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE)
626 printf("Fail to get Wi-Fi max speed!\n");
628 printf("Wi-Fi max speed : %d\n", max_speed);
630 if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
631 printf("Fail to get Wi-Fi security type!\n");
633 printf("Wi-Fi security type : %d\n", security_type);
635 if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE)
636 printf("Fail to get Wi-Fi encryption type!\n");
638 printf("Wi-Fi encryption type : %d\n", encryption_type);
640 if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
641 printf("Fail to get Wi-Fi passphrase required!\n");
643 printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false");
645 if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE)
646 printf("Fail to get Wi-Fi wps info\n");
648 printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
651 static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
653 char *interface_name = NULL;
654 connection_ip_config_type_e ip_type;
657 char *gateway = NULL;
660 connection_proxy_type_e proxy_type;
663 if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
664 printf("Fail to get interface name!\n");
666 printf("Interface name : %s\n", interface_name);
667 g_free(interface_name);
670 if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
671 printf("Fail to get ipconfig type!\n");
673 printf("Ipconfig type : %d\n", ip_type);
675 if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
676 printf("Fail to get IP address!\n");
678 printf("IP address : %s\n", ip);
682 if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
683 printf("Fail to get subnet mask!\n");
685 printf("Subnet mask : %s\n", subnet);
689 if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
690 printf("Fail to get gateway!\n");
692 printf("Gateway : %s\n", gateway);
696 if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
697 printf("Fail to get DNS1!\n");
699 printf("DNS1 : %s\n", dns1);
703 if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
704 printf("Fail to get DNS2!\n");
706 printf("DNS2 : %s\n", dns2);
710 if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
711 printf("Fail to get proxy type!\n");
713 printf("Proxy type : %d\n", proxy_type);
715 if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
716 printf("Fail to get proxy!\n");
718 printf("Proxy : %s\n", proxy);
723 int test_register_client(void)
726 int err = connection_create(&connection);
728 if (CONNECTION_ERROR_NONE == err) {
729 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
730 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
731 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
732 connection_set_ethernet_cable_state_chaged_cb(connection,
733 test_get_ethernet_cable_state_callback, NULL);
735 printf("Client registration failed %d\n", err);
739 printf("Client registration success\n");
743 int test_deregister_client(void)
747 connection_profile_h profile;
749 if (connection != NULL)
750 rv = connection_destroy(connection);
752 printf("Cannot deregister : Handle is NULL\n");
753 rv = CONNECTION_ERROR_INVALID_OPERATION;
756 if (rv != CONNECTION_ERROR_NONE){
757 printf("Client deregistration fail [%d]\n", rv);
762 for (list = state_cb_list; list; list = list->next) {
763 profile = list->data;
764 connection_profile_destroy(profile);
767 g_slist_free(state_cb_list);
768 state_cb_list = NULL;
772 printf("Client deregistration success\n");
777 int test_get_network_state(void)
780 connection_type_e net_state;
782 rv = connection_get_type(connection, &net_state);
784 if (rv != CONNECTION_ERROR_NONE) {
785 printf("Fail to get network state [%d]\n", rv);
789 printf("Retval = %d network connection state [%d]\n", rv, net_state);
794 int test_get_cellular_state(void)
797 connection_cellular_state_e cellular_state;
799 rv = connection_get_cellular_state(connection, &cellular_state);
801 if (rv != CONNECTION_ERROR_NONE) {
802 printf("Fail to get Cellular state [%d]\n", rv);
806 printf("Retval = %d Cellular state [%d]\n", rv, cellular_state);
811 int test_get_wifi_state(void)
814 connection_wifi_state_e wifi_state;
816 rv = connection_get_wifi_state(connection, &wifi_state);
818 if (rv != CONNECTION_ERROR_NONE) {
819 printf("Fail to get WiFi state [%d]\n", rv);
823 printf("Retval = %d WiFi state [%d]\n", rv, wifi_state);
828 int test_get_current_proxy(void)
830 char *proxy_addr = NULL;
832 connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
834 if (proxy_addr == NULL) {
835 printf("Proxy address does not exist\n");
839 printf("Current Proxy [%s]\n", proxy_addr);
845 int test_get_current_ip(void)
847 char *ip_addr = NULL;
851 rv = test_get_user_int("Input Address type to get"
852 "(1:IPV4, 2:IPV6):", &input);
855 printf("Invalid input!!\n");
861 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
862 if (ip_addr == NULL) {
863 printf("IPv4 address does not exist\n");
866 printf("IPv4 address : %s\n", ip_addr);
870 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
871 if (ip_addr == NULL) {
872 printf("IPv6 address does not exist\n");
875 printf("IPv6 address : %s\n", ip_addr);
878 printf("Wrong IP address family!!\n");
886 int test_get_call_statistics_info(void)
890 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
891 printf("last recv data size [%lld]\n", rv);
892 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
893 printf("last sent data size [%lld]\n",rv );
894 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
895 printf("total received data size [%lld]\n",rv );
896 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
897 printf("total sent data size [%lld]\n", rv);
902 int test_get_wifi_call_statistics_info(void)
906 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
907 printf("WiFi last recv data size [%lld]\n", rv);
908 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
909 printf("WiFi last sent data size [%lld]\n",rv );
910 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
911 printf("WiFi total received data size [%lld]\n",rv );
912 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
913 printf("WiFi total sent data size [%lld]\n", rv);
918 int test_get_profile_list(void)
920 if (test_get_user_selected_profile(NULL, false) == false)
926 int test_get_default_profile_list(void)
929 char *profile_name = NULL;
930 connection_profile_iterator_h profile_iter;
931 connection_profile_h profile_h;
932 connection_cellular_service_type_e service_type;
933 bool is_default = false;
935 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
936 if (rv != CONNECTION_ERROR_NONE) {
937 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
941 while (connection_profile_iterator_has_next(profile_iter)) {
942 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
943 printf("Fail to get profile handle\n");
947 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
948 printf("Fail to get profile name\n");
951 printf("profile name : %s\n", profile_name);
952 g_free(profile_name);
954 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
955 printf("Fail to get profile service type\n");
958 printf("service type : %d\n", service_type);
960 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
961 printf("Fail to get profile subscriber id\n");
964 printf("Default : %d\n", is_default);
970 int test_get_connected_profile_list(void)
973 char *profile_name = NULL;
974 connection_profile_iterator_h profile_iter;
975 connection_profile_h profile_h;
976 bool is_default = false;
977 connection_profile_type_e type;
979 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
980 if (rv != CONNECTION_ERROR_NONE) {
981 printf("Fail to get profile iterator [%d]\n", rv);
985 while (connection_profile_iterator_has_next(profile_iter)) {
986 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
987 printf("Fail to get profile handle\n");
991 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
992 printf("Fail to get profile name\n");
995 printf("profile name : %s\n", profile_name);
996 g_free(profile_name);
998 if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
999 printf("Fail to get profile type\n");
1002 printf("profile type is %d\n", type);
1004 if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
1005 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1006 printf("Fail to get profile is default\n");
1009 printf("[%s]\n", is_default ? "default" : "not default");
1016 int test_get_current_profile(void)
1019 char *profile_name = NULL;
1020 connection_profile_h profile_h;
1022 rv = connection_get_current_profile(connection, &profile_h);
1023 if (rv != CONNECTION_ERROR_NONE) {
1024 printf("Fail to get profile iterator [%d]\n", rv);
1028 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1029 printf("Fail to get profile name\n");
1032 printf("profile name : %s\n", profile_name);
1033 g_free(profile_name);
1035 connection_profile_destroy(profile_h);
1040 int test_open_profile(void)
1042 connection_profile_h profile;
1044 printf("\n** Choose a profile to open. **\n");
1046 if (test_get_user_selected_profile(&profile, true) == false)
1049 if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
1050 printf("Connection open Failed!!\n");
1057 int test_get_default_cellular_service_type(void)
1062 connection_profile_h profile;
1063 char *profile_name = NULL;
1065 rv = test_get_user_int("Input profile type to get"
1066 "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering):", &input);
1069 printf("Invalid input!!\n");
1075 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
1078 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
1081 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
1084 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
1087 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
1090 printf("Wrong number!!\n");
1094 if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
1097 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1098 printf("Fail to get profile name\n");
1099 connection_profile_destroy(profile);
1102 printf("Default profile name : %s\n", profile_name);
1103 g_free(profile_name);
1105 connection_profile_destroy(profile);
1110 int test_set_default_cellular_service_type(void)
1112 connection_profile_h profile;
1113 connection_cellular_service_type_e type;
1116 rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
1118 if (rv == false || (input != 1 && input != 2)) {
1119 printf("Invalid input!!\n");
1123 printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
1125 if (test_get_user_selected_profile(&profile, true) == false)
1128 if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
1129 printf("Fail to get cellular service type\n");
1134 if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
1137 if (connection_set_default_cellular_service_profile_async(connection,
1138 type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
1145 int test_close_profile(void)
1147 connection_profile_h profile;
1149 printf("\n** Choose a profile to close. **\n");
1151 if (test_get_user_selected_profile(&profile, true) == false)
1154 if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
1155 printf("Connection close Failed!!\n");
1162 int test_add_profile(void)
1165 connection_profile_h profile;
1166 char input_str[100] = {0,};
1168 if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
1171 rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
1172 if (rv != CONNECTION_ERROR_NONE)
1173 RETURN_FAIL_DESTROY(profile);
1175 if (test_update_cellular_info(profile) == -1)
1176 RETURN_FAIL_DESTROY(profile);
1178 rv = connection_add_profile(connection, profile);
1179 if (rv != CONNECTION_ERROR_NONE)
1180 RETURN_FAIL_DESTROY(profile);
1182 connection_profile_destroy(profile);
1186 int test_remove_profile(void)
1188 connection_profile_h profile;
1190 printf("\n** Choose a profile to remove. **\n");
1191 if (test_get_user_selected_profile(&profile, true) == false)
1194 if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
1195 printf("Remove profile Failed!!\n");
1202 int test_update_profile(void)
1206 connection_profile_type_e prof_type;
1207 connection_profile_h profile;
1209 printf("\n** Choose a profile to update. **\n");
1210 if (test_get_user_selected_profile(&profile, true) == false)
1213 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1216 switch (prof_type) {
1217 case CONNECTION_PROFILE_TYPE_CELLULAR:
1218 if (test_update_cellular_info(profile) == -1)
1222 case CONNECTION_PROFILE_TYPE_WIFI:
1223 if (test_update_wifi_info(profile) == -1)
1226 if (test_update_network_info(profile) == -1)
1230 case CONNECTION_PROFILE_TYPE_ETHERNET:
1231 case CONNECTION_PROFILE_TYPE_BT:
1232 printf("Not supported!\n");
1238 rv = connection_update_profile(connection, profile);
1239 if (rv != CONNECTION_ERROR_NONE)
1245 int test_get_profile_info(void)
1247 connection_profile_type_e prof_type;
1248 connection_profile_state_e profile_state;
1249 connection_profile_h profile;
1250 char *profile_name = NULL;
1251 int address_family = 0;
1253 printf("\n** Choose a profile to print. **\n");
1254 if (test_get_user_selected_profile(&profile, true) == false)
1257 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1258 printf("Fail to get profile name\n");
1261 printf("Profile Name : %s\n", profile_name);
1262 g_free(profile_name);
1265 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1266 printf("Fail to get profile state\n");
1269 printf("Profile State : %s\n", test_print_state(profile_state));
1271 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1274 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1276 switch (prof_type) {
1277 case CONNECTION_PROFILE_TYPE_CELLULAR:
1278 printf("Profile Type : Cellular\n");
1279 test_print_cellular_info(profile);
1281 case CONNECTION_PROFILE_TYPE_WIFI:
1282 printf("Profile Type : Wi-Fi\n");
1283 test_print_wifi_info(profile);
1285 case CONNECTION_PROFILE_TYPE_ETHERNET:
1286 printf("Profile Type : Ethernet\n");
1288 case CONNECTION_PROFILE_TYPE_BT:
1289 printf("Profile Type : Bluetooth\n");
1295 test_print_network_info(profile, address_family);
1300 int test_refresh_profile_info(void)
1302 connection_profile_type_e prof_type;
1303 connection_profile_state_e profile_state;
1304 connection_profile_h profile;
1305 char *profile_name = NULL;
1306 int address_family = 0;
1308 printf("\n** Choose a profile to refresh. **\n");
1309 if (test_get_user_selected_profile(&profile, true) == false)
1312 if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
1315 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1316 printf("Fail to get profile name\n");
1319 printf("Profile Name : %s\n", profile_name);
1320 g_free(profile_name);
1323 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1324 printf("Fail to get profile state\n");
1327 printf("Profile State : %s\n", test_print_state(profile_state));
1330 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1333 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1335 switch (prof_type) {
1336 case CONNECTION_PROFILE_TYPE_CELLULAR:
1337 printf("Profile Type : Cellular\n");
1338 test_print_cellular_info(profile);
1340 case CONNECTION_PROFILE_TYPE_WIFI:
1341 printf("Profile Type : Wi-Fi\n");
1342 test_print_wifi_info(profile);
1344 case CONNECTION_PROFILE_TYPE_ETHERNET:
1345 printf("Profile Type : Ethernet\n");
1347 case CONNECTION_PROFILE_TYPE_BT:
1348 printf("Profile Type : Bluetooth\n");
1354 test_print_network_info(profile, address_family);
1359 int test_set_state_changed_callback()
1361 connection_profile_h profile;
1362 connection_profile_h profile_clone;
1364 printf("\n** Choose a profile to set callback. **\n");
1365 if (test_get_user_selected_profile(&profile, true) == false)
1368 if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
1371 if (connection_profile_set_state_changed_cb(profile,
1372 test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
1373 connection_profile_destroy(profile_clone);
1377 state_cb_list = g_slist_append(state_cb_list, profile_clone);
1382 int test_unset_state_changed_callback()
1384 connection_profile_h profile;
1386 char *profile_name = NULL;
1390 printf("\n** Choose a profile to unset callback. **\n");
1391 for (list = state_cb_list; list; list = list->next) {
1392 profile = list->data;
1393 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1394 printf("Fail to get profile name!\n");
1397 printf("%d. %s\n", count, profile_name);
1398 g_free(profile_name);
1404 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
1407 printf("Wrong number!!\n");
1412 for (list = state_cb_list; list; list = list->next) {
1413 if (count == input) {
1414 profile = list->data;
1424 if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
1427 state_cb_list = g_slist_remove(state_cb_list, profile);
1428 connection_profile_destroy(profile);
1433 int test_reset_call_statistics_info(void)
1435 int ret = CONNECTION_ERROR_NONE;
1437 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1438 printf("reset last recv data size [%d]\n", ret);
1439 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1440 printf("last sent data size [%d]\n", ret);
1441 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1442 printf("total received data size [%d]\n", ret);
1443 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1444 printf("total sent data size [%d]\n", ret);
1449 int test_reset_wifi_call_statistics_info(void)
1451 int ret = CONNECTION_ERROR_NONE;
1453 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1454 printf("WiFi last sent data size [%d]\n", ret);
1455 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1456 printf("WiFi last recv data size [%d]\n", ret);
1457 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1458 printf("WiFi total sent data size [%d]\n", ret);
1459 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1460 printf("WiFi total received data size [%d]\n", ret);
1465 int test_add_route(void)
1468 char ip_addr[100] = {0};
1469 char if_name[40] = {0};
1471 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1474 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1477 g_strstrip(ip_addr);
1478 g_strstrip(if_name);
1479 rv = connection_add_route(connection, if_name, ip_addr);
1480 if (rv != CONNECTION_ERROR_NONE) {
1481 printf("Fail to get add new route [%d]\n", rv);
1484 printf("Add Route successfully\n");
1489 int test_remove_route(void)
1492 char ip_addr[100] = {0};
1493 char if_name[40] = {0};
1495 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1498 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1501 g_strstrip(ip_addr);
1502 g_strstrip(if_name);
1503 rv = connection_remove_route(connection, if_name, ip_addr);
1504 if (rv != CONNECTION_ERROR_NONE) {
1505 printf("Fail to remove the route [%s]\n", test_print_error(rv));
1508 printf("Remove Route successfully\n");
1513 int test_add_route_ipv6(void)
1516 char ip_addr[100] = {0};
1517 char gateway[100] = {0};
1518 char if_name[40] = {0};
1520 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1523 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1526 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1529 g_strstrip(ip_addr);
1530 g_strstrip(gateway);
1531 g_strstrip(if_name);
1532 rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
1533 if (rv != CONNECTION_ERROR_NONE) {
1534 printf("Fail to get add new route [%d]\n", rv);
1537 printf("Add Route successfully\n");
1542 int test_remove_route_ipv6(void)
1545 char ip_addr[100] = {0};
1546 char gateway[100] = {0};
1547 char if_name[40] = {0};
1549 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1552 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1555 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1558 g_strstrip(ip_addr);
1559 g_strstrip(gateway);
1560 g_strstrip(if_name);
1561 rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
1562 if (rv != CONNECTION_ERROR_NONE) {
1563 printf("Fail to remove the route [%d]\n", rv);
1566 printf("Remove Route successfully\n");
1571 int test_get_bt_state(void)
1574 connection_bt_state_e bt_state;
1576 rv = connection_get_bt_state(connection, &bt_state);
1578 if (rv != CONNECTION_ERROR_NONE) {
1579 printf("Fail to get Bluetooth state [%d]\n", rv);
1583 printf("Retval = %d, Bluetooth state [%d]\n", rv, bt_state);
1588 int test_get_profile_id(void)
1590 connection_profile_h profile;
1593 printf("\n** Choose a profile to see profile id. **\n");
1594 if (test_get_user_selected_profile(&profile, true) == false)
1597 if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
1598 printf("Fail to get profile name\n");
1601 printf("Profile id : %s\n", profile_id);
1608 int test_get_mac_address(void)
1610 int rv = 0, type = 0;
1611 connection_type_e conn_type;
1612 char *mac_addr = NULL;
1614 test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
1618 conn_type = CONNECTION_TYPE_WIFI;
1621 conn_type = CONNECTION_TYPE_ETHERNET;
1624 printf("Wrong number!!\n");
1628 rv = connection_get_mac_address(connection, conn_type, &mac_addr);
1630 if (rv != CONNECTION_ERROR_NONE) {
1631 printf("Fail to get MAC address [%s]\n", test_print_error(rv));
1635 printf("mac address is %s\n", mac_addr);
1642 int test_get_ethernet_cable_state(void)
1645 connection_ethernet_cable_state_e cable_state;
1647 rv = connection_get_ethernet_cable_state(connection, &cable_state);
1649 if (rv != CONNECTION_ERROR_NONE) {
1650 printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
1654 printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
1659 int test_reset_profile(void)
1661 int type, sim_id, rv;
1663 rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
1665 if (rv == false || (type != 0 && type != 1)) {
1666 printf("Invalid input!!\n");
1670 rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
1672 if (rv == false || (sim_id != 0 && sim_id != 1)) {
1673 printf("Invalid input!!\n");
1677 if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) {
1684 int main(int argc, char **argv)
1686 GMainLoop *mainloop;
1687 mainloop = g_main_loop_new (NULL, FALSE);
1689 GIOChannel *channel = g_io_channel_unix_new(0);
1690 g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread,NULL );
1692 printf("Test Thread created...\n");
1694 g_main_loop_run (mainloop);
1699 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
1704 memset(a, '\0', 100);
1705 printf("Event received from stdin\n");
1707 rv = read(0, a, 100);
1709 if (rv < 0 || a[0] == '0') {
1710 if (connection != NULL)
1711 test_deregister_client();
1716 if (*a == '\n' || *a == '\r'){
1717 printf("\n\n Network Connection API Test App\n\n");
1718 printf("Options..\n");
1719 printf("1 - Create Handle and set callbacks\n");
1720 printf("2 - Destroy Handle(unset callbacks automatically)\n");
1721 printf("3 - Get network state\n");
1722 printf("4 - Get cellular state (please insert SIM Card)\n");
1723 printf("5 - Get wifi state (please turn on WiFi)\n");
1724 printf("6 - Get current proxy address \n");
1725 printf("7 - Get current Ip address\n");
1726 printf("8 - Get cellular data call statistics\n");
1727 printf("9 - Get WiFi data call statistics\n");
1728 printf("a - Get Profile list\n");
1729 printf("b - Get Connected Profile list\n");
1730 printf("c - Get Current profile\n");
1731 printf("d - Open connection with profile\n");
1732 printf("e - Get default cellular service by type\n");
1733 printf("f - Set default cellular service by type\n");
1734 printf("g - Close connection with profile\n");
1735 printf("h - Add profile(Cellular only)\n");
1736 printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
1737 printf("j - Update profile\n");
1738 printf("k - Get profile info\n");
1739 printf("l - Refresh profile info\n");
1740 printf("m - Set state changed callback\n");
1741 printf("n - Unset state changed callback\n");
1742 printf("o - Reset cellular data call statistics\n");
1743 printf("p - Reset WiFi data call statistics\n");
1744 printf("q - Add new route\n");
1745 printf("r - Remove a route\n");
1746 printf("s - Get Bluetooth state\n");
1747 printf("t - Get profile id\n");
1748 printf("u - Reset profile\n");
1749 printf("v - Get all cellular default profiles\n");
1750 printf("w - Get mac address\n");
1751 printf("x - Get ethernet cable state\n");
1752 printf("B - Add IPv6 new route\n");
1753 printf("C - Remove IPv6 route\n");
1754 printf("0 - Exit \n");
1755 printf("ENTER - Show options menu.......\n");
1760 rv = test_register_client();
1763 rv = test_deregister_client();
1766 rv = test_get_network_state();
1769 rv = test_get_cellular_state();
1772 rv = test_get_wifi_state();
1775 rv = test_get_current_proxy();
1778 rv = test_get_current_ip();
1781 rv = test_get_call_statistics_info();
1784 rv = test_get_wifi_call_statistics_info();
1787 rv = test_get_profile_list();
1790 rv = test_get_connected_profile_list();
1793 rv = test_get_current_profile();
1796 rv = test_open_profile();
1799 rv = test_get_default_cellular_service_type();
1802 rv = test_set_default_cellular_service_type();
1805 rv = test_close_profile();
1808 rv = test_add_profile();
1811 rv = test_remove_profile();
1814 rv = test_update_profile();
1817 rv = test_get_profile_info();
1820 rv = test_refresh_profile_info();
1823 rv = test_set_state_changed_callback();
1826 rv = test_unset_state_changed_callback();
1829 rv = test_reset_call_statistics_info();
1832 rv = test_reset_wifi_call_statistics_info();
1835 rv = test_add_route();
1838 rv = test_remove_route();
1841 rv = test_get_bt_state();
1844 rv = test_get_profile_id();
1847 rv = test_reset_profile();
1850 rv = test_get_default_profile_list();
1853 rv = test_get_mac_address();
1856 rv = test_get_ethernet_cable_state();
1859 rv = test_add_route_ipv6();
1862 rv = test_remove_route_ipv6();
1867 printf("Operation succeeded!\n");
1869 printf("Operation failed!\n");