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_network_info(connection_profile_h profile, connection_address_family_e address_family)
863 char *interface_name = NULL;
866 char *gateway = NULL;
867 char *dhcp_server = NULL;
868 int dhcp_lease_duration = 0;
873 connection_ip_config_type_e ip_type;
874 connection_proxy_type_e proxy_type;
875 connection_dns_config_type_e dns_type;
877 if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
878 printf("Fail to get interface name!\n");
880 printf("Interface name : %s\n", interface_name);
881 g_free(interface_name);
884 if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
885 printf("Fail to get ipconfig type!\n");
887 if (ip_type == CONNECTION_IP_CONFIG_TYPE_STATIC)
888 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_STATIC");
889 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_DYNAMIC)
890 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_DYNAMIC");
891 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_AUTO)
892 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_AUTO");
893 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_FIXED)
894 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_FIXED");
896 printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_NONE");
899 if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
900 printf("Fail to get IP address!\n");
902 printf("IP address : %s\n", ip);
906 if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
907 printf("Fail to get gateway!\n");
909 printf("Gateway : %s\n", gateway);
913 if (connection_profile_get_dhcp_server_address(profile, address_family, &dhcp_server) != CONNECTION_ERROR_NONE)
914 printf("Fail to get DHCP Server address!\n");
916 printf("DHCP Server : %s\n", dhcp_server);
920 if (connection_profile_get_dhcp_lease_duration(profile, address_family, &dhcp_lease_duration) != CONNECTION_ERROR_NONE)
921 printf("Fail to get DHCP lease duration!\n");
923 printf("DHCP lease duration : %d\n", dhcp_lease_duration);
926 if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
927 printf("Fail to get subnet mask!\n");
929 printf("Subnet mask : %s\n", subnet);
933 if (connection_profile_get_prefix_length(profile, address_family, &prefix_len) != CONNECTION_ERROR_NONE)
934 printf("Fail to get prefix length!\n");
936 printf("Prefix length : %d\n", prefix_len);
938 if (connection_profile_get_dns_config_type(profile, address_family, &dns_type) != CONNECTION_ERROR_NONE)
939 printf("Fail to get DNS configuration type!\n");
941 if (dns_type == CONNECTION_DNS_CONFIG_TYPE_STATIC)
942 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_STATIC");
943 else if (dns_type == CONNECTION_DNS_CONFIG_TYPE_DYNAMIC)
944 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_DYNAMIC");
946 printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_NONE");
949 if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
950 printf("Fail to get DNS1!\n");
952 printf("DNS1 : %s\n", dns1);
956 if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
957 printf("Fail to get DNS2!\n");
959 printf("DNS2 : %s\n", dns2);
963 if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
964 printf("Fail to get proxy type!\n");
966 if (proxy_type == CONNECTION_PROXY_TYPE_DIRECT)
967 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_DIRECT");
968 else if (proxy_type == CONNECTION_PROXY_TYPE_AUTO)
969 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_AUTO");
971 printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_MANUAL");
974 if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
975 printf("Fail to get proxy!\n");
977 printf("Proxy : %s\n", proxy);
982 int test_register_client(void)
985 int err = connection_create(&connection);
987 if (CONNECTION_ERROR_NONE == err) {
988 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
989 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
990 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
991 connection_set_ethernet_cable_state_chaged_cb(connection,
992 test_get_ethernet_cable_state_callback, NULL);
994 printf("Client registration failed [%s]\n", test_print_error(err));
998 printf("Client registration success\n");
1002 int test_deregister_client(void)
1006 connection_profile_h profile;
1008 if (connection != NULL)
1009 rv = connection_destroy(connection);
1011 printf("Cannot deregister : Handle is NULL\n");
1012 rv = CONNECTION_ERROR_INVALID_OPERATION;
1015 if (rv != CONNECTION_ERROR_NONE) {
1016 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1020 if (state_cb_list) {
1021 for (list = state_cb_list; list; list = list->next) {
1022 profile = list->data;
1023 connection_profile_destroy(profile);
1026 g_slist_free(state_cb_list);
1027 state_cb_list = NULL;
1031 printf("Client deregistration success\n");
1036 int test_register_client_cs(void)
1039 test_get_user_int("Input a TID in C# API :", &tid);
1041 int err = connection_create_cs(tid, &connection);
1043 if (CONNECTION_ERROR_NONE == err) {
1044 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
1045 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
1046 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
1047 connection_set_ethernet_cable_state_chaged_cb(connection,
1048 test_get_ethernet_cable_state_callback, NULL);
1050 printf("Client registration failed [%s]\n", test_print_error(err));
1054 printf("Client registration success\n");
1058 int test_deregister_client_cs(void)
1062 connection_profile_h profile;
1065 test_get_user_int("Input a TID in C# API :", &tid);
1067 if (connection != NULL)
1068 rv = connection_destroy_cs(tid, connection);
1070 printf("Cannot deregister : Handle is NULL\n");
1071 rv = CONNECTION_ERROR_INVALID_OPERATION;
1074 if (rv != CONNECTION_ERROR_NONE) {
1075 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1079 if (state_cb_list) {
1080 for (list = state_cb_list; list; list = list->next) {
1081 profile = list->data;
1082 connection_profile_destroy(profile);
1085 g_slist_free(state_cb_list);
1086 state_cb_list = NULL;
1090 printf("Client deregistration success\n");
1095 int test_get_network_state(void)
1098 connection_type_e net_state;
1100 rv = connection_get_type(connection, &net_state);
1102 if (rv != CONNECTION_ERROR_NONE) {
1103 printf("Fail to get network state [%s]\n", test_print_error(rv));
1107 printf("Retval = [%s] network connection state [%s]\n",
1108 test_print_error(rv), test_print_connection_type(net_state));
1113 int test_get_cellular_state(void)
1116 connection_cellular_state_e cellular_state;
1118 rv = connection_get_cellular_state(connection, &cellular_state);
1120 if (rv != CONNECTION_ERROR_NONE) {
1121 printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
1125 printf("Retval = [%s] Cellular state [%s]\n",
1126 test_print_error(rv), test_print_cellular_state(cellular_state));
1131 int test_get_wifi_state(void)
1134 connection_wifi_state_e wifi_state;
1136 rv = connection_get_wifi_state(connection, &wifi_state);
1138 if (rv != CONNECTION_ERROR_NONE) {
1139 printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
1143 printf("Retval = [%s] WiFi state [%s]\n",
1144 test_print_error(rv), test_print_wifi_state(wifi_state));
1149 int test_get_current_proxy(void)
1151 char *proxy_addr = NULL;
1153 connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
1155 if (proxy_addr == NULL) {
1156 printf("Proxy address does not exist\n");
1160 printf("Current Proxy [%s]\n", proxy_addr);
1166 int test_get_current_ip(void)
1168 char *ip_addr = NULL;
1172 rv = test_get_user_int("Input Address type to get"
1173 "(1:IPV4, 2:IPV6):", &input);
1176 printf("Invalid input!!\n");
1182 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
1183 if (ip_addr == NULL) {
1184 printf("IPv4 address does not exist\n");
1187 printf("IPv4 address : %s\n", ip_addr);
1191 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
1192 if (ip_addr == NULL) {
1193 printf("IPv6 address does not exist\n");
1196 printf("IPv6 address : %s\n", ip_addr);
1199 printf("Wrong IP address family!!\n");
1207 int test_get_call_statistics_info(void)
1211 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1212 printf("last recv data size [%lld]\n", rv);
1213 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1214 printf("last sent data size [%lld]\n", rv);
1215 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1216 printf("total received data size [%lld]\n", rv);
1217 connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1218 printf("total sent data size [%lld]\n", rv);
1223 int test_get_wifi_call_statistics_info(void)
1227 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1228 printf("WiFi last recv data size [%lld]\n", rv);
1229 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1230 printf("WiFi last sent data size [%lld]\n", rv);
1231 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1232 printf("WiFi total received data size [%lld]\n", rv);
1233 connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1234 printf("WiFi total sent data size [%lld]\n", rv);
1239 int test_get_profile_list(void)
1241 if (test_get_user_selected_profile(NULL, false) == false)
1247 int test_get_default_profile_list(void)
1250 char *profile_name = NULL;
1251 connection_profile_iterator_h profile_iter;
1252 connection_profile_h profile_h;
1253 connection_cellular_service_type_e service_type;
1254 bool is_default = false;
1256 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
1257 if (rv != CONNECTION_ERROR_NONE) {
1258 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1262 while (connection_profile_iterator_has_next(profile_iter)) {
1263 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1264 printf("Fail to get profile handle\n");
1268 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1269 printf("Fail to get profile name\n");
1272 printf("profile name : %s\n", profile_name);
1273 g_free(profile_name);
1275 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
1276 printf("Fail to get profile service type\n");
1279 printf("service type : %d\n", service_type);
1281 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1282 printf("Fail to get profile subscriber id\n");
1285 printf("Default : %d\n", is_default);
1291 int test_get_connected_profile_list(void)
1294 char *profile_name = NULL;
1295 connection_profile_iterator_h profile_iter;
1296 connection_profile_h profile_h;
1297 bool is_default = false;
1298 connection_profile_type_e type;
1300 rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &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 is %s\n", profile_name);
1317 g_free(profile_name);
1319 if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
1320 printf("Fail to get profile type\n");
1323 printf("profile type is %d\n", type);
1325 if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
1326 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1327 printf("Fail to get profile is default\n");
1330 printf("[%s]\n", is_default ? "default" : "not default");
1337 int test_get_current_profile(void)
1340 char *profile_name = NULL;
1341 connection_profile_h profile_h;
1343 rv = connection_get_current_profile(connection, &profile_h);
1344 if (rv != CONNECTION_ERROR_NONE) {
1345 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1349 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1350 printf("Fail to get profile name\n");
1353 printf("profile name : %s\n", profile_name);
1354 g_free(profile_name);
1356 connection_profile_destroy(profile_h);
1361 int test_open_profile(void)
1363 connection_profile_h profile;
1365 printf("\n** Choose a profile to open. **\n");
1367 if (test_get_user_selected_profile(&profile, true) == false)
1370 if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
1371 printf("Connection open Failed!!\n");
1378 int test_get_default_cellular_service_type(void)
1383 connection_profile_h profile;
1384 char *profile_name = NULL;
1386 rv = test_get_user_int("Input profile type to get"
1387 "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input);
1390 printf("Invalid input!!\n");
1396 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
1399 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
1402 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
1405 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
1408 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
1411 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
1414 printf("Wrong number!!\n");
1418 if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
1421 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1422 printf("Fail to get profile name\n");
1423 connection_profile_destroy(profile);
1426 printf("Default profile name : %s\n", profile_name);
1427 g_free(profile_name);
1429 connection_profile_destroy(profile);
1434 int test_set_default_cellular_service_type(void)
1436 connection_profile_h profile;
1437 connection_cellular_service_type_e type;
1440 rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
1442 if (rv == false || (input != 1 && input != 2)) {
1443 printf("Invalid input!!\n");
1447 printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
1449 if (test_get_user_selected_profile(&profile, true) == false)
1452 if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
1453 printf("Fail to get cellular service type\n");
1458 if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
1461 if (connection_set_default_cellular_service_profile_async(connection,
1462 type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
1469 int test_close_profile(void)
1471 connection_profile_h profile;
1473 printf("\n** Choose a profile to close. **\n");
1475 if (test_get_user_selected_profile(&profile, true) == false)
1478 if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
1479 printf("Connection close Failed!!\n");
1486 int test_add_profile(void)
1489 connection_profile_h profile;
1490 char input_str[100] = {0,};
1492 if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
1495 g_strstrip(input_str);
1496 rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
1497 if (rv != CONNECTION_ERROR_NONE)
1498 RETURN_FAIL_DESTROY(profile);
1500 if (test_update_cellular_info(profile) == -1)
1501 RETURN_FAIL_DESTROY(profile);
1503 rv = connection_add_profile(connection, profile);
1504 if (rv != CONNECTION_ERROR_NONE)
1505 RETURN_FAIL_DESTROY(profile);
1507 connection_profile_destroy(profile);
1511 int test_remove_profile(void)
1513 connection_profile_h profile;
1515 printf("\n** Choose a profile to remove. **\n");
1516 if (test_get_user_selected_profile(&profile, true) == false)
1519 if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
1520 printf("Remove profile Failed!!\n");
1527 int test_update_profile(void)
1531 connection_profile_type_e prof_type;
1532 connection_profile_h profile;
1534 printf("\n** Choose a profile to update. **\n");
1535 if (test_get_user_selected_profile(&profile, true) == false)
1538 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1541 switch (prof_type) {
1542 case CONNECTION_PROFILE_TYPE_CELLULAR:
1543 if (test_update_cellular_info(profile) == -1)
1547 case CONNECTION_PROFILE_TYPE_WIFI:
1548 if (test_update_wifi_info(profile) == -1)
1551 if (test_update_network_info(profile) == -1)
1555 case CONNECTION_PROFILE_TYPE_ETHERNET:
1556 if (test_update_network_info(profile) == -1)
1560 case CONNECTION_PROFILE_TYPE_BT:
1561 printf("Not supported!\n");
1567 rv = connection_update_profile(connection, profile);
1568 if (rv != CONNECTION_ERROR_NONE)
1574 int test_get_profile_info(void)
1576 connection_profile_type_e prof_type;
1577 connection_profile_state_e profile_state;
1578 connection_profile_state_e profile_ipv6_state;
1579 connection_profile_h profile;
1580 char *profile_name = NULL;
1581 int address_family = 0;
1583 printf("\n** Choose a profile to print. **\n");
1584 if (test_get_user_selected_profile(&profile, true) == false)
1587 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1588 printf("Fail to get profile name\n");
1591 printf("Profile Name : %s\n", profile_name);
1592 g_free(profile_name);
1595 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1596 printf("Fail to get profile IPv4 state\n");
1599 printf("Profile State : %s\n", test_print_state(profile_state));
1601 if (connection_profile_get_ipv6_state(profile, &profile_ipv6_state) != CONNECTION_ERROR_NONE) {
1602 printf("Fail to get profile IPv6 state\n");
1605 printf("Profile IPv6 State : %s\n", test_print_state(profile_ipv6_state));
1608 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1611 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1613 switch (prof_type) {
1614 case CONNECTION_PROFILE_TYPE_CELLULAR:
1615 printf("Profile Type : Cellular\n");
1616 test_print_cellular_info(profile);
1618 case CONNECTION_PROFILE_TYPE_WIFI:
1619 printf("Profile Type : Wi-Fi\n");
1620 test_print_wifi_info(profile);
1622 case CONNECTION_PROFILE_TYPE_ETHERNET:
1623 printf("Profile Type : Ethernet\n");
1625 case CONNECTION_PROFILE_TYPE_BT:
1626 printf("Profile Type : Bluetooth\n");
1632 test_print_network_info(profile, address_family);
1637 int test_refresh_profile_info(void)
1639 connection_profile_type_e prof_type;
1640 connection_profile_state_e profile_state;
1641 connection_profile_h profile;
1642 char *profile_name = NULL;
1643 int address_family = 0;
1645 printf("\n** Choose a profile to refresh. **\n");
1646 if (test_get_user_selected_profile(&profile, true) == false)
1649 if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
1652 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1653 printf("Fail to get profile name\n");
1656 printf("Profile Name : %s\n", profile_name);
1657 g_free(profile_name);
1660 if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1661 printf("Fail to get profile state\n");
1664 printf("Profile State : %s\n", test_print_state(profile_state));
1667 if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1670 test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1672 switch (prof_type) {
1673 case CONNECTION_PROFILE_TYPE_CELLULAR:
1674 printf("Profile Type : Cellular\n");
1675 test_print_cellular_info(profile);
1677 case CONNECTION_PROFILE_TYPE_WIFI:
1678 printf("Profile Type : Wi-Fi\n");
1679 test_print_wifi_info(profile);
1681 case CONNECTION_PROFILE_TYPE_ETHERNET:
1682 printf("Profile Type : Ethernet\n");
1684 case CONNECTION_PROFILE_TYPE_BT:
1685 printf("Profile Type : Bluetooth\n");
1691 test_print_network_info(profile, address_family);
1696 int test_set_state_changed_callback()
1698 connection_profile_h profile;
1699 connection_profile_h profile_clone;
1701 printf("\n** Choose a profile to set callback. **\n");
1702 if (test_get_user_selected_profile(&profile, true) == false)
1705 if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
1708 if (connection_profile_set_state_changed_cb(profile,
1709 test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
1710 connection_profile_destroy(profile_clone);
1714 state_cb_list = g_slist_append(state_cb_list, profile_clone);
1719 int test_unset_state_changed_callback()
1721 connection_profile_h profile;
1723 char *profile_name = NULL;
1727 printf("\n** Choose a profile to unset callback. **\n");
1728 for (list = state_cb_list; list; list = list->next) {
1729 profile = list->data;
1730 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1731 printf("Fail to get profile name!\n");
1734 printf("%d. %s\n", count, profile_name);
1735 g_free(profile_name);
1741 if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
1744 printf("Wrong number!!\n");
1749 for (list = state_cb_list; list; list = list->next) {
1750 if (count == input) {
1751 profile = list->data;
1761 if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
1764 state_cb_list = g_slist_remove(state_cb_list, profile);
1765 connection_profile_destroy(profile);
1770 int test_reset_call_statistics_info(void)
1772 int ret = CONNECTION_ERROR_NONE;
1774 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1775 printf("reset last recv data size [%d]\n", ret);
1776 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1777 printf("last sent data size [%d]\n", ret);
1778 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1779 printf("total received data size [%d]\n", ret);
1780 ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1781 printf("total sent data size [%d]\n", ret);
1786 int test_reset_wifi_call_statistics_info(void)
1788 int ret = CONNECTION_ERROR_NONE;
1790 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1791 printf("WiFi last sent data size [%d]\n", ret);
1792 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1793 printf("WiFi last recv data size [%d]\n", ret);
1794 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1795 printf("WiFi total sent data size [%d]\n", ret);
1796 ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1797 printf("WiFi total received data size [%d]\n", ret);
1802 int test_add_route(void)
1805 char ip_addr[100] = {0};
1806 char if_name[40] = {0};
1808 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1811 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1814 g_strstrip(ip_addr);
1815 g_strstrip(if_name);
1816 rv = connection_add_route(connection, if_name, ip_addr);
1817 if (rv != CONNECTION_ERROR_NONE) {
1818 printf("Fail to get add new route [%d]\n", rv);
1821 printf("Add Route successfully\n");
1826 int test_remove_route(void)
1829 char ip_addr[100] = {0};
1830 char if_name[40] = {0};
1832 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1835 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1838 g_strstrip(ip_addr);
1839 g_strstrip(if_name);
1840 rv = connection_remove_route(connection, if_name, ip_addr);
1841 if (rv != CONNECTION_ERROR_NONE) {
1842 printf("Fail to remove the route [%s]\n", test_print_error(rv));
1845 printf("Remove Route successfully\n");
1850 int test_add_route_ipv6(void)
1853 char ip_addr[100] = {0};
1854 char gateway[100] = {0};
1855 char if_name[40] = {0};
1857 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1860 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1863 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1866 g_strstrip(ip_addr);
1867 g_strstrip(gateway);
1868 g_strstrip(if_name);
1869 rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
1870 if (rv != CONNECTION_ERROR_NONE) {
1871 printf("Fail to get add new route [%d]\n", rv);
1874 printf("Add Route successfully\n");
1879 int test_remove_route_ipv6(void)
1882 char ip_addr[100] = {0};
1883 char gateway[100] = {0};
1884 char if_name[40] = {0};
1886 if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1889 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1892 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1895 g_strstrip(ip_addr);
1896 g_strstrip(gateway);
1897 g_strstrip(if_name);
1898 rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
1899 if (rv != CONNECTION_ERROR_NONE) {
1900 printf("Fail to remove the route [%d]\n", rv);
1903 printf("Remove Route successfully\n");
1908 int test_add_route_entry(void)
1910 char ip_addr[100] = {0};
1911 char gateway[100] = {0};
1912 char if_name[40] = {0};
1917 input_rv = test_get_user_int("Input Address type to get"
1918 "(1:IPV4, 2:IPV6):", &input);
1920 if (input_rv == false) {
1921 printf("Invalid input!!\n");
1927 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1930 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1933 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1936 g_strstrip(ip_addr);
1937 g_strstrip(gateway);
1938 g_strstrip(if_name);
1939 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
1940 if (rv != CONNECTION_ERROR_NONE) {
1941 printf("Fail to get add new route [%d]\n", rv);
1944 printf("Add Route successfully\n");
1948 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1951 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1954 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
1957 g_strstrip(ip_addr);
1958 g_strstrip(gateway);
1959 g_strstrip(if_name);
1960 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
1961 if (rv != CONNECTION_ERROR_NONE) {
1962 printf("Fail to get add new route [%d]\n", rv);
1965 printf("Add Route successfully\n");
1969 printf("Wrong IP address family!!\n");
1978 int test_remove_route_entry(void)
1980 char ip_addr[100] = {0};
1981 char gateway[100] = {0};
1982 char if_name[40] = {0};
1987 input_rv = test_get_user_int("Input Address type to get"
1988 "(1:IPV4, 2:IPV6):", &input);
1990 if (input_rv == false) {
1991 printf("Invalid input!!\n");
1997 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2000 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2003 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2006 g_strstrip(ip_addr);
2007 g_strstrip(gateway);
2008 g_strstrip(if_name);
2009 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
2010 if (rv != CONNECTION_ERROR_NONE) {
2011 printf("Fail to remove the route [%s]\n", test_print_error(rv));
2014 printf("Remove Route successfully\n");
2019 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2022 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2025 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2028 g_strstrip(ip_addr);
2029 g_strstrip(gateway);
2030 g_strstrip(if_name);
2031 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
2032 if (rv != CONNECTION_ERROR_NONE) {
2033 printf("Fail to remove the route [%d]\n", rv);
2036 printf("Remove Route successfully\n");
2040 printf("Wrong IP address family!!\n");
2049 int test_get_bt_state(void)
2052 connection_bt_state_e bt_state;
2054 rv = connection_get_bt_state(connection, &bt_state);
2056 if (rv != CONNECTION_ERROR_NONE) {
2057 printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv));
2061 printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state);
2066 int test_get_profile_id(void)
2068 connection_profile_h profile;
2071 printf("\n** Choose a profile to see profile id. **\n");
2072 if (test_get_user_selected_profile(&profile, true) == false)
2075 if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
2076 printf("Fail to get profile name\n");
2079 printf("Profile id : %s\n", profile_id);
2086 int test_get_mac_address(void)
2088 int rv = 0, type = 0;
2089 connection_type_e conn_type;
2090 char *mac_addr = NULL;
2092 test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
2096 conn_type = CONNECTION_TYPE_WIFI;
2099 conn_type = CONNECTION_TYPE_ETHERNET;
2102 printf("Wrong number!!\n");
2106 rv = connection_get_mac_address(connection, conn_type, &mac_addr);
2108 if (rv != CONNECTION_ERROR_NONE) {
2109 printf("Fail to get MAC address [%s]\n", test_print_error(rv));
2113 printf("mac address is %s\n", mac_addr);
2120 int test_get_ethernet_cable_state(void)
2123 connection_ethernet_cable_state_e cable_state;
2125 rv = connection_get_ethernet_cable_state(connection, &cable_state);
2127 if (rv != CONNECTION_ERROR_NONE) {
2128 printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
2132 printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
2137 int test_reset_profile(void)
2139 int type, sim_id, rv;
2141 rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
2143 if (rv == false || (type != 0 && type != 1)) {
2144 printf("Invalid input!!\n");
2148 rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
2150 if (rv == false || (sim_id != 0 && sim_id != 1)) {
2151 printf("Invalid input!!\n");
2155 if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE)
2161 static bool test_get_ipv6_address_callback(char *ipv6_address, void* user_data)
2163 printf("IPv6 Address : %s\n", ipv6_address);
2167 int test_foreach_ipv6_address(void)
2171 connection_type_e conn_type;
2173 test_get_user_int("Input Connection Type(1: WiFi 2: Ethernet) :", &type);
2177 conn_type = CONNECTION_TYPE_WIFI;
2180 conn_type = CONNECTION_TYPE_ETHERNET;
2183 printf("Wrong number!!\n");
2187 rv = connection_foreach_ipv6_address(connection, conn_type, test_get_ipv6_address_callback, NULL);
2188 if (rv != CONNECTION_ERROR_NONE) {
2189 printf("Fail to get IPv6 address\n");
2196 int test_is_metered_network(void)
2201 rv = connection_is_metered_network(connection, &metered_state);
2203 if (rv != CONNECTION_ERROR_NONE) {
2204 printf("Fail to get metered state [%s]\n", test_print_error(rv));
2208 printf("Retval = [%s] metered state [%s]\n",
2209 test_print_error(rv), metered_state ? "TRUE" : "FALSE");
2214 int test_start_tcpdump(void)
2216 if (connection_profile_start_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2220 printf("Successfully started tcpdump\n");
2225 int test_stop_tcpdump(void)
2227 if (connection_profile_stop_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2231 printf("Successfully stopped tcpdump\n");
2236 int test_get_tcpdump_state(void)
2238 gboolean tcpdump_state = FALSE;
2240 if (connection_profile_get_tcpdump_state(connection, &tcpdump_state) != CONNECTION_ERROR_NONE) {
2244 printf("tcpdump %s running\n", tcpdump_state ? "is" : "is not");
2249 int test_mptcp_enable(void)
2252 bool supported = false;
2253 rv = connection_mptcp_is_supported(connection, &supported);
2254 if (rv != CONNECTION_ERROR_NONE) {
2255 printf("Failure[%s]\n", test_print_error(rv));
2258 printf("MPTCP Support: %d\n", supported);
2260 rv = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL);
2261 if (rv != CONNECTION_ERROR_NONE) {
2262 printf("Failure[%s]\n", test_print_error(rv));
2268 int test_mptcp_disable(void)
2271 rv = connection_mptcp_disable(connection);
2273 if (rv != CONNECTION_ERROR_NONE) {
2274 printf("Failure[%s]\n", test_print_error(rv));
2280 int test_mptcp_set_path_manager(void)
2284 rv = test_get_user_int("Input Path Manager (1: default, 2: fullmesh)", &input);
2288 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT);
2291 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_FULLMESH);
2294 printf("Invalid input!!\n");
2298 if (rv != CONNECTION_ERROR_NONE) {
2299 printf("Failure[%s]\n", test_print_error(rv));
2306 int test_mptcp_get_path_manager(void)
2309 connection_mptcp_path_manager_e pm;
2311 rv = connection_mptcp_get_path_manager(connection, &pm);
2312 if (rv != CONNECTION_ERROR_NONE) {
2313 printf("Failure[%s]\n", test_print_error(rv));
2318 case CONNECTION_MPTCP_PM_DEFAULT:
2319 printf("Path Manager: Default\n");
2321 case CONNECTION_MPTCP_PM_FULLMESH:
2322 printf("Path Manager: FullMesh\n");
2325 printf("Error: Invalid Path Manager\n");
2332 int test_mptcp_set_scheduler(void)
2336 rv = test_get_user_int("Input Scheduler (1: default, 2: roundrobin)", &input);
2340 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT);
2343 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
2346 printf("Invalid input!!\n");
2350 if (rv != CONNECTION_ERROR_NONE) {
2351 printf("Failure[%s]\n", test_print_error(rv));
2358 int test_mptcp_get_scheduler(void)
2361 connection_mptcp_scheduler_e scheduler;
2363 rv = connection_mptcp_get_scheduler(connection, &scheduler);
2364 if (rv != CONNECTION_ERROR_NONE) {
2365 printf("Failure[%s]\n", test_print_error(rv));
2369 switch (scheduler) {
2370 case CONNECTION_MPTCP_SCHEDULER_DEFAULT:
2371 printf("Scheduler: Default\n");
2373 case CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN:
2374 printf("Scheduler: RountRobin\n");
2377 printf("Error: Invalid Scheduler\n");
2384 int main(int argc, char **argv)
2386 GMainLoop *mainloop;
2387 mainloop = g_main_loop_new(NULL, FALSE);
2389 GIOChannel *channel = g_io_channel_unix_new(0);
2390 g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
2392 printf("Test Thread created...\n");
2394 g_main_loop_run(mainloop);
2399 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
2404 memset(a, '\0', 100);
2405 printf("Event received from stdin\n");
2407 rv = read(0, a, 100);
2409 if (rv < 0 || a[0] == '0') {
2410 if (connection != NULL)
2411 test_deregister_client();
2416 if (*a == '\n' || *a == '\r') {
2418 printf("\n\n Network Connection API Test App\n\n");
2419 printf("Options..\n");
2420 printf(LOG_BLUE "[Public APIs]\n" LOG_END);
2421 printf(LOG_GREEN "1 - Create Handle and set callbacks\n" LOG_END);
2422 printf("2 - Destroy Handle(unset callbacks automatically)\n");
2423 printf(LOG_GREEN "3 - Get network state\n" LOG_END);
2424 printf(LOG_GREEN "4 - Get cellular state (please insert SIM Card)\n" LOG_END);
2425 printf(LOG_GREEN "5 - Get wifi state (please turn on WiFi)\n" LOG_END);
2426 printf("6 - Get current proxy address \n");
2427 printf("7 - Get current Ip address\n");
2428 printf("8 - Get cellular data call statistics\n");
2429 printf("9 - Get WiFi data call statistics\n");
2430 printf(LOG_GREEN "a - Get Profile list\n" LOG_END);
2431 printf(LOG_GREEN "b - Get Connected Profile list\n" LOG_END);
2432 printf(LOG_GREEN "c - Get Current profile\n" LOG_END);
2433 printf("d - Open connection with profile\n");
2434 printf("e - Get default cellular service by type\n");
2435 printf("f - Set default cellular service by type\n");
2436 printf("g - Close connection with profile\n");
2437 printf("h - Add profile(Cellular and Wifi only)\n");
2438 printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
2439 printf("j - Update profile\n");
2440 printf("k - Get profile info\n");
2441 printf("l - Refresh profile info\n");
2442 printf("m - Set state changed callback\n");
2443 printf("n - Unset state changed callback\n");
2444 printf("o - Reset cellular data call statistics\n");
2445 printf("p - Reset WiFi data call statistics\n");
2446 printf("q - Add new route\n");
2447 printf("r - Remove a route\n");
2448 printf("s - Get Bluetooth state\n");
2449 printf("t - Get profile id\n");
2450 printf("u - Reset profile\n");
2451 printf("v - Get all cellular default profiles\n");
2452 printf("w - Get mac address\n");
2453 printf("x - Get ethernet cable state\n");
2454 printf("B - Add IPv6 new route\n");
2455 printf("C - Remove IPv6 route\n");
2456 printf("D - Add new route entry\n");
2457 printf("E - Remove route entry\n");
2458 printf("F - Get all IPv6 address\n");
2459 printf("G - Get metered state\n");
2461 printf(LOG_BLUE "[Extension API]\n" LOG_END);
2462 printf("H - Start TCP Dump\n");
2463 printf("I - Stop TCP Dump\n");
2464 printf("J - Get TCP Dump State\n");
2465 printf("K - Enable MPTCP (internal)\n");
2466 printf("L - Disable MPTCP (internal)\n");
2467 printf("M - Set MPTCP Path Manager (internal)\n");
2468 printf("N - Get MPTCP Path Manager (internal)\n");
2469 printf("O - Set MPTCP Scheduler (internal)\n");
2470 printf("P - Get MPTCP Scheduler (internal)\n");
2471 printf(LOG_GREEN "Q - Create Handle and set callbacks in C# API\n" LOG_END);
2472 printf("R - Destroy Handle(unset callbacks automatically in C# API)\n");
2473 printf(LOG_RED "0 - Exit \n" LOG_END);
2474 printf("ENTER - Show options menu.......\n");
2480 rv = test_register_client();
2483 rv = test_deregister_client();
2486 rv = test_get_network_state();
2489 rv = test_get_cellular_state();
2492 rv = test_get_wifi_state();
2495 rv = test_get_current_proxy();
2498 rv = test_get_current_ip();
2501 rv = test_get_call_statistics_info();
2504 rv = test_get_wifi_call_statistics_info();
2507 rv = test_get_profile_list();
2510 rv = test_get_connected_profile_list();
2513 rv = test_get_current_profile();
2516 rv = test_open_profile();
2519 rv = test_get_default_cellular_service_type();
2522 rv = test_set_default_cellular_service_type();
2525 rv = test_close_profile();
2528 rv = test_add_profile();
2531 rv = test_remove_profile();
2534 rv = test_update_profile();
2537 rv = test_get_profile_info();
2540 rv = test_refresh_profile_info();
2543 rv = test_set_state_changed_callback();
2546 rv = test_unset_state_changed_callback();
2549 rv = test_reset_call_statistics_info();
2552 rv = test_reset_wifi_call_statistics_info();
2555 rv = test_add_route();
2558 rv = test_remove_route();
2561 rv = test_get_bt_state();
2564 rv = test_get_profile_id();
2567 rv = test_reset_profile();
2570 rv = test_get_default_profile_list();
2573 rv = test_get_mac_address();
2576 rv = test_get_ethernet_cable_state();
2579 rv = test_add_route_ipv6();
2582 rv = test_remove_route_ipv6();
2585 rv = test_add_route_entry();
2588 rv = test_remove_route_entry();
2591 rv = test_foreach_ipv6_address();
2594 rv = test_is_metered_network();
2598 rv = test_start_tcpdump();
2601 rv = test_stop_tcpdump();
2604 rv = test_get_tcpdump_state();
2607 rv = test_mptcp_enable();
2610 rv = test_mptcp_disable();
2613 rv = test_mptcp_set_path_manager();
2616 rv = test_mptcp_get_path_manager();
2619 rv = test_mptcp_set_scheduler();
2622 rv = test_mptcp_get_scheduler();
2625 rv = test_register_client_cs();
2628 rv = test_deregister_client_cs();
2634 printf("Operation succeeded!\n");
2636 printf("Operation failed!\n");