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_internet_state(connection_internet_state_e state)
97 if (state == CONNECTION_INTERNET_STATE_ONLINE)
103 static const char *test_print_connection_type(connection_type_e type)
106 case CONNECTION_TYPE_DISCONNECTED:
107 return "Disconnected";
108 case CONNECTION_TYPE_WIFI:
110 case CONNECTION_TYPE_CELLULAR:
112 case CONNECTION_TYPE_ETHERNET:
114 case CONNECTION_TYPE_BT:
116 case CONNECTION_TYPE_NET_PROXY:
123 static const char *test_print_cellular_state(connection_cellular_state_e state)
126 case CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE:
127 return "Out of service";
128 case CONNECTION_CELLULAR_STATE_FLIGHT_MODE:
129 return "Flight mode";
130 case CONNECTION_CELLULAR_STATE_ROAMING_OFF:
131 return "Roaming off";
132 case CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE:
133 return "Call only available";
134 case CONNECTION_CELLULAR_STATE_AVAILABLE:
136 case CONNECTION_CELLULAR_STATE_CONNECTED:
143 static const char *test_print_wifi_state(connection_wifi_state_e state)
146 case CONNECTION_WIFI_STATE_DEACTIVATED:
147 return "Deactivated";
148 case CONNECTION_WIFI_STATE_DISCONNECTED:
149 return "Disconnected";
150 case CONNECTION_WIFI_STATE_CONNECTED:
157 static const char *test_print_cellular_service_type(connection_cellular_service_type_e type)
160 case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
162 case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET:
164 case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
166 case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET:
167 return "Prepaid internet";
168 case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS:
169 return "Prepaid MMS";
170 case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING:
172 case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION:
173 return "Application";
179 static const char* test_print_cellular_auth_type(connection_cellular_auth_type_e type)
182 case CONNECTION_CELLULAR_AUTH_TYPE_PAP:
184 case CONNECTION_CELLULAR_AUTH_TYPE_CHAP:
186 case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
192 static const char* test_print_cellular_pdn_type(connection_cellular_pdn_type_e type)
195 case CONNECTION_CELLULAR_PDN_TYPE_IPV4:
197 case CONNECTION_CELLULAR_PDN_TYPE_IPV6:
199 case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6:
201 case CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN:
207 static const char *test_print_error(connection_error_e error)
210 case CONNECTION_ERROR_NONE:
211 return "CONNECTION_ERROR_NONE";
212 case CONNECTION_ERROR_INVALID_PARAMETER:
213 return "CONNECTION_ERROR_INVALID_PARAMETER";
214 case CONNECTION_ERROR_OUT_OF_MEMORY:
215 return "CONNECTION_ERROR_OUT_OF_MEMORY";
216 case CONNECTION_ERROR_INVALID_OPERATION:
217 return "CONNECTION_ERROR_INVALID_OPERATION";
218 case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
219 return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
220 case CONNECTION_ERROR_OPERATION_FAILED:
221 return "CONNECTION_ERROR_OPERATION_FAILED";
222 case CONNECTION_ERROR_ITERATOR_END:
223 return "CONNECTION_ERROR_ITERATOR_END";
224 case CONNECTION_ERROR_NO_CONNECTION:
225 return "CONNECTION_ERROR_NO_CONNECTION";
226 case CONNECTION_ERROR_NOW_IN_PROGRESS:
227 return "CONNECTION_ERROR_NOW_IN_PROGRESS";
228 case CONNECTION_ERROR_ALREADY_EXISTS:
229 return "CONNECTION_ERROR_ALREADY_EXISTS";
230 case CONNECTION_ERROR_OPERATION_ABORTED:
231 return "CONNECTION_ERROR_OPERATION_ABORTED";
232 case CONNECTION_ERROR_DHCP_FAILED:
233 return "CONNECTION_ERROR_DHCP_FAILED";
234 case CONNECTION_ERROR_INVALID_KEY:
235 return "CONNECTION_ERROR_INVALID_KEY";
236 case CONNECTION_ERROR_NO_REPLY:
237 return "CONNECTION_ERROR_NO_REPLY";
238 case CONNECTION_ERROR_PERMISSION_DENIED:
239 return "CONNECTION_ERROR_PERMISSION_DENIED";
240 case CONNECTION_ERROR_NOT_SUPPORTED:
241 return "CONNECTION_ERROR_NOT_SUPPORTED";
242 case CONNECTION_ERROR_NOT_INITIALIZED:
243 return "CONNECTION_ERROR_NOT_INITIALIZED";
244 case CONNECTION_ERROR_ALREADY_INITIALIZED:
245 return "CONNECTION_ERROR_ALREADY_INITIALIZED";
247 return "CONNECTION_ERROR_UNKNOWN";
251 static void test_type_changed_callback(connection_type_e type, void* user_data)
253 printf("Type changed callback, connection type : %d\n", type);
256 static void test_ip_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
258 printf("IP changed callback, IPv4 address : %s, IPv6 address : %s\n",
259 ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
262 static void test_proxy_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
264 printf("Proxy changed callback, IPv4 address : %s, IPv6 address : %s\n",
265 ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
268 static void test_internet_state_changed_callback(connection_internet_state_e state, void* user_data)
270 printf("Internet state changed callback, state : %d\n", state);
273 static void test_profile_state_callback(connection_profile_state_e state, void* user_data)
276 connection_profile_h profile = user_data;
281 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE)
284 printf("[%s] : %s\n", test_print_state(state), profile_name);
285 g_free(profile_name);
288 static void test_connection_opened_callback(connection_error_e result, void* user_data)
290 if (result == CONNECTION_ERROR_NONE)
291 printf("Connection open Succeeded\n");
293 printf("Connection open Failed, err : [%s]\n", test_print_error(result));
296 static void test_connection_closed_callback(connection_error_e result, void* user_data)
298 if (result == CONNECTION_ERROR_NONE)
299 printf("Connection close Succeeded\n");
301 printf("Connection close Failed, err : [%s]\n", test_print_error(result));
304 static void test_connection_reset_profile_callback(connection_error_e result, void* user_data)
306 if (result == CONNECTION_ERROR_NONE)
307 printf("Reset profile Succeeded\n");
309 printf("Reset profile Failed, err : [%s]\n", test_print_error(result));
312 static void test_connection_set_default_callback(connection_error_e result, void* user_data)
314 if (result == CONNECTION_ERROR_NONE)
315 printf("Default profile setting Succeeded\n");
317 printf("Default profile setting Failed, err : [%s]\n", test_print_error(result));
320 void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state,
323 if (state == CONNECTION_ETHERNET_CABLE_ATTACHED)
324 printf("Ethernet Cable Connected\n");
325 else if (state == CONNECTION_ETHERNET_CABLE_DETACHED)
326 printf("Ethernet Cable Disconnected\n");
329 static bool test_get_user_selected_profile(connection_profile_h *profile, bool select)
334 connection_profile_type_e profile_type;
335 connection_profile_state_e profile_state;
336 connection_profile_iterator_h profile_iter;
337 connection_profile_h profile_h;
339 connection_profile_h profile_list[100] = {0,};
340 int profile_count = 0;
342 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
343 if (rv != CONNECTION_ERROR_NONE) {
344 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
348 while (connection_profile_iterator_has_next(profile_iter)) {
349 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
350 printf("Fail to get profile handle\n");
354 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
355 printf("Fail to get profile name\n");
359 if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) {
360 printf("Fail to get profile type\n");
361 g_free(profile_name);
365 if (connection_profile_get_state(profile_h, &profile_state) != CONNECTION_ERROR_NONE) {
366 printf("Fail to get profile state\n");
367 g_free(profile_name);
371 printf("%d. state:[%s], profile name:%s", profile_count,
372 test_print_state(profile_state), profile_name);
373 if (profile_type == CONNECTION_PROFILE_TYPE_CELLULAR) {
374 connection_cellular_service_type_e service_type;
375 if (connection_profile_get_cellular_service_type(
376 profile_h, &service_type) !=
377 CONNECTION_ERROR_NONE)
378 printf("Fail to get cellular service type!\n");
381 test_print_cellular_service_type(service_type));
385 profile_list[profile_count] = profile_h;
388 g_free(profile_name);
389 if (profile_count >= 100)
396 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
397 input >= profile_count ||
399 printf("Wrong number!!\n");
404 *profile = profile_list[input];
409 static int test_update_cellular_info(connection_profile_h profile)
412 char input_str1[100] = {0,};
413 char input_str2[100] = {0,};
417 if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, "
418 "Prepaid MMS:4, Tethering:5, Application:6)"
419 " - (Enter for skip) :", &input_int)) {
422 rv = connection_profile_set_cellular_service_type(profile,
423 CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
426 rv = connection_profile_set_cellular_service_type(profile,
427 CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
430 rv = connection_profile_set_cellular_service_type(profile,
431 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET);
434 rv = connection_profile_set_cellular_service_type(profile,
435 CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS);
438 rv = connection_profile_set_cellular_service_type(profile,
439 CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING);
442 rv = connection_profile_set_cellular_service_type(profile,
443 CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
449 if (rv != CONNECTION_ERROR_NONE)
454 if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) {
455 g_strstrip(input_str1);
456 rv = connection_profile_set_cellular_apn(profile, input_str1);
457 if (rv != CONNECTION_ERROR_NONE)
461 if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
462 g_strstrip(input_str1);
463 rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
464 if (rv != CONNECTION_ERROR_NONE)
468 if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) {
469 g_strstrip(input_str1);
470 rv = connection_profile_set_cellular_home_url(profile, input_str1);
471 if (rv != CONNECTION_ERROR_NONE)
475 if (test_get_user_int("Input AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) {
478 rv = connection_profile_set_cellular_auth_info(profile,
479 CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", "");
480 if (rv != CONNECTION_ERROR_NONE)
485 type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
488 if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
490 if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false)
492 if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
495 g_strstrip(input_str1);
496 g_strstrip(input_str2);
497 rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
498 if (rv != CONNECTION_ERROR_NONE)
503 if (test_get_user_int("Input PdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
506 rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
509 rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
512 rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
516 if (rv != CONNECTION_ERROR_NONE)
520 if (test_get_user_int("Input RoamPdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
523 rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
526 rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
529 rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
533 if (rv != CONNECTION_ERROR_NONE)
540 static int test_update_wifi_info(connection_profile_h profile)
543 char input_str[100] = {0,};
545 if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) {
546 rv = connection_profile_set_wifi_passphrase(profile, input_str);
547 if (rv != CONNECTION_ERROR_NONE)
554 static int test_update_dns_info(connection_profile_h profile,
555 connection_address_family_e address_family)
558 char input_str[100] = {0,};
559 if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
560 rv = connection_profile_set_dns_address(profile,
564 if (rv != CONNECTION_ERROR_NONE)
567 if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
568 rv = connection_profile_set_dns_address(profile,
572 if (rv != CONNECTION_ERROR_NONE)
579 static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
583 char input_str[100] = {0,};
585 if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
586 rv = connection_profile_set_ip_address(profile,
589 if (rv != CONNECTION_ERROR_NONE)
593 if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
594 rv = connection_profile_set_subnet_mask(profile,
597 if (rv != CONNECTION_ERROR_NONE)
601 if (test_get_user_int("Input Prefix Length - (Enter for skip) :", &input_int)) {
602 rv = connection_profile_set_prefix_length(profile,
605 if (rv != CONNECTION_ERROR_NONE)
609 if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
610 rv = connection_profile_set_gateway_address(profile,
613 if (rv != CONNECTION_ERROR_NONE)
617 if (test_update_dns_info(profile, address_family) < 0)
623 static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
627 char input_str[100] = {0,};
629 if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)"
630 " - (Enter for skip) :", &input_int)) {
633 rv = connection_profile_set_proxy_type(profile,
634 CONNECTION_PROXY_TYPE_DIRECT);
636 if (rv != CONNECTION_ERROR_NONE)
641 rv = connection_profile_set_proxy_type(profile,
642 CONNECTION_PROXY_TYPE_AUTO);
645 rv = connection_profile_set_proxy_type(profile,
646 CONNECTION_PROXY_TYPE_MANUAL);
652 if (rv != CONNECTION_ERROR_NONE)
655 if (test_get_user_string("Input auto Proxy URL or Proxy address"
656 " - (Enter for skip) :", input_str, 100)) {
657 rv = connection_profile_set_proxy_address(profile,
660 if (rv != CONNECTION_ERROR_NONE)
672 static int test_update_network_info(connection_profile_h profile)
677 int address_family = 0;
679 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
681 if (test_get_user_int("Input IPv4/IPv6 Address Type (DHCP:1, Static:2, Auto:3)"
682 " - (Enter for skip) :", &input_int)) {
685 rv = connection_profile_set_ip_config_type(profile,
687 CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
688 if (test_get_user_int("Input DNS Address Type (Static:1, DHCP:2)"
689 " - (Enter for skip) :", &dns_input)) {
691 case CONNECTION_DNS_CONFIG_TYPE_STATIC:
692 rv = connection_profile_set_dns_config_type(
695 CONNECTION_DNS_CONFIG_TYPE_STATIC);
696 if (rv != CONNECTION_ERROR_NONE)
698 if (test_update_dns_info(profile,
699 address_family) == -1)
702 case CONNECTION_DNS_CONFIG_TYPE_DYNAMIC:
703 rv = connection_profile_set_dns_config_type(
706 CONNECTION_DNS_CONFIG_TYPE_DYNAMIC);
707 if (rv != CONNECTION_ERROR_NONE)
714 rv = connection_profile_set_ip_config_type(profile,
716 CONNECTION_IP_CONFIG_TYPE_STATIC);
717 if (rv != CONNECTION_ERROR_NONE)
720 if (test_update_ip_info(profile, address_family) == -1)
723 if (test_update_proxy_info(profile, address_family) == -1)
727 rv = connection_profile_set_ip_config_type(profile,
729 CONNECTION_IP_CONFIG_TYPE_AUTO);
735 if (rv != CONNECTION_ERROR_NONE)
743 static void test_print_cellular_info(connection_profile_h profile)
745 connection_cellular_service_type_e service_type;
746 connection_cellular_pdn_type_e pdn_type;
747 connection_cellular_pdn_type_e roam_pdn_type;
749 connection_cellular_auth_type_e auth_type;
750 char *user_name = NULL;
751 char *password = NULL;
752 char *home_url = NULL;
753 bool roaming = false;
755 bool editable = false;
757 if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
758 printf("Fail to get cellular service type!\n");
760 printf("Cellular service type : %s\n", test_print_cellular_service_type(service_type));
762 if (connection_profile_get_cellular_pdn_type(profile, &pdn_type) != CONNECTION_ERROR_NONE)
763 printf("Fail to get cellular pdn type!\n");
765 printf("Cellular pdn type : %s\n", test_print_cellular_pdn_type(pdn_type));
767 if (connection_profile_get_cellular_roam_pdn_type(profile, &roam_pdn_type) != CONNECTION_ERROR_NONE)
768 printf("Fail to get cellular roam pdn type!\n");
770 printf("Cellular roam pdn type : %s\n", test_print_cellular_pdn_type(roam_pdn_type));
772 if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
773 printf("Fail to get cellular APN!\n");
775 printf("Cellular APN : %s\n", apn);
779 if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
780 printf("Fail to get auth info!\n");
782 printf("Cellular auth type : %s\n", test_print_cellular_auth_type(auth_type));
783 printf("Cellular user_name : %s\n", user_name);
784 printf("Cellular password : %s\n", password);
789 if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE)
790 printf("Fail to get cellular home url!\n");
792 printf("Cellular home url : %s\n", home_url);
796 if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
797 printf("Fail to get cellular roaming state!\n");
799 printf("Cellular roaming : %s\n", roaming ? "true" : "false");
801 if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE)
802 printf("Fail to get cellular hidden state!\n");
804 printf("Cellular hidden : %s\n", hidden ? "true" : "false");
806 if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE)
807 printf("Fail to get cellular editing state!\n");
809 printf("Cellular editable : %s\n", editable ? "true" : "false");
812 static void test_print_wifi_info(connection_profile_h profile)
819 connection_wifi_security_type_e security_type;
820 connection_wifi_encryption_type_e encryption_type;
821 bool pass_required = false;
822 bool wps_supported = false;
824 if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
825 printf("Fail to get Wi-Fi essid!\n");
827 printf("Wi-Fi essid : %s\n", essid);
831 if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
832 printf("Fail to get Wi-Fi bssid!\n");
834 printf("Wi-Fi bssid : %s\n", bssid);
838 if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
839 printf("Fail to get Wi-Fi rssi!\n");
841 printf("Wi-Fi rssi : %d\n", rssi);
843 if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
844 printf("Fail to get Wi-Fi frequency!\n");
846 printf("Wi-Fi frequency : %d\n", frequency);
848 if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE)
849 printf("Fail to get Wi-Fi max speed!\n");
851 printf("Wi-Fi max speed : %d\n", max_speed);
853 if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
854 printf("Fail to get Wi-Fi security type!\n");
856 printf("Wi-Fi security type : %d\n", security_type);
858 if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE)
859 printf("Fail to get Wi-Fi encryption type!\n");
861 printf("Wi-Fi encryption type : %d\n", encryption_type);
863 if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
864 printf("Fail to get Wi-Fi passphrase required!\n");
866 printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false");
868 if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE)
869 printf("Fail to get Wi-Fi wps info\n");
871 printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
874 static void test_print_mesh_info(connection_profile_h profile)
880 connection_wifi_security_type_e security_type;
881 bool pass_required = false;
883 if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
884 printf("Fail to get Mesh essid!\n");
886 printf("Mesh essid : %s\n", essid);
890 if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
891 printf("Fail to get Mesh bssid!\n");
893 printf("Mesh bssid : %s\n", bssid);
897 if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
898 printf("Fail to get Mesh rssi!\n");
900 printf("Mesh rssi : %d\n", rssi);
902 if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
903 printf("Fail to get Mesh frequency!\n");
905 printf("Mesh frequency : %d\n", frequency);
907 if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
908 printf("Fail to get Mesh security type!\n");
910 printf("Mesh security type : %d\n", security_type);
912 if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
913 printf("Fail to get Mesh passphrase required!\n");
915 printf("Mesh passphrase required : %s\n", pass_required ? "true" : "false");
918 static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
920 char *interface_name = NULL;
923 char *gateway = NULL;
924 char *dhcp_server = NULL;
925 int dhcp_lease_duration = 0;
930 connection_ip_config_type_e ip_type;
931 connection_proxy_type_e proxy_type;
932 connection_dns_config_type_e dns_type;
934 if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
935 printf("Fail to get interface name!\n");
937 printf("Interface name : %s\n", interface_name);
938 g_free(interface_name);
941 if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
942 printf("Fail to get ipconfig type!\n");
944 if (ip_type == CONNECTION_IP_CONFIG_TYPE_STATIC)
945 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_STATIC");
946 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_DYNAMIC)
947 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_DYNAMIC");
948 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_AUTO)
949 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_AUTO");
950 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_FIXED)
951 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_FIXED");
953 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_NONE");
956 if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
957 printf("Fail to get IP address!\n");
959 printf("IP address : %s\n", ip);
963 if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
964 printf("Fail to get gateway!\n");
966 printf("Gateway : %s\n", gateway);
970 if (connection_profile_get_dhcp_server_address(profile, address_family, &dhcp_server) != CONNECTION_ERROR_NONE)
971 printf("Fail to get DHCP Server address!\n");
973 printf("DHCP Server : %s\n", dhcp_server);
977 if (connection_profile_get_dhcp_lease_duration(profile, address_family, &dhcp_lease_duration) != CONNECTION_ERROR_NONE)
978 printf("Fail to get DHCP lease duration!\n");
980 printf("DHCP lease duration : %d\n", dhcp_lease_duration);
983 if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
984 printf("Fail to get subnet mask!\n");
986 printf("Subnet mask : %s\n", subnet);
990 if (connection_profile_get_prefix_length(profile, address_family, &prefix_len) != CONNECTION_ERROR_NONE)
991 printf("Fail to get prefix length!\n");
993 printf("Prefix length : %d\n", prefix_len);
995 if (connection_profile_get_dns_config_type(profile, address_family, &dns_type) != CONNECTION_ERROR_NONE)
996 printf("Fail to get DNS configuration type!\n");
998 if (dns_type == CONNECTION_DNS_CONFIG_TYPE_STATIC)
999 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_STATIC");
1000 else if (dns_type == CONNECTION_DNS_CONFIG_TYPE_DYNAMIC)
1001 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_DYNAMIC");
1003 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_NONE");
1006 if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
1007 printf("Fail to get DNS1!\n");
1009 printf("DNS1 : %s\n", dns1);
1013 if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
1014 printf("Fail to get DNS2!\n");
1016 printf("DNS2 : %s\n", dns2);
1020 if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
1021 printf("Fail to get proxy type!\n");
1023 if (proxy_type == CONNECTION_PROXY_TYPE_DIRECT)
1024 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_DIRECT");
1025 else if (proxy_type == CONNECTION_PROXY_TYPE_AUTO)
1026 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_AUTO");
1028 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_MANUAL");
1031 if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
1032 printf("Fail to get proxy!\n");
1034 printf("Proxy : %s\n", proxy);
1039 int test_register_client(void)
1042 int err = connection_create(&connection);
1044 if (CONNECTION_ERROR_NONE == err) {
1045 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
1046 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
1047 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
1048 connection_set_ethernet_cable_state_chaged_cb(connection,
1049 test_get_ethernet_cable_state_callback, NULL);
1050 connection_set_internet_state_changed_cb(connection, test_internet_state_changed_callback, NULL);
1052 printf("Client registration failed [%s]\n", test_print_error(err));
1056 printf("Client registration success\n");
1060 int test_deregister_client(void)
1064 connection_profile_h profile;
1066 if (connection != NULL)
1067 rv = connection_destroy(connection);
1069 printf("Cannot deregister : Handle is NULL\n");
1070 rv = CONNECTION_ERROR_INVALID_OPERATION;
1073 if (rv != CONNECTION_ERROR_NONE) {
1074 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1078 if (state_cb_list) {
1079 for (list = state_cb_list; list; list = list->next) {
1080 profile = list->data;
1081 connection_profile_destroy(profile);
1084 g_slist_free(state_cb_list);
1085 state_cb_list = NULL;
1089 printf("Client deregistration success\n");
1094 int test_register_client_cs(void)
1097 test_get_user_int("Input a TID in C# API :", &tid);
1099 int err = connection_create_cs(tid, &connection);
1101 if (CONNECTION_ERROR_NONE == err) {
1102 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
1103 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
1104 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
1105 connection_set_ethernet_cable_state_chaged_cb(connection,
1106 test_get_ethernet_cable_state_callback, NULL);
1108 printf("Client registration failed [%s]\n", test_print_error(err));
1112 printf("Client registration success\n");
1116 int test_deregister_client_cs(void)
1120 connection_profile_h profile;
1123 test_get_user_int("Input a TID in C# API :", &tid);
1125 if (connection != NULL)
1126 rv = connection_destroy_cs(tid, connection);
1128 printf("Cannot deregister : Handle is NULL\n");
1129 rv = CONNECTION_ERROR_INVALID_OPERATION;
1132 if (rv != CONNECTION_ERROR_NONE) {
1133 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1137 if (state_cb_list) {
1138 for (list = state_cb_list; list; list = list->next) {
1139 profile = list->data;
1140 connection_profile_destroy(profile);
1143 g_slist_free(state_cb_list);
1144 state_cb_list = NULL;
1148 printf("Client deregistration success\n");
1153 int test_get_network_state(void)
1156 connection_type_e net_state;
1158 rv = connection_get_type(connection, &net_state);
1160 if (rv != CONNECTION_ERROR_NONE) {
1161 printf("Fail to get network state [%s]\n", test_print_error(rv));
1165 printf("Retval = [%s] network connection state [%s]\n",
1166 test_print_error(rv), test_print_connection_type(net_state));
1171 int test_get_cellular_state(void)
1174 connection_cellular_state_e cellular_state;
1176 rv = connection_get_cellular_state(connection, &cellular_state);
1178 if (rv != CONNECTION_ERROR_NONE) {
1179 printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
1183 printf("Retval = [%s] Cellular state [%s]\n",
1184 test_print_error(rv), test_print_cellular_state(cellular_state));
1189 int test_get_wifi_state(void)
1192 connection_wifi_state_e wifi_state;
1194 rv = connection_get_wifi_state(connection, &wifi_state);
1196 if (rv != CONNECTION_ERROR_NONE) {
1197 printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
1201 printf("Retval = [%s] WiFi state [%s]\n",
1202 test_print_error(rv), test_print_wifi_state(wifi_state));
1207 int test_get_current_proxy(void)
1209 char *proxy_addr = NULL;
1211 connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
1213 if (proxy_addr == NULL) {
1214 printf("Proxy address does not exist\n");
1218 printf("Current Proxy [%s]\n", proxy_addr);
1224 int test_get_current_ip(void)
1226 char *ip_addr = NULL;
1230 rv = test_get_user_int("Input Address type to get"
1231 "(1:IPV4, 2:IPV6):", &input);
1234 printf("Invalid input!!\n");
1240 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
1241 if (ip_addr == NULL) {
1242 printf("IPv4 address does not exist\n");
1245 printf("IPv4 address : %s\n", ip_addr);
1249 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
1250 if (ip_addr == NULL) {
1251 printf("IPv6 address does not exist\n");
1254 printf("IPv6 address : %s\n", ip_addr);
1257 printf("Wrong IP address family!!\n");
1265 int test_get_call_statistics_info(void)
1269 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1270 printf("last recv data size [%lld]\n", rv);
1271 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1272 printf("last sent data size [%lld]\n", rv);
1273 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1274 printf("total received data size [%lld]\n", rv);
1275 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1276 printf("total sent data size [%lld]\n", rv);
1281 int test_get_wifi_call_statistics_info(void)
1285 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1286 printf("WiFi last recv data size [%lld]\n", rv);
1287 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1288 printf("WiFi last sent data size [%lld]\n", rv);
1289 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1290 printf("WiFi total received data size [%lld]\n", rv);
1291 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1292 printf("WiFi total sent data size [%lld]\n", rv);
1297 int test_get_profile_list(void)
1299 if (test_get_user_selected_profile(NULL, false) == false)
1305 int test_get_default_profile_list(void)
1308 char *profile_name = NULL;
1309 connection_profile_iterator_h profile_iter;
1310 connection_profile_h profile_h;
1311 connection_cellular_service_type_e service_type;
1312 bool is_default = false;
1314 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
1315 if (rv != CONNECTION_ERROR_NONE) {
1316 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1320 while (connection_profile_iterator_has_next(profile_iter)) {
1321 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1322 printf("Fail to get profile handle\n");
1326 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1327 printf("Fail to get profile name\n");
1330 printf("profile name : %s\n", profile_name);
1331 g_free(profile_name);
1333 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
1334 printf("Fail to get profile service type\n");
1337 printf("service type : %d\n", service_type);
1339 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1340 printf("Fail to get profile subscriber id\n");
1343 printf("Default : %d\n", is_default);
1349 int test_get_connected_profile_list(void)
1352 char *profile_name = NULL;
1353 connection_profile_iterator_h profile_iter;
1354 connection_profile_h profile_h;
1355 bool is_default = false;
1356 connection_profile_type_e type;
1358 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
1359 if (rv != CONNECTION_ERROR_NONE) {
1360 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1364 while (connection_profile_iterator_has_next(profile_iter)) {
1365 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1366 printf("Fail to get profile handle\n");
1370 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1371 printf("Fail to get profile name\n");
1374 printf("profile name is %s\n", profile_name);
1375 g_free(profile_name);
1377 if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
1378 printf("Fail to get profile type\n");
1381 printf("profile type is %d\n", type);
1383 if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
1384 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1385 printf("Fail to get profile is default\n");
1388 printf("[%s]\n", is_default ? "default" : "not default");
1395 int test_get_current_profile(void)
1398 char *profile_name = NULL;
1399 connection_profile_h profile_h;
1401 rv = connection_get_current_profile(connection, &profile_h);
1402 if (rv != CONNECTION_ERROR_NONE) {
1403 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1407 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1408 printf("Fail to get profile name\n");
1411 printf("profile name : %s\n", profile_name);
1412 g_free(profile_name);
1414 connection_profile_destroy(profile_h);
1419 int test_open_profile(void)
1421 connection_profile_h profile;
1423 printf("\n** Choose a profile to open. **\n");
1425 if (test_get_user_selected_profile(&profile, true) == false)
1428 if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
1429 printf("Connection open Failed!!\n");
1436 int test_get_default_cellular_service_type(void)
1441 connection_profile_h profile;
1442 char *profile_name = NULL;
1444 rv = test_get_user_int("Input profile type to get"
1445 "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input);
1448 printf("Invalid input!!\n");
1454 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
1457 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
1460 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
1463 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
1466 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
1469 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
1472 printf("Wrong number!!\n");
1476 if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
1479 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1480 printf("Fail to get profile name\n");
1481 connection_profile_destroy(profile);
1484 printf("Default profile name : %s\n", profile_name);
1485 g_free(profile_name);
1487 connection_profile_destroy(profile);
1492 int test_set_default_cellular_service_type(void)
1494 connection_profile_h profile;
1495 connection_cellular_service_type_e type;
1498 rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
1500 if (rv == false || (input != 1 && input != 2)) {
1501 printf("Invalid input!!\n");
1505 printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
1507 if (test_get_user_selected_profile(&profile, true) == false)
1510 if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
1511 printf("Fail to get cellular service type\n");
1516 if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
1519 if (connection_set_default_cellular_service_profile_async(connection,
1520 type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
1527 int test_close_profile(void)
1529 connection_profile_h profile;
1531 printf("\n** Choose a profile to close. **\n");
1533 if (test_get_user_selected_profile(&profile, true) == false)
1536 if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
1537 printf("Connection close Failed!!\n");
1544 int test_add_profile(void)
1547 connection_profile_h profile;
1548 char input_str[100] = {0,};
1550 if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
1553 g_strstrip(input_str);
1554 rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
1555 if (rv != CONNECTION_ERROR_NONE)
1556 RETURN_FAIL_DESTROY(profile);
1558 if (test_update_cellular_info(profile) == -1)
1559 RETURN_FAIL_DESTROY(profile);
1561 rv = connection_add_profile(connection, profile);
1562 if (rv != CONNECTION_ERROR_NONE)
1563 RETURN_FAIL_DESTROY(profile);
1565 connection_profile_destroy(profile);
1569 int test_remove_profile(void)
1571 connection_profile_h profile;
1573 printf("\n** Choose a profile to remove. **\n");
1574 if (test_get_user_selected_profile(&profile, true) == false)
1577 if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
1578 printf("Remove profile Failed!!\n");
1585 int test_update_profile(void)
1589 connection_profile_type_e prof_type;
1590 connection_profile_h profile;
1592 printf("\n** Choose a profile to update. **\n");
1593 if (test_get_user_selected_profile(&profile, true) == false)
1596 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1599 switch (prof_type) {
1600 case CONNECTION_PROFILE_TYPE_CELLULAR:
1601 if (test_update_cellular_info(profile) == -1)
1605 case CONNECTION_PROFILE_TYPE_WIFI:
1606 if (test_update_wifi_info(profile) == -1)
1609 if (test_update_network_info(profile) == -1)
1613 case CONNECTION_PROFILE_TYPE_ETHERNET:
1614 if (test_update_network_info(profile) == -1)
1618 case CONNECTION_PROFILE_TYPE_BT:
1619 printf("Not supported!\n");
1623 int profile_type = prof_type;
1624 if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1625 if (test_update_wifi_info(profile) == -1)
1633 rv = connection_update_profile(connection, profile);
1634 if (rv != CONNECTION_ERROR_NONE)
1640 int test_get_profile_info(void)
1642 connection_profile_type_e prof_type;
1643 connection_profile_state_e profile_state;
1644 connection_profile_state_e profile_ipv6_state;
1645 connection_internet_state_e internet_state;
1646 connection_profile_h profile;
1647 char *profile_name = NULL;
1648 int address_family = 0;
1650 printf("\n** Choose a profile to print. **\n");
1651 if (test_get_user_selected_profile(&profile, true) == false)
1654 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1655 printf("Fail to get profile name\n");
1658 printf("Profile Name : %s\n", profile_name);
1659 g_free(profile_name);
1662 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1663 printf("Fail to get profile IPv4 state\n");
1666 printf("Profile State : %s\n", test_print_state(profile_state));
1668 if (connection_profile_get_ipv6_state(profile, &profile_ipv6_state) != CONNECTION_ERROR_NONE) {
1669 printf("Fail to get profile IPv6 state\n");
1672 printf("Profile IPv6 State : %s\n", test_print_state(profile_ipv6_state));
1674 if (connection_profile_get_internet_state(profile, &internet_state) != CONNECTION_ERROR_NONE) {
1675 printf("Fail to get Internet state\n");
1678 printf("Internet State : %s\n", test_print_internet_state(internet_state));
1680 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1683 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1685 switch (prof_type) {
1686 case CONNECTION_PROFILE_TYPE_CELLULAR:
1687 printf("Profile Type : Cellular\n");
1688 test_print_cellular_info(profile);
1690 case CONNECTION_PROFILE_TYPE_WIFI:
1691 printf("Profile Type : Wi-Fi\n");
1692 test_print_wifi_info(profile);
1694 case CONNECTION_PROFILE_TYPE_ETHERNET:
1695 printf("Profile Type : Ethernet\n");
1697 case CONNECTION_PROFILE_TYPE_BT:
1698 printf("Profile Type : Bluetooth\n");
1702 int profile_type = prof_type;
1703 if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1704 printf("Profile Type : Mesh\n");
1705 test_print_mesh_info(profile);
1712 test_print_network_info(profile, address_family);
1717 int test_refresh_profile_info(void)
1719 connection_profile_type_e prof_type;
1720 connection_profile_state_e profile_state;
1721 connection_profile_h profile;
1722 char *profile_name = NULL;
1723 int address_family = 0;
1725 printf("\n** Choose a profile to refresh. **\n");
1726 if (test_get_user_selected_profile(&profile, true) == false)
1729 if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
1732 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1733 printf("Fail to get profile name\n");
1736 printf("Profile Name : %s\n", profile_name);
1737 g_free(profile_name);
1740 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1741 printf("Fail to get profile state\n");
1744 printf("Profile State : %s\n", test_print_state(profile_state));
1747 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1750 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1752 switch (prof_type) {
1753 case CONNECTION_PROFILE_TYPE_CELLULAR:
1754 printf("Profile Type : Cellular\n");
1755 test_print_cellular_info(profile);
1757 case CONNECTION_PROFILE_TYPE_WIFI:
1758 printf("Profile Type : Wi-Fi\n");
1759 test_print_wifi_info(profile);
1761 case CONNECTION_PROFILE_TYPE_ETHERNET:
1762 printf("Profile Type : Ethernet\n");
1764 case CONNECTION_PROFILE_TYPE_BT:
1765 printf("Profile Type : Bluetooth\n");
1769 int profile_type = prof_type;
1770 if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1771 printf("Profile Type : Mesh\n");
1772 test_print_mesh_info(profile);
1779 test_print_network_info(profile, address_family);
1784 int test_set_state_changed_callback()
1786 connection_profile_h profile;
1787 connection_profile_h profile_clone;
1789 printf("\n** Choose a profile to set callback. **\n");
1790 if (test_get_user_selected_profile(&profile, true) == false)
1793 if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
1796 if (connection_profile_set_state_changed_cb(profile,
1797 test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
1798 connection_profile_destroy(profile_clone);
1802 state_cb_list = g_slist_append(state_cb_list, profile_clone);
1807 int test_unset_state_changed_callback()
1809 connection_profile_h profile;
1811 char *profile_name = NULL;
1815 printf("\n** Choose a profile to unset callback. **\n");
1816 for (list = state_cb_list; list; list = list->next) {
1817 profile = list->data;
1818 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1819 printf("Fail to get profile name!\n");
1822 printf("%d. %s\n", count, profile_name);
1823 g_free(profile_name);
1829 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
1832 printf("Wrong number!!\n");
1837 for (list = state_cb_list; list; list = list->next) {
1838 if (count == input) {
1839 profile = list->data;
1849 if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
1852 state_cb_list = g_slist_remove(state_cb_list, profile);
1853 connection_profile_destroy(profile);
1858 int test_reset_call_statistics_info(void)
1860 int ret = CONNECTION_ERROR_NONE;
1862 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1863 printf("reset last recv data size [%d]\n", ret);
1864 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1865 printf("last sent data size [%d]\n", ret);
1866 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1867 printf("total received data size [%d]\n", ret);
1868 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1869 printf("total sent data size [%d]\n", ret);
1874 int test_reset_wifi_call_statistics_info(void)
1876 int ret = CONNECTION_ERROR_NONE;
1878 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1879 printf("WiFi last sent data size [%d]\n", ret);
1880 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1881 printf("WiFi last recv data size [%d]\n", ret);
1882 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1883 printf("WiFi total sent data size [%d]\n", ret);
1884 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1885 printf("WiFi total received data size [%d]\n", ret);
1890 int test_add_route(void)
1893 char ip_addr[100] = {0};
1894 char if_name[40] = {0};
1896 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1899 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1902 g_strstrip(ip_addr);
1903 g_strstrip(if_name);
1904 rv = connection_add_route(connection, if_name, ip_addr);
1905 if (rv != CONNECTION_ERROR_NONE) {
1906 printf("Fail to get add new route [%d]\n", rv);
1909 printf("Add Route successfully\n");
1914 int test_remove_route(void)
1917 char ip_addr[100] = {0};
1918 char if_name[40] = {0};
1920 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1923 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1926 g_strstrip(ip_addr);
1927 g_strstrip(if_name);
1928 rv = connection_remove_route(connection, if_name, ip_addr);
1929 if (rv != CONNECTION_ERROR_NONE) {
1930 printf("Fail to remove the route [%s]\n", test_print_error(rv));
1933 printf("Remove Route successfully\n");
1938 int test_add_route_ipv6(void)
1941 char ip_addr[100] = {0};
1942 char gateway[100] = {0};
1943 char if_name[40] = {0};
1945 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1948 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1951 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1954 g_strstrip(ip_addr);
1955 g_strstrip(gateway);
1956 g_strstrip(if_name);
1957 rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
1958 if (rv != CONNECTION_ERROR_NONE) {
1959 printf("Fail to get add new route [%d]\n", rv);
1962 printf("Add Route successfully\n");
1967 int test_remove_route_ipv6(void)
1970 char ip_addr[100] = {0};
1971 char gateway[100] = {0};
1972 char if_name[40] = {0};
1974 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1977 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1980 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1983 g_strstrip(ip_addr);
1984 g_strstrip(gateway);
1985 g_strstrip(if_name);
1986 rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
1987 if (rv != CONNECTION_ERROR_NONE) {
1988 printf("Fail to remove the route [%d]\n", rv);
1991 printf("Remove Route successfully\n");
1996 int test_add_route_entry(void)
1998 char ip_addr[100] = {0};
1999 char gateway[100] = {0};
2000 char if_name[40] = {0};
2005 input_rv = test_get_user_int("Input Address type to get"
2006 "(1:IPV4, 2:IPV6):", &input);
2008 if (input_rv == false) {
2009 printf("Invalid input!!\n");
2015 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2018 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2021 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2024 g_strstrip(ip_addr);
2025 g_strstrip(gateway);
2026 g_strstrip(if_name);
2027 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
2028 if (rv != CONNECTION_ERROR_NONE) {
2029 printf("Fail to get add new route [%d]\n", rv);
2032 printf("Add Route successfully\n");
2036 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2039 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2042 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2045 g_strstrip(ip_addr);
2046 g_strstrip(gateway);
2047 g_strstrip(if_name);
2048 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
2049 if (rv != CONNECTION_ERROR_NONE) {
2050 printf("Fail to get add new route [%d]\n", rv);
2053 printf("Add Route successfully\n");
2057 printf("Wrong IP address family!!\n");
2066 int test_remove_route_entry(void)
2068 char ip_addr[100] = {0};
2069 char gateway[100] = {0};
2070 char if_name[40] = {0};
2075 input_rv = test_get_user_int("Input Address type to get"
2076 "(1:IPV4, 2:IPV6):", &input);
2078 if (input_rv == false) {
2079 printf("Invalid input!!\n");
2085 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2088 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2091 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2094 g_strstrip(ip_addr);
2095 g_strstrip(gateway);
2096 g_strstrip(if_name);
2097 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
2098 if (rv != CONNECTION_ERROR_NONE) {
2099 printf("Fail to remove the route [%s]\n", test_print_error(rv));
2102 printf("Remove Route successfully\n");
2107 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2110 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2113 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2116 g_strstrip(ip_addr);
2117 g_strstrip(gateway);
2118 g_strstrip(if_name);
2119 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
2120 if (rv != CONNECTION_ERROR_NONE) {
2121 printf("Fail to remove the route [%d]\n", rv);
2124 printf("Remove Route successfully\n");
2128 printf("Wrong IP address family!!\n");
2137 int test_get_bt_state(void)
2140 connection_bt_state_e bt_state;
2142 rv = connection_get_bt_state(connection, &bt_state);
2144 if (rv != CONNECTION_ERROR_NONE) {
2145 printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv));
2149 printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state);
2154 int test_get_profile_id(void)
2156 connection_profile_h profile;
2159 printf("\n** Choose a profile to see profile id. **\n");
2160 if (test_get_user_selected_profile(&profile, true) == false)
2163 if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
2164 printf("Fail to get profile name\n");
2167 printf("Profile id : %s\n", profile_id);
2174 int test_get_mac_address(void)
2176 int rv = 0, type = 0;
2177 connection_type_e conn_type;
2178 char *mac_addr = NULL;
2180 test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
2184 conn_type = CONNECTION_TYPE_WIFI;
2187 conn_type = CONNECTION_TYPE_ETHERNET;
2190 printf("Wrong number!!\n");
2194 rv = connection_get_mac_address(connection, conn_type, &mac_addr);
2196 if (rv != CONNECTION_ERROR_NONE) {
2197 printf("Fail to get MAC address [%s]\n", test_print_error(rv));
2201 printf("mac address is %s\n", mac_addr);
2208 int test_get_ethernet_cable_state(void)
2211 connection_ethernet_cable_state_e cable_state;
2213 rv = connection_get_ethernet_cable_state(connection, &cable_state);
2215 if (rv != CONNECTION_ERROR_NONE) {
2216 printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
2220 printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
2225 int test_reset_profile(void)
2227 int type, sim_id, rv;
2229 rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
2231 if (rv == false || (type != 0 && type != 1)) {
2232 printf("Invalid input!!\n");
2236 rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
2238 if (rv == false || (sim_id != 0 && sim_id != 1)) {
2239 printf("Invalid input!!\n");
2243 if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE)
2249 static bool test_get_ipv6_address_callback(char *ipv6_address, void* user_data)
2251 printf("IPv6 Address : %s\n", ipv6_address);
2255 int test_foreach_ipv6_address(void)
2259 connection_type_e conn_type;
2261 test_get_user_int("Input Connection Type(1: WiFi 2: Ethernet) :", &type);
2265 conn_type = CONNECTION_TYPE_WIFI;
2268 conn_type = CONNECTION_TYPE_ETHERNET;
2271 printf("Wrong number!!\n");
2275 rv = connection_foreach_ipv6_address(connection, conn_type, test_get_ipv6_address_callback, NULL);
2276 if (rv != CONNECTION_ERROR_NONE) {
2277 printf("Fail to get IPv6 address\n");
2284 int test_is_metered_network(void)
2289 rv = connection_is_metered_network(connection, &metered_state);
2291 if (rv != CONNECTION_ERROR_NONE) {
2292 printf("Fail to get metered state [%s]\n", test_print_error(rv));
2296 printf("Retval = [%s] metered state [%s]\n",
2297 test_print_error(rv), metered_state ? "TRUE" : "FALSE");
2302 int test_start_tcpdump(void)
2304 if (connection_profile_start_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2308 printf("Successfully started tcpdump\n");
2313 int test_stop_tcpdump(void)
2315 if (connection_profile_stop_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2319 printf("Successfully stopped tcpdump\n");
2324 int test_get_tcpdump_state(void)
2326 gboolean tcpdump_state = FALSE;
2328 if (connection_profile_get_tcpdump_state(connection, &tcpdump_state) != CONNECTION_ERROR_NONE) {
2332 printf("tcpdump %s running\n", tcpdump_state ? "is" : "is not");
2337 int test_mptcp_enable(void)
2340 bool supported = false;
2341 rv = connection_mptcp_is_supported(connection, &supported);
2342 if (rv != CONNECTION_ERROR_NONE) {
2343 printf("Failure[%s]\n", test_print_error(rv));
2346 printf("MPTCP Support: %d\n", supported);
2348 rv = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL);
2349 if (rv != CONNECTION_ERROR_NONE) {
2350 printf("Failure[%s]\n", test_print_error(rv));
2356 int test_mptcp_disable(void)
2359 rv = connection_mptcp_disable(connection);
2361 if (rv != CONNECTION_ERROR_NONE) {
2362 printf("Failure[%s]\n", test_print_error(rv));
2368 int test_mptcp_set_path_manager(void)
2372 rv = test_get_user_int("Input Path Manager (1: default, 2: fullmesh)", &input);
2376 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT);
2379 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_FULLMESH);
2382 printf("Invalid input!!\n");
2386 if (rv != CONNECTION_ERROR_NONE) {
2387 printf("Failure[%s]\n", test_print_error(rv));
2394 int test_mptcp_get_path_manager(void)
2397 connection_mptcp_path_manager_e pm;
2399 rv = connection_mptcp_get_path_manager(connection, &pm);
2400 if (rv != CONNECTION_ERROR_NONE) {
2401 printf("Failure[%s]\n", test_print_error(rv));
2406 case CONNECTION_MPTCP_PM_DEFAULT:
2407 printf("Path Manager: Default\n");
2409 case CONNECTION_MPTCP_PM_FULLMESH:
2410 printf("Path Manager: FullMesh\n");
2413 printf("Error: Invalid Path Manager\n");
2420 int test_mptcp_set_scheduler(void)
2424 rv = test_get_user_int("Input Scheduler (1: default, 2: roundrobin)", &input);
2428 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT);
2431 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
2434 printf("Invalid input!!\n");
2438 if (rv != CONNECTION_ERROR_NONE) {
2439 printf("Failure[%s]\n", test_print_error(rv));
2446 int test_mptcp_get_scheduler(void)
2449 connection_mptcp_scheduler_e scheduler;
2451 rv = connection_mptcp_get_scheduler(connection, &scheduler);
2452 if (rv != CONNECTION_ERROR_NONE) {
2453 printf("Failure[%s]\n", test_print_error(rv));
2457 switch (scheduler) {
2458 case CONNECTION_MPTCP_SCHEDULER_DEFAULT:
2459 printf("Scheduler: Default\n");
2461 case CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN:
2462 printf("Scheduler: RountRobin\n");
2465 printf("Error: Invalid Scheduler\n");
2472 int main(int argc, char **argv)
2474 GMainLoop *mainloop;
2475 mainloop = g_main_loop_new(NULL, FALSE);
2477 GIOChannel *channel = g_io_channel_unix_new(0);
2478 g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
2480 printf("Test Thread created...\n");
2482 g_main_loop_run(mainloop);
2487 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
2492 memset(a, '\0', 100);
2493 printf("Event received from stdin\n");
2495 rv = read(0, a, 100);
2497 if (rv < 0 || a[0] == '0') {
2498 if (connection != NULL)
2499 test_deregister_client();
2504 if (*a == '\n' || *a == '\r') {
2506 printf("\n\n Network Connection API Test App\n\n");
2507 printf("Options..\n");
2508 printf(LOG_BLUE "[Public APIs]\n" LOG_END);
2509 printf(LOG_GREEN "1 - Create Handle and set callbacks\n" LOG_END);
2510 printf("2 - Destroy Handle(unset callbacks automatically)\n");
2511 printf(LOG_GREEN "3 - Get network state\n" LOG_END);
2512 printf(LOG_GREEN "4 - Get cellular state (please insert SIM Card)\n" LOG_END);
2513 printf(LOG_GREEN "5 - Get wifi state (please turn on WiFi)\n" LOG_END);
2514 printf("6 - Get current proxy address \n");
2515 printf("7 - Get current Ip address\n");
2516 printf("8 - Get cellular data call statistics\n");
2517 printf("9 - Get WiFi data call statistics\n");
2518 printf(LOG_GREEN "a - Get Profile list\n" LOG_END);
2519 printf(LOG_GREEN "b - Get Connected Profile list\n" LOG_END);
2520 printf(LOG_GREEN "c - Get Current profile\n" LOG_END);
2521 printf("d - Open connection with profile\n");
2522 printf("e - Get default cellular service by type\n");
2523 printf("f - Set default cellular service by type\n");
2524 printf("g - Close connection with profile\n");
2525 printf("h - Add profile(Cellular and Wifi only)\n");
2526 printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
2527 printf("j - Update profile\n");
2528 printf("k - Get profile info\n");
2529 printf("l - Refresh profile info\n");
2530 printf("m - Set state changed callback\n");
2531 printf("n - Unset state changed callback\n");
2532 printf("o - Reset cellular data call statistics\n");
2533 printf("p - Reset WiFi data call statistics\n");
2534 printf("q - Add new route\n");
2535 printf("r - Remove a route\n");
2536 printf("s - Get Bluetooth state\n");
2537 printf("t - Get profile id\n");
2538 printf("u - Reset profile\n");
2539 printf("v - Get all cellular default profiles\n");
2540 printf("w - Get mac address\n");
2541 printf("x - Get ethernet cable state\n");
2542 printf("B - Add IPv6 new route\n");
2543 printf("C - Remove IPv6 route\n");
2544 printf("D - Add new route entry\n");
2545 printf("E - Remove route entry\n");
2546 printf("F - Get all IPv6 address\n");
2547 printf("G - Get metered state\n");
2549 printf(LOG_BLUE "[Extension API]\n" LOG_END);
2550 printf("H - Start TCP Dump\n");
2551 printf("I - Stop TCP Dump\n");
2552 printf("J - Get TCP Dump State\n");
2553 printf("K - Enable MPTCP (internal)\n");
2554 printf("L - Disable MPTCP (internal)\n");
2555 printf("M - Set MPTCP Path Manager (internal)\n");
2556 printf("N - Get MPTCP Path Manager (internal)\n");
2557 printf("O - Set MPTCP Scheduler (internal)\n");
2558 printf("P - Get MPTCP Scheduler (internal)\n");
2559 printf(LOG_GREEN "Q - Create Handle and set callbacks in C# API\n" LOG_END);
2560 printf("R - Destroy Handle(unset callbacks automatically in C# API)\n");
2561 printf(LOG_RED "0 - Exit \n" LOG_END);
2562 printf("ENTER - Show options menu.......\n");
2568 rv = test_register_client();
2571 rv = test_deregister_client();
2574 rv = test_get_network_state();
2577 rv = test_get_cellular_state();
2580 rv = test_get_wifi_state();
2583 rv = test_get_current_proxy();
2586 rv = test_get_current_ip();
2589 rv = test_get_call_statistics_info();
2592 rv = test_get_wifi_call_statistics_info();
2595 rv = test_get_profile_list();
2598 rv = test_get_connected_profile_list();
2601 rv = test_get_current_profile();
2604 rv = test_open_profile();
2607 rv = test_get_default_cellular_service_type();
2610 rv = test_set_default_cellular_service_type();
2613 rv = test_close_profile();
2616 rv = test_add_profile();
2619 rv = test_remove_profile();
2622 rv = test_update_profile();
2625 rv = test_get_profile_info();
2628 rv = test_refresh_profile_info();
2631 rv = test_set_state_changed_callback();
2634 rv = test_unset_state_changed_callback();
2637 rv = test_reset_call_statistics_info();
2640 rv = test_reset_wifi_call_statistics_info();
2643 rv = test_add_route();
2646 rv = test_remove_route();
2649 rv = test_get_bt_state();
2652 rv = test_get_profile_id();
2655 rv = test_reset_profile();
2658 rv = test_get_default_profile_list();
2661 rv = test_get_mac_address();
2664 rv = test_get_ethernet_cable_state();
2667 rv = test_add_route_ipv6();
2670 rv = test_remove_route_ipv6();
2673 rv = test_add_route_entry();
2676 rv = test_remove_route_entry();
2679 rv = test_foreach_ipv6_address();
2682 rv = test_is_metered_network();
2686 rv = test_start_tcpdump();
2689 rv = test_stop_tcpdump();
2692 rv = test_get_tcpdump_state();
2695 rv = test_mptcp_enable();
2698 rv = test_mptcp_disable();
2701 rv = test_mptcp_set_path_manager();
2704 rv = test_mptcp_get_path_manager();
2707 rv = test_mptcp_set_scheduler();
2710 rv = test_mptcp_get_scheduler();
2713 rv = test_register_client_cs();
2716 rv = test_deregister_client_cs();
2722 printf("Operation succeeded!\n");
2724 printf("Operation failed!\n");