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"
26 #include <tizen_error.h>
28 #define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1; }
30 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
32 connection_h connection = NULL;
33 static GSList *state_cb_list = NULL;
36 static bool test_get_user_string(const char *msg, char *buf, int buf_size)
38 if (msg == NULL || buf == NULL || buf_size < 2)
43 memset(buf, 0, buf_size);
44 rv = read(0, buf, buf_size - 1);
46 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 : [%s]\n", test_print_error(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 : [%s]\n", test_print_error(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 : [%s]\n", test_print_error(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 [%s]\n", test_print_error(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 connection_cellular_service_type_e service_type;
255 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE)
256 printf("Fail to get cellular service type!\n");
258 printf("%d. state:[%s], profile name:%s[%d]\n",
259 profile_count, test_print_state(profile_state), profile_name, service_type);
261 profile_list[profile_count] = profile_h;
265 g_free(profile_name);
266 if (profile_count >= 100)
273 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
274 input >= profile_count ||
276 printf("Wrong number!!\n");
281 *profile = profile_list[input];
286 static int test_update_cellular_info(connection_profile_h profile)
289 char input_str1[100] = {0,};
290 char input_str2[100] = {0,};
294 if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, "
295 "Prepaid MMS:4, Tethering:5, Application:6)"
296 " - (Enter for skip) :", &input_int)) {
299 rv = connection_profile_set_cellular_service_type(profile,
300 CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
303 rv = connection_profile_set_cellular_service_type(profile,
304 CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
307 rv = connection_profile_set_cellular_service_type(profile,
308 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET);
311 rv = connection_profile_set_cellular_service_type(profile,
312 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS);
315 rv = connection_profile_set_cellular_service_type(profile,
316 CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING);
319 rv = connection_profile_set_cellular_service_type(profile,
320 CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
326 if (rv != CONNECTION_ERROR_NONE)
331 if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) {
332 g_strstrip(input_str1);
333 rv = connection_profile_set_cellular_apn(profile, input_str1);
334 if (rv != CONNECTION_ERROR_NONE)
338 if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
339 g_strstrip(input_str1);
340 rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
341 if (rv != CONNECTION_ERROR_NONE)
345 if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) {
346 g_strstrip(input_str1);
347 rv = connection_profile_set_cellular_home_url(profile, input_str1);
348 if (rv != CONNECTION_ERROR_NONE)
352 if (test_get_user_int("Input AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) {
355 rv = connection_profile_set_cellular_auth_info(profile,
356 CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", "");
357 if (rv != CONNECTION_ERROR_NONE)
362 type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
365 if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
367 if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false)
369 if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
372 g_strstrip(input_str1);
373 g_strstrip(input_str2);
374 rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
375 if (rv != CONNECTION_ERROR_NONE)
383 static int test_update_wifi_info(connection_profile_h profile)
386 char input_str[100] = {0,};
388 if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) {
389 rv = connection_profile_set_wifi_passphrase(profile, input_str);
390 if (rv != CONNECTION_ERROR_NONE)
397 static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
400 char input_str[100] = {0,};
402 if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
403 rv = connection_profile_set_ip_address(profile,
406 if (rv != CONNECTION_ERROR_NONE)
410 if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
411 rv = connection_profile_set_subnet_mask(profile,
414 if (rv != CONNECTION_ERROR_NONE)
418 if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
419 rv = connection_profile_set_gateway_address(profile,
422 if (rv != CONNECTION_ERROR_NONE)
426 if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
427 rv = connection_profile_set_dns_address(profile,
431 if (rv != CONNECTION_ERROR_NONE)
434 if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
435 rv = connection_profile_set_dns_address(profile,
439 if (rv != CONNECTION_ERROR_NONE)
447 static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
451 char input_str[100] = {0,};
453 if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)"
454 " - (Enter for skip) :", &input_int)) {
457 rv = connection_profile_set_proxy_type(profile,
458 CONNECTION_PROXY_TYPE_DIRECT);
460 if (rv != CONNECTION_ERROR_NONE)
465 rv = connection_profile_set_proxy_type(profile,
466 CONNECTION_PROXY_TYPE_AUTO);
469 rv = connection_profile_set_proxy_type(profile,
470 CONNECTION_PROXY_TYPE_MANUAL);
476 if (rv != CONNECTION_ERROR_NONE)
479 if (test_get_user_string("Input auto Proxy URL or Proxy address"
480 " - (Enter for skip) :", input_str, 100)) {
481 rv = connection_profile_set_proxy_address(profile,
484 if (rv != CONNECTION_ERROR_NONE)
494 static int test_update_network_info(connection_profile_h profile)
498 int address_family = 0;
500 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
502 if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)"
503 " - (Enter for skip) :", &input_int)) {
506 rv = connection_profile_set_ip_config_type(profile,
508 CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
511 rv = connection_profile_set_ip_config_type(profile,
513 CONNECTION_IP_CONFIG_TYPE_STATIC);
514 if (rv != CONNECTION_ERROR_NONE)
517 if (test_update_ip_info(profile, address_family) == -1)
520 if (test_update_proxy_info(profile, address_family) == -1)
527 if (rv != CONNECTION_ERROR_NONE)
535 static void test_print_cellular_info(connection_profile_h profile)
537 connection_cellular_service_type_e service_type;
539 connection_cellular_auth_type_e auth_type;
540 char *user_name = NULL;
541 char *password = NULL;
542 char *home_url = NULL;
543 bool roaming = false;
545 bool editable = false;
547 if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
548 printf("Fail to get cellular service type!\n");
550 printf("Cellular service type : %d\n", service_type);
552 if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
553 printf("Fail to get cellular APN!\n");
555 printf("Cellular APN : %s\n", apn);
559 if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
560 printf("Fail to get auth info!\n");
562 printf("Cellular auth type : %d\n", auth_type);
563 printf("Cellular user_name : %s\n", user_name);
564 printf("Cellular password : %s\n", password);
569 if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE)
570 printf("Fail to get cellular home url!\n");
572 printf("Cellular home url : %s\n", home_url);
576 if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
577 printf("Fail to get cellular roaming state!\n");
579 printf("Cellular roaming : %s\n", roaming ? "true" : "false");
581 if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE)
582 printf("Fail to get cellular hidden state!\n");
584 printf("Cellular hidden : %s\n", hidden ? "true" : "false");
586 if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE)
587 printf("Fail to get cellular editing state!\n");
589 printf("Cellular editable : %s\n", editable ? "true" : "false");
592 static void test_print_wifi_info(connection_profile_h profile)
599 connection_wifi_security_type_e security_type;
600 connection_wifi_encryption_type_e encryption_type;
601 bool pass_required = false;
602 bool wps_supported = false;
604 if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
605 printf("Fail to get Wi-Fi essid!\n");
607 printf("Wi-Fi essid : %s\n", essid);
611 if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
612 printf("Fail to get Wi-Fi bssid!\n");
614 printf("Wi-Fi bssid : %s\n", bssid);
618 if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
619 printf("Fail to get Wi-Fi rssi!\n");
621 printf("Wi-Fi rssi : %d\n", rssi);
623 if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
624 printf("Fail to get Wi-Fi frequency!\n");
626 printf("Wi-Fi frequency : %d\n", frequency);
628 if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE)
629 printf("Fail to get Wi-Fi max speed!\n");
631 printf("Wi-Fi max speed : %d\n", max_speed);
633 if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
634 printf("Fail to get Wi-Fi security type!\n");
636 printf("Wi-Fi security type : %d\n", security_type);
638 if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE)
639 printf("Fail to get Wi-Fi encryption type!\n");
641 printf("Wi-Fi encryption type : %d\n", encryption_type);
643 if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
644 printf("Fail to get Wi-Fi passphrase required!\n");
646 printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false");
648 if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE)
649 printf("Fail to get Wi-Fi wps info\n");
651 printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
654 static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
656 char *interface_name = NULL;
657 connection_ip_config_type_e ip_type;
660 char *gateway = NULL;
663 connection_proxy_type_e proxy_type;
666 if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
667 printf("Fail to get interface name!\n");
669 printf("Interface name : %s\n", interface_name);
670 g_free(interface_name);
673 if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
674 printf("Fail to get ipconfig type!\n");
676 printf("Ipconfig type : %d\n", ip_type);
678 if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
679 printf("Fail to get IP address!\n");
681 printf("IP address : %s\n", ip);
685 if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
686 printf("Fail to get subnet mask!\n");
688 printf("Subnet mask : %s\n", subnet);
692 if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
693 printf("Fail to get gateway!\n");
695 printf("Gateway : %s\n", gateway);
699 if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
700 printf("Fail to get DNS1!\n");
702 printf("DNS1 : %s\n", dns1);
706 if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
707 printf("Fail to get DNS2!\n");
709 printf("DNS2 : %s\n", dns2);
713 if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
714 printf("Fail to get proxy type!\n");
716 printf("Proxy type : %d\n", proxy_type);
718 if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
719 printf("Fail to get proxy!\n");
721 printf("Proxy : %s\n", proxy);
726 int test_register_client(void)
729 int err = connection_create(&connection);
731 if (CONNECTION_ERROR_NONE == err) {
732 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
733 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
734 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
735 connection_set_ethernet_cable_state_chaged_cb(connection,
736 test_get_ethernet_cable_state_callback, NULL);
738 printf("Client registration failed [%s]\n", test_print_error(err));
742 printf("Client registration success\n");
746 int test_deregister_client(void)
750 connection_profile_h profile;
752 if (connection != NULL)
753 rv = connection_destroy(connection);
755 printf("Cannot deregister : Handle is NULL\n");
756 rv = CONNECTION_ERROR_INVALID_OPERATION;
759 if (rv != CONNECTION_ERROR_NONE) {
760 printf("Client deregistration fail [%s]\n", test_print_error(rv));
765 for (list = state_cb_list; list; list = list->next) {
766 profile = list->data;
767 connection_profile_destroy(profile);
770 g_slist_free(state_cb_list);
771 state_cb_list = NULL;
775 printf("Client deregistration success\n");
780 int test_get_network_state(void)
783 connection_type_e net_state;
785 rv = connection_get_type(connection, &net_state);
787 if (rv != CONNECTION_ERROR_NONE) {
788 printf("Fail to get network state [%s]\n", test_print_error(rv));
792 printf("Retval = [%s] network connection state [%d]\n", test_print_error(rv), net_state);
797 int test_get_cellular_state(void)
800 connection_cellular_state_e cellular_state;
802 rv = connection_get_cellular_state(connection, &cellular_state);
804 if (rv != CONNECTION_ERROR_NONE) {
805 printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
809 printf("Retval = [%s] Cellular state [%d]\n", test_print_error(rv), cellular_state);
814 int test_get_wifi_state(void)
817 connection_wifi_state_e wifi_state;
819 rv = connection_get_wifi_state(connection, &wifi_state);
821 if (rv != CONNECTION_ERROR_NONE) {
822 printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
826 printf("Retval = [%s] WiFi state [%d]\n", test_print_error(rv), wifi_state);
831 int test_get_current_proxy(void)
833 char *proxy_addr = NULL;
835 connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
837 if (proxy_addr == NULL) {
838 printf("Proxy address does not exist\n");
842 printf("Current Proxy [%s]\n", proxy_addr);
848 int test_get_current_ip(void)
850 char *ip_addr = NULL;
854 rv = test_get_user_int("Input Address type to get"
855 "(1:IPV4, 2:IPV6):", &input);
858 printf("Invalid input!!\n");
864 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
865 if (ip_addr == NULL) {
866 printf("IPv4 address does not exist\n");
869 printf("IPv4 address : %s\n", ip_addr);
873 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
874 if (ip_addr == NULL) {
875 printf("IPv6 address does not exist\n");
878 printf("IPv6 address : %s\n", ip_addr);
881 printf("Wrong IP address family!!\n");
889 int test_get_call_statistics_info(void)
893 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
894 printf("last recv data size [%lld]\n", rv);
895 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
896 printf("last sent data size [%lld]\n", rv);
897 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
898 printf("total received data size [%lld]\n", rv);
899 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
900 printf("total sent data size [%lld]\n", rv);
905 int test_get_wifi_call_statistics_info(void)
909 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
910 printf("WiFi last recv data size [%lld]\n", rv);
911 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
912 printf("WiFi last sent data size [%lld]\n", rv);
913 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
914 printf("WiFi total received data size [%lld]\n", rv);
915 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
916 printf("WiFi total sent data size [%lld]\n", rv);
921 int test_get_profile_list(void)
923 if (test_get_user_selected_profile(NULL, false) == false)
929 int test_get_default_profile_list(void)
932 char *profile_name = NULL;
933 connection_profile_iterator_h profile_iter;
934 connection_profile_h profile_h;
935 connection_cellular_service_type_e service_type;
936 bool is_default = false;
938 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
939 if (rv != CONNECTION_ERROR_NONE) {
940 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
944 while (connection_profile_iterator_has_next(profile_iter)) {
945 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
946 printf("Fail to get profile handle\n");
950 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
951 printf("Fail to get profile name\n");
954 printf("profile name : %s\n", profile_name);
955 g_free(profile_name);
957 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
958 printf("Fail to get profile service type\n");
961 printf("service type : %d\n", service_type);
963 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
964 printf("Fail to get profile subscriber id\n");
967 printf("Default : %d\n", is_default);
973 int test_get_connected_profile_list(void)
976 char *profile_name = NULL;
977 connection_profile_iterator_h profile_iter;
978 connection_profile_h profile_h;
979 bool is_default = false;
980 connection_profile_type_e type;
982 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
983 if (rv != CONNECTION_ERROR_NONE) {
984 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
988 while (connection_profile_iterator_has_next(profile_iter)) {
989 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
990 printf("Fail to get profile handle\n");
994 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
995 printf("Fail to get profile name\n");
998 printf("profile name is %s\n", profile_name);
999 g_free(profile_name);
1001 if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
1002 printf("Fail to get profile type\n");
1005 printf("profile type is %d\n", type);
1007 if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
1008 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1009 printf("Fail to get profile is default\n");
1012 printf("[%s]\n", is_default ? "default" : "not default");
1019 int test_get_current_profile(void)
1022 char *profile_name = NULL;
1023 connection_profile_h profile_h;
1025 rv = connection_get_current_profile(connection, &profile_h);
1026 if (rv != CONNECTION_ERROR_NONE) {
1027 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1031 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1032 printf("Fail to get profile name\n");
1035 printf("profile name : %s\n", profile_name);
1036 g_free(profile_name);
1038 connection_profile_destroy(profile_h);
1043 int test_open_profile(void)
1045 connection_profile_h profile;
1047 printf("\n** Choose a profile to open. **\n");
1049 if (test_get_user_selected_profile(&profile, true) == false)
1052 if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
1053 printf("Connection open Failed!!\n");
1060 int test_get_default_cellular_service_type(void)
1065 connection_profile_h profile;
1066 char *profile_name = NULL;
1068 rv = test_get_user_int("Input profile type to get"
1069 "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input);
1072 printf("Invalid input!!\n");
1078 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
1081 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
1084 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
1087 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
1090 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
1093 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
1096 printf("Wrong number!!\n");
1100 if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
1103 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1104 printf("Fail to get profile name\n");
1105 connection_profile_destroy(profile);
1108 printf("Default profile name : %s\n", profile_name);
1109 g_free(profile_name);
1111 connection_profile_destroy(profile);
1116 int test_set_default_cellular_service_type(void)
1118 connection_profile_h profile;
1119 connection_cellular_service_type_e type;
1122 rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
1124 if (rv == false || (input != 1 && input != 2)) {
1125 printf("Invalid input!!\n");
1129 printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
1131 if (test_get_user_selected_profile(&profile, true) == false)
1134 if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
1135 printf("Fail to get cellular service type\n");
1140 if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
1143 if (connection_set_default_cellular_service_profile_async(connection,
1144 type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
1151 int test_close_profile(void)
1153 connection_profile_h profile;
1155 printf("\n** Choose a profile to close. **\n");
1157 if (test_get_user_selected_profile(&profile, true) == false)
1160 if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
1161 printf("Connection close Failed!!\n");
1168 int test_add_profile(void)
1171 connection_profile_h profile;
1172 char input_str[100] = {0,};
1174 if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
1177 g_strstrip(input_str);
1178 rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
1179 if (rv != CONNECTION_ERROR_NONE)
1180 RETURN_FAIL_DESTROY(profile);
1182 if (test_update_cellular_info(profile) == -1)
1183 RETURN_FAIL_DESTROY(profile);
1185 rv = connection_add_profile(connection, profile);
1186 if (rv != CONNECTION_ERROR_NONE)
1187 RETURN_FAIL_DESTROY(profile);
1189 connection_profile_destroy(profile);
1193 int test_remove_profile(void)
1195 connection_profile_h profile;
1197 printf("\n** Choose a profile to remove. **\n");
1198 if (test_get_user_selected_profile(&profile, true) == false)
1201 if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
1202 printf("Remove profile Failed!!\n");
1209 int test_update_profile(void)
1213 connection_profile_type_e prof_type;
1214 connection_profile_h profile;
1216 printf("\n** Choose a profile to update. **\n");
1217 if (test_get_user_selected_profile(&profile, true) == false)
1220 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1223 switch (prof_type) {
1224 case CONNECTION_PROFILE_TYPE_CELLULAR:
1225 if (test_update_cellular_info(profile) == -1)
1229 case CONNECTION_PROFILE_TYPE_WIFI:
1230 if (test_update_wifi_info(profile) == -1)
1233 if (test_update_network_info(profile) == -1)
1237 case CONNECTION_PROFILE_TYPE_ETHERNET:
1238 if (test_update_network_info(profile) == -1)
1242 case CONNECTION_PROFILE_TYPE_BT:
1243 printf("Not supported!\n");
1249 rv = connection_update_profile(connection, profile);
1250 if (rv != CONNECTION_ERROR_NONE)
1256 int test_get_profile_info(void)
1258 connection_profile_type_e prof_type;
1259 connection_profile_state_e profile_state;
1260 connection_profile_h profile;
1261 char *profile_name = NULL;
1262 int address_family = 0;
1264 printf("\n** Choose a profile to print. **\n");
1265 if (test_get_user_selected_profile(&profile, true) == false)
1268 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1269 printf("Fail to get profile name\n");
1272 printf("Profile Name : %s\n", profile_name);
1273 g_free(profile_name);
1276 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1277 printf("Fail to get profile state\n");
1280 printf("Profile State : %s\n", test_print_state(profile_state));
1282 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1285 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1287 switch (prof_type) {
1288 case CONNECTION_PROFILE_TYPE_CELLULAR:
1289 printf("Profile Type : Cellular\n");
1290 test_print_cellular_info(profile);
1292 case CONNECTION_PROFILE_TYPE_WIFI:
1293 printf("Profile Type : Wi-Fi\n");
1294 test_print_wifi_info(profile);
1296 case CONNECTION_PROFILE_TYPE_ETHERNET:
1297 printf("Profile Type : Ethernet\n");
1299 case CONNECTION_PROFILE_TYPE_BT:
1300 printf("Profile Type : Bluetooth\n");
1306 test_print_network_info(profile, address_family);
1311 int test_refresh_profile_info(void)
1313 connection_profile_type_e prof_type;
1314 connection_profile_state_e profile_state;
1315 connection_profile_h profile;
1316 char *profile_name = NULL;
1317 int address_family = 0;
1319 printf("\n** Choose a profile to refresh. **\n");
1320 if (test_get_user_selected_profile(&profile, true) == false)
1323 if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
1326 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1327 printf("Fail to get profile name\n");
1330 printf("Profile Name : %s\n", profile_name);
1331 g_free(profile_name);
1334 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1335 printf("Fail to get profile state\n");
1338 printf("Profile State : %s\n", test_print_state(profile_state));
1341 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1344 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1346 switch (prof_type) {
1347 case CONNECTION_PROFILE_TYPE_CELLULAR:
1348 printf("Profile Type : Cellular\n");
1349 test_print_cellular_info(profile);
1351 case CONNECTION_PROFILE_TYPE_WIFI:
1352 printf("Profile Type : Wi-Fi\n");
1353 test_print_wifi_info(profile);
1355 case CONNECTION_PROFILE_TYPE_ETHERNET:
1356 printf("Profile Type : Ethernet\n");
1358 case CONNECTION_PROFILE_TYPE_BT:
1359 printf("Profile Type : Bluetooth\n");
1365 test_print_network_info(profile, address_family);
1370 int test_set_state_changed_callback()
1372 connection_profile_h profile;
1373 connection_profile_h profile_clone;
1375 printf("\n** Choose a profile to set callback. **\n");
1376 if (test_get_user_selected_profile(&profile, true) == false)
1379 if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
1382 if (connection_profile_set_state_changed_cb(profile,
1383 test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
1384 connection_profile_destroy(profile_clone);
1388 state_cb_list = g_slist_append(state_cb_list, profile_clone);
1393 int test_unset_state_changed_callback()
1395 connection_profile_h profile;
1397 char *profile_name = NULL;
1401 printf("\n** Choose a profile to unset callback. **\n");
1402 for (list = state_cb_list; list; list = list->next) {
1403 profile = list->data;
1404 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1405 printf("Fail to get profile name!\n");
1408 printf("%d. %s\n", count, profile_name);
1409 g_free(profile_name);
1415 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
1418 printf("Wrong number!!\n");
1423 for (list = state_cb_list; list; list = list->next) {
1424 if (count == input) {
1425 profile = list->data;
1435 if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
1438 state_cb_list = g_slist_remove(state_cb_list, profile);
1439 connection_profile_destroy(profile);
1444 int test_reset_call_statistics_info(void)
1446 int ret = CONNECTION_ERROR_NONE;
1448 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1449 printf("reset last recv data size [%d]\n", ret);
1450 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1451 printf("last sent data size [%d]\n", ret);
1452 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1453 printf("total received data size [%d]\n", ret);
1454 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1455 printf("total sent data size [%d]\n", ret);
1460 int test_reset_wifi_call_statistics_info(void)
1462 int ret = CONNECTION_ERROR_NONE;
1464 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1465 printf("WiFi last sent data size [%d]\n", ret);
1466 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1467 printf("WiFi last recv data size [%d]\n", ret);
1468 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1469 printf("WiFi total sent data size [%d]\n", ret);
1470 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1471 printf("WiFi total received data size [%d]\n", ret);
1476 int test_add_route(void)
1479 char ip_addr[100] = {0};
1480 char if_name[40] = {0};
1482 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1485 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1488 g_strstrip(ip_addr);
1489 g_strstrip(if_name);
1490 rv = connection_add_route(connection, if_name, ip_addr);
1491 if (rv != CONNECTION_ERROR_NONE) {
1492 printf("Fail to get add new route [%d]\n", rv);
1495 printf("Add Route successfully\n");
1500 int test_remove_route(void)
1503 char ip_addr[100] = {0};
1504 char if_name[40] = {0};
1506 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1509 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1512 g_strstrip(ip_addr);
1513 g_strstrip(if_name);
1514 rv = connection_remove_route(connection, if_name, ip_addr);
1515 if (rv != CONNECTION_ERROR_NONE) {
1516 printf("Fail to remove the route [%s]\n", test_print_error(rv));
1519 printf("Remove Route successfully\n");
1524 int test_add_route_ipv6(void)
1527 char ip_addr[100] = {0};
1528 char gateway[100] = {0};
1529 char if_name[40] = {0};
1531 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1534 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1537 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1540 g_strstrip(ip_addr);
1541 g_strstrip(gateway);
1542 g_strstrip(if_name);
1543 rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
1544 if (rv != CONNECTION_ERROR_NONE) {
1545 printf("Fail to get add new route [%d]\n", rv);
1548 printf("Add Route successfully\n");
1553 int test_remove_route_ipv6(void)
1556 char ip_addr[100] = {0};
1557 char gateway[100] = {0};
1558 char if_name[40] = {0};
1560 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1563 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1566 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1569 g_strstrip(ip_addr);
1570 g_strstrip(gateway);
1571 g_strstrip(if_name);
1572 rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
1573 if (rv != CONNECTION_ERROR_NONE) {
1574 printf("Fail to remove the route [%d]\n", rv);
1577 printf("Remove Route successfully\n");
1582 int test_get_bt_state(void)
1585 connection_bt_state_e bt_state;
1587 rv = connection_get_bt_state(connection, &bt_state);
1589 if (rv != CONNECTION_ERROR_NONE) {
1590 printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv));
1594 printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state);
1599 int test_get_profile_id(void)
1601 connection_profile_h profile;
1604 printf("\n** Choose a profile to see profile id. **\n");
1605 if (test_get_user_selected_profile(&profile, true) == false)
1608 if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
1609 printf("Fail to get profile name\n");
1612 printf("Profile id : %s\n", profile_id);
1619 int test_get_mac_address(void)
1621 int rv = 0, type = 0;
1622 connection_type_e conn_type;
1623 char *mac_addr = NULL;
1625 test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
1629 conn_type = CONNECTION_TYPE_WIFI;
1632 conn_type = CONNECTION_TYPE_ETHERNET;
1635 printf("Wrong number!!\n");
1639 rv = connection_get_mac_address(connection, conn_type, &mac_addr);
1641 if (rv != CONNECTION_ERROR_NONE) {
1642 printf("Fail to get MAC address [%s]\n", test_print_error(rv));
1646 printf("mac address is %s\n", mac_addr);
1653 int test_get_ethernet_cable_state(void)
1656 connection_ethernet_cable_state_e cable_state;
1658 rv = connection_get_ethernet_cable_state(connection, &cable_state);
1660 if (rv != CONNECTION_ERROR_NONE) {
1661 printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
1665 printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
1670 int test_reset_profile(void)
1672 int type, sim_id, rv;
1674 rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
1676 if (rv == false || (type != 0 && type != 1)) {
1677 printf("Invalid input!!\n");
1681 rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
1683 if (rv == false || (sim_id != 0 && sim_id != 1)) {
1684 printf("Invalid input!!\n");
1688 if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE)
1694 int main(int argc, char **argv)
1696 GMainLoop *mainloop;
1697 mainloop = g_main_loop_new(NULL, FALSE);
1699 GIOChannel *channel = g_io_channel_unix_new(0);
1700 g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
1702 printf("Test Thread created...\n");
1704 g_main_loop_run(mainloop);
1709 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
1714 memset(a, '\0', 100);
1715 printf("Event received from stdin\n");
1717 rv = read(0, a, 100);
1719 if (rv < 0 || a[0] == '0') {
1720 if (connection != NULL)
1721 test_deregister_client();
1726 if (*a == '\n' || *a == '\r') {
1727 printf("\n\n Network Connection API Test App\n\n");
1728 printf("Options..\n");
1729 printf("1 - Create Handle and set callbacks\n");
1730 printf("2 - Destroy Handle(unset callbacks automatically)\n");
1731 printf("3 - Get network state\n");
1732 printf("4 - Get cellular state (please insert SIM Card)\n");
1733 printf("5 - Get wifi state (please turn on WiFi)\n");
1734 printf("6 - Get current proxy address \n");
1735 printf("7 - Get current Ip address\n");
1736 printf("8 - Get cellular data call statistics\n");
1737 printf("9 - Get WiFi data call statistics\n");
1738 printf("a - Get Profile list\n");
1739 printf("b - Get Connected Profile list\n");
1740 printf("c - Get Current profile\n");
1741 printf("d - Open connection with profile\n");
1742 printf("e - Get default cellular service by type\n");
1743 printf("f - Set default cellular service by type\n");
1744 printf("g - Close connection with profile\n");
1745 printf("h - Add profile(Cellular and Wifi only)\n");
1746 printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
1747 printf("j - Update profile\n");
1748 printf("k - Get profile info\n");
1749 printf("l - Refresh profile info\n");
1750 printf("m - Set state changed callback\n");
1751 printf("n - Unset state changed callback\n");
1752 printf("o - Reset cellular data call statistics\n");
1753 printf("p - Reset WiFi data call statistics\n");
1754 printf("q - Add new route\n");
1755 printf("r - Remove a route\n");
1756 printf("s - Get Bluetooth state\n");
1757 printf("t - Get profile id\n");
1758 printf("u - Reset profile\n");
1759 printf("v - Get all cellular default profiles\n");
1760 printf("w - Get mac address\n");
1761 printf("x - Get ethernet cable state\n");
1762 printf("B - Add IPv6 new route\n");
1763 printf("C - Remove IPv6 route\n");
1764 printf("0 - Exit \n");
1765 printf("ENTER - Show options menu.......\n");
1770 rv = test_register_client();
1773 rv = test_deregister_client();
1776 rv = test_get_network_state();
1779 rv = test_get_cellular_state();
1782 rv = test_get_wifi_state();
1785 rv = test_get_current_proxy();
1788 rv = test_get_current_ip();
1791 rv = test_get_call_statistics_info();
1794 rv = test_get_wifi_call_statistics_info();
1797 rv = test_get_profile_list();
1800 rv = test_get_connected_profile_list();
1803 rv = test_get_current_profile();
1806 rv = test_open_profile();
1809 rv = test_get_default_cellular_service_type();
1812 rv = test_set_default_cellular_service_type();
1815 rv = test_close_profile();
1818 rv = test_add_profile();
1821 rv = test_remove_profile();
1824 rv = test_update_profile();
1827 rv = test_get_profile_info();
1830 rv = test_refresh_profile_info();
1833 rv = test_set_state_changed_callback();
1836 rv = test_unset_state_changed_callback();
1839 rv = test_reset_call_statistics_info();
1842 rv = test_reset_wifi_call_statistics_info();
1845 rv = test_add_route();
1848 rv = test_remove_route();
1851 rv = test_get_bt_state();
1854 rv = test_get_profile_id();
1857 rv = test_reset_profile();
1860 rv = test_get_default_profile_list();
1863 rv = test_get_mac_address();
1866 rv = test_get_ethernet_cable_state();
1869 rv = test_add_route_ipv6();
1872 rv = test_remove_route_ipv6();
1877 printf("Operation succeeded!\n");
1879 printf("Operation failed!\n");