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");
259 printf("%d. state:[%s], profile name:%s[%d]\n",
260 profile_count, test_print_state(profile_state), profile_name, service_type);
262 profile_list[profile_count] = profile_h;
266 g_free(profile_name);
267 if (profile_count >= 100)
274 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
275 input >= profile_count ||
277 printf("Wrong number!!\n");
282 *profile = profile_list[input];
287 static int test_update_cellular_info(connection_profile_h profile)
290 char input_str1[100] = {0,};
291 char input_str2[100] = {0,};
295 if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, "
296 "Prepaid MMS:4, Tethering:5, Application:6)"
297 " - (Enter for skip) :", &input_int)) {
300 rv = connection_profile_set_cellular_service_type(profile,
301 CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
304 rv = connection_profile_set_cellular_service_type(profile,
305 CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
308 rv = connection_profile_set_cellular_service_type(profile,
309 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET);
312 rv = connection_profile_set_cellular_service_type(profile,
313 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS);
316 rv = connection_profile_set_cellular_service_type(profile,
317 CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING);
320 rv = connection_profile_set_cellular_service_type(profile,
321 CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
327 if (rv != CONNECTION_ERROR_NONE)
332 if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) {
333 g_strstrip(input_str1);
334 rv = connection_profile_set_cellular_apn(profile, input_str1);
335 if (rv != CONNECTION_ERROR_NONE)
339 if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
340 g_strstrip(input_str1);
341 rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
342 if (rv != CONNECTION_ERROR_NONE)
346 if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) {
347 g_strstrip(input_str1);
348 rv = connection_profile_set_cellular_home_url(profile, input_str1);
349 if (rv != CONNECTION_ERROR_NONE)
353 if (test_get_user_int("Input AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) {
356 rv = connection_profile_set_cellular_auth_info(profile,
357 CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", "");
358 if (rv != CONNECTION_ERROR_NONE)
363 type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
366 if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
368 if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false)
370 if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
373 g_strstrip(input_str1);
374 g_strstrip(input_str2);
375 rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
376 if (rv != CONNECTION_ERROR_NONE)
384 static int test_update_wifi_info(connection_profile_h profile)
387 char input_str[100] = {0,};
389 if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) {
390 rv = connection_profile_set_wifi_passphrase(profile, input_str);
391 if (rv != CONNECTION_ERROR_NONE)
398 static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
401 char input_str[100] = {0,};
403 if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
404 rv = connection_profile_set_ip_address(profile,
407 if (rv != CONNECTION_ERROR_NONE)
411 if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
412 rv = connection_profile_set_subnet_mask(profile,
415 if (rv != CONNECTION_ERROR_NONE)
419 if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
420 rv = connection_profile_set_gateway_address(profile,
423 if (rv != CONNECTION_ERROR_NONE)
427 if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
428 rv = connection_profile_set_dns_address(profile,
432 if (rv != CONNECTION_ERROR_NONE)
435 if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
436 rv = connection_profile_set_dns_address(profile,
440 if (rv != CONNECTION_ERROR_NONE)
448 static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
452 char input_str[100] = {0,};
454 if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)"
455 " - (Enter for skip) :", &input_int)) {
458 rv = connection_profile_set_proxy_type(profile,
459 CONNECTION_PROXY_TYPE_DIRECT);
461 if (rv != CONNECTION_ERROR_NONE)
466 rv = connection_profile_set_proxy_type(profile,
467 CONNECTION_PROXY_TYPE_AUTO);
470 rv = connection_profile_set_proxy_type(profile,
471 CONNECTION_PROXY_TYPE_MANUAL);
477 if (rv != CONNECTION_ERROR_NONE)
480 if (test_get_user_string("Input auto Proxy URL or Proxy address"
481 " - (Enter for skip) :", input_str, 100)) {
482 rv = connection_profile_set_proxy_address(profile,
485 if (rv != CONNECTION_ERROR_NONE)
495 static int test_update_network_info(connection_profile_h profile)
499 int address_family = 0;
501 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
503 if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)"
504 " - (Enter for skip) :", &input_int)) {
507 rv = connection_profile_set_ip_config_type(profile,
509 CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
512 rv = connection_profile_set_ip_config_type(profile,
514 CONNECTION_IP_CONFIG_TYPE_STATIC);
515 if (rv != CONNECTION_ERROR_NONE)
518 if (test_update_ip_info(profile, address_family) == -1)
521 if (test_update_proxy_info(profile, address_family) == -1)
528 if (rv != CONNECTION_ERROR_NONE)
536 static void test_print_cellular_info(connection_profile_h profile)
538 connection_cellular_service_type_e service_type;
540 connection_cellular_auth_type_e auth_type;
541 char *user_name = NULL;
542 char *password = NULL;
543 char *home_url = NULL;
544 bool roaming = false;
546 bool editable = false;
548 if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
549 printf("Fail to get cellular service type!\n");
551 printf("Cellular service type : %d\n", service_type);
553 if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
554 printf("Fail to get cellular APN!\n");
556 printf("Cellular APN : %s\n", apn);
560 if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
561 printf("Fail to get auth info!\n");
563 printf("Cellular auth type : %d\n", auth_type);
564 printf("Cellular user_name : %s\n", user_name);
565 printf("Cellular password : %s\n", password);
570 if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE)
571 printf("Fail to get cellular home url!\n");
573 printf("Cellular home url : %s\n", home_url);
577 if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
578 printf("Fail to get cellular roaming state!\n");
580 printf("Cellular roaming : %s\n", roaming ? "true" : "false");
582 if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE)
583 printf("Fail to get cellular hidden state!\n");
585 printf("Cellular hidden : %s\n", hidden ? "true" : "false");
587 if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE)
588 printf("Fail to get cellular editing state!\n");
590 printf("Cellular editable : %s\n", editable ? "true" : "false");
593 static void test_print_wifi_info(connection_profile_h profile)
600 connection_wifi_security_type_e security_type;
601 connection_wifi_encryption_type_e encryption_type;
602 bool pass_required = false;
603 bool wps_supported = false;
605 if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
606 printf("Fail to get Wi-Fi essid!\n");
608 printf("Wi-Fi essid : %s\n", essid);
612 if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
613 printf("Fail to get Wi-Fi bssid!\n");
615 printf("Wi-Fi bssid : %s\n", bssid);
619 if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
620 printf("Fail to get Wi-Fi rssi!\n");
622 printf("Wi-Fi rssi : %d\n", rssi);
624 if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
625 printf("Fail to get Wi-Fi frequency!\n");
627 printf("Wi-Fi frequency : %d\n", frequency);
629 if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE)
630 printf("Fail to get Wi-Fi max speed!\n");
632 printf("Wi-Fi max speed : %d\n", max_speed);
634 if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
635 printf("Fail to get Wi-Fi security type!\n");
637 printf("Wi-Fi security type : %d\n", security_type);
639 if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE)
640 printf("Fail to get Wi-Fi encryption type!\n");
642 printf("Wi-Fi encryption type : %d\n", encryption_type);
644 if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
645 printf("Fail to get Wi-Fi passphrase required!\n");
647 printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false");
649 if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE)
650 printf("Fail to get Wi-Fi wps info\n");
652 printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
655 static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
657 char *interface_name = NULL;
658 connection_ip_config_type_e ip_type;
661 char *gateway = NULL;
664 connection_proxy_type_e proxy_type;
667 if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
668 printf("Fail to get interface name!\n");
670 printf("Interface name : %s\n", interface_name);
671 g_free(interface_name);
674 if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
675 printf("Fail to get ipconfig type!\n");
677 printf("Ipconfig type : %d\n", ip_type);
679 if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
680 printf("Fail to get IP address!\n");
682 printf("IP address : %s\n", ip);
686 if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
687 printf("Fail to get subnet mask!\n");
689 printf("Subnet mask : %s\n", subnet);
693 if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
694 printf("Fail to get gateway!\n");
696 printf("Gateway : %s\n", gateway);
700 if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
701 printf("Fail to get DNS1!\n");
703 printf("DNS1 : %s\n", dns1);
707 if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
708 printf("Fail to get DNS2!\n");
710 printf("DNS2 : %s\n", dns2);
714 if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
715 printf("Fail to get proxy type!\n");
717 printf("Proxy type : %d\n", proxy_type);
719 if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
720 printf("Fail to get proxy!\n");
722 printf("Proxy : %s\n", proxy);
727 int test_register_client(void)
730 int err = connection_create(&connection);
732 if (CONNECTION_ERROR_NONE == err) {
733 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
734 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
735 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
736 connection_set_ethernet_cable_state_chaged_cb(connection,
737 test_get_ethernet_cable_state_callback, NULL);
739 printf("Client registration failed [%s]\n", test_print_error(err));
743 printf("Client registration success\n");
747 int test_deregister_client(void)
751 connection_profile_h profile;
753 if (connection != NULL)
754 rv = connection_destroy(connection);
756 printf("Cannot deregister : Handle is NULL\n");
757 rv = CONNECTION_ERROR_INVALID_OPERATION;
760 if (rv != CONNECTION_ERROR_NONE) {
761 printf("Client deregistration fail [%s]\n", test_print_error(rv));
766 for (list = state_cb_list; list; list = list->next) {
767 profile = list->data;
768 connection_profile_destroy(profile);
771 g_slist_free(state_cb_list);
772 state_cb_list = NULL;
776 printf("Client deregistration success\n");
781 int test_get_network_state(void)
784 connection_type_e net_state;
786 rv = connection_get_type(connection, &net_state);
788 if (rv != CONNECTION_ERROR_NONE) {
789 printf("Fail to get network state [%s]\n", test_print_error(rv));
793 printf("Retval = [%s] network connection state [%d]\n", test_print_error(rv), net_state);
798 int test_get_cellular_state(void)
801 connection_cellular_state_e cellular_state;
803 rv = connection_get_cellular_state(connection, &cellular_state);
805 if (rv != CONNECTION_ERROR_NONE) {
806 printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
810 printf("Retval = [%s] Cellular state [%d]\n", test_print_error(rv), cellular_state);
815 int test_get_wifi_state(void)
818 connection_wifi_state_e wifi_state;
820 rv = connection_get_wifi_state(connection, &wifi_state);
822 if (rv != CONNECTION_ERROR_NONE) {
823 printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
827 printf("Retval = [%s] WiFi state [%d]\n", test_print_error(rv), wifi_state);
832 int test_get_current_proxy(void)
834 char *proxy_addr = NULL;
836 connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
838 if (proxy_addr == NULL) {
839 printf("Proxy address does not exist\n");
843 printf("Current Proxy [%s]\n", proxy_addr);
849 int test_get_current_ip(void)
851 char *ip_addr = NULL;
855 rv = test_get_user_int("Input Address type to get"
856 "(1:IPV4, 2:IPV6):", &input);
859 printf("Invalid input!!\n");
865 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
866 if (ip_addr == NULL) {
867 printf("IPv4 address does not exist\n");
870 printf("IPv4 address : %s\n", ip_addr);
874 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
875 if (ip_addr == NULL) {
876 printf("IPv6 address does not exist\n");
879 printf("IPv6 address : %s\n", ip_addr);
882 printf("Wrong IP address family!!\n");
890 int test_get_call_statistics_info(void)
894 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
895 printf("last recv data size [%lld]\n", rv);
896 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
897 printf("last sent data size [%lld]\n",rv );
898 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
899 printf("total received data size [%lld]\n",rv );
900 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
901 printf("total sent data size [%lld]\n", rv);
906 int test_get_wifi_call_statistics_info(void)
910 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
911 printf("WiFi last recv data size [%lld]\n", rv);
912 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
913 printf("WiFi last sent data size [%lld]\n",rv );
914 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
915 printf("WiFi total received data size [%lld]\n",rv );
916 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
917 printf("WiFi total sent data size [%lld]\n", rv);
922 int test_get_profile_list(void)
924 if (test_get_user_selected_profile(NULL, false) == false)
930 int test_get_default_profile_list(void)
933 char *profile_name = NULL;
934 connection_profile_iterator_h profile_iter;
935 connection_profile_h profile_h;
936 connection_cellular_service_type_e service_type;
937 bool is_default = false;
939 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
940 if (rv != CONNECTION_ERROR_NONE) {
941 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
945 while (connection_profile_iterator_has_next(profile_iter)) {
946 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
947 printf("Fail to get profile handle\n");
951 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
952 printf("Fail to get profile name\n");
955 printf("profile name : %s\n", profile_name);
956 g_free(profile_name);
958 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
959 printf("Fail to get profile service type\n");
962 printf("service type : %d\n", service_type);
964 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
965 printf("Fail to get profile subscriber id\n");
968 printf("Default : %d\n", is_default);
974 int test_get_connected_profile_list(void)
977 char *profile_name = NULL;
978 connection_profile_iterator_h profile_iter;
979 connection_profile_h profile_h;
980 bool is_default = false;
981 connection_profile_type_e type;
983 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
984 if (rv != CONNECTION_ERROR_NONE) {
985 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
989 while (connection_profile_iterator_has_next(profile_iter)) {
990 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
991 printf("Fail to get profile handle\n");
995 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
996 printf("Fail to get profile name\n");
999 printf("profile name is %s\n", profile_name);
1000 g_free(profile_name);
1002 if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
1003 printf("Fail to get profile type\n");
1006 printf("profile type is %d\n", type);
1008 if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
1009 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1010 printf("Fail to get profile is default\n");
1013 printf("[%s]\n", is_default ? "default" : "not default");
1020 int test_get_current_profile(void)
1023 char *profile_name = NULL;
1024 connection_profile_h profile_h;
1026 rv = connection_get_current_profile(connection, &profile_h);
1027 if (rv != CONNECTION_ERROR_NONE) {
1028 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1032 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1033 printf("Fail to get profile name\n");
1036 printf("profile name : %s\n", profile_name);
1037 g_free(profile_name);
1039 connection_profile_destroy(profile_h);
1044 int test_open_profile(void)
1046 connection_profile_h profile;
1048 printf("\n** Choose a profile to open. **\n");
1050 if (test_get_user_selected_profile(&profile, true) == false)
1053 if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
1054 printf("Connection open Failed!!\n");
1061 int test_get_default_cellular_service_type(void)
1066 connection_profile_h profile;
1067 char *profile_name = NULL;
1069 rv = test_get_user_int("Input profile type to get"
1070 "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input);
1073 printf("Invalid input!!\n");
1079 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
1082 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
1085 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
1088 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
1091 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
1094 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
1097 printf("Wrong number!!\n");
1101 if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
1104 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1105 printf("Fail to get profile name\n");
1106 connection_profile_destroy(profile);
1109 printf("Default profile name : %s\n", profile_name);
1110 g_free(profile_name);
1112 connection_profile_destroy(profile);
1117 int test_set_default_cellular_service_type(void)
1119 connection_profile_h profile;
1120 connection_cellular_service_type_e type;
1123 rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
1125 if (rv == false || (input != 1 && input != 2)) {
1126 printf("Invalid input!!\n");
1130 printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
1132 if (test_get_user_selected_profile(&profile, true) == false)
1135 if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
1136 printf("Fail to get cellular service type\n");
1141 if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
1144 if (connection_set_default_cellular_service_profile_async(connection,
1145 type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
1152 int test_close_profile(void)
1154 connection_profile_h profile;
1156 printf("\n** Choose a profile to close. **\n");
1158 if (test_get_user_selected_profile(&profile, true) == false)
1161 if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
1162 printf("Connection close Failed!!\n");
1169 int test_add_profile(void)
1172 connection_profile_h profile;
1173 char input_str[100] = {0,};
1175 if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
1178 g_strstrip(input_str);
1179 rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
1180 if (rv != CONNECTION_ERROR_NONE)
1181 RETURN_FAIL_DESTROY(profile);
1183 if (test_update_cellular_info(profile) == -1)
1184 RETURN_FAIL_DESTROY(profile);
1186 rv = connection_add_profile(connection, profile);
1187 if (rv != CONNECTION_ERROR_NONE)
1188 RETURN_FAIL_DESTROY(profile);
1190 connection_profile_destroy(profile);
1194 int test_remove_profile(void)
1196 connection_profile_h profile;
1198 printf("\n** Choose a profile to remove. **\n");
1199 if (test_get_user_selected_profile(&profile, true) == false)
1202 if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
1203 printf("Remove profile Failed!!\n");
1210 int test_update_profile(void)
1214 connection_profile_type_e prof_type;
1215 connection_profile_h profile;
1217 printf("\n** Choose a profile to update. **\n");
1218 if (test_get_user_selected_profile(&profile, true) == false)
1221 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1224 switch (prof_type) {
1225 case CONNECTION_PROFILE_TYPE_CELLULAR:
1226 if (test_update_cellular_info(profile) == -1)
1230 case CONNECTION_PROFILE_TYPE_WIFI:
1231 if (test_update_wifi_info(profile) == -1)
1234 if (test_update_network_info(profile) == -1)
1238 case CONNECTION_PROFILE_TYPE_ETHERNET:
1239 if (test_update_network_info(profile) == -1)
1243 case CONNECTION_PROFILE_TYPE_BT:
1244 printf("Not supported!\n");
1250 rv = connection_update_profile(connection, profile);
1251 if (rv != CONNECTION_ERROR_NONE)
1257 int test_get_profile_info(void)
1259 connection_profile_type_e prof_type;
1260 connection_profile_state_e profile_state;
1261 connection_profile_h profile;
1262 char *profile_name = NULL;
1263 int address_family = 0;
1265 printf("\n** Choose a profile to print. **\n");
1266 if (test_get_user_selected_profile(&profile, true) == false)
1269 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1270 printf("Fail to get profile name\n");
1273 printf("Profile Name : %s\n", profile_name);
1274 g_free(profile_name);
1277 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1278 printf("Fail to get profile state\n");
1281 printf("Profile State : %s\n", test_print_state(profile_state));
1283 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1286 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1288 switch (prof_type) {
1289 case CONNECTION_PROFILE_TYPE_CELLULAR:
1290 printf("Profile Type : Cellular\n");
1291 test_print_cellular_info(profile);
1293 case CONNECTION_PROFILE_TYPE_WIFI:
1294 printf("Profile Type : Wi-Fi\n");
1295 test_print_wifi_info(profile);
1297 case CONNECTION_PROFILE_TYPE_ETHERNET:
1298 printf("Profile Type : Ethernet\n");
1300 case CONNECTION_PROFILE_TYPE_BT:
1301 printf("Profile Type : Bluetooth\n");
1307 test_print_network_info(profile, address_family);
1312 int test_refresh_profile_info(void)
1314 connection_profile_type_e prof_type;
1315 connection_profile_state_e profile_state;
1316 connection_profile_h profile;
1317 char *profile_name = NULL;
1318 int address_family = 0;
1320 printf("\n** Choose a profile to refresh. **\n");
1321 if (test_get_user_selected_profile(&profile, true) == false)
1324 if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
1327 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1328 printf("Fail to get profile name\n");
1331 printf("Profile Name : %s\n", profile_name);
1332 g_free(profile_name);
1335 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1336 printf("Fail to get profile state\n");
1339 printf("Profile State : %s\n", test_print_state(profile_state));
1342 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1345 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1347 switch (prof_type) {
1348 case CONNECTION_PROFILE_TYPE_CELLULAR:
1349 printf("Profile Type : Cellular\n");
1350 test_print_cellular_info(profile);
1352 case CONNECTION_PROFILE_TYPE_WIFI:
1353 printf("Profile Type : Wi-Fi\n");
1354 test_print_wifi_info(profile);
1356 case CONNECTION_PROFILE_TYPE_ETHERNET:
1357 printf("Profile Type : Ethernet\n");
1359 case CONNECTION_PROFILE_TYPE_BT:
1360 printf("Profile Type : Bluetooth\n");
1366 test_print_network_info(profile, address_family);
1371 int test_set_state_changed_callback()
1373 connection_profile_h profile;
1374 connection_profile_h profile_clone;
1376 printf("\n** Choose a profile to set callback. **\n");
1377 if (test_get_user_selected_profile(&profile, true) == false)
1380 if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
1383 if (connection_profile_set_state_changed_cb(profile,
1384 test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
1385 connection_profile_destroy(profile_clone);
1389 state_cb_list = g_slist_append(state_cb_list, profile_clone);
1394 int test_unset_state_changed_callback()
1396 connection_profile_h profile;
1398 char *profile_name = NULL;
1402 printf("\n** Choose a profile to unset callback. **\n");
1403 for (list = state_cb_list; list; list = list->next) {
1404 profile = list->data;
1405 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1406 printf("Fail to get profile name!\n");
1409 printf("%d. %s\n", count, profile_name);
1410 g_free(profile_name);
1416 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
1419 printf("Wrong number!!\n");
1424 for (list = state_cb_list; list; list = list->next) {
1425 if (count == input) {
1426 profile = list->data;
1436 if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
1439 state_cb_list = g_slist_remove(state_cb_list, profile);
1440 connection_profile_destroy(profile);
1445 int test_reset_call_statistics_info(void)
1447 int ret = CONNECTION_ERROR_NONE;
1449 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1450 printf("reset last recv data size [%d]\n", ret);
1451 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1452 printf("last sent data size [%d]\n", ret);
1453 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1454 printf("total received data size [%d]\n", ret);
1455 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1456 printf("total sent data size [%d]\n", ret);
1461 int test_reset_wifi_call_statistics_info(void)
1463 int ret = CONNECTION_ERROR_NONE;
1465 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1466 printf("WiFi last sent data size [%d]\n", ret);
1467 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1468 printf("WiFi last recv data size [%d]\n", ret);
1469 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1470 printf("WiFi total sent data size [%d]\n", ret);
1471 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1472 printf("WiFi total received data size [%d]\n", ret);
1477 int test_add_route(void)
1480 char ip_addr[100] = {0};
1481 char if_name[40] = {0};
1483 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1486 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1489 g_strstrip(ip_addr);
1490 g_strstrip(if_name);
1491 rv = connection_add_route(connection, if_name, ip_addr);
1492 if (rv != CONNECTION_ERROR_NONE) {
1493 printf("Fail to get add new route [%d]\n", rv);
1496 printf("Add Route successfully\n");
1501 int test_remove_route(void)
1504 char ip_addr[100] = {0};
1505 char if_name[40] = {0};
1507 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1510 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1513 g_strstrip(ip_addr);
1514 g_strstrip(if_name);
1515 rv = connection_remove_route(connection, if_name, ip_addr);
1516 if (rv != CONNECTION_ERROR_NONE) {
1517 printf("Fail to remove the route [%s]\n", test_print_error(rv));
1520 printf("Remove Route successfully\n");
1525 int test_add_route_ipv6(void)
1528 char ip_addr[100] = {0};
1529 char gateway[100] = {0};
1530 char if_name[40] = {0};
1532 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1535 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1538 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1541 g_strstrip(ip_addr);
1542 g_strstrip(gateway);
1543 g_strstrip(if_name);
1544 rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
1545 if (rv != CONNECTION_ERROR_NONE) {
1546 printf("Fail to get add new route [%d]\n", rv);
1549 printf("Add Route successfully\n");
1554 int test_remove_route_ipv6(void)
1557 char ip_addr[100] = {0};
1558 char gateway[100] = {0};
1559 char if_name[40] = {0};
1561 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1564 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1567 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1570 g_strstrip(ip_addr);
1571 g_strstrip(gateway);
1572 g_strstrip(if_name);
1573 rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
1574 if (rv != CONNECTION_ERROR_NONE) {
1575 printf("Fail to remove the route [%d]\n", rv);
1578 printf("Remove Route successfully\n");
1583 int test_get_bt_state(void)
1586 connection_bt_state_e bt_state;
1588 rv = connection_get_bt_state(connection, &bt_state);
1590 if (rv != CONNECTION_ERROR_NONE) {
1591 printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv));
1595 printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state);
1600 int test_get_profile_id(void)
1602 connection_profile_h profile;
1605 printf("\n** Choose a profile to see profile id. **\n");
1606 if (test_get_user_selected_profile(&profile, true) == false)
1609 if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
1610 printf("Fail to get profile name\n");
1613 printf("Profile id : %s\n", profile_id);
1620 int test_get_mac_address(void)
1622 int rv = 0, type = 0;
1623 connection_type_e conn_type;
1624 char *mac_addr = NULL;
1626 test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
1630 conn_type = CONNECTION_TYPE_WIFI;
1633 conn_type = CONNECTION_TYPE_ETHERNET;
1636 printf("Wrong number!!\n");
1640 rv = connection_get_mac_address(connection, conn_type, &mac_addr);
1642 if (rv != CONNECTION_ERROR_NONE) {
1643 printf("Fail to get MAC address [%s]\n", test_print_error(rv));
1647 printf("mac address is %s\n", mac_addr);
1654 int test_get_ethernet_cable_state(void)
1657 connection_ethernet_cable_state_e cable_state;
1659 rv = connection_get_ethernet_cable_state(connection, &cable_state);
1661 if (rv != CONNECTION_ERROR_NONE) {
1662 printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
1666 printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
1671 int test_reset_profile(void)
1673 int type, sim_id, rv;
1675 rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
1677 if (rv == false || (type != 0 && type != 1)) {
1678 printf("Invalid input!!\n");
1682 rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
1684 if (rv == false || (sim_id != 0 && sim_id != 1)) {
1685 printf("Invalid input!!\n");
1689 if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) {
1696 int main(int argc, char **argv)
1698 GMainLoop *mainloop;
1699 mainloop = g_main_loop_new (NULL, FALSE);
1701 GIOChannel *channel = g_io_channel_unix_new(0);
1702 g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread,NULL );
1704 printf("Test Thread created...\n");
1706 g_main_loop_run (mainloop);
1711 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
1716 memset(a, '\0', 100);
1717 printf("Event received from stdin\n");
1719 rv = read(0, a, 100);
1721 if (rv < 0 || a[0] == '0') {
1722 if (connection != NULL)
1723 test_deregister_client();
1728 if (*a == '\n' || *a == '\r') {
1729 printf("\n\n Network Connection API Test App\n\n");
1730 printf("Options..\n");
1731 printf("1 - Create Handle and set callbacks\n");
1732 printf("2 - Destroy Handle(unset callbacks automatically)\n");
1733 printf("3 - Get network state\n");
1734 printf("4 - Get cellular state (please insert SIM Card)\n");
1735 printf("5 - Get wifi state (please turn on WiFi)\n");
1736 printf("6 - Get current proxy address \n");
1737 printf("7 - Get current Ip address\n");
1738 printf("8 - Get cellular data call statistics\n");
1739 printf("9 - Get WiFi data call statistics\n");
1740 printf("a - Get Profile list\n");
1741 printf("b - Get Connected Profile list\n");
1742 printf("c - Get Current profile\n");
1743 printf("d - Open connection with profile\n");
1744 printf("e - Get default cellular service by type\n");
1745 printf("f - Set default cellular service by type\n");
1746 printf("g - Close connection with profile\n");
1747 printf("h - Add profile(Cellular and Wifi only)\n");
1748 printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
1749 printf("j - Update profile\n");
1750 printf("k - Get profile info\n");
1751 printf("l - Refresh profile info\n");
1752 printf("m - Set state changed callback\n");
1753 printf("n - Unset state changed callback\n");
1754 printf("o - Reset cellular data call statistics\n");
1755 printf("p - Reset WiFi data call statistics\n");
1756 printf("q - Add new route\n");
1757 printf("r - Remove a route\n");
1758 printf("s - Get Bluetooth state\n");
1759 printf("t - Get profile id\n");
1760 printf("u - Reset profile\n");
1761 printf("v - Get all cellular default profiles\n");
1762 printf("w - Get mac address\n");
1763 printf("x - Get ethernet cable state\n");
1764 printf("B - Add IPv6 new route\n");
1765 printf("C - Remove IPv6 route\n");
1766 printf("0 - Exit \n");
1767 printf("ENTER - Show options menu.......\n");
1772 rv = test_register_client();
1775 rv = test_deregister_client();
1778 rv = test_get_network_state();
1781 rv = test_get_cellular_state();
1784 rv = test_get_wifi_state();
1787 rv = test_get_current_proxy();
1790 rv = test_get_current_ip();
1793 rv = test_get_call_statistics_info();
1796 rv = test_get_wifi_call_statistics_info();
1799 rv = test_get_profile_list();
1802 rv = test_get_connected_profile_list();
1805 rv = test_get_current_profile();
1808 rv = test_open_profile();
1811 rv = test_get_default_cellular_service_type();
1814 rv = test_set_default_cellular_service_type();
1817 rv = test_close_profile();
1820 rv = test_add_profile();
1823 rv = test_remove_profile();
1826 rv = test_update_profile();
1829 rv = test_get_profile_info();
1832 rv = test_refresh_profile_info();
1835 rv = test_set_state_changed_callback();
1838 rv = test_unset_state_changed_callback();
1841 rv = test_reset_call_statistics_info();
1844 rv = test_reset_wifi_call_statistics_info();
1847 rv = test_add_route();
1850 rv = test_remove_route();
1853 rv = test_get_bt_state();
1856 rv = test_get_profile_id();
1859 rv = test_reset_profile();
1862 rv = test_get_default_profile_list();
1865 rv = test_get_mac_address();
1868 rv = test_get_ethernet_cable_state();
1871 rv = test_add_route_ipv6();
1874 rv = test_remove_route_ipv6();
1879 printf("Operation succeeded!\n");
1881 printf("Operation failed!\n");