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 "connection_extension.h"
27 #include <tizen_error.h>
29 #define LOG_RED "\033[0;31m"
30 #define LOG_GREEN "\033[0;32m"
31 #define LOG_BROWN "\033[0;33m"
32 #define LOG_BLUE "\033[0;34m"
33 #define LOG_END "\033[0;m"
35 #define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1; }
37 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
39 connection_h connection = NULL;
40 static GSList *state_cb_list = NULL;
43 static bool test_get_user_string(const char *msg, char *buf, int buf_size)
45 if (msg == NULL || buf == NULL || buf_size < 2)
50 memset(buf, 0, buf_size);
51 rv = read(0, buf, buf_size - 1);
53 if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
62 static bool test_get_user_int(const char *msg, int *num)
64 if (msg == NULL || num == NULL)
70 rv = read(0, buf, 32);
72 if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
79 static const char *test_print_state(connection_profile_state_e state)
82 case CONNECTION_PROFILE_STATE_DISCONNECTED:
83 return "Disconnected";
84 case CONNECTION_PROFILE_STATE_ASSOCIATION:
86 case CONNECTION_PROFILE_STATE_CONFIGURATION:
87 return "Configuration";
88 case CONNECTION_PROFILE_STATE_CONNECTED:
95 static const char *test_print_connection_type(connection_type_e type)
98 case CONNECTION_TYPE_DISCONNECTED:
99 return "Disconnected";
100 case CONNECTION_TYPE_WIFI:
102 case CONNECTION_TYPE_CELLULAR:
104 case CONNECTION_TYPE_ETHERNET:
106 case CONNECTION_TYPE_BT:
108 case CONNECTION_TYPE_NET_PROXY:
115 static const char *test_print_cellular_state(connection_cellular_state_e state)
118 case CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE:
119 return "Out of service";
120 case CONNECTION_CELLULAR_STATE_FLIGHT_MODE:
121 return "Flight mode";
122 case CONNECTION_CELLULAR_STATE_ROAMING_OFF:
123 return "Roaming off";
124 case CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE:
125 return "Call only available";
126 case CONNECTION_CELLULAR_STATE_AVAILABLE:
128 case CONNECTION_CELLULAR_STATE_CONNECTED:
135 static const char *test_print_wifi_state(connection_wifi_state_e state)
138 case CONNECTION_WIFI_STATE_DEACTIVATED:
139 return "Deactivated";
140 case CONNECTION_WIFI_STATE_DISCONNECTED:
141 return "Disconnected";
142 case CONNECTION_WIFI_STATE_CONNECTED:
149 static const char *test_print_cellular_service_type(connection_cellular_service_type_e type)
152 case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
154 case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET:
156 case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
158 case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET:
159 return "Prepaid internet";
160 case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS:
161 return "Prepaid MMS";
162 case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING:
164 case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION:
165 return "Application";
171 static const char* test_print_cellular_auth_type(connection_cellular_auth_type_e type)
174 case CONNECTION_CELLULAR_AUTH_TYPE_PAP:
176 case CONNECTION_CELLULAR_AUTH_TYPE_CHAP:
178 case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
184 static const char* test_print_cellular_pdn_type(connection_cellular_pdn_type_e type)
187 case CONNECTION_CELLULAR_PDN_TYPE_IPV4:
189 case CONNECTION_CELLULAR_PDN_TYPE_IPV6:
191 case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6:
193 case CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN:
199 static const char *test_print_error(connection_error_e error)
202 case CONNECTION_ERROR_NONE:
203 return "CONNECTION_ERROR_NONE";
204 case CONNECTION_ERROR_INVALID_PARAMETER:
205 return "CONNECTION_ERROR_INVALID_PARAMETER";
206 case CONNECTION_ERROR_OUT_OF_MEMORY:
207 return "CONNECTION_ERROR_OUT_OF_MEMORY";
208 case CONNECTION_ERROR_INVALID_OPERATION:
209 return "CONNECTION_ERROR_INVALID_OPERATION";
210 case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
211 return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
212 case CONNECTION_ERROR_OPERATION_FAILED:
213 return "CONNECTION_ERROR_OPERATION_FAILED";
214 case CONNECTION_ERROR_ITERATOR_END:
215 return "CONNECTION_ERROR_ITERATOR_END";
216 case CONNECTION_ERROR_NO_CONNECTION:
217 return "CONNECTION_ERROR_NO_CONNECTION";
218 case CONNECTION_ERROR_NOW_IN_PROGRESS:
219 return "CONNECTION_ERROR_NOW_IN_PROGRESS";
220 case CONNECTION_ERROR_ALREADY_EXISTS:
221 return "CONNECTION_ERROR_ALREADY_EXISTS";
222 case CONNECTION_ERROR_OPERATION_ABORTED:
223 return "CONNECTION_ERROR_OPERATION_ABORTED";
224 case CONNECTION_ERROR_DHCP_FAILED:
225 return "CONNECTION_ERROR_DHCP_FAILED";
226 case CONNECTION_ERROR_INVALID_KEY:
227 return "CONNECTION_ERROR_INVALID_KEY";
228 case CONNECTION_ERROR_NO_REPLY:
229 return "CONNECTION_ERROR_NO_REPLY";
230 case CONNECTION_ERROR_PERMISSION_DENIED:
231 return "CONNECTION_ERROR_PERMISSION_DENIED";
232 case CONNECTION_ERROR_NOT_SUPPORTED:
233 return "CONNECTION_ERROR_NOT_SUPPORTED";
234 case CONNECTION_ERROR_NOT_INITIALIZED:
235 return "CONNECTION_ERROR_NOT_INITIALIZED";
236 case CONNECTION_ERROR_ALREADY_INITIALIZED:
237 return "CONNECTION_ERROR_ALREADY_INITIALIZED";
239 return "CONNECTION_ERROR_UNKNOWN";
243 static void test_type_changed_callback(connection_type_e type, void* user_data)
245 printf("Type changed callback, connection type : %d\n", type);
248 static void test_ip_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
250 printf("IP changed callback, IPv4 address : %s, IPv6 address : %s\n",
251 ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
254 static void test_proxy_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
256 printf("Proxy changed callback, IPv4 address : %s, IPv6 address : %s\n",
257 ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
260 static void test_profile_state_callback(connection_profile_state_e state, void* user_data)
263 connection_profile_h profile = user_data;
268 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE)
271 printf("[%s] : %s\n", test_print_state(state), profile_name);
272 g_free(profile_name);
275 static void test_connection_opened_callback(connection_error_e result, void* user_data)
277 if (result == CONNECTION_ERROR_NONE)
278 printf("Connection open Succeeded\n");
280 printf("Connection open Failed, err : [%s]\n", test_print_error(result));
283 static void test_connection_closed_callback(connection_error_e result, void* user_data)
285 if (result == CONNECTION_ERROR_NONE)
286 printf("Connection close Succeeded\n");
288 printf("Connection close Failed, err : [%s]\n", test_print_error(result));
291 static void test_connection_reset_profile_callback(connection_error_e result, void* user_data)
293 if (result == CONNECTION_ERROR_NONE)
294 printf("Reset profile Succeeded\n");
296 printf("Reset profile Failed, err : [%s]\n", test_print_error(result));
299 static void test_connection_set_default_callback(connection_error_e result, void* user_data)
301 if (result == CONNECTION_ERROR_NONE)
302 printf("Default profile setting Succeeded\n");
304 printf("Default profile setting Failed, err : [%s]\n", test_print_error(result));
307 void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state,
310 if (state == CONNECTION_ETHERNET_CABLE_ATTACHED)
311 printf("Ethernet Cable Connected\n");
312 else if (state == CONNECTION_ETHERNET_CABLE_DETACHED)
313 printf("Ethernet Cable Disconnected\n");
316 static bool test_get_user_selected_profile(connection_profile_h *profile, bool select)
321 connection_profile_type_e profile_type;
322 connection_profile_state_e profile_state;
323 connection_profile_iterator_h profile_iter;
324 connection_profile_h profile_h;
326 connection_profile_h profile_list[100] = {0,};
327 int profile_count = 0;
329 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
330 if (rv != CONNECTION_ERROR_NONE) {
331 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
335 while (connection_profile_iterator_has_next(profile_iter)) {
336 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
337 printf("Fail to get profile handle\n");
341 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
342 printf("Fail to get profile name\n");
346 if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) {
347 printf("Fail to get profile type\n");
348 g_free(profile_name);
352 if (connection_profile_get_state(profile_h, &profile_state) != CONNECTION_ERROR_NONE) {
353 printf("Fail to get profile state\n");
354 g_free(profile_name);
358 printf("%d. state:[%s], profile name:%s", profile_count,
359 test_print_state(profile_state), profile_name);
360 if (profile_type == CONNECTION_PROFILE_TYPE_CELLULAR) {
361 connection_cellular_service_type_e service_type;
362 if (connection_profile_get_cellular_service_type(
363 profile_h, &service_type) !=
364 CONNECTION_ERROR_NONE)
365 printf("Fail to get cellular service type!\n");
368 test_print_cellular_service_type(service_type));
372 profile_list[profile_count] = profile_h;
375 g_free(profile_name);
376 if (profile_count >= 100)
383 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
384 input >= profile_count ||
386 printf("Wrong number!!\n");
391 *profile = profile_list[input];
396 static int test_update_cellular_info(connection_profile_h profile)
399 char input_str1[100] = {0,};
400 char input_str2[100] = {0,};
404 if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, "
405 "Prepaid MMS:4, Tethering:5, Application:6)"
406 " - (Enter for skip) :", &input_int)) {
409 rv = connection_profile_set_cellular_service_type(profile,
410 CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
413 rv = connection_profile_set_cellular_service_type(profile,
414 CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
417 rv = connection_profile_set_cellular_service_type(profile,
418 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET);
421 rv = connection_profile_set_cellular_service_type(profile,
422 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS);
425 rv = connection_profile_set_cellular_service_type(profile,
426 CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING);
429 rv = connection_profile_set_cellular_service_type(profile,
430 CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
436 if (rv != CONNECTION_ERROR_NONE)
441 if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) {
442 g_strstrip(input_str1);
443 rv = connection_profile_set_cellular_apn(profile, input_str1);
444 if (rv != CONNECTION_ERROR_NONE)
448 if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
449 g_strstrip(input_str1);
450 rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
451 if (rv != CONNECTION_ERROR_NONE)
455 if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) {
456 g_strstrip(input_str1);
457 rv = connection_profile_set_cellular_home_url(profile, input_str1);
458 if (rv != CONNECTION_ERROR_NONE)
462 if (test_get_user_int("Input AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) {
465 rv = connection_profile_set_cellular_auth_info(profile,
466 CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", "");
467 if (rv != CONNECTION_ERROR_NONE)
472 type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
475 if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
477 if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false)
479 if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
482 g_strstrip(input_str1);
483 g_strstrip(input_str2);
484 rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
485 if (rv != CONNECTION_ERROR_NONE)
490 if (test_get_user_int("Input PdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
493 rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
496 rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
499 rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
503 if (rv != CONNECTION_ERROR_NONE)
507 if (test_get_user_int("Input RoamPdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
510 rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
513 rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
516 rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
520 if (rv != CONNECTION_ERROR_NONE)
527 static int test_update_wifi_info(connection_profile_h profile)
530 char input_str[100] = {0,};
532 if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) {
533 rv = connection_profile_set_wifi_passphrase(profile, input_str);
534 if (rv != CONNECTION_ERROR_NONE)
541 static int test_update_dns_info(connection_profile_h profile,
542 connection_address_family_e address_family)
545 char input_str[100] = {0,};
546 if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
547 rv = connection_profile_set_dns_address(profile,
551 if (rv != CONNECTION_ERROR_NONE)
554 if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
555 rv = connection_profile_set_dns_address(profile,
559 if (rv != CONNECTION_ERROR_NONE)
566 static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
570 char input_str[100] = {0,};
572 if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
573 rv = connection_profile_set_ip_address(profile,
576 if (rv != CONNECTION_ERROR_NONE)
580 if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
581 rv = connection_profile_set_subnet_mask(profile,
584 if (rv != CONNECTION_ERROR_NONE)
588 if (test_get_user_int("Input Prefix Length - (Enter for skip) :", &input_int)) {
589 rv = connection_profile_set_prefix_length(profile,
592 if (rv != CONNECTION_ERROR_NONE)
596 if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
597 rv = connection_profile_set_gateway_address(profile,
600 if (rv != CONNECTION_ERROR_NONE)
604 if (test_update_dns_info(profile, address_family) < 0)
610 static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
614 char input_str[100] = {0,};
616 if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)"
617 " - (Enter for skip) :", &input_int)) {
620 rv = connection_profile_set_proxy_type(profile,
621 CONNECTION_PROXY_TYPE_DIRECT);
623 if (rv != CONNECTION_ERROR_NONE)
628 rv = connection_profile_set_proxy_type(profile,
629 CONNECTION_PROXY_TYPE_AUTO);
632 rv = connection_profile_set_proxy_type(profile,
633 CONNECTION_PROXY_TYPE_MANUAL);
639 if (rv != CONNECTION_ERROR_NONE)
642 if (test_get_user_string("Input auto Proxy URL or Proxy address"
643 " - (Enter for skip) :", input_str, 100)) {
644 rv = connection_profile_set_proxy_address(profile,
647 if (rv != CONNECTION_ERROR_NONE)
659 static int test_update_network_info(connection_profile_h profile)
664 int address_family = 0;
666 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
668 if (test_get_user_int("Input IPv4/IPv6 Address Type (DHCP:1, Static:2, Auto:3)"
669 " - (Enter for skip) :", &input_int)) {
672 rv = connection_profile_set_ip_config_type(profile,
674 CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
675 if (test_get_user_int("Input DNS Address Type (Static:1, DHCP:2)"
676 " - (Enter for skip) :", &dns_input)) {
678 case CONNECTION_DNS_CONFIG_TYPE_STATIC:
679 rv = connection_profile_set_dns_config_type(
682 CONNECTION_DNS_CONFIG_TYPE_STATIC);
683 if (rv != CONNECTION_ERROR_NONE)
685 if (test_update_dns_info(profile,
686 address_family) == -1)
689 case CONNECTION_DNS_CONFIG_TYPE_DYNAMIC:
690 rv = connection_profile_set_dns_config_type(
693 CONNECTION_DNS_CONFIG_TYPE_DYNAMIC);
694 if (rv != CONNECTION_ERROR_NONE)
701 rv = connection_profile_set_ip_config_type(profile,
703 CONNECTION_IP_CONFIG_TYPE_STATIC);
704 if (rv != CONNECTION_ERROR_NONE)
707 if (test_update_ip_info(profile, address_family) == -1)
710 if (test_update_proxy_info(profile, address_family) == -1)
714 rv = connection_profile_set_ip_config_type(profile,
716 CONNECTION_IP_CONFIG_TYPE_AUTO);
722 if (rv != CONNECTION_ERROR_NONE)
730 static void test_print_cellular_info(connection_profile_h profile)
732 connection_cellular_service_type_e service_type;
733 connection_cellular_pdn_type_e pdn_type;
734 connection_cellular_pdn_type_e roam_pdn_type;
736 connection_cellular_auth_type_e auth_type;
737 char *user_name = NULL;
738 char *password = NULL;
739 char *home_url = NULL;
740 bool roaming = false;
742 bool editable = false;
744 if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
745 printf("Fail to get cellular service type!\n");
747 printf("Cellular service type : %s\n", test_print_cellular_service_type(service_type));
749 if (connection_profile_get_cellular_pdn_type(profile, &pdn_type) != CONNECTION_ERROR_NONE)
750 printf("Fail to get cellular pdn type!\n");
752 printf("Cellular pdn type : %s\n", test_print_cellular_pdn_type(pdn_type));
754 if (connection_profile_get_cellular_roam_pdn_type(profile, &roam_pdn_type) != CONNECTION_ERROR_NONE)
755 printf("Fail to get cellular roam pdn type!\n");
757 printf("Cellular roam pdn type : %s\n", test_print_cellular_pdn_type(roam_pdn_type));
759 if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
760 printf("Fail to get cellular APN!\n");
762 printf("Cellular APN : %s\n", apn);
766 if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
767 printf("Fail to get auth info!\n");
769 printf("Cellular auth type : %s\n", test_print_cellular_auth_type(auth_type));
770 printf("Cellular user_name : %s\n", user_name);
771 printf("Cellular password : %s\n", password);
776 if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE)
777 printf("Fail to get cellular home url!\n");
779 printf("Cellular home url : %s\n", home_url);
783 if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
784 printf("Fail to get cellular roaming state!\n");
786 printf("Cellular roaming : %s\n", roaming ? "true" : "false");
788 if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE)
789 printf("Fail to get cellular hidden state!\n");
791 printf("Cellular hidden : %s\n", hidden ? "true" : "false");
793 if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE)
794 printf("Fail to get cellular editing state!\n");
796 printf("Cellular editable : %s\n", editable ? "true" : "false");
799 static void test_print_wifi_info(connection_profile_h profile)
806 connection_wifi_security_type_e security_type;
807 connection_wifi_encryption_type_e encryption_type;
808 bool pass_required = false;
809 bool wps_supported = false;
811 if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
812 printf("Fail to get Wi-Fi essid!\n");
814 printf("Wi-Fi essid : %s\n", essid);
818 if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
819 printf("Fail to get Wi-Fi bssid!\n");
821 printf("Wi-Fi bssid : %s\n", bssid);
825 if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
826 printf("Fail to get Wi-Fi rssi!\n");
828 printf("Wi-Fi rssi : %d\n", rssi);
830 if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
831 printf("Fail to get Wi-Fi frequency!\n");
833 printf("Wi-Fi frequency : %d\n", frequency);
835 if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE)
836 printf("Fail to get Wi-Fi max speed!\n");
838 printf("Wi-Fi max speed : %d\n", max_speed);
840 if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
841 printf("Fail to get Wi-Fi security type!\n");
843 printf("Wi-Fi security type : %d\n", security_type);
845 if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE)
846 printf("Fail to get Wi-Fi encryption type!\n");
848 printf("Wi-Fi encryption type : %d\n", encryption_type);
850 if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
851 printf("Fail to get Wi-Fi passphrase required!\n");
853 printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false");
855 if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE)
856 printf("Fail to get Wi-Fi wps info\n");
858 printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
861 static void test_print_mesh_info(connection_profile_h profile)
867 connection_wifi_security_type_e security_type;
868 bool pass_required = false;
870 if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
871 printf("Fail to get Mesh essid!\n");
873 printf("Mesh essid : %s\n", essid);
877 if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
878 printf("Fail to get Mesh bssid!\n");
880 printf("Mesh bssid : %s\n", bssid);
884 if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
885 printf("Fail to get Mesh rssi!\n");
887 printf("Mesh rssi : %d\n", rssi);
889 if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
890 printf("Fail to get Mesh frequency!\n");
892 printf("Mesh frequency : %d\n", frequency);
894 if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
895 printf("Fail to get Mesh security type!\n");
897 printf("Mesh security type : %d\n", security_type);
899 if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
900 printf("Fail to get Mesh passphrase required!\n");
902 printf("Mesh passphrase required : %s\n", pass_required ? "true" : "false");
905 static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
907 char *interface_name = NULL;
910 char *gateway = NULL;
911 char *dhcp_server = NULL;
912 int dhcp_lease_duration = 0;
917 connection_ip_config_type_e ip_type;
918 connection_proxy_type_e proxy_type;
919 connection_dns_config_type_e dns_type;
921 if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
922 printf("Fail to get interface name!\n");
924 printf("Interface name : %s\n", interface_name);
925 g_free(interface_name);
928 if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
929 printf("Fail to get ipconfig type!\n");
931 if (ip_type == CONNECTION_IP_CONFIG_TYPE_STATIC)
932 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_STATIC");
933 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_DYNAMIC)
934 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_DYNAMIC");
935 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_AUTO)
936 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_AUTO");
937 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_FIXED)
938 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_FIXED");
940 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_NONE");
943 if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
944 printf("Fail to get IP address!\n");
946 printf("IP address : %s\n", ip);
950 if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
951 printf("Fail to get gateway!\n");
953 printf("Gateway : %s\n", gateway);
957 if (connection_profile_get_dhcp_server_address(profile, address_family, &dhcp_server) != CONNECTION_ERROR_NONE)
958 printf("Fail to get DHCP Server address!\n");
960 printf("DHCP Server : %s\n", dhcp_server);
964 if (connection_profile_get_dhcp_lease_duration(profile, address_family, &dhcp_lease_duration) != CONNECTION_ERROR_NONE)
965 printf("Fail to get DHCP lease duration!\n");
967 printf("DHCP lease duration : %d\n", dhcp_lease_duration);
970 if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
971 printf("Fail to get subnet mask!\n");
973 printf("Subnet mask : %s\n", subnet);
977 if (connection_profile_get_prefix_length(profile, address_family, &prefix_len) != CONNECTION_ERROR_NONE)
978 printf("Fail to get prefix length!\n");
980 printf("Prefix length : %d\n", prefix_len);
982 if (connection_profile_get_dns_config_type(profile, address_family, &dns_type) != CONNECTION_ERROR_NONE)
983 printf("Fail to get DNS configuration type!\n");
985 if (dns_type == CONNECTION_DNS_CONFIG_TYPE_STATIC)
986 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_STATIC");
987 else if (dns_type == CONNECTION_DNS_CONFIG_TYPE_DYNAMIC)
988 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_DYNAMIC");
990 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_NONE");
993 if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
994 printf("Fail to get DNS1!\n");
996 printf("DNS1 : %s\n", dns1);
1000 if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
1001 printf("Fail to get DNS2!\n");
1003 printf("DNS2 : %s\n", dns2);
1007 if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
1008 printf("Fail to get proxy type!\n");
1010 if (proxy_type == CONNECTION_PROXY_TYPE_DIRECT)
1011 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_DIRECT");
1012 else if (proxy_type == CONNECTION_PROXY_TYPE_AUTO)
1013 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_AUTO");
1015 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_MANUAL");
1018 if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
1019 printf("Fail to get proxy!\n");
1021 printf("Proxy : %s\n", proxy);
1026 int test_register_client(void)
1029 int err = connection_create(&connection);
1031 if (CONNECTION_ERROR_NONE == err) {
1032 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
1033 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
1034 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
1035 connection_set_ethernet_cable_state_changed_cb(connection,
1036 test_get_ethernet_cable_state_callback, NULL);
1038 printf("Client registration failed [%s]\n", test_print_error(err));
1042 printf("Client registration success\n");
1046 int test_deregister_client(void)
1050 connection_profile_h profile;
1052 if (connection != NULL)
1053 rv = connection_destroy(connection);
1055 printf("Cannot deregister : Handle is NULL\n");
1056 rv = CONNECTION_ERROR_INVALID_OPERATION;
1059 if (rv != CONNECTION_ERROR_NONE) {
1060 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1064 if (state_cb_list) {
1065 for (list = state_cb_list; list; list = list->next) {
1066 profile = list->data;
1067 connection_profile_destroy(profile);
1070 g_slist_free(state_cb_list);
1071 state_cb_list = NULL;
1075 printf("Client deregistration success\n");
1080 int test_register_client_cs(void)
1083 test_get_user_int("Input a TID in C# API :", &tid);
1085 int err = connection_create_cs(tid, &connection);
1087 if (CONNECTION_ERROR_NONE == err) {
1088 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
1089 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
1090 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
1091 connection_set_ethernet_cable_state_changed_cb(connection,
1092 test_get_ethernet_cable_state_callback, NULL);
1094 printf("Client registration failed [%s]\n", test_print_error(err));
1098 printf("Client registration success\n");
1102 int test_deregister_client_cs(void)
1106 connection_profile_h profile;
1109 test_get_user_int("Input a TID in C# API :", &tid);
1111 if (connection != NULL)
1112 rv = connection_destroy_cs(tid, connection);
1114 printf("Cannot deregister : Handle is NULL\n");
1115 rv = CONNECTION_ERROR_INVALID_OPERATION;
1118 if (rv != CONNECTION_ERROR_NONE) {
1119 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1123 if (state_cb_list) {
1124 for (list = state_cb_list; list; list = list->next) {
1125 profile = list->data;
1126 connection_profile_destroy(profile);
1129 g_slist_free(state_cb_list);
1130 state_cb_list = NULL;
1134 printf("Client deregistration success\n");
1139 int test_get_network_state(void)
1142 connection_type_e net_state;
1144 rv = connection_get_type(connection, &net_state);
1146 if (rv != CONNECTION_ERROR_NONE) {
1147 printf("Fail to get network state [%s]\n", test_print_error(rv));
1151 printf("Retval = [%s] network connection state [%s]\n",
1152 test_print_error(rv), test_print_connection_type(net_state));
1157 int test_get_cellular_state(void)
1160 connection_cellular_state_e cellular_state;
1162 rv = connection_get_cellular_state(connection, &cellular_state);
1164 if (rv != CONNECTION_ERROR_NONE) {
1165 printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
1169 printf("Retval = [%s] Cellular state [%s]\n",
1170 test_print_error(rv), test_print_cellular_state(cellular_state));
1175 int test_get_wifi_state(void)
1178 connection_wifi_state_e wifi_state;
1180 rv = connection_get_wifi_state(connection, &wifi_state);
1182 if (rv != CONNECTION_ERROR_NONE) {
1183 printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
1187 printf("Retval = [%s] WiFi state [%s]\n",
1188 test_print_error(rv), test_print_wifi_state(wifi_state));
1193 int test_get_current_proxy(void)
1195 char *proxy_addr = NULL;
1197 connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
1199 if (proxy_addr == NULL) {
1200 printf("Proxy address does not exist\n");
1204 printf("Current Proxy [%s]\n", proxy_addr);
1210 int test_get_current_ip(void)
1212 char *ip_addr = NULL;
1216 rv = test_get_user_int("Input Address type to get"
1217 "(1:IPV4, 2:IPV6):", &input);
1220 printf("Invalid input!!\n");
1226 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
1227 if (ip_addr == NULL) {
1228 printf("IPv4 address does not exist\n");
1231 printf("IPv4 address : %s\n", ip_addr);
1235 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
1236 if (ip_addr == NULL) {
1237 printf("IPv6 address does not exist\n");
1240 printf("IPv6 address : %s\n", ip_addr);
1243 printf("Wrong IP address family!!\n");
1251 int test_get_call_statistics_info(void)
1255 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1256 printf("last recv data size [%lld]\n", rv);
1257 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1258 printf("last sent data size [%lld]\n", rv);
1259 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1260 printf("total received data size [%lld]\n", rv);
1261 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1262 printf("total sent data size [%lld]\n", rv);
1267 int test_get_wifi_call_statistics_info(void)
1271 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1272 printf("WiFi last recv data size [%lld]\n", rv);
1273 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1274 printf("WiFi last sent data size [%lld]\n", rv);
1275 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1276 printf("WiFi total received data size [%lld]\n", rv);
1277 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1278 printf("WiFi total sent data size [%lld]\n", rv);
1283 int test_get_profile_list(void)
1285 if (test_get_user_selected_profile(NULL, false) == false)
1291 int test_get_default_profile_list(void)
1294 char *profile_name = NULL;
1295 connection_profile_iterator_h profile_iter;
1296 connection_profile_h profile_h;
1297 connection_cellular_service_type_e service_type;
1298 bool is_default = false;
1300 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
1301 if (rv != CONNECTION_ERROR_NONE) {
1302 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1306 while (connection_profile_iterator_has_next(profile_iter)) {
1307 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1308 printf("Fail to get profile handle\n");
1312 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1313 printf("Fail to get profile name\n");
1316 printf("profile name : %s\n", profile_name);
1317 g_free(profile_name);
1319 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
1320 printf("Fail to get profile service type\n");
1323 printf("service type : %d\n", service_type);
1325 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1326 printf("Fail to get profile subscriber id\n");
1329 printf("Default : %d\n", is_default);
1335 int test_get_connected_profile_list(void)
1338 char *profile_name = NULL;
1339 connection_profile_iterator_h profile_iter;
1340 connection_profile_h profile_h;
1341 bool is_default = false;
1342 connection_profile_type_e type;
1344 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
1345 if (rv != CONNECTION_ERROR_NONE) {
1346 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1350 while (connection_profile_iterator_has_next(profile_iter)) {
1351 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1352 printf("Fail to get profile handle\n");
1356 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1357 printf("Fail to get profile name\n");
1360 printf("profile name is %s\n", profile_name);
1361 g_free(profile_name);
1363 if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
1364 printf("Fail to get profile type\n");
1367 printf("profile type is %d\n", type);
1369 if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
1370 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1371 printf("Fail to get profile is default\n");
1374 printf("[%s]\n", is_default ? "default" : "not default");
1381 int test_get_current_profile(void)
1384 char *profile_name = NULL;
1385 connection_profile_h profile_h;
1387 rv = connection_get_current_profile(connection, &profile_h);
1388 if (rv != CONNECTION_ERROR_NONE) {
1389 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1393 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1394 printf("Fail to get profile name\n");
1397 printf("profile name : %s\n", profile_name);
1398 g_free(profile_name);
1400 connection_profile_destroy(profile_h);
1405 int test_open_profile(void)
1407 connection_profile_h profile;
1409 printf("\n** Choose a profile to open. **\n");
1411 if (test_get_user_selected_profile(&profile, true) == false)
1414 if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
1415 printf("Connection open Failed!!\n");
1422 int test_get_default_cellular_service_type(void)
1427 connection_profile_h profile;
1428 char *profile_name = NULL;
1430 rv = test_get_user_int("Input profile type to get"
1431 "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input);
1434 printf("Invalid input!!\n");
1440 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
1443 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
1446 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
1449 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
1452 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
1455 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
1458 printf("Wrong number!!\n");
1462 if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
1465 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1466 printf("Fail to get profile name\n");
1467 connection_profile_destroy(profile);
1470 printf("Default profile name : %s\n", profile_name);
1471 g_free(profile_name);
1473 connection_profile_destroy(profile);
1478 int test_set_default_cellular_service_type(void)
1480 connection_profile_h profile;
1481 connection_cellular_service_type_e type;
1484 rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
1486 if (rv == false || (input != 1 && input != 2)) {
1487 printf("Invalid input!!\n");
1491 printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
1493 if (test_get_user_selected_profile(&profile, true) == false)
1496 if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
1497 printf("Fail to get cellular service type\n");
1502 if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
1505 if (connection_set_default_cellular_service_profile_async(connection,
1506 type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
1513 int test_close_profile(void)
1515 connection_profile_h profile;
1517 printf("\n** Choose a profile to close. **\n");
1519 if (test_get_user_selected_profile(&profile, true) == false)
1522 if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
1523 printf("Connection close Failed!!\n");
1530 int test_add_profile(void)
1533 connection_profile_h profile;
1534 char input_str[100] = {0,};
1536 if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
1539 g_strstrip(input_str);
1540 rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
1541 if (rv != CONNECTION_ERROR_NONE)
1542 RETURN_FAIL_DESTROY(profile);
1544 if (test_update_cellular_info(profile) == -1)
1545 RETURN_FAIL_DESTROY(profile);
1547 rv = connection_add_profile(connection, profile);
1548 if (rv != CONNECTION_ERROR_NONE)
1549 RETURN_FAIL_DESTROY(profile);
1551 connection_profile_destroy(profile);
1555 int test_remove_profile(void)
1557 connection_profile_h profile;
1559 printf("\n** Choose a profile to remove. **\n");
1560 if (test_get_user_selected_profile(&profile, true) == false)
1563 if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
1564 printf("Remove profile Failed!!\n");
1571 int test_update_profile(void)
1575 connection_profile_type_e prof_type;
1576 connection_profile_h profile;
1578 printf("\n** Choose a profile to update. **\n");
1579 if (test_get_user_selected_profile(&profile, true) == false)
1582 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1585 switch (prof_type) {
1586 case CONNECTION_PROFILE_TYPE_CELLULAR:
1587 if (test_update_cellular_info(profile) == -1)
1591 case CONNECTION_PROFILE_TYPE_WIFI:
1592 if (test_update_wifi_info(profile) == -1)
1595 if (test_update_network_info(profile) == -1)
1599 case CONNECTION_PROFILE_TYPE_ETHERNET:
1600 if (test_update_network_info(profile) == -1)
1604 case CONNECTION_PROFILE_TYPE_BT:
1605 printf("Not supported!\n");
1609 int profile_type = prof_type;
1610 if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1611 if (test_update_wifi_info(profile) == -1)
1619 rv = connection_update_profile(connection, profile);
1620 if (rv != CONNECTION_ERROR_NONE)
1626 int test_get_profile_info(void)
1628 connection_profile_type_e prof_type;
1629 connection_profile_state_e profile_state;
1630 connection_profile_state_e profile_ipv6_state;
1631 connection_profile_h profile;
1632 char *profile_name = NULL;
1633 int address_family = 0;
1635 printf("\n** Choose a profile to print. **\n");
1636 if (test_get_user_selected_profile(&profile, true) == false)
1639 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1640 printf("Fail to get profile name\n");
1643 printf("Profile Name : %s\n", profile_name);
1644 g_free(profile_name);
1647 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1648 printf("Fail to get profile IPv4 state\n");
1651 printf("Profile State : %s\n", test_print_state(profile_state));
1653 if (connection_profile_get_ipv6_state(profile, &profile_ipv6_state) != CONNECTION_ERROR_NONE) {
1654 printf("Fail to get profile IPv6 state\n");
1657 printf("Profile IPv6 State : %s\n", test_print_state(profile_ipv6_state));
1660 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1663 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1665 switch (prof_type) {
1666 case CONNECTION_PROFILE_TYPE_CELLULAR:
1667 printf("Profile Type : Cellular\n");
1668 test_print_cellular_info(profile);
1670 case CONNECTION_PROFILE_TYPE_WIFI:
1671 printf("Profile Type : Wi-Fi\n");
1672 test_print_wifi_info(profile);
1674 case CONNECTION_PROFILE_TYPE_ETHERNET:
1675 printf("Profile Type : Ethernet\n");
1677 case CONNECTION_PROFILE_TYPE_BT:
1678 printf("Profile Type : Bluetooth\n");
1682 int profile_type = prof_type;
1683 if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1684 printf("Profile Type : Mesh\n");
1685 test_print_mesh_info(profile);
1692 test_print_network_info(profile, address_family);
1697 int test_refresh_profile_info(void)
1699 connection_profile_type_e prof_type;
1700 connection_profile_state_e profile_state;
1701 connection_profile_h profile;
1702 char *profile_name = NULL;
1703 int address_family = 0;
1705 printf("\n** Choose a profile to refresh. **\n");
1706 if (test_get_user_selected_profile(&profile, true) == false)
1709 if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
1712 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1713 printf("Fail to get profile name\n");
1716 printf("Profile Name : %s\n", profile_name);
1717 g_free(profile_name);
1720 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1721 printf("Fail to get profile state\n");
1724 printf("Profile State : %s\n", test_print_state(profile_state));
1727 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1730 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1732 switch (prof_type) {
1733 case CONNECTION_PROFILE_TYPE_CELLULAR:
1734 printf("Profile Type : Cellular\n");
1735 test_print_cellular_info(profile);
1737 case CONNECTION_PROFILE_TYPE_WIFI:
1738 printf("Profile Type : Wi-Fi\n");
1739 test_print_wifi_info(profile);
1741 case CONNECTION_PROFILE_TYPE_ETHERNET:
1742 printf("Profile Type : Ethernet\n");
1744 case CONNECTION_PROFILE_TYPE_BT:
1745 printf("Profile Type : Bluetooth\n");
1749 int profile_type = prof_type;
1750 if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1751 printf("Profile Type : Mesh\n");
1752 test_print_mesh_info(profile);
1759 test_print_network_info(profile, address_family);
1764 int test_set_state_changed_callback()
1766 connection_profile_h profile;
1767 connection_profile_h profile_clone;
1769 printf("\n** Choose a profile to set callback. **\n");
1770 if (test_get_user_selected_profile(&profile, true) == false)
1773 if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
1776 if (connection_profile_set_state_changed_cb(profile,
1777 test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
1778 connection_profile_destroy(profile_clone);
1782 state_cb_list = g_slist_append(state_cb_list, profile_clone);
1787 int test_unset_state_changed_callback()
1789 connection_profile_h profile;
1791 char *profile_name = NULL;
1795 printf("\n** Choose a profile to unset callback. **\n");
1796 for (list = state_cb_list; list; list = list->next) {
1797 profile = list->data;
1798 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1799 printf("Fail to get profile name!\n");
1802 printf("%d. %s\n", count, profile_name);
1803 g_free(profile_name);
1809 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
1812 printf("Wrong number!!\n");
1817 for (list = state_cb_list; list; list = list->next) {
1818 if (count == input) {
1819 profile = list->data;
1829 if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
1832 state_cb_list = g_slist_remove(state_cb_list, profile);
1833 connection_profile_destroy(profile);
1838 int test_reset_call_statistics_info(void)
1840 int ret = CONNECTION_ERROR_NONE;
1842 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1843 printf("reset last recv data size [%d]\n", ret);
1844 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1845 printf("last sent data size [%d]\n", ret);
1846 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1847 printf("total received data size [%d]\n", ret);
1848 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1849 printf("total sent data size [%d]\n", ret);
1854 int test_reset_wifi_call_statistics_info(void)
1856 int ret = CONNECTION_ERROR_NONE;
1858 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1859 printf("WiFi last sent data size [%d]\n", ret);
1860 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1861 printf("WiFi last recv data size [%d]\n", ret);
1862 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1863 printf("WiFi total sent data size [%d]\n", ret);
1864 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1865 printf("WiFi total received data size [%d]\n", ret);
1870 int test_add_route(void)
1873 char ip_addr[100] = {0};
1874 char if_name[40] = {0};
1876 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1879 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1882 g_strstrip(ip_addr);
1883 g_strstrip(if_name);
1884 rv = connection_add_route(connection, if_name, ip_addr);
1885 if (rv != CONNECTION_ERROR_NONE) {
1886 printf("Fail to get add new route [%d]\n", rv);
1889 printf("Add Route successfully\n");
1894 int test_remove_route(void)
1897 char ip_addr[100] = {0};
1898 char if_name[40] = {0};
1900 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1903 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1906 g_strstrip(ip_addr);
1907 g_strstrip(if_name);
1908 rv = connection_remove_route(connection, if_name, ip_addr);
1909 if (rv != CONNECTION_ERROR_NONE) {
1910 printf("Fail to remove the route [%s]\n", test_print_error(rv));
1913 printf("Remove Route successfully\n");
1918 int test_add_route_ipv6(void)
1921 char ip_addr[100] = {0};
1922 char gateway[100] = {0};
1923 char if_name[40] = {0};
1925 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1928 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1931 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1934 g_strstrip(ip_addr);
1935 g_strstrip(gateway);
1936 g_strstrip(if_name);
1937 rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
1938 if (rv != CONNECTION_ERROR_NONE) {
1939 printf("Fail to get add new route [%d]\n", rv);
1942 printf("Add Route successfully\n");
1947 int test_remove_route_ipv6(void)
1950 char ip_addr[100] = {0};
1951 char gateway[100] = {0};
1952 char if_name[40] = {0};
1954 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1957 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1960 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1963 g_strstrip(ip_addr);
1964 g_strstrip(gateway);
1965 g_strstrip(if_name);
1966 rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
1967 if (rv != CONNECTION_ERROR_NONE) {
1968 printf("Fail to remove the route [%d]\n", rv);
1971 printf("Remove Route successfully\n");
1976 int test_add_route_entry(void)
1978 char ip_addr[100] = {0};
1979 char gateway[100] = {0};
1980 char if_name[40] = {0};
1985 input_rv = test_get_user_int("Input Address type to get"
1986 "(1:IPV4, 2:IPV6):", &input);
1988 if (input_rv == false) {
1989 printf("Invalid input!!\n");
1995 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1998 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2001 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2004 g_strstrip(ip_addr);
2005 g_strstrip(gateway);
2006 g_strstrip(if_name);
2007 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
2008 if (rv != CONNECTION_ERROR_NONE) {
2009 printf("Fail to get add new route [%d]\n", rv);
2012 printf("Add Route successfully\n");
2016 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2019 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2022 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2025 g_strstrip(ip_addr);
2026 g_strstrip(gateway);
2027 g_strstrip(if_name);
2028 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
2029 if (rv != CONNECTION_ERROR_NONE) {
2030 printf("Fail to get add new route [%d]\n", rv);
2033 printf("Add Route successfully\n");
2037 printf("Wrong IP address family!!\n");
2046 int test_remove_route_entry(void)
2048 char ip_addr[100] = {0};
2049 char gateway[100] = {0};
2050 char if_name[40] = {0};
2055 input_rv = test_get_user_int("Input Address type to get"
2056 "(1:IPV4, 2:IPV6):", &input);
2058 if (input_rv == false) {
2059 printf("Invalid input!!\n");
2065 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2068 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2071 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2074 g_strstrip(ip_addr);
2075 g_strstrip(gateway);
2076 g_strstrip(if_name);
2077 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
2078 if (rv != CONNECTION_ERROR_NONE) {
2079 printf("Fail to remove the route [%s]\n", test_print_error(rv));
2082 printf("Remove Route successfully\n");
2087 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2090 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2093 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2096 g_strstrip(ip_addr);
2097 g_strstrip(gateway);
2098 g_strstrip(if_name);
2099 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
2100 if (rv != CONNECTION_ERROR_NONE) {
2101 printf("Fail to remove the route [%d]\n", rv);
2104 printf("Remove Route successfully\n");
2108 printf("Wrong IP address family!!\n");
2117 int test_get_bt_state(void)
2120 connection_bt_state_e bt_state;
2122 rv = connection_get_bt_state(connection, &bt_state);
2124 if (rv != CONNECTION_ERROR_NONE) {
2125 printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv));
2129 printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state);
2134 int test_get_profile_id(void)
2136 connection_profile_h profile;
2139 printf("\n** Choose a profile to see profile id. **\n");
2140 if (test_get_user_selected_profile(&profile, true) == false)
2143 if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
2144 printf("Fail to get profile name\n");
2147 printf("Profile id : %s\n", profile_id);
2154 int test_get_mac_address(void)
2156 int rv = 0, type = 0;
2157 connection_type_e conn_type;
2158 char *mac_addr = NULL;
2160 test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
2164 conn_type = CONNECTION_TYPE_WIFI;
2167 conn_type = CONNECTION_TYPE_ETHERNET;
2170 printf("Wrong number!!\n");
2174 rv = connection_get_mac_address(connection, conn_type, &mac_addr);
2176 if (rv != CONNECTION_ERROR_NONE) {
2177 printf("Fail to get MAC address [%s]\n", test_print_error(rv));
2181 printf("mac address is %s\n", mac_addr);
2188 int test_get_ethernet_cable_state(void)
2191 connection_ethernet_cable_state_e cable_state;
2193 rv = connection_get_ethernet_cable_state(connection, &cable_state);
2195 if (rv != CONNECTION_ERROR_NONE) {
2196 printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
2200 printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
2205 int test_reset_profile(void)
2207 int type, sim_id, rv;
2209 rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
2211 if (rv == false || (type != 0 && type != 1)) {
2212 printf("Invalid input!!\n");
2216 rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
2218 if (rv == false || (sim_id != 0 && sim_id != 1)) {
2219 printf("Invalid input!!\n");
2223 if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE)
2229 static bool test_get_ipv6_address_callback(char *ipv6_address, void* user_data)
2231 printf("IPv6 Address : %s\n", ipv6_address);
2235 int test_foreach_ipv6_address(void)
2239 connection_type_e conn_type;
2241 test_get_user_int("Input Connection Type(1: WiFi 2: Ethernet) :", &type);
2245 conn_type = CONNECTION_TYPE_WIFI;
2248 conn_type = CONNECTION_TYPE_ETHERNET;
2251 printf("Wrong number!!\n");
2255 rv = connection_foreach_ipv6_address(connection, conn_type, test_get_ipv6_address_callback, NULL);
2256 if (rv != CONNECTION_ERROR_NONE) {
2257 printf("Fail to get IPv6 address\n");
2264 int test_is_metered_network(void)
2269 rv = connection_is_metered_network(connection, &metered_state);
2271 if (rv != CONNECTION_ERROR_NONE) {
2272 printf("Fail to get metered state [%s]\n", test_print_error(rv));
2276 printf("Retval = [%s] metered state [%s]\n",
2277 test_print_error(rv), metered_state ? "TRUE" : "FALSE");
2282 int test_start_tcpdump(void)
2284 if (connection_profile_start_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2288 printf("Successfully started tcpdump\n");
2293 int test_stop_tcpdump(void)
2295 if (connection_profile_stop_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2299 printf("Successfully stopped tcpdump\n");
2304 int test_get_tcpdump_state(void)
2306 gboolean tcpdump_state = FALSE;
2308 if (connection_profile_get_tcpdump_state(connection, &tcpdump_state) != CONNECTION_ERROR_NONE) {
2312 printf("tcpdump %s running\n", tcpdump_state ? "is" : "is not");
2317 int test_mptcp_enable(void)
2320 bool supported = false;
2321 rv = connection_mptcp_is_supported(connection, &supported);
2322 if (rv != CONNECTION_ERROR_NONE) {
2323 printf("Failure[%s]\n", test_print_error(rv));
2326 printf("MPTCP Support: %d\n", supported);
2328 rv = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL);
2329 if (rv != CONNECTION_ERROR_NONE) {
2330 printf("Failure[%s]\n", test_print_error(rv));
2336 int test_mptcp_disable(void)
2339 rv = connection_mptcp_disable(connection);
2341 if (rv != CONNECTION_ERROR_NONE) {
2342 printf("Failure[%s]\n", test_print_error(rv));
2348 int test_mptcp_set_path_manager(void)
2352 rv = test_get_user_int("Input Path Manager (1: default, 2: fullmesh)", &input);
2356 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT);
2359 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_FULLMESH);
2362 printf("Invalid input!!\n");
2366 if (rv != CONNECTION_ERROR_NONE) {
2367 printf("Failure[%s]\n", test_print_error(rv));
2374 int test_mptcp_get_path_manager(void)
2377 connection_mptcp_path_manager_e pm;
2379 rv = connection_mptcp_get_path_manager(connection, &pm);
2380 if (rv != CONNECTION_ERROR_NONE) {
2381 printf("Failure[%s]\n", test_print_error(rv));
2386 case CONNECTION_MPTCP_PM_DEFAULT:
2387 printf("Path Manager: Default\n");
2389 case CONNECTION_MPTCP_PM_FULLMESH:
2390 printf("Path Manager: FullMesh\n");
2393 printf("Error: Invalid Path Manager\n");
2400 int test_mptcp_set_scheduler(void)
2404 rv = test_get_user_int("Input Scheduler (1: default, 2: roundrobin)", &input);
2408 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT);
2411 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
2414 printf("Invalid input!!\n");
2418 if (rv != CONNECTION_ERROR_NONE) {
2419 printf("Failure[%s]\n", test_print_error(rv));
2426 int test_mptcp_get_scheduler(void)
2429 connection_mptcp_scheduler_e scheduler;
2431 rv = connection_mptcp_get_scheduler(connection, &scheduler);
2432 if (rv != CONNECTION_ERROR_NONE) {
2433 printf("Failure[%s]\n", test_print_error(rv));
2437 switch (scheduler) {
2438 case CONNECTION_MPTCP_SCHEDULER_DEFAULT:
2439 printf("Scheduler: Default\n");
2441 case CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN:
2442 printf("Scheduler: RountRobin\n");
2445 printf("Error: Invalid Scheduler\n");
2452 int main(int argc, char **argv)
2454 GMainLoop *mainloop;
2455 mainloop = g_main_loop_new(NULL, FALSE);
2457 GIOChannel *channel = g_io_channel_unix_new(0);
2458 g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
2460 printf("Test Thread created...\n");
2462 g_main_loop_run(mainloop);
2467 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
2472 memset(a, '\0', 100);
2473 printf("Event received from stdin\n");
2475 rv = read(0, a, 100);
2477 if (rv < 0 || a[0] == '0') {
2478 if (connection != NULL)
2479 test_deregister_client();
2484 if (*a == '\n' || *a == '\r') {
2486 printf("\n\n Network Connection API Test App\n\n");
2487 printf("Options..\n");
2488 printf(LOG_BLUE "[Public APIs]\n" LOG_END);
2489 printf(LOG_GREEN "1 - Create Handle and set callbacks\n" LOG_END);
2490 printf("2 - Destroy Handle(unset callbacks automatically)\n");
2491 printf(LOG_GREEN "3 - Get network state\n" LOG_END);
2492 printf(LOG_GREEN "4 - Get cellular state (please insert SIM Card)\n" LOG_END);
2493 printf(LOG_GREEN "5 - Get wifi state (please turn on WiFi)\n" LOG_END);
2494 printf("6 - Get current proxy address \n");
2495 printf("7 - Get current Ip address\n");
2496 printf("8 - Get cellular data call statistics\n");
2497 printf("9 - Get WiFi data call statistics\n");
2498 printf(LOG_GREEN "a - Get Profile list\n" LOG_END);
2499 printf(LOG_GREEN "b - Get Connected Profile list\n" LOG_END);
2500 printf(LOG_GREEN "c - Get Current profile\n" LOG_END);
2501 printf("d - Open connection with profile\n");
2502 printf("e - Get default cellular service by type\n");
2503 printf("f - Set default cellular service by type\n");
2504 printf("g - Close connection with profile\n");
2505 printf("h - Add profile(Cellular and Wifi only)\n");
2506 printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
2507 printf("j - Update profile\n");
2508 printf("k - Get profile info\n");
2509 printf("l - Refresh profile info\n");
2510 printf("m - Set state changed callback\n");
2511 printf("n - Unset state changed callback\n");
2512 printf("o - Reset cellular data call statistics\n");
2513 printf("p - Reset WiFi data call statistics\n");
2514 printf("q - Add new route\n");
2515 printf("r - Remove a route\n");
2516 printf("s - Get Bluetooth state\n");
2517 printf("t - Get profile id\n");
2518 printf("u - Reset profile\n");
2519 printf("v - Get all cellular default profiles\n");
2520 printf("w - Get mac address\n");
2521 printf("x - Get ethernet cable state\n");
2522 printf("B - Add IPv6 new route\n");
2523 printf("C - Remove IPv6 route\n");
2524 printf("D - Add new route entry\n");
2525 printf("E - Remove route entry\n");
2526 printf("F - Get all IPv6 address\n");
2527 printf("G - Get metered state\n");
2529 printf(LOG_BLUE "[Extension API]\n" LOG_END);
2530 printf("H - Start TCP Dump\n");
2531 printf("I - Stop TCP Dump\n");
2532 printf("J - Get TCP Dump State\n");
2533 printf("K - Enable MPTCP (internal)\n");
2534 printf("L - Disable MPTCP (internal)\n");
2535 printf("M - Set MPTCP Path Manager (internal)\n");
2536 printf("N - Get MPTCP Path Manager (internal)\n");
2537 printf("O - Set MPTCP Scheduler (internal)\n");
2538 printf("P - Get MPTCP Scheduler (internal)\n");
2539 printf(LOG_GREEN "Q - Create Handle and set callbacks in C# API\n" LOG_END);
2540 printf("R - Destroy Handle(unset callbacks automatically in C# API)\n");
2541 printf(LOG_RED "0 - Exit \n" LOG_END);
2542 printf("ENTER - Show options menu.......\n");
2548 rv = test_register_client();
2551 rv = test_deregister_client();
2554 rv = test_get_network_state();
2557 rv = test_get_cellular_state();
2560 rv = test_get_wifi_state();
2563 rv = test_get_current_proxy();
2566 rv = test_get_current_ip();
2569 rv = test_get_call_statistics_info();
2572 rv = test_get_wifi_call_statistics_info();
2575 rv = test_get_profile_list();
2578 rv = test_get_connected_profile_list();
2581 rv = test_get_current_profile();
2584 rv = test_open_profile();
2587 rv = test_get_default_cellular_service_type();
2590 rv = test_set_default_cellular_service_type();
2593 rv = test_close_profile();
2596 rv = test_add_profile();
2599 rv = test_remove_profile();
2602 rv = test_update_profile();
2605 rv = test_get_profile_info();
2608 rv = test_refresh_profile_info();
2611 rv = test_set_state_changed_callback();
2614 rv = test_unset_state_changed_callback();
2617 rv = test_reset_call_statistics_info();
2620 rv = test_reset_wifi_call_statistics_info();
2623 rv = test_add_route();
2626 rv = test_remove_route();
2629 rv = test_get_bt_state();
2632 rv = test_get_profile_id();
2635 rv = test_reset_profile();
2638 rv = test_get_default_profile_list();
2641 rv = test_get_mac_address();
2644 rv = test_get_ethernet_cable_state();
2647 rv = test_add_route_ipv6();
2650 rv = test_remove_route_ipv6();
2653 rv = test_add_route_entry();
2656 rv = test_remove_route_entry();
2659 rv = test_foreach_ipv6_address();
2662 rv = test_is_metered_network();
2666 rv = test_start_tcpdump();
2669 rv = test_stop_tcpdump();
2672 rv = test_get_tcpdump_state();
2675 rv = test_mptcp_enable();
2678 rv = test_mptcp_disable();
2681 rv = test_mptcp_set_path_manager();
2684 rv = test_mptcp_get_path_manager();
2687 rv = test_mptcp_set_scheduler();
2690 rv = test_mptcp_get_scheduler();
2693 rv = test_register_client_cs();
2696 rv = test_deregister_client_cs();
2702 printf("Operation succeeded!\n");
2704 printf("Operation failed!\n");