Change a gcov path
[platform/core/api/connection.git] / test / connection_test.c
1 /*
2  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <stdio.h>
18 #include <errno.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include <glib.h>
23
24 #include "net_connection.h"
25 #include "connection_extension.h"
26
27 #include <tizen_error.h>
28
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"
34
35 #define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1; }
36
37 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
38
39 connection_h connection = NULL;
40 static GSList *state_cb_list = NULL;
41
42
43 static bool test_get_user_string(const char *msg, char *buf, int buf_size)
44 {
45         if (msg == NULL || buf == NULL || buf_size < 2)
46                 return false;
47
48         int rv;
49         printf("%s\n", msg);
50         memset(buf, 0, buf_size);
51         rv = read(0, buf, buf_size - 1);
52
53         if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
54                 buf[0] = '\0';
55                 return false;
56         }
57
58         buf[rv-1] = '\0';
59         return true;
60 }
61
62 static bool test_get_user_int(const char *msg, int *num)
63 {
64         if (msg == NULL || num == NULL)
65                 return false;
66
67         int rv;
68         char buf[32] = {0,};
69         printf("%s\n", msg);
70         rv = read(0, buf, 32);
71
72         if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
73                 return false;
74
75         *num = atoi(buf);
76         return true;
77 }
78
79 static const char *test_print_state(connection_profile_state_e state)
80 {
81         switch (state) {
82         case CONNECTION_PROFILE_STATE_DISCONNECTED:
83                 return "Disconnected";
84         case CONNECTION_PROFILE_STATE_ASSOCIATION:
85                 return "Association";
86         case CONNECTION_PROFILE_STATE_CONFIGURATION:
87                 return "Configuration";
88         case CONNECTION_PROFILE_STATE_CONNECTED:
89                 return "Connected";
90         default:
91                 return "Unknown";
92         }
93 }
94
95 static const char *test_print_internet_state(connection_internet_state_e state)
96 {
97         if (state == CONNECTION_INTERNET_STATE_ONLINE)
98                 return "Online";
99
100         return "Offline";
101 }
102
103 static const char *test_print_connection_type(connection_type_e type)
104 {
105         switch (type) {
106         case CONNECTION_TYPE_DISCONNECTED:
107                 return "Disconnected";
108         case CONNECTION_TYPE_WIFI:
109                 return "Wifi";
110         case CONNECTION_TYPE_CELLULAR:
111                 return "Cellular";
112         case CONNECTION_TYPE_ETHERNET:
113                 return "Ethernet";
114         case CONNECTION_TYPE_BT:
115                 return "BT";
116         case CONNECTION_TYPE_NET_PROXY:
117                 return "Net_Proxy";
118         default:
119                 return "Unknown";
120         }
121 }
122
123 static const char *test_print_cellular_state(connection_cellular_state_e state)
124 {
125         switch (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:
135                 return "Available";
136         case CONNECTION_CELLULAR_STATE_CONNECTED:
137                 return "Connected";
138         default:
139                 return "Unknown";
140         }
141 }
142
143 static const char *test_print_wifi_state(connection_wifi_state_e state)
144 {
145         switch (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:
151                 return "Connected";
152         default:
153                 return "Unknown";
154         }
155 }
156
157 static const char *test_print_wifi_security_type(connection_wifi_security_type_e type)
158 {
159         switch (type) {
160         case CONNECTION_WIFI_SECURITY_TYPE_NONE:
161                 return "None";
162         case CONNECTION_WIFI_SECURITY_TYPE_WEP:
163                 return "WEP";
164         case CONNECTION_WIFI_SECURITY_TYPE_WPA_PSK:
165                 return "WPA_PSK";
166         case CONNECTION_WIFI_SECURITY_TYPE_WPA2_PSK:
167                 return "WPA2_PSK";
168         case CONNECTION_WIFI_SECURITY_TYPE_EAP:
169                 return "EAP";
170         case CONNECTION_WIFI_SECURITY_TYPE_SAE:
171                 return "SAE";
172         default:
173                 return "Unknown";
174         }
175 }
176
177 static const char *test_print_cellular_service_type(connection_cellular_service_type_e type)
178 {
179         switch (type) {
180         case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
181                 return "Unknown";
182         case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET:
183                 return "Internet";
184         case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
185                 return "MMS";
186         case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET:
187                 return "Prepaid internet";
188         case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS:
189                 return "Prepaid MMS";
190         case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING:
191                 return "Tethering";
192         case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION:
193                 return "Application";
194         default:
195                 return "Unknown";
196         }
197 }
198
199 static const char* test_print_cellular_auth_type(connection_cellular_auth_type_e type)
200 {
201         switch (type) {
202         case CONNECTION_CELLULAR_AUTH_TYPE_PAP:
203                 return "PAP";
204         case CONNECTION_CELLULAR_AUTH_TYPE_CHAP:
205                 return "CHAP";
206         case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
207         default:
208                 return "None";
209         }
210 }
211
212 static const char* test_print_cellular_pdn_type(connection_cellular_pdn_type_e type)
213 {
214         switch (type) {
215         case CONNECTION_CELLULAR_PDN_TYPE_IPV4:
216                 return "IPv4";
217         case CONNECTION_CELLULAR_PDN_TYPE_IPV6:
218                 return "IPv6";
219         case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6:
220                 return "Dual";
221         case CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN:
222         default:
223                 return "Unknown";
224         }
225 }
226
227 static const char *test_print_error(connection_error_e error)
228 {
229         switch (error) {
230         case CONNECTION_ERROR_NONE:
231                 return "CONNECTION_ERROR_NONE";
232         case CONNECTION_ERROR_INVALID_PARAMETER:
233                 return "CONNECTION_ERROR_INVALID_PARAMETER";
234         case CONNECTION_ERROR_OUT_OF_MEMORY:
235                 return "CONNECTION_ERROR_OUT_OF_MEMORY";
236         case CONNECTION_ERROR_INVALID_OPERATION:
237                 return "CONNECTION_ERROR_INVALID_OPERATION";
238         case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
239                 return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
240         case CONNECTION_ERROR_OPERATION_FAILED:
241                 return "CONNECTION_ERROR_OPERATION_FAILED";
242         case CONNECTION_ERROR_ITERATOR_END:
243                 return "CONNECTION_ERROR_ITERATOR_END";
244         case CONNECTION_ERROR_NO_CONNECTION:
245                 return "CONNECTION_ERROR_NO_CONNECTION";
246         case CONNECTION_ERROR_NOW_IN_PROGRESS:
247                 return "CONNECTION_ERROR_NOW_IN_PROGRESS";
248         case CONNECTION_ERROR_ALREADY_EXISTS:
249                 return "CONNECTION_ERROR_ALREADY_EXISTS";
250         case CONNECTION_ERROR_OPERATION_ABORTED:
251                 return "CONNECTION_ERROR_OPERATION_ABORTED";
252         case CONNECTION_ERROR_DHCP_FAILED:
253                 return "CONNECTION_ERROR_DHCP_FAILED";
254         case CONNECTION_ERROR_INVALID_KEY:
255                 return "CONNECTION_ERROR_INVALID_KEY";
256         case CONNECTION_ERROR_NO_REPLY:
257                 return "CONNECTION_ERROR_NO_REPLY";
258         case CONNECTION_ERROR_PERMISSION_DENIED:
259                 return "CONNECTION_ERROR_PERMISSION_DENIED";
260         case CONNECTION_ERROR_NOT_SUPPORTED:
261                 return "CONNECTION_ERROR_NOT_SUPPORTED";
262         case CONNECTION_ERROR_NOT_INITIALIZED:
263                 return "CONNECTION_ERROR_NOT_INITIALIZED";
264         case CONNECTION_ERROR_ALREADY_INITIALIZED:
265                 return "CONNECTION_ERROR_ALREADY_INITIALIZED";
266         default:
267                 return "CONNECTION_ERROR_UNKNOWN";
268         }
269 }
270
271 static void test_type_changed_callback(connection_type_e type, void* user_data)
272 {
273         printf("Type changed callback, connection type : %d\n", type);
274 }
275
276 static void test_ip_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
277 {
278         printf("IP changed callback, IPv4 address : %s, IPv6 address : %s\n",
279                         ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
280 }
281
282 static void test_proxy_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data)
283 {
284         printf("Proxy changed callback, IPv4 address : %s, IPv6 address : %s\n",
285                         ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
286 }
287
288 static void test_internet_state_changed_callback(connection_internet_state_e state, void* user_data)
289 {
290         printf("Internet state changed callback, state : %d\n", state);
291 }
292
293 static void test_profile_state_callback(connection_profile_state_e state, void* user_data)
294 {
295         char *profile_name;
296         connection_profile_h profile = user_data;
297
298         if (profile == NULL)
299                 return;
300
301         if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE)
302                 return;
303
304         printf("[%s] : %s\n", test_print_state(state), profile_name);
305         g_free(profile_name);
306 }
307
308 static void test_connection_opened_callback(connection_error_e result, void* user_data)
309 {
310         if (result ==  CONNECTION_ERROR_NONE)
311                 printf("Connection open Succeeded\n");
312         else
313                 printf("Connection open Failed, err : [%s]\n", test_print_error(result));
314 }
315
316 static void test_connection_closed_callback(connection_error_e result, void* user_data)
317 {
318         if (result ==  CONNECTION_ERROR_NONE)
319                 printf("Connection close Succeeded\n");
320         else
321                 printf("Connection close Failed, err : [%s]\n", test_print_error(result));
322 }
323
324 static void test_connection_reset_profile_callback(connection_error_e result, void* user_data)
325 {
326         if (result ==  CONNECTION_ERROR_NONE)
327                 printf("Reset profile Succeeded\n");
328         else
329                 printf("Reset profile Failed, err : [%s]\n", test_print_error(result));
330 }
331
332 static void test_connection_set_default_callback(connection_error_e result, void* user_data)
333 {
334         if (result ==  CONNECTION_ERROR_NONE)
335                 printf("Default profile setting Succeeded\n");
336         else
337                 printf("Default profile setting Failed, err : [%s]\n", test_print_error(result));
338 }
339
340 void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state,
341                                                                 void* user_data)
342 {
343         if (state == CONNECTION_ETHERNET_CABLE_ATTACHED)
344                 printf("Ethernet Cable Connected\n");
345         else if (state == CONNECTION_ETHERNET_CABLE_DETACHED)
346                 printf("Ethernet Cable Disconnected\n");
347 }
348
349 static bool test_get_user_selected_profile(connection_profile_h *profile, bool select)
350 {
351         int rv = 0;
352         int input = 0;
353         char *profile_name;
354         connection_profile_type_e profile_type;
355         connection_profile_state_e profile_state;
356         connection_profile_iterator_h profile_iter;
357         connection_profile_h profile_h;
358
359         connection_profile_h profile_list[100] = {0,};
360         int profile_count = 0;
361
362         rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
363         if (rv != CONNECTION_ERROR_NONE) {
364                 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
365                 return false;
366         }
367
368         while (connection_profile_iterator_has_next(profile_iter)) {
369                 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
370                         printf("Fail to get profile handle\n");
371                         return false;
372                 }
373
374                 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
375                         printf("Fail to get profile name\n");
376                         return false;
377                 }
378
379                 if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) {
380                         printf("Fail to get profile type\n");
381                         g_free(profile_name);
382                         return false;
383                 }
384
385                 if (connection_profile_get_state(profile_h, &profile_state) != CONNECTION_ERROR_NONE) {
386                         printf("Fail to get profile state\n");
387                         g_free(profile_name);
388                         return false;
389                 }
390
391                 printf("%d. state:[%s], profile name:%s", profile_count,
392                                 test_print_state(profile_state), profile_name);
393                 if (profile_type == CONNECTION_PROFILE_TYPE_CELLULAR) {
394                         connection_cellular_service_type_e service_type;
395                         if (connection_profile_get_cellular_service_type(
396                                 profile_h, &service_type) !=
397                                 CONNECTION_ERROR_NONE)
398                                 printf("Fail to get cellular service type!\n");
399
400                         printf(" [%s]",
401                                 test_print_cellular_service_type(service_type));
402                 } else if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) {
403                         connection_wifi_security_type_e security_type;
404                         if (connection_profile_get_wifi_security_type(
405                                 profile_h, &security_type) !=
406                                 CONNECTION_ERROR_NONE)
407                                 printf("Fail to get wifi security type!\n");
408
409                         printf(" [%s]",
410                                 test_print_wifi_security_type(security_type));
411                 }
412                 printf("\n");
413
414                 profile_list[profile_count] = profile_h;
415                 profile_count++;
416
417                 g_free(profile_name);
418                 if (profile_count >= 100)
419                         break;
420         }
421
422         if (select == false)
423                 return true;
424
425         if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
426             input >= profile_count ||
427             input < 0) {
428                 printf("Wrong number!!\n");
429                 return false;
430         }
431
432         if (profile)
433                 *profile = profile_list[input];
434
435         return true;
436 }
437
438 static int test_update_cellular_info(connection_profile_h profile)
439 {
440         int rv = 0;
441         char input_str1[100] = {0,};
442         char input_str2[100] = {0,};
443         int input_int = 0;
444         int type_val = 0;
445
446         if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, "
447                         "Prepaid MMS:4, Tethering:5, Application:6)"
448                         " - (Enter for skip) :", &input_int)) {
449                 switch (input_int) {
450                 case 1:
451                         rv = connection_profile_set_cellular_service_type(profile,
452                                         CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
453                         break;
454                 case 2:
455                         rv = connection_profile_set_cellular_service_type(profile,
456                                         CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
457                         break;
458                 case 3:
459                         rv = connection_profile_set_cellular_service_type(profile,
460                                         CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET);
461                         break;
462                 case 4:
463                         rv = connection_profile_set_cellular_service_type(profile,
464                                         CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS);
465                         break;
466                 case 5:
467                         rv = connection_profile_set_cellular_service_type(profile,
468                                         CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING);
469                         break;
470                 case 6:
471                         rv = connection_profile_set_cellular_service_type(profile,
472                                         CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
473                         break;
474                 default:
475                         return -1;
476                 }
477
478                 if (rv != CONNECTION_ERROR_NONE)
479                         return -1;
480         } else
481                 return -1;
482
483         if (test_get_user_string("Input apn - (Enter for skip) :", input_str1, 100)) {
484                 g_strstrip(input_str1);
485                 rv = connection_profile_set_cellular_apn(profile, input_str1);
486                 if (rv != CONNECTION_ERROR_NONE)
487                         return -1;
488         }
489
490         if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
491                 g_strstrip(input_str1);
492                 rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
493                 if (rv != CONNECTION_ERROR_NONE)
494                         return -1;
495         }
496
497         if (test_get_user_string("Input home_url - (Enter for skip) :", input_str1, 100)) {
498                 g_strstrip(input_str1);
499                 rv = connection_profile_set_cellular_home_url(profile, input_str1);
500                 if (rv != CONNECTION_ERROR_NONE)
501                         return -1;
502         }
503
504         if (test_get_user_int("Input auth_type(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) {
505                 switch (input_int) {
506                 case 0:
507                         rv = connection_profile_set_cellular_auth_info(profile,
508                                         CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", "");
509                         if (rv != CONNECTION_ERROR_NONE)
510                                 return -1;
511
512                         break;
513                 case 1:
514                         type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
515                         /* fall through */
516                 case 2:
517                         if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
518
519                         if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false)
520                                 input_str1[0] = 0;
521                         if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
522                                 input_str2[0] = 0;
523
524                         g_strstrip(input_str1);
525                         g_strstrip(input_str2);
526                         rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
527                         if (rv != CONNECTION_ERROR_NONE)
528                                 return -1;
529                 }
530         }
531
532         if (test_get_user_int("Input pdn_type(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
533                 switch (input_int) {
534                 case 1:
535                         rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
536                         break;
537                 case 2:
538                         rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
539                         break;
540                 case 3:
541                         rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
542                         break;
543                 }
544
545                 if (rv != CONNECTION_ERROR_NONE)
546                         return -1;
547         }
548
549         if (test_get_user_int("Input roam_pdn_type(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
550                 switch (input_int) {
551                 case 1:
552                         rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
553                         break;
554                 case 2:
555                         rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
556                         break;
557                 case 3:
558                         rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
559                         break;
560                 }
561
562                 if (rv != CONNECTION_ERROR_NONE)
563                         return -1;
564         }
565
566         return 1;
567 }
568
569 static int test_update_wifi_info(connection_profile_h profile)
570 {
571         int rv = 0;
572         char input_str[100] = {0,};
573
574         if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) {
575                 rv = connection_profile_set_wifi_passphrase(profile, input_str);
576                 if (rv != CONNECTION_ERROR_NONE)
577                         return -1;
578         }
579
580         return 1;
581 }
582
583 static int test_update_dns_info(connection_profile_h profile,
584                 connection_address_family_e address_family)
585 {
586         int rv = 0;
587         char input_str[100] = {0,};
588         if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
589                 rv = connection_profile_set_dns_address(profile,
590                                 1,
591                                 address_family,
592                                 input_str);
593                 if (rv != CONNECTION_ERROR_NONE)
594                         return -1;
595
596                 if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
597                         rv = connection_profile_set_dns_address(profile,
598                                         2,
599                                         address_family,
600                                         input_str);
601                         if (rv != CONNECTION_ERROR_NONE)
602                                 return -1;
603                 }
604         }
605         return 1;
606 }
607
608 static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
609 {
610         int rv = 0;
611         int input_int = 0;
612         char input_str[100] = {0,};
613         int dns_input = 0;
614
615         if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
616                 rv = connection_profile_set_ip_address(profile,
617                                                         address_family,
618                                                         input_str);
619                 if (rv != CONNECTION_ERROR_NONE)
620                         return -1;
621         }
622
623         if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
624                 rv = connection_profile_set_subnet_mask(profile,
625                                                         address_family,
626                                                         input_str);
627                 if (rv != CONNECTION_ERROR_NONE)
628                         return -1;
629         }
630
631         if (test_get_user_int("Input Prefix Length - (Enter for skip) :", &input_int)) {
632                 rv = connection_profile_set_prefix_length(profile,
633                                                         address_family,
634                                                         input_int);
635                 if (rv != CONNECTION_ERROR_NONE)
636                         return -1;
637         }
638
639         if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
640                 rv = connection_profile_set_gateway_address(profile,
641                                                         address_family,
642                                                         input_str);
643                 if (rv != CONNECTION_ERROR_NONE)
644                         return -1;
645         }
646
647         if (test_get_user_int("Input DNS Address Type (Static:1, DHCP:2)"
648                                 " - (Enter for skip) :", &dns_input)) {
649                 switch (dns_input) {
650                 case CONNECTION_DNS_CONFIG_TYPE_STATIC:
651                         rv = connection_profile_set_dns_config_type(
652                                         profile,
653                                         address_family,
654                                         CONNECTION_DNS_CONFIG_TYPE_STATIC);
655                         if (rv != CONNECTION_ERROR_NONE)
656                                 return -1;
657                         if (test_update_dns_info(profile,
658                                                 address_family) == -1)
659                                 return -1;
660                         break;
661                 case CONNECTION_DNS_CONFIG_TYPE_DYNAMIC:
662                         rv = connection_profile_set_dns_config_type(
663                                         profile,
664                                         address_family,
665                                         CONNECTION_DNS_CONFIG_TYPE_DYNAMIC);
666                         if (rv != CONNECTION_ERROR_NONE)
667                                 return -1;
668                         break;
669                 }
670         }
671
672         return 1;
673 }
674
675 static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
676 {
677         int rv = 0;
678         int input_int = 0;
679         char input_str[100] = {0,};
680
681         if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)"
682                                         " - (Enter for skip) :", &input_int)) {
683                 switch (input_int) {
684                 case 1:
685                         rv = connection_profile_set_proxy_type(profile,
686                                         CONNECTION_PROXY_TYPE_DIRECT);
687
688                         if (rv != CONNECTION_ERROR_NONE)
689                                 return -1;
690                         else
691                                 return 1;
692                 case 2:
693                         rv = connection_profile_set_proxy_type(profile,
694                                         CONNECTION_PROXY_TYPE_AUTO);
695                         break;
696                 case 3:
697                         rv = connection_profile_set_proxy_type(profile,
698                                         CONNECTION_PROXY_TYPE_MANUAL);
699                         break;
700                 default:
701                         return -1;
702                 }
703
704                 if (rv != CONNECTION_ERROR_NONE)
705                         return -1;
706
707                 if (test_get_user_string("Input auto Proxy URL or Proxy address"
708                                         " - (Enter for skip) :", input_str, 100)) {
709                         rv = connection_profile_set_proxy_address(profile,
710                                                                 address_family,
711                                                                 input_str);
712                         if (rv != CONNECTION_ERROR_NONE)
713                                 return -1;
714                 }
715
716         } else
717                 return -1;
718
719         return 1;
720 }
721
722
723
724 static int test_update_network_info(connection_profile_h profile)
725 {
726         int rv = 0;
727         int input_int = 0;
728         int dns_input = 0;
729         int address_family = 0;
730
731         test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
732
733         if (test_get_user_int("Input IPv4/IPv6 Address Type (DHCP:1, Static:2, Auto:3)"
734                                 " - (Enter for skip) :", &input_int)) {
735                 switch (input_int) {
736                 case 1:
737                         rv = connection_profile_set_ip_config_type(profile,
738                                         address_family,
739                                         CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
740                         if (test_get_user_int("Input DNS Address Type (Static:1, DHCP:2)"
741                                                 " - (Enter for skip) :", &dns_input)) {
742                                 switch (dns_input) {
743                                 case CONNECTION_DNS_CONFIG_TYPE_STATIC:
744                                         rv = connection_profile_set_dns_config_type(
745                                                         profile,
746                                                         address_family,
747                                                         CONNECTION_DNS_CONFIG_TYPE_STATIC);
748                                         if (rv != CONNECTION_ERROR_NONE)
749                                                 return -1;
750                                         if (test_update_dns_info(profile,
751                                                                 address_family) == -1)
752                                                 return -1;
753                                         break;
754                                 case CONNECTION_DNS_CONFIG_TYPE_DYNAMIC:
755                                         rv = connection_profile_set_dns_config_type(
756                                                         profile,
757                                                         address_family,
758                                                         CONNECTION_DNS_CONFIG_TYPE_DYNAMIC);
759                                         if (rv != CONNECTION_ERROR_NONE)
760                                                 return -1;
761                                         break;
762                                 }
763                         }
764                         break;
765                 case 2:
766                         rv = connection_profile_set_ip_config_type(profile,
767                                                                    address_family,
768                                                                    CONNECTION_IP_CONFIG_TYPE_STATIC);
769                         if (rv != CONNECTION_ERROR_NONE)
770                                 return -1;
771
772                         if (test_update_ip_info(profile, address_family) == -1)
773                                 return -1;
774
775                         if (test_update_proxy_info(profile, address_family) == -1)
776                                 return -1;
777                         break;
778                 case 3:
779                         rv = connection_profile_set_ip_config_type(profile,
780                                                                 address_family,
781                                                                 CONNECTION_IP_CONFIG_TYPE_AUTO);
782                         break;
783                 default:
784                         return -1;
785                 }
786
787                 if (rv != CONNECTION_ERROR_NONE)
788                         return -1;
789         } else
790                 return -1;
791
792         return 1;
793 }
794
795 static void test_print_cellular_info(connection_profile_h profile)
796 {
797         connection_cellular_service_type_e service_type;
798         connection_cellular_pdn_type_e pdn_type;
799         connection_cellular_pdn_type_e roam_pdn_type;
800         char *apn = NULL;
801         connection_cellular_auth_type_e auth_type;
802         char *user_name = NULL;
803         char *password = NULL;
804         char *home_url = NULL;
805         bool roaming = false;
806         bool hidden = false;
807         bool editable = false;
808
809         if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
810                 printf("Fail to get cellular service type!\n");
811         else
812                 printf("Cellular service type : %s\n", test_print_cellular_service_type(service_type));
813
814         if (connection_profile_get_cellular_pdn_type(profile, &pdn_type) != CONNECTION_ERROR_NONE)
815                 printf("Fail to get cellular pdn type!\n");
816         else
817                 printf("Cellular pdn type : %s\n", test_print_cellular_pdn_type(pdn_type));
818
819         if (connection_profile_get_cellular_roam_pdn_type(profile, &roam_pdn_type) != CONNECTION_ERROR_NONE)
820                 printf("Fail to get cellular roam pdn type!\n");
821         else
822                 printf("Cellular roam pdn type : %s\n", test_print_cellular_pdn_type(roam_pdn_type));
823
824         if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
825                 printf("Fail to get cellular APN!\n");
826         else {
827                 printf("Cellular APN : %s\n", apn);
828                 g_free(apn);
829         }
830
831         if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
832                 printf("Fail to get auth info!\n");
833         else {
834                 printf("Cellular auth type : %s\n", test_print_cellular_auth_type(auth_type));
835                 printf("Cellular user_name : %s\n", user_name);
836                 printf("Cellular password : %s\n", password);
837                 g_free(user_name);
838                 g_free(password);
839         }
840
841         if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE)
842                 printf("Fail to get cellular home url!\n");
843         else {
844                 printf("Cellular home url : %s\n", home_url);
845                 g_free(home_url);
846         }
847
848         if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
849                 printf("Fail to get cellular roaming state!\n");
850         else
851                 printf("Cellular roaming : %s\n", roaming ? "true" : "false");
852
853         if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE)
854                 printf("Fail to get cellular hidden state!\n");
855         else
856                 printf("Cellular hidden : %s\n", hidden ? "true" : "false");
857
858         if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE)
859                 printf("Fail to get cellular editing state!\n");
860         else
861                 printf("Cellular editable : %s\n", editable ? "true" : "false");
862 }
863
864 static void test_print_wifi_info(connection_profile_h profile)
865 {
866         char *essid = NULL;
867         char *bssid = NULL;
868         int rssi = 0;
869         int frequency = 0;
870         int max_speed = 0;
871         connection_wifi_security_type_e security_type;
872         connection_wifi_encryption_type_e encryption_type;
873         bool pass_required = false;
874         bool wps_supported = false;
875
876         if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
877                 printf("Fail to get Wi-Fi essid!\n");
878         else {
879                 printf("Wi-Fi essid : %s\n", essid);
880                 g_free(essid);
881         }
882
883         if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
884                 printf("Fail to get Wi-Fi bssid!\n");
885         else {
886                 printf("Wi-Fi bssid : %s\n", bssid);
887                 g_free(bssid);
888         }
889
890         if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
891                 printf("Fail to get Wi-Fi rssi!\n");
892         else
893                 printf("Wi-Fi rssi : %d\n", rssi);
894
895         if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
896                 printf("Fail to get Wi-Fi frequency!\n");
897         else
898                 printf("Wi-Fi frequency : %d\n", frequency);
899
900         if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE)
901                 printf("Fail to get Wi-Fi max speed!\n");
902         else
903                 printf("Wi-Fi max speed : %d\n", max_speed);
904
905         if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
906                 printf("Fail to get Wi-Fi security type!\n");
907         else
908                 printf("Wi-Fi security type : %s\n", test_print_wifi_security_type(security_type));
909
910         if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE)
911                 printf("Fail to get Wi-Fi encryption type!\n");
912         else
913                 printf("Wi-Fi encryption type : %d\n", encryption_type);
914
915         if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
916                 printf("Fail to get Wi-Fi passphrase required!\n");
917         else
918                 printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false");
919
920         if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE)
921                 printf("Fail to get Wi-Fi wps info\n");
922         else
923                 printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
924 }
925
926 static void test_print_mesh_info(connection_profile_h profile)
927 {
928         char *essid = NULL;
929         char *bssid = NULL;
930         int rssi = 0;
931         int frequency = 0;
932         connection_wifi_security_type_e security_type;
933         bool pass_required = false;
934
935         if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
936                 printf("Fail to get Mesh essid!\n");
937         else {
938                 printf("Mesh essid : %s\n", essid);
939                 g_free(essid);
940         }
941
942         if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
943                 printf("Fail to get Mesh bssid!\n");
944         else {
945                 printf("Mesh bssid : %s\n", bssid);
946                 g_free(bssid);
947         }
948
949         if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
950                 printf("Fail to get Mesh rssi!\n");
951         else
952                 printf("Mesh rssi : %d\n", rssi);
953
954         if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
955                 printf("Fail to get Mesh frequency!\n");
956         else
957                 printf("Mesh frequency : %d\n", frequency);
958
959         if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
960                 printf("Fail to get Mesh security type!\n");
961         else
962                 printf("Mesh security type : %s\n", test_print_wifi_security_type(security_type));
963
964         if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
965                 printf("Fail to get Mesh passphrase required!\n");
966         else
967                 printf("Mesh passphrase required : %s\n", pass_required ? "true" : "false");
968 }
969
970 static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
971 {
972         char *interface_name = NULL;
973         char *ip = NULL;
974         char *subnet = NULL;
975         char *gateway = NULL;
976         char *dhcp_server = NULL;
977         int dhcp_lease_duration = 0;
978         char *dns1 = NULL;
979         char *dns2 = NULL;
980         char *proxy = NULL;
981         int prefix_len;
982         connection_ip_config_type_e ip_type;
983         connection_proxy_type_e proxy_type;
984         connection_dns_config_type_e dns_type;
985
986         if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
987                 printf("Fail to get interface name!\n");
988         else {
989                 printf("Interface name : %s\n", interface_name);
990                 g_free(interface_name);
991         }
992
993         if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
994                 printf("Fail to get ipconfig type!\n");
995         else {
996                 if (ip_type == CONNECTION_IP_CONFIG_TYPE_STATIC)
997                         printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_STATIC");
998                 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_DYNAMIC)
999                         printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_DYNAMIC");
1000                 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_AUTO)
1001                         printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_AUTO");
1002                 else if (ip_type == CONNECTION_IP_CONFIG_TYPE_FIXED)
1003                         printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_FIXED");
1004                 else
1005                         printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_NONE");
1006         }
1007
1008         if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
1009                 printf("Fail to get IP address!\n");
1010         else {
1011                 printf("IP address : %s\n", ip);
1012                 g_free(ip);
1013         }
1014
1015         if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
1016                 printf("Fail to get gateway!\n");
1017         else {
1018                 printf("Gateway : %s\n", gateway);
1019                 g_free(gateway);
1020         }
1021
1022         if (connection_profile_get_dhcp_server_address(profile, address_family, &dhcp_server) != CONNECTION_ERROR_NONE)
1023                 printf("Fail to get DHCP Server address!\n");
1024         else {
1025                 printf("DHCP Server : %s\n", dhcp_server);
1026                 g_free(dhcp_server);
1027         }
1028
1029         if (connection_profile_get_dhcp_lease_duration(profile, address_family, &dhcp_lease_duration) != CONNECTION_ERROR_NONE)
1030                 printf("Fail to get DHCP lease duration!\n");
1031         else {
1032                 printf("DHCP lease duration : %d\n", dhcp_lease_duration);
1033         }
1034
1035         if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
1036                 printf("Fail to get subnet mask!\n");
1037         else {
1038                 printf("Subnet mask : %s\n", subnet);
1039                 g_free(subnet);
1040         }
1041
1042         if (connection_profile_get_prefix_length(profile, address_family, &prefix_len) != CONNECTION_ERROR_NONE)
1043                 printf("Fail to get prefix length!\n");
1044         else
1045                 printf("Prefix length : %d\n", prefix_len);
1046
1047         if (connection_profile_get_dns_config_type(profile, address_family, &dns_type) != CONNECTION_ERROR_NONE)
1048                 printf("Fail to get DNS configuration type!\n");
1049         else {
1050                 if (dns_type == CONNECTION_DNS_CONFIG_TYPE_STATIC)
1051                         printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_STATIC");
1052                 else if (dns_type == CONNECTION_DNS_CONFIG_TYPE_DYNAMIC)
1053                         printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_DYNAMIC");
1054                 else
1055                         printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_NONE");
1056         }
1057
1058         if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
1059                 printf("Fail to get DNS1!\n");
1060         else {
1061                 printf("DNS1 : %s\n", dns1);
1062                 g_free(dns1);
1063         }
1064
1065         if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
1066                 printf("Fail to get DNS2!\n");
1067         else {
1068                 printf("DNS2 : %s\n", dns2);
1069                 g_free(dns2);
1070         }
1071
1072         if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
1073                 printf("Fail to get proxy type!\n");
1074         else {
1075                 if (proxy_type == CONNECTION_PROXY_TYPE_DIRECT)
1076                         printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_DIRECT");
1077                 else if (proxy_type == CONNECTION_PROXY_TYPE_AUTO)
1078                         printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_AUTO");
1079                 else
1080                         printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_MANUAL");
1081         }
1082
1083         if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
1084                 printf("Fail to get proxy!\n");
1085         else {
1086                 printf("Proxy : %s\n", proxy);
1087                 g_free(proxy);
1088         }
1089 }
1090
1091 int test_register_client(void)
1092 {
1093
1094         int err = connection_create(&connection);
1095
1096         if (CONNECTION_ERROR_NONE == err) {
1097                 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
1098                 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
1099                 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
1100                 connection_set_ethernet_cable_state_changed_cb(connection,
1101                                         test_get_ethernet_cable_state_callback, NULL);
1102                 connection_set_internet_state_changed_cb(connection, test_internet_state_changed_callback, NULL);
1103         } else {
1104                 printf("Client registration failed [%s]\n", test_print_error(err));
1105                 return -1;
1106         }
1107
1108         printf("Client registration success\n");
1109         return 1;
1110 }
1111
1112 int  test_deregister_client(void)
1113 {
1114         int rv = 0;
1115         GSList *list;
1116         connection_profile_h profile;
1117
1118         if (connection != NULL)
1119                 rv = connection_destroy(connection);
1120         else {
1121                 printf("Cannot deregister : Handle is NULL\n");
1122                 rv = CONNECTION_ERROR_INVALID_OPERATION;
1123         }
1124
1125         if (rv != CONNECTION_ERROR_NONE) {
1126                 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1127                 return -1;
1128         }
1129
1130         if (state_cb_list) {
1131                 for (list = state_cb_list; list; list = list->next) {
1132                         profile = list->data;
1133                         connection_profile_destroy(profile);
1134                 }
1135
1136                 g_slist_free(state_cb_list);
1137                 state_cb_list = NULL;
1138         }
1139
1140         connection = NULL;
1141         printf("Client deregistration success\n");
1142
1143         return 1;
1144 }
1145
1146 int test_register_client_cs(void)
1147 {
1148         int tid = 0;
1149         test_get_user_int("Input a TID in C# API :", &tid);
1150
1151         int err = connection_create_cs(tid, &connection);
1152
1153         if (CONNECTION_ERROR_NONE == err) {
1154                 connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
1155                 connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
1156                 connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
1157                 connection_set_ethernet_cable_state_changed_cb(connection,
1158                                         test_get_ethernet_cable_state_callback, NULL);
1159         } else {
1160                 printf("Client registration failed [%s]\n", test_print_error(err));
1161                 return -1;
1162         }
1163
1164         printf("Client registration success\n");
1165         return 1;
1166 }
1167
1168 int  test_deregister_client_cs(void)
1169 {
1170         int rv = 0;
1171         GSList *list;
1172         connection_profile_h profile;
1173         int tid = 0;
1174
1175         test_get_user_int("Input a TID in C# API :", &tid);
1176
1177         if (connection != NULL)
1178                 rv = connection_destroy_cs(tid, connection);
1179         else {
1180                 printf("Cannot deregister : Handle is NULL\n");
1181                 rv = CONNECTION_ERROR_INVALID_OPERATION;
1182         }
1183
1184         if (rv != CONNECTION_ERROR_NONE) {
1185                 printf("Client deregistration fail [%s]\n", test_print_error(rv));
1186                 return -1;
1187         }
1188
1189         if (state_cb_list) {
1190                 for (list = state_cb_list; list; list = list->next) {
1191                         profile = list->data;
1192                         connection_profile_destroy(profile);
1193                 }
1194
1195                 g_slist_free(state_cb_list);
1196                 state_cb_list = NULL;
1197         }
1198
1199         connection = NULL;
1200         printf("Client deregistration success\n");
1201
1202         return 1;
1203 }
1204
1205 int test_get_network_state(void)
1206 {
1207         int rv = 0;
1208         connection_type_e net_state;
1209
1210         rv = connection_get_type(connection, &net_state);
1211
1212         if (rv != CONNECTION_ERROR_NONE) {
1213                 printf("Fail to get network state [%s]\n", test_print_error(rv));
1214                 return -1;
1215         }
1216
1217         printf("Retval = [%s] network connection state [%s]\n",
1218                 test_print_error(rv), test_print_connection_type(net_state));
1219
1220         return 1;
1221 }
1222
1223 int test_get_cellular_state(void)
1224 {
1225         int rv = 0;
1226         connection_cellular_state_e cellular_state;
1227
1228         rv = connection_get_cellular_state(connection, &cellular_state);
1229
1230         if (rv != CONNECTION_ERROR_NONE) {
1231                 printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
1232                 return -1;
1233         }
1234
1235         printf("Retval = [%s] Cellular state [%s]\n",
1236                 test_print_error(rv), test_print_cellular_state(cellular_state));
1237
1238         return 1;
1239 }
1240
1241 int test_get_wifi_state(void)
1242 {
1243         int rv = 0;
1244         connection_wifi_state_e wifi_state;
1245
1246         rv = connection_get_wifi_state(connection, &wifi_state);
1247
1248         if (rv != CONNECTION_ERROR_NONE) {
1249                 printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
1250                 return -1;
1251         }
1252
1253         printf("Retval = [%s] WiFi state [%s]\n",
1254                 test_print_error(rv), test_print_wifi_state(wifi_state));
1255
1256         return 1;
1257 }
1258
1259 int test_get_current_proxy(void)
1260 {
1261         char *proxy_addr = NULL;
1262
1263         connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr);
1264
1265         if (proxy_addr == NULL) {
1266                 printf("Proxy address does not exist\n");
1267                 return -1;
1268         }
1269
1270         printf("Current Proxy [%s]\n", proxy_addr);
1271         g_free(proxy_addr);
1272
1273         return 1;
1274 }
1275
1276 int test_get_current_ip(void)
1277 {
1278         char *ip_addr = NULL;
1279         int input;
1280         bool rv;
1281
1282         rv = test_get_user_int("Input Address type to get"
1283                 "(1:IPV4, 2:IPV6):", &input);
1284
1285         if (rv == false) {
1286                 printf("Invalid input!!\n");
1287                 return -1;
1288         }
1289
1290         switch (input) {
1291         case 1:
1292                 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
1293                 if (ip_addr == NULL) {
1294                         printf("IPv4 address does not exist\n");
1295                         return -1;
1296                 }
1297                 printf("IPv4 address : %s\n", ip_addr);
1298                 break;
1299
1300         case 2:
1301                 connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
1302                 if (ip_addr == NULL) {
1303                         printf("IPv6 address does not exist\n");
1304                         return -1;
1305                 }
1306                 printf("IPv6 address : %s\n", ip_addr);
1307                 break;
1308         default:
1309                 printf("Wrong IP address family!!\n");
1310                 return -1;
1311         }
1312
1313         g_free(ip_addr);
1314         return 1;
1315 }
1316
1317 int test_get_call_statistics_info(void)
1318 {
1319         long long rv = 0;
1320
1321         connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1322         printf("last recv data size [%lld]\n", rv);
1323         connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1324         printf("last sent data size [%lld]\n", rv);
1325         connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1326         printf("total received data size [%lld]\n", rv);
1327         connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1328         printf("total sent data size [%lld]\n", rv);
1329
1330         return 1;
1331 }
1332
1333 int test_get_wifi_call_statistics_info(void)
1334 {
1335         long long rv = 0;
1336
1337         connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
1338         printf("WiFi last recv data size [%lld]\n", rv);
1339         connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
1340         printf("WiFi last sent data size [%lld]\n", rv);
1341         connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
1342         printf("WiFi total received data size [%lld]\n", rv);
1343         connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
1344         printf("WiFi total sent data size [%lld]\n", rv);
1345
1346         return 1;
1347 }
1348
1349 int test_get_profile_list(void)
1350 {
1351         if (test_get_user_selected_profile(NULL, false) == false)
1352                 return -1;
1353
1354         return 1;
1355 }
1356
1357 int test_get_default_profile_list(void)
1358 {
1359         int rv = 0;
1360         char *profile_name = NULL;
1361         connection_profile_iterator_h profile_iter;
1362         connection_profile_h profile_h;
1363         connection_cellular_service_type_e service_type;
1364         bool is_default = false;
1365
1366         rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
1367         if (rv != CONNECTION_ERROR_NONE) {
1368                 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1369                 return -1;
1370         }
1371
1372         while (connection_profile_iterator_has_next(profile_iter)) {
1373                 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1374                         printf("Fail to get profile handle\n");
1375                         return -1;
1376                 }
1377
1378                 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1379                         printf("Fail to get profile name\n");
1380                         return -1;
1381                 }
1382                 printf("profile name : %s\n", profile_name);
1383                 g_free(profile_name);
1384
1385                 if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
1386                         printf("Fail to get profile service type\n");
1387                         return -1;
1388                 }
1389                 printf("service type : %d\n", service_type);
1390
1391                 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1392                         printf("Fail to get profile subscriber id\n");
1393                         return -1;
1394                 }
1395                 printf("Default : %d\n", is_default);
1396         }
1397
1398         return 1;
1399 }
1400
1401 int test_get_connected_profile_list(void)
1402 {
1403         int rv = 0;
1404         char *profile_name = NULL;
1405         connection_profile_iterator_h profile_iter;
1406         connection_profile_h profile_h;
1407         bool is_default = false;
1408         connection_profile_type_e type;
1409
1410         rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
1411         if (rv != CONNECTION_ERROR_NONE) {
1412                 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1413                 return -1;
1414         }
1415
1416         while (connection_profile_iterator_has_next(profile_iter)) {
1417                 if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) {
1418                         printf("Fail to get profile handle\n");
1419                         return -1;
1420                 }
1421
1422                 if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1423                         printf("Fail to get profile name\n");
1424                         return -1;
1425                 }
1426                 printf("profile name is %s\n", profile_name);
1427                 g_free(profile_name);
1428
1429                 if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
1430                         printf("Fail to get profile type\n");
1431                         return -1;
1432                 }
1433                 printf("profile type is %d\n", type);
1434
1435                 if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
1436                 if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
1437                         printf("Fail to get profile is default\n");
1438                         return -1;
1439                 }
1440                         printf("[%s]\n", is_default ? "default" : "not default");
1441                 }
1442         }
1443
1444         return 1;
1445 }
1446
1447 int test_get_current_profile(void)
1448 {
1449         int rv = 0;
1450         char *profile_name = NULL;
1451         connection_profile_h profile_h;
1452
1453         rv = connection_get_current_profile(connection, &profile_h);
1454         if (rv != CONNECTION_ERROR_NONE) {
1455                 printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
1456                 return -1;
1457         }
1458
1459         if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) {
1460                 printf("Fail to get profile name\n");
1461                 return -1;
1462         }
1463         printf("profile name : %s\n", profile_name);
1464         g_free(profile_name);
1465
1466         connection_profile_destroy(profile_h);
1467
1468         return 1;
1469 }
1470
1471 int test_open_profile(void)
1472 {
1473         connection_profile_h profile;
1474
1475         printf("\n** Choose a profile to open. **\n");
1476
1477         if (test_get_user_selected_profile(&profile, true) == false)
1478                 return -1;
1479
1480         if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
1481                 printf("Connection open Failed!!\n");
1482                 return -1;
1483         }
1484
1485         return 1;
1486 }
1487
1488 int test_get_default_cellular_service_type(void)
1489 {
1490         int input;
1491         int rv;
1492         int service_type;
1493         connection_profile_h profile;
1494         char *profile_name = NULL;
1495
1496         rv = test_get_user_int("Input profile type to get"
1497                         "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input);
1498
1499         if (rv == false) {
1500                 printf("Invalid input!!\n");
1501                 return -1;
1502         }
1503
1504         switch (input) {
1505         case 1:
1506                 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
1507                 break;
1508         case 2:
1509                 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
1510                 break;
1511         case 3:
1512                 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
1513                 break;
1514         case 4:
1515                 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
1516                 break;
1517         case 5:
1518                 service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
1519                 break;
1520         case 6:
1521                 service_type =  CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
1522                 break;
1523         default:
1524                 printf("Wrong number!!\n");
1525                 return -1;
1526         }
1527
1528         if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
1529                 return -1;
1530
1531         if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1532                 printf("Fail to get profile name\n");
1533                 connection_profile_destroy(profile);
1534                 return -1;
1535         }
1536         printf("Default profile name : %s\n", profile_name);
1537         g_free(profile_name);
1538
1539         connection_profile_destroy(profile);
1540
1541         return 1;
1542 }
1543
1544 int test_set_default_cellular_service_type(void)
1545 {
1546         connection_profile_h profile;
1547         connection_cellular_service_type_e type;
1548         int input, rv;
1549
1550         rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
1551
1552         if (rv == false || (input != 1 && input != 2)) {
1553                 printf("Invalid input!!\n");
1554                 return -1;
1555         }
1556
1557         printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
1558
1559         if (test_get_user_selected_profile(&profile, true) == false)
1560                 return -1;
1561
1562         if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
1563                 printf("Fail to get cellular service type\n");
1564                 return -1;
1565         }
1566
1567         if (input == 1) {
1568                 if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
1569                         return -1;
1570         } else {
1571                 if (connection_set_default_cellular_service_profile_async(connection,
1572                                 type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
1573                         return -1;
1574         }
1575
1576         return 1;
1577 }
1578
1579 int test_close_profile(void)
1580 {
1581         connection_profile_h profile;
1582
1583         printf("\n** Choose a profile to close. **\n");
1584
1585         if (test_get_user_selected_profile(&profile, true) == false)
1586                 return -1;
1587
1588         if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
1589                 printf("Connection close Failed!!\n");
1590                 return -1;
1591         }
1592
1593         return 1;
1594 }
1595
1596 int test_add_profile(void)
1597 {
1598         int rv = 0;
1599         connection_profile_h profile;
1600         char input_str[100] = {0,};
1601
1602         if (test_get_user_string("Input keyword - (Enter for skip) :", input_str, 100) == false)
1603                 return -1;
1604
1605         g_strstrip(input_str);
1606         rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
1607         if (rv != CONNECTION_ERROR_NONE)
1608                 RETURN_FAIL_DESTROY(profile);
1609
1610         if (test_update_cellular_info(profile) == -1)
1611                 RETURN_FAIL_DESTROY(profile);
1612
1613         rv = connection_add_profile(connection, profile);
1614         if (rv != CONNECTION_ERROR_NONE)
1615                 RETURN_FAIL_DESTROY(profile);
1616
1617         connection_profile_destroy(profile);
1618         return 1;
1619 }
1620
1621 int test_remove_profile(void)
1622 {
1623         connection_profile_h profile;
1624
1625         printf("\n** Choose a profile to remove. **\n");
1626         if (test_get_user_selected_profile(&profile, true) == false)
1627                 return -1;
1628
1629         if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
1630                 printf("Remove profile Failed!!\n");
1631                 return -1;
1632         }
1633
1634         return 1;
1635 }
1636
1637 int test_update_profile(void)
1638 {
1639         int rv = 0;
1640
1641         connection_profile_type_e prof_type;
1642         connection_profile_h profile;
1643
1644         printf("\n** Choose a profile to update. **\n");
1645         if (test_get_user_selected_profile(&profile, true) == false)
1646                 return -1;
1647
1648         if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1649                 return -1;
1650
1651         switch (prof_type) {
1652         case CONNECTION_PROFILE_TYPE_CELLULAR:
1653                 if (test_update_cellular_info(profile) == -1)
1654                         return -1;
1655
1656                 break;
1657         case CONNECTION_PROFILE_TYPE_WIFI:
1658                 if (test_update_wifi_info(profile) == -1)
1659                         return -1;
1660
1661                 if (test_update_network_info(profile) == -1)
1662                         return -1;
1663
1664                 break;
1665         case CONNECTION_PROFILE_TYPE_ETHERNET:
1666                 if (test_update_network_info(profile) == -1)
1667                         return -1;
1668
1669                 break;
1670         case CONNECTION_PROFILE_TYPE_BT:
1671                 printf("Not supported!\n");
1672                 /* fall through */
1673         default:
1674                 {
1675                         int profile_type = prof_type;
1676                         if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1677                                 if (test_update_wifi_info(profile) == -1)
1678                                         return -1;
1679                                 break;
1680                         }
1681                 }
1682                 return -1;
1683         }
1684
1685         rv = connection_update_profile(connection, profile);
1686         if (rv != CONNECTION_ERROR_NONE)
1687                 return -1;
1688
1689         return 1;
1690 }
1691
1692 int test_get_profile_info(void)
1693 {
1694         connection_profile_type_e prof_type;
1695         connection_profile_state_e profile_state;
1696         connection_profile_state_e profile_ipv6_state;
1697         connection_internet_state_e internet_state;
1698         connection_profile_h profile;
1699         char *profile_name = NULL;
1700         int address_family = 0;
1701
1702         printf("\n** Choose a profile to print. **\n");
1703         if (test_get_user_selected_profile(&profile, true) == false)
1704                 return -1;
1705
1706         if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1707                 printf("Fail to get profile name\n");
1708                 return -1;
1709         } else {
1710                 printf("Profile Name : %s\n", profile_name);
1711                 g_free(profile_name);
1712         }
1713
1714         if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1715                 printf("Fail to get profile IPv4 state\n");
1716                 return -1;
1717         } else
1718                 printf("Profile State : %s\n", test_print_state(profile_state));
1719
1720         if (connection_profile_get_ipv6_state(profile, &profile_ipv6_state) != CONNECTION_ERROR_NONE) {
1721                 printf("Fail to get profile IPv6 state\n");
1722                 return -1;
1723         } else
1724                 printf("Profile IPv6 State : %s\n", test_print_state(profile_ipv6_state));
1725
1726         if (connection_profile_get_internet_state(profile, &internet_state) != CONNECTION_ERROR_NONE) {
1727                 printf("Fail to get Internet state\n");
1728                 return -1;
1729         } else
1730                 printf("Internet State : %s\n", test_print_internet_state(internet_state));
1731
1732         if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1733                 return -1;
1734
1735         test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1736
1737         switch (prof_type) {
1738         case CONNECTION_PROFILE_TYPE_CELLULAR:
1739                 printf("Profile Type : Cellular\n");
1740                 test_print_cellular_info(profile);
1741                 break;
1742         case CONNECTION_PROFILE_TYPE_WIFI:
1743                 printf("Profile Type : Wi-Fi\n");
1744                 test_print_wifi_info(profile);
1745                 break;
1746         case CONNECTION_PROFILE_TYPE_ETHERNET:
1747                 printf("Profile Type : Ethernet\n");
1748                 break;
1749         case CONNECTION_PROFILE_TYPE_BT:
1750                 printf("Profile Type : bluetooth\n");
1751                 break;
1752         default:
1753                 {
1754                         int profile_type = prof_type;
1755                         if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1756                                 printf("Profile Type : Mesh\n");
1757                                 test_print_mesh_info(profile);
1758                                 break;
1759                         }
1760                 }
1761                 return -1;
1762         }
1763
1764         test_print_network_info(profile, address_family);
1765
1766         return 1;
1767 }
1768
1769 int test_refresh_profile_info(void)
1770 {
1771         connection_profile_type_e prof_type;
1772         connection_profile_state_e profile_state;
1773         connection_profile_h profile;
1774         char *profile_name = NULL;
1775         int address_family = 0;
1776
1777         printf("\n** Choose a profile to refresh. **\n");
1778         if (test_get_user_selected_profile(&profile, true) == false)
1779                 return -1;
1780
1781         if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
1782                 return -1;
1783
1784         if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1785                 printf("Fail to get profile name\n");
1786                 return -1;
1787         } else {
1788                 printf("Profile Name : %s\n", profile_name);
1789                 g_free(profile_name);
1790         }
1791
1792         if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
1793                 printf("Fail to get profile state\n");
1794                 return -1;
1795         } else
1796                 printf("Profile State : %s\n", test_print_state(profile_state));
1797
1798
1799         if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
1800                 return -1;
1801
1802         test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
1803
1804         switch (prof_type) {
1805         case CONNECTION_PROFILE_TYPE_CELLULAR:
1806                 printf("Profile Type : Cellular\n");
1807                 test_print_cellular_info(profile);
1808                 break;
1809         case CONNECTION_PROFILE_TYPE_WIFI:
1810                 printf("Profile Type : Wi-Fi\n");
1811                 test_print_wifi_info(profile);
1812                 break;
1813         case CONNECTION_PROFILE_TYPE_ETHERNET:
1814                 printf("Profile Type : Ethernet\n");
1815                 break;
1816         case CONNECTION_PROFILE_TYPE_BT:
1817                 printf("Profile Type : bluetooth\n");
1818                 break;
1819         default:
1820                 {
1821                         int profile_type = prof_type;
1822                         if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
1823                                 printf("Profile Type : Mesh\n");
1824                                 test_print_mesh_info(profile);
1825                                 break;
1826                         }
1827                 }
1828                 return -1;
1829         }
1830
1831         test_print_network_info(profile, address_family);
1832
1833         return 1;
1834 }
1835
1836 int test_set_state_changed_callback()
1837 {
1838         connection_profile_h profile;
1839         connection_profile_h profile_clone;
1840
1841         printf("\n** Choose a profile to set callback. **\n");
1842         if (test_get_user_selected_profile(&profile, true) == false)
1843                 return -1;
1844
1845         if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
1846                 return -1;
1847
1848         if (connection_profile_set_state_changed_cb(profile,
1849                         test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
1850                 connection_profile_destroy(profile_clone);
1851                 return -1;
1852         }
1853
1854         state_cb_list = g_slist_append(state_cb_list, profile_clone);
1855
1856         return 1;
1857 }
1858
1859 int test_unset_state_changed_callback()
1860 {
1861         connection_profile_h profile;
1862         GSList *list;
1863         char *profile_name = NULL;
1864         int count = 0;
1865         int input = 0;
1866
1867         printf("\n** Choose a profile to unset callback. **\n");
1868         for (list = state_cb_list; list; list = list->next) {
1869                 profile = list->data;
1870                 if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
1871                         printf("Fail to get profile name!\n");
1872                         return -1;
1873                 } else {
1874                         printf("%d. %s\n", count, profile_name);
1875                         g_free(profile_name);
1876                 }
1877
1878                 count++;
1879         }
1880
1881         if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
1882             input >= count ||
1883             input < 0) {
1884                 printf("Wrong number!!\n");
1885                 return -1;
1886         }
1887
1888         count = 0;
1889         for (list = state_cb_list; list; list = list->next) {
1890                 if (count == input) {
1891                         profile = list->data;
1892                         goto unset;
1893                 }
1894
1895                 count++;
1896         }
1897
1898         return -1;
1899
1900 unset:
1901         if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
1902                 return -1;
1903
1904         state_cb_list = g_slist_remove(state_cb_list, profile);
1905         connection_profile_destroy(profile);
1906
1907         return 1;
1908 }
1909
1910 int test_reset_call_statistics_info(void)
1911 {
1912         int ret = CONNECTION_ERROR_NONE;
1913
1914         ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1915         printf("reset last recv data size [%d]\n", ret);
1916         ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1917         printf("last sent data size [%d]\n", ret);
1918         ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1919         printf("total received data size [%d]\n", ret);
1920         ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1921         printf("total sent data size [%d]\n", ret);
1922
1923         return 1;
1924 }
1925
1926 int test_reset_wifi_call_statistics_info(void)
1927 {
1928         int ret = CONNECTION_ERROR_NONE;
1929
1930         ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
1931         printf("WiFi last sent data size [%d]\n", ret);
1932         ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
1933         printf("WiFi last recv data size [%d]\n", ret);
1934         ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
1935         printf("WiFi total sent data size [%d]\n", ret);
1936         ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
1937         printf("WiFi total received data size [%d]\n", ret);
1938
1939         return 1;
1940 }
1941
1942 int test_add_route(void)
1943 {
1944         int rv = 0;
1945         char ip_addr[100] = {0};
1946         char if_name[40] = {0};
1947
1948         if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1949                 return -1;
1950
1951         if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1952                 return -1;
1953
1954         g_strstrip(ip_addr);
1955         g_strstrip(if_name);
1956         rv = connection_add_route(connection, if_name, ip_addr);
1957         if (rv != CONNECTION_ERROR_NONE) {
1958                 printf("Fail to get add new route [%d]\n", rv);
1959                 return -1;
1960         }
1961         printf("Add Route successfully\n");
1962
1963         return 1;
1964 }
1965
1966 int test_remove_route(void)
1967 {
1968         int rv = 0;
1969         char ip_addr[100] = {0};
1970         char if_name[40] = {0};
1971
1972         if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
1973                 return -1;
1974
1975         if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
1976                 return -1;
1977
1978         g_strstrip(ip_addr);
1979         g_strstrip(if_name);
1980         rv = connection_remove_route(connection, if_name, ip_addr);
1981         if (rv != CONNECTION_ERROR_NONE) {
1982                 printf("Fail to remove the route [%s]\n", test_print_error(rv));
1983                 return -1;
1984         }
1985         printf("Remove Route successfully\n");
1986
1987         return 1;
1988 }
1989
1990 int test_add_route_ipv6(void)
1991 {
1992         int rv = 0;
1993         char ip_addr[100] = {0};
1994         char gateway[100] = {0};
1995         char if_name[40] = {0};
1996
1997         if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
1998                 return -1;
1999
2000         if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2001                 return -1;
2002
2003         if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2004                 return -1;
2005
2006         g_strstrip(ip_addr);
2007         g_strstrip(gateway);
2008         g_strstrip(if_name);
2009         rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
2010         if (rv != CONNECTION_ERROR_NONE) {
2011                 printf("Fail to get add new route [%d]\n", rv);
2012                 return -1;
2013         }
2014         printf("Add Route successfully\n");
2015
2016         return 1;
2017 }
2018
2019 int test_remove_route_ipv6(void)
2020 {
2021         int rv = 0;
2022         char ip_addr[100] = {0};
2023         char gateway[100] = {0};
2024         char if_name[40] = {0};
2025
2026         if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
2027                 return -1;
2028
2029         if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2030                 return -1;
2031
2032         if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2033                 return -1;
2034
2035         g_strstrip(ip_addr);
2036         g_strstrip(gateway);
2037         g_strstrip(if_name);
2038         rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
2039         if (rv != CONNECTION_ERROR_NONE) {
2040                 printf("Fail to remove the route [%d]\n", rv);
2041                 return -1;
2042         }
2043         printf("Remove Route successfully\n");
2044
2045         return 1;
2046 }
2047
2048 int test_add_route_entry(void)
2049 {
2050         char ip_addr[100] = {0};
2051         char gateway[100] = {0};
2052         char if_name[40] = {0};
2053         int input;
2054         bool input_rv;
2055         int rv = 0;
2056
2057         input_rv = test_get_user_int("Input Address type to get"
2058                 "(1:IPV4, 2:IPV6):", &input);
2059
2060         if (input_rv == false) {
2061                 printf("Invalid input!!\n");
2062                 return -1;
2063         }
2064
2065         switch (input) {
2066         case 1:
2067                 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2068                         return -1;
2069
2070                 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2071                         return -1;
2072
2073                 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2074                         return -1;
2075
2076                 g_strstrip(ip_addr);
2077                 g_strstrip(gateway);
2078                 g_strstrip(if_name);
2079                 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
2080                 if (rv != CONNECTION_ERROR_NONE) {
2081                         printf("Fail to get add new route [%d]\n", rv);
2082                         return -1;
2083                 }
2084                 printf("Add Route successfully\n");
2085                 break;
2086
2087         case 2:
2088                 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2089                         return -1;
2090
2091                 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2092                         return -1;
2093
2094                 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2095                         return -1;
2096
2097                 g_strstrip(ip_addr);
2098                 g_strstrip(gateway);
2099                 g_strstrip(if_name);
2100                 rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
2101                 if (rv != CONNECTION_ERROR_NONE) {
2102                         printf("Fail to get add new route [%d]\n", rv);
2103                         return -1;
2104                 }
2105                 printf("Add Route successfully\n");
2106                 break;
2107
2108         default:
2109                 printf("Wrong IP address family!!\n");
2110                 return -1;
2111
2112         }
2113
2114         return 1;
2115
2116 }
2117
2118 int test_remove_route_entry(void)
2119 {
2120         char ip_addr[100] = {0};
2121         char gateway[100] = {0};
2122         char if_name[40] = {0};
2123         int input;
2124         bool input_rv;
2125         int rv = 0;
2126
2127         input_rv = test_get_user_int("Input Address type to get"
2128                 "(1:IPV4, 2:IPV6):", &input);
2129
2130         if (input_rv == false) {
2131                 printf("Invalid input!!\n");
2132                 return -1;
2133         }
2134
2135         switch (input) {
2136         case 1:
2137                 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2138                         return -1;
2139
2140                 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2141                         return -1;
2142
2143                 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2144                         return -1;
2145
2146                 g_strstrip(ip_addr);
2147                 g_strstrip(gateway);
2148                 g_strstrip(if_name);
2149                 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
2150                 if (rv != CONNECTION_ERROR_NONE) {
2151                         printf("Fail to remove the route [%s]\n", test_print_error(rv));
2152                         return -1;
2153                 }
2154                 printf("Remove Route successfully\n");
2155
2156                 break;
2157
2158         case 2:
2159                 if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
2160                         return -1;
2161
2162                 if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
2163                         return -1;
2164
2165                 if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
2166                         return -1;
2167
2168                 g_strstrip(ip_addr);
2169                 g_strstrip(gateway);
2170                 g_strstrip(if_name);
2171                 rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
2172                 if (rv != CONNECTION_ERROR_NONE) {
2173                         printf("Fail to remove the route [%d]\n", rv);
2174                         return -1;
2175                 }
2176                 printf("Remove Route successfully\n");
2177                 break;
2178
2179         default:
2180                 printf("Wrong IP address family!!\n");
2181                 return -1;
2182
2183         }
2184
2185         return 1;
2186
2187 }
2188
2189 int test_get_bt_state(void)
2190 {
2191         int rv = 0;
2192         connection_bt_state_e bt_state;
2193
2194         rv = connection_get_bt_state(connection, &bt_state);
2195
2196         if (rv != CONNECTION_ERROR_NONE) {
2197                 printf("Fail to get bluetooth state [%s]\n", test_print_error(rv));
2198                 return -1;
2199         }
2200
2201         printf("Retval = [%s], bluetooth state [%d]\n", test_print_error(rv), bt_state);
2202
2203         return 1;
2204 }
2205
2206 int test_get_profile_id(void)
2207 {
2208         connection_profile_h profile;
2209         char *profile_id;
2210
2211         printf("\n** Choose a profile to see profile id. **\n");
2212         if (test_get_user_selected_profile(&profile, true) == false)
2213                 return -1;
2214
2215         if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
2216                 printf("Fail to get profile name\n");
2217                 return -1;
2218         } else {
2219                 printf("Profile id : %s\n", profile_id);
2220                 g_free(profile_id);
2221         }
2222
2223         return 1;
2224 }
2225
2226 int test_get_mac_address(void)
2227 {
2228         int rv = 0, type = 0;
2229         connection_type_e conn_type;
2230         char *mac_addr = NULL;
2231
2232         test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
2233
2234         switch (type) {
2235         case 1:
2236                 conn_type = CONNECTION_TYPE_WIFI;
2237                 break;
2238         case 2:
2239                 conn_type = CONNECTION_TYPE_ETHERNET;
2240                 break;
2241         default:
2242                 printf("Wrong number!!\n");
2243                 return -1;
2244         }
2245
2246         rv = connection_get_mac_address(connection, conn_type, &mac_addr);
2247
2248         if (rv != CONNECTION_ERROR_NONE) {
2249                 printf("Fail to get MAC address [%s]\n", test_print_error(rv));
2250                 return -1;
2251         }
2252
2253         printf("mac address is %s\n", mac_addr);
2254
2255         g_free(mac_addr);
2256
2257         return 1;
2258 }
2259
2260 int test_get_ethernet_cable_state(void)
2261 {
2262         int rv = 0;
2263         connection_ethernet_cable_state_e cable_state;
2264
2265         rv = connection_get_ethernet_cable_state(connection, &cable_state);
2266
2267         if (rv != CONNECTION_ERROR_NONE) {
2268                 printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
2269                 return -1;
2270         }
2271
2272         printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
2273
2274         return 1;
2275 }
2276
2277 int test_reset_profile(void)
2278 {
2279         int type, sim_id, rv;
2280
2281         rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
2282
2283         if (rv == false || (type != 0 && type != 1)) {
2284                 printf("Invalid input!!\n");
2285                 return -1;
2286         }
2287
2288         rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
2289
2290         if (rv == false || (sim_id != 0 && sim_id != 1)) {
2291                 printf("Invalid input!!\n");
2292                 return -1;
2293         }
2294
2295         if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE)
2296                 return -1;
2297
2298         return 1;
2299 }
2300
2301 static bool test_get_ipv6_address_callback(char *ipv6_address, void* user_data)
2302 {
2303         printf("IPv6 Address : %s\n", ipv6_address);
2304         return true;
2305 }
2306
2307 int test_foreach_ipv6_address(void)
2308 {
2309         int rv = 0;
2310         int type;
2311         connection_type_e conn_type;
2312
2313         test_get_user_int("Input Connection Type(1: WiFi 2: Ethernet) :", &type);
2314
2315         switch (type) {
2316         case 1:
2317                 conn_type = CONNECTION_TYPE_WIFI;
2318                 break;
2319         case 2:
2320                 conn_type = CONNECTION_TYPE_ETHERNET;
2321                 break;
2322         default:
2323                 printf("Wrong number!!\n");
2324                 return -1;
2325         }
2326
2327         rv = connection_foreach_ipv6_address(connection, conn_type, test_get_ipv6_address_callback, NULL);
2328         if (rv != CONNECTION_ERROR_NONE) {
2329                 printf("Fail to get IPv6 address\n");
2330                 return -1;
2331         }
2332
2333         return 1;
2334 }
2335
2336 int test_is_metered_network(void)
2337 {
2338         int rv = 0;
2339         bool metered_state;
2340
2341         rv = connection_is_metered_network(connection, &metered_state);
2342
2343         if (rv != CONNECTION_ERROR_NONE) {
2344                 printf("Fail to get metered state [%s]\n", test_print_error(rv));
2345                 return -1;
2346         }
2347
2348         printf("Retval = [%s] metered state [%s]\n",
2349                 test_print_error(rv), metered_state ? "TRUE" : "FALSE");
2350
2351         return 1;
2352 }
2353
2354 int test_start_tcpdump(void)
2355 {
2356         if (connection_profile_start_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2357                 return -1;
2358         }
2359
2360         printf("Successfully started tcpdump\n");
2361
2362         return 1;
2363 }
2364
2365 int test_stop_tcpdump(void)
2366 {
2367         if (connection_profile_stop_tcpdump(connection) != CONNECTION_ERROR_NONE) {
2368                 return -1;
2369         }
2370
2371         printf("Successfully stopped tcpdump\n");
2372
2373         return 1;
2374 }
2375
2376 int test_get_tcpdump_state(void)
2377 {
2378         gboolean tcpdump_state = FALSE;
2379
2380         if (connection_profile_get_tcpdump_state(connection, &tcpdump_state) != CONNECTION_ERROR_NONE) {
2381                 return -1;
2382         }
2383
2384         printf("tcpdump %s running\n", tcpdump_state ? "is" : "is not");
2385
2386         return 1;
2387 }
2388
2389 int test_mptcp_enable(void)
2390 {
2391         int rv = 0;
2392         bool supported = false;
2393         rv = connection_mptcp_is_supported(connection, &supported);
2394         if (rv != CONNECTION_ERROR_NONE) {
2395                 printf("Failure[%s]\n", test_print_error(rv));
2396                 return -1;
2397         }
2398         printf("MPTCP Support: %d\n", supported);
2399
2400         rv = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL);
2401         if (rv != CONNECTION_ERROR_NONE) {
2402                 printf("Failure[%s]\n", test_print_error(rv));
2403                 return -1;
2404         }
2405         return 1;
2406 }
2407
2408 int test_mptcp_disable(void)
2409 {
2410         int rv = 0;
2411         rv = connection_mptcp_disable(connection);
2412
2413         if (rv != CONNECTION_ERROR_NONE) {
2414                 printf("Failure[%s]\n", test_print_error(rv));
2415                 return -1;
2416         }
2417         return 1;
2418 }
2419
2420 int test_mptcp_set_path_manager(void)
2421 {
2422         int rv = 0;
2423         int input = 0;
2424         rv = test_get_user_int("Input Path Manager (1: default, 2: fullmesh)", &input);
2425
2426         switch (input) {
2427         case 1:
2428                 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT);
2429                 break;
2430         case 2:
2431                 rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_FULLMESH);
2432                 break;
2433         default:
2434                 printf("Invalid input!!\n");
2435                 return -1;
2436         }
2437
2438         if (rv != CONNECTION_ERROR_NONE) {
2439                 printf("Failure[%s]\n", test_print_error(rv));
2440                 return -1;
2441         }
2442
2443         return 1;
2444 }
2445
2446 int test_mptcp_get_path_manager(void)
2447 {
2448         int rv = 0;
2449         connection_mptcp_path_manager_e pm;
2450
2451         rv = connection_mptcp_get_path_manager(connection, &pm);
2452         if (rv != CONNECTION_ERROR_NONE) {
2453                 printf("Failure[%s]\n", test_print_error(rv));
2454                 return -1;
2455         }
2456
2457         switch (pm) {
2458         case CONNECTION_MPTCP_PM_DEFAULT:
2459                 printf("Path Manager: Default\n");
2460                 break;
2461         case CONNECTION_MPTCP_PM_FULLMESH:
2462                 printf("Path Manager: FullMesh\n");
2463                 break;
2464         default:
2465                 printf("Error: Invalid Path Manager\n");
2466                 return -1;
2467         }
2468
2469         return 1;
2470 }
2471
2472 int test_mptcp_set_scheduler(void)
2473 {
2474         int rv = 0;
2475         int input = 0;
2476         rv = test_get_user_int("Input Scheduler (1: default, 2: roundrobin)", &input);
2477
2478         switch (input) {
2479         case 1:
2480                 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT);
2481                 break;
2482         case 2:
2483                 rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
2484                 break;
2485         default:
2486                 printf("Invalid input!!\n");
2487                 return -1;
2488         }
2489
2490         if (rv != CONNECTION_ERROR_NONE) {
2491                 printf("Failure[%s]\n", test_print_error(rv));
2492                 return -1;
2493         }
2494
2495         return 1;
2496 }
2497
2498 int test_mptcp_get_scheduler(void)
2499 {
2500         int rv = 0;
2501         connection_mptcp_scheduler_e scheduler;
2502
2503         rv = connection_mptcp_get_scheduler(connection, &scheduler);
2504         if (rv != CONNECTION_ERROR_NONE) {
2505                 printf("Failure[%s]\n", test_print_error(rv));
2506                 return -1;
2507         }
2508
2509         switch (scheduler) {
2510         case CONNECTION_MPTCP_SCHEDULER_DEFAULT:
2511                 printf("Scheduler: Default\n");
2512                 break;
2513         case CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN:
2514                 printf("Scheduler: RountRobin\n");
2515                 break;
2516         default:
2517                 printf("Error: Invalid Scheduler\n");
2518                 return -1;
2519         }
2520
2521         return 1;
2522 }
2523
2524 int test_ethernet_eap_connect(void)
2525 {
2526         int rv;
2527         int input;
2528         bool enabled = false;
2529         int type = 0;
2530         int auth_type = 0;
2531         char input_str1[130];
2532         char input_str2[130];
2533         connection_profile_h profile;
2534
2535         printf("\n** Choose a ethernet profile to connect. **\n");
2536
2537         if (test_get_user_selected_profile(&profile, true) == false)
2538                 return -1;
2539
2540         test_get_user_int("Input options (0:Use LAN 1:Use EAPoL) :", &input);
2541         if (input == 1) {
2542                 if (connection_profile_enable_ethernet_eap(profile, true) != CONNECTION_ERROR_NONE) {
2543                         printf("Failed to enable EAP over Ethernet\n");
2544                         return -1;
2545                 }
2546         } else {
2547                 printf("Disabling EAPoL. Use proper option for normal Lan connection.\n");
2548                 if (connection_profile_enable_ethernet_eap(profile, false) != CONNECTION_ERROR_NONE)
2549                         printf("Failed to disable EAP over Ethernet\n");
2550                 return -1;
2551         }
2552
2553         if (connection_profile_is_ethernet_eap_enabled(profile, &enabled) != CONNECTION_ERROR_NONE) {
2554                 printf("Failed to get ethernet eap enabled status!!\n");
2555                 return -1;
2556         }
2557
2558         printf("EAP over Ethernet is %s\n", enabled ? "enabled" : "not enabled");
2559
2560         printf("Input EAP type:\n");
2561         printf("0 -> CONNECTION_ETHERNET_EAP_TYPE_MD5\n");
2562         printf("1 -> CONNECTION_ETHERNET_EAP_TYPE_PEAP\n");
2563         printf("2 -> CONNECTION_ETHERNET_EAP_TYPE_TLS\n");
2564         printf("3 -> CONNECTION_ETHERNET_EAP_TYPE_TTLS\n");
2565         printf("4 -> CONNECTION_ETHERNET_EAP_TYPE_FAST\n");
2566         rv = scanf("%d", &type);
2567
2568         switch (type) {
2569         case CONNECTION_ETHERNET_EAP_TYPE_MD5:
2570                 rv = connection_profile_set_ethernet_eap_type(profile, type);
2571                 if (rv != CONNECTION_ERROR_NONE) {
2572                         printf("Fail to set eap type : %s\n", test_print_error(rv));
2573                         return -1;
2574                 }
2575
2576                 printf("Input user name for ethernet:");
2577                 rv = scanf("%99s", input_str1);
2578
2579                 printf("Input password for ethernet:");
2580                 rv = scanf("%99s", input_str2);
2581
2582                 rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
2583                 if (rv != CONNECTION_ERROR_NONE) {
2584                         printf("Fail to set eap passphrase : %s\n", test_print_error(rv));
2585                         return -1;
2586                 }
2587                 break;
2588
2589         case CONNECTION_ETHERNET_EAP_TYPE_TLS:
2590                 {
2591                         rv = connection_profile_set_ethernet_eap_type(profile, type);
2592                         if (rv != CONNECTION_ERROR_NONE) {
2593                                 printf("Fail to set eap type : %s\n", test_print_error(rv));
2594                                 return -1;
2595                         }
2596
2597                         printf("Input user identity for ethernet:");
2598                         rv = scanf("%99s", input_str1);
2599
2600                         rv = connection_profile_set_ethernet_eap_identity(profile, input_str1);
2601                         if (rv != CONNECTION_ERROR_NONE) {
2602                                 printf("Fail to set eap identity : %s\n", test_print_error(rv));
2603                                 return -1;
2604                         }
2605
2606                         printf("Input user certificate for ethernet:");
2607                         rv = scanf("%129s", input_str1);
2608
2609                         rv = connection_profile_set_ethernet_eap_client_cert_file(profile, input_str1);
2610                         if (rv != CONNECTION_ERROR_NONE) {
2611                                 printf("Fail to set eap user cetificate : %s\n", test_print_error(rv));
2612                                 return -1;
2613                         }
2614
2615                         printf("Input CA certificate for ethernet:");
2616                         rv = scanf("%129s", input_str1);
2617
2618                         rv = connection_profile_set_ethernet_eap_ca_cert_file(profile, input_str1);
2619                         if (rv != CONNECTION_ERROR_NONE) {
2620                                 printf("Fail to set eap CA cetificate : %s\n", test_print_error(rv));
2621                                 return -1;
2622                         }
2623
2624                         printf("Input private key for ethernet:");
2625                         rv = scanf("%129s", input_str1);
2626
2627                         printf("Input private key password for ethernet:");
2628                         rv = scanf("%129s", input_str2);
2629
2630                         rv = connection_profile_set_ethernet_eap_private_key_info(profile, input_str1, input_str2);
2631                         if (rv != CONNECTION_ERROR_NONE) {
2632                                 printf("Fail to set eap private key  passphrase : %s\n", test_print_error(rv));
2633                                 return -1;
2634                         }
2635                 }
2636                 break;
2637
2638         case CONNECTION_ETHERNET_EAP_TYPE_PEAP:
2639                 {
2640                         rv = connection_profile_set_ethernet_eap_type(profile, type);
2641                         if (rv != CONNECTION_ERROR_NONE) {
2642                                 printf("Fail to set eap type : %s\n", test_print_error(rv));
2643                                 return -1;
2644                         }
2645
2646                         printf("Input anonymous_identity for PEAP ethernet:");
2647                         rv = scanf("%99s", input_str1);
2648
2649                         rv = connection_profile_set_ethernet_eap_anonymous_identity(profile, input_str1);
2650                         if (rv != CONNECTION_ERROR_NONE) {
2651                                 printf("Fail to set eap anonymous_identity: %s\n", test_print_error(rv));
2652                                 return -1;
2653                         }
2654
2655                         printf("Input CA file for PEAP ethernet:");
2656                         rv = scanf("%129s", input_str1);
2657
2658                         rv = connection_profile_set_ethernet_eap_ca_cert_file(profile, input_str1);
2659                         if (rv != CONNECTION_ERROR_NONE) {
2660                                 printf("Fail to set eap CA file : %s\n", test_print_error(rv));
2661                                 return -1;
2662                         }
2663
2664                         int peap_version = 0;
2665                         printf("Input peap version[ 0 ~ 2] for PEAP ethernet:");
2666                         rv = scanf("%1d", &peap_version);
2667
2668                         rv = connection_profile_set_ethernet_eap_peap_version(profile, peap_version);
2669                         if (rv != CONNECTION_ERROR_NONE) {
2670                                 printf("Fail to set eap peap version : %s\n", test_print_error(rv));
2671                                 return -1;
2672                         }
2673
2674                         printf("Input authentication type[3:MSCHAPV2 4:GTC 5:MD5] for PEAP ethernet:");
2675                         rv = scanf("%1d", &auth_type);
2676
2677                         rv = connection_profile_set_ethernet_eap_auth_type(profile, auth_type);
2678                         if (rv != CONNECTION_ERROR_NONE) {
2679                                 printf("Fail to set eap authentication type : %s\n", test_print_error(rv));
2680                                 return -1;
2681                         }
2682
2683                         printf("Input username for PEAP ethernet:");
2684                         rv = scanf("%129s", input_str1);
2685
2686                         printf("Input password for PEAP ethernet:");
2687                         rv = scanf("%129s", input_str2);
2688
2689                         rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
2690                         if (rv != CONNECTION_ERROR_NONE) {
2691                                 printf("Fail to set eap username and password : %s\n", test_print_error(rv));
2692                                 return -1;
2693                         }
2694                 }
2695                 break;
2696
2697         case CONNECTION_ETHERNET_EAP_TYPE_TTLS:
2698                 {
2699                         rv = connection_profile_set_ethernet_eap_type(profile, type);
2700                         if (rv != CONNECTION_ERROR_NONE) {
2701                                 printf("Fail to set eap type : %s\n", test_print_error(rv));
2702                                 return -1;
2703                         }
2704
2705                         printf("Input anonymous_identity for TTLS ethernet:");
2706                         rv = scanf("%99s", input_str1);
2707
2708                         rv = connection_profile_set_ethernet_eap_anonymous_identity(profile, input_str1);
2709                         if (rv != CONNECTION_ERROR_NONE) {
2710                                 printf("Fail to set eap anonymous_identity: %s\n", test_print_error(rv));
2711                                 return -1;
2712                         }
2713
2714                         printf("Input CA file for TTLS ethernet:");
2715                         rv = scanf("%129s", input_str1);
2716
2717                         rv = connection_profile_set_ethernet_eap_ca_cert_file(profile, input_str1);
2718                         if (rv != CONNECTION_ERROR_NONE) {
2719                                 printf("Fail to set eap CA file : %s\n", test_print_error(rv));
2720                                 return -1;
2721                         }
2722
2723                         printf("Input authentication type[1:PAP, 2:MSCHAP, 3:MSCHAPV2] for TTLS ethernet:");
2724                         rv = scanf("%1d", &auth_type);
2725
2726                         rv = connection_profile_set_ethernet_eap_auth_type(profile, auth_type);
2727                         if (rv != CONNECTION_ERROR_NONE) {
2728                                 printf("Fail to set eap authentication type : %s\n", test_print_error(rv));
2729                                 return -1;
2730                         }
2731
2732                         printf("Input username for TTLS ethernet:");
2733                         rv = scanf("%129s", input_str1);
2734
2735                         printf("Input password for TTLS ethernet:");
2736                         rv = scanf("%129s", input_str2);
2737
2738                         rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
2739                         if (rv != CONNECTION_ERROR_NONE) {
2740                                 printf("Fail to set eap username and password : %s\n", test_print_error(rv));
2741                                 return -1;
2742                         }
2743                 }
2744                 break;
2745
2746         case CONNECTION_ETHERNET_EAP_TYPE_FAST:
2747                 {
2748                         rv = connection_profile_set_ethernet_eap_type(profile, type);
2749                         if (rv != CONNECTION_ERROR_NONE) {
2750                                 printf("Fail to set eap type : %s\n", test_print_error(rv));
2751                                 return -1;
2752                         }
2753
2754                         printf("Input anonymous_identity for FAST ethernet:");
2755                         rv = scanf("%99s", input_str1);
2756
2757                         rv = connection_profile_set_ethernet_eap_anonymous_identity(profile, input_str1);
2758                         if (rv != CONNECTION_ERROR_NONE) {
2759                                 printf("Fail to set eap anonymous_identity: %s\n", test_print_error(rv));
2760                                 return -1;
2761                         }
2762
2763                         printf("Input pac file for FAST ethernet:");
2764                         rv = scanf("%129s", input_str1);
2765
2766                         rv = connection_profile_set_ethernet_eap_pac_file(profile, input_str1);
2767                         if (rv != CONNECTION_ERROR_NONE) {
2768                                 printf("Fail to set eap pac file : %s\n", test_print_error(rv));
2769                                 return -1;
2770                         }
2771
2772                         printf("Input authentication type[3:MSCHAPV2, 4:GTC] for FAST ethernet:");
2773                         rv = scanf("%1d", &auth_type);
2774
2775                         rv = connection_profile_set_ethernet_eap_auth_type(profile, auth_type);
2776                         if (rv != CONNECTION_ERROR_NONE) {
2777                                 printf("Fail to set eap authentication type : %s\n", test_print_error(rv));
2778                                 return -1;
2779                         }
2780
2781                         printf("Input username for FAST ethernet:");
2782                         rv = scanf("%129s", input_str1);
2783
2784                         printf("Input password for FAST ethernet:");
2785                         rv = scanf("%129s", input_str2);
2786
2787                         rv = connection_profile_set_ethernet_eap_passphrase(profile, input_str1, input_str2);
2788                         if (rv != CONNECTION_ERROR_NONE) {
2789                                 printf("Fail to set eap username and password : %s\n", test_print_error(rv));
2790                                 return -1;
2791                         }
2792                 }
2793                 break;
2794
2795         default:
2796                 printf("Invalid EAP type\n");
2797                 return -1;
2798         }
2799
2800         rv = connection_profile_save_ethernet_eap_config(connection, profile);
2801         if (rv != CONNECTION_ERROR_NONE) {
2802                 printf("Fail to save eap config : %s\n", test_print_error(rv));
2803                 return -1;
2804         }
2805
2806         if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
2807                 printf("Connection open Failed!!\n");
2808                 return -1;
2809         }
2810
2811         return 1;
2812 }
2813
2814 static const char *test_print_eap_type(connection_ethernet_eap_type_e type)
2815 {
2816         switch (type) {
2817         case CONNECTION_ETHERNET_EAP_TYPE_MD5:
2818                 return "MD5";
2819         case CONNECTION_ETHERNET_EAP_TYPE_PEAP:
2820                 return "PEAP";
2821         case CONNECTION_ETHERNET_EAP_TYPE_TLS:
2822                 return "TLS";
2823         case CONNECTION_ETHERNET_EAP_TYPE_TTLS:
2824                 return "TTLS";
2825         case CONNECTION_ETHERNET_EAP_TYPE_FAST:
2826                 return "FAST";
2827         default:
2828                 return NULL;
2829         }
2830 }
2831
2832 static const char *test_print_eap_auth_type(connection_ethernet_eap_auth_type_e type)
2833 {
2834         switch (type) {
2835         case CONNECTION_ETHERNET_EAP_AUTH_TYPE_PAP:
2836                 return "PAP";
2837         case CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAP:
2838                 return "MSCHAP";
2839         case CONNECTION_ETHERNET_EAP_AUTH_TYPE_MSCHAPV2:
2840                 return "MSCHAPV2";
2841         case CONNECTION_ETHERNET_EAP_AUTH_TYPE_GTC:
2842                 return "GTC";
2843         case CONNECTION_ETHERNET_EAP_AUTH_TYPE_MD5:
2844                 return "MD5";
2845         case CONNECTION_ETHERNET_EAP_AUTH_TYPE_NONE:
2846                 return "NONE";
2847         default:
2848                 return NULL;
2849         }
2850 }
2851
2852 int test_get_eapol_info(void)
2853 {
2854         connection_profile_type_e prof_type;
2855         connection_profile_state_e profile_state;
2856         connection_profile_h profile;
2857         char *profile_name = NULL;
2858         connection_ethernet_eap_type_e type;
2859         connection_ethernet_eap_auth_type_e auth_type;
2860         connection_ethernet_eap_peap_version_e peapver;
2861         char *str = NULL;
2862
2863         printf("\n** Choose a ethernet profile to print eapol info. **\n");
2864         if (test_get_user_selected_profile(&profile, true) == false)
2865                 return -1;
2866
2867         bool enabled = false;
2868         if (connection_profile_is_ethernet_eap_enabled(profile, &enabled) != CONNECTION_ERROR_NONE) {
2869                 printf("Failed to get ethernet eap enabled status!!\n");
2870         }
2871         printf("EAP over Ethernet is %s\n", enabled ? "enabled" : "not enabled");
2872
2873         if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
2874                 printf("Fail to get profile name\n");
2875                 return -1;
2876         } else {
2877                 printf("Profile Name : %s\n", profile_name);
2878                 g_free(profile_name);
2879         }
2880
2881         if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE) {
2882                 printf("Fail to get profile type\n");
2883                 return -1;
2884         }
2885
2886         if (prof_type != CONNECTION_PROFILE_TYPE_ETHERNET) {
2887                 printf("Not ethernet profile\n");
2888                 return -1;
2889         }
2890
2891         if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
2892                 printf("Fail to get profile state\n");
2893                 return -1;
2894         } else
2895                 printf("Profile State : %s\n", test_print_state(profile_state));
2896
2897
2898         if (connection_profile_get_ethernet_eap_type(profile, &type)  != CONNECTION_ERROR_NONE) {
2899                 printf("Fail to get eap type\n");
2900                 return -1;
2901         } else {
2902                 printf("eap_type: %s\n", test_print_eap_type(type));
2903         }
2904
2905         if (connection_profile_get_ethernet_eap_identity(profile, &str) != CONNECTION_ERROR_NONE) {
2906                 printf("Fail to get eap identity\n");
2907                 return -1;
2908         } else {
2909                 printf("identity: %s\n", str);
2910                 g_free(str);
2911         }
2912
2913         if (type == CONNECTION_ETHERNET_EAP_TYPE_MD5)
2914                 goto out;
2915
2916         if (type == CONNECTION_ETHERNET_EAP_TYPE_PEAP || type == CONNECTION_ETHERNET_EAP_TYPE_TTLS ||
2917                         type == CONNECTION_ETHERNET_EAP_TYPE_FAST) {
2918                 if (connection_profile_get_ethernet_eap_anonymous_identity(profile, &str) != CONNECTION_ERROR_NONE) {
2919                         printf("Fail to get eap anonymous_identity\n");
2920                         return -1;
2921                 } else {
2922                         printf("anonymous_identity: %s\n", str);
2923                         g_free(str);
2924                 }
2925         }
2926
2927         if (connection_profile_get_ethernet_eap_ca_cert_file(profile, &str) != CONNECTION_ERROR_NONE) {
2928                 printf("Fail to get eap ca_cert_file\n");
2929                 return -1;
2930         } else {
2931                 printf("ca_cert_file: %s\n", str);
2932                 g_free(str);
2933         }
2934
2935         if (type == CONNECTION_ETHERNET_EAP_TYPE_TLS) {
2936                 if (connection_profile_get_ethernet_eap_client_cert_file(profile, &str) != CONNECTION_ERROR_NONE) {
2937                         printf("Fail to get eap client_cert_file\n");
2938                         return -1;
2939                 } else {
2940                         printf("client_cert_file: %s\n", str);
2941                         g_free(str);
2942                 }
2943
2944                 if (connection_profile_get_ethernet_eap_private_key_file(profile, &str) != CONNECTION_ERROR_NONE) {
2945                         printf("Fail to get eap private_key_file\n");
2946                         return -1;
2947                 } else {
2948                         printf("private_key_file: %s\n", str);
2949                         g_free(str);
2950                 }
2951         }
2952
2953         if (type == CONNECTION_ETHERNET_EAP_TYPE_PEAP || type == CONNECTION_ETHERNET_EAP_TYPE_TTLS ||
2954                         type == CONNECTION_ETHERNET_EAP_TYPE_FAST) {
2955                 if (connection_profile_get_ethernet_eap_auth_type(profile, &auth_type) != CONNECTION_ERROR_NONE) {
2956                         printf("Fail to get eap auth type\n");
2957                         return -1;
2958                 } else {
2959                         printf("eap_auth: %s\n", test_print_eap_auth_type(auth_type));
2960                 }
2961         }
2962
2963         if (type == CONNECTION_ETHERNET_EAP_TYPE_PEAP) {
2964                 if (connection_profile_get_ethernet_eap_peap_version(profile, &peapver) != CONNECTION_ERROR_NONE) {
2965                         printf("Fail to get eap peap_version\n");
2966                         return -1;
2967                 } else {
2968                         printf("peap_version: %d\n", peapver);
2969                 }
2970         }
2971
2972         if (type == CONNECTION_ETHERNET_EAP_TYPE_FAST) {
2973                 if (connection_profile_get_ethernet_eap_pac_file(profile, &str) != CONNECTION_ERROR_NONE) {
2974                         printf("Fail to get eap pac_file\n");
2975                         return -1;
2976                 } else {
2977                         printf("pac_file: %s\n", str);
2978                         g_free(str);
2979                 }
2980         }
2981
2982 out:
2983         return 1;
2984 }
2985
2986 int test_get_clock_update_info(void)
2987 {
2988         int rv = 0;
2989         bool updated;
2990
2991         rv = connection_clock_is_updated(connection, &updated);
2992
2993         if (rv != CONNECTION_ERROR_NONE) {
2994                 printf("Fail to get clock update information [%s]\n", test_print_error(rv));
2995                 return -1;
2996         }
2997
2998         printf("Retval = [%s] clock updated [%s]\n",
2999                 test_print_error(rv), updated ? "TRUE" : "FALSE");
3000
3001         return 1;
3002 }
3003
3004 int main(int argc, char **argv)
3005 {
3006         GMainLoop *mainloop;
3007         mainloop = g_main_loop_new(NULL, FALSE);
3008
3009         GIOChannel *channel = g_io_channel_unix_new(0);
3010         g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
3011
3012         printf("Test Thread created...\n");
3013
3014         g_main_loop_run(mainloop);
3015
3016         return 0;
3017 }
3018
3019 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
3020 {
3021         int rv = 0;
3022         char a[100];
3023
3024         memset(a, '\0', 100);
3025         printf("event received from stdin\n");
3026
3027         rv = read(0, a, 100);
3028
3029         if (rv < 0 || a[0] == '0') {
3030                 if (connection != NULL)
3031                         test_deregister_client();
3032
3033                 exit(1);
3034         }
3035
3036         if (*a == '\n' || *a == '\r') {
3037 /* Public API */
3038                 printf("\n\n Network Connection API Test App\n\n");
3039                 printf("Options..\n");
3040                 printf(LOG_BLUE "[Public APIs]\n" LOG_END);
3041                 printf(LOG_GREEN "1   - Create Handle and set callbacks\n" LOG_END);
3042                 printf("2   - Destroy Handle(unset callbacks automatically)\n");
3043                 printf(LOG_GREEN "3   - Get network state\n" LOG_END);
3044                 printf(LOG_GREEN "4   - Get cellular state (please insert SIM Card)\n" LOG_END);
3045                 printf(LOG_GREEN "5   - Get wifi state (please turn on WiFi)\n" LOG_END);
3046                 printf("6   - Get current proxy address \n");
3047                 printf("7   - Get current Ip address\n");
3048                 printf("8   - Get cellular data call statistics\n");
3049                 printf("9   - Get WiFi data call statistics\n");
3050                 printf(LOG_GREEN "a   - Get Profile list\n" LOG_END);
3051                 printf(LOG_GREEN "b   - Get Connected Profile list\n" LOG_END);
3052                 printf(LOG_GREEN "c   - Get Current profile\n" LOG_END);
3053                 printf("d   - Open connection with profile\n");
3054                 printf("e   - Get default cellular service by type\n");
3055                 printf("f   - Set default cellular service by type\n");
3056                 printf("g   - Close connection with profile\n");
3057                 printf("h   - Add profile(Cellular and Wifi only)\n");
3058                 printf("i   - Remove profile(Cellular:delete, WiFi:forgot)\n");
3059                 printf("j   - Update profile\n");
3060                 printf("k   - Get profile info\n");
3061                 printf("l   - Refresh profile info\n");
3062                 printf("m   - Set state changed callback\n");
3063                 printf("n   - Unset state changed callback\n");
3064                 printf("o   - Reset cellular data call statistics\n");
3065                 printf("p   - Reset WiFi data call statistics\n");
3066                 printf("q   - Add new route\n");
3067                 printf("r   - Remove a route\n");
3068                 printf("s   - Get bluetooth state\n");
3069                 printf("t   - Get profile id\n");
3070                 printf("u   - Reset profile\n");
3071                 printf("v   - Get all cellular default profiles\n");
3072                 printf("w   - Get mac address\n");
3073                 printf("x   - Get ethernet cable state\n");
3074                 printf("B   - Add IPv6 new route\n");
3075                 printf("C   - Remove IPv6 route\n");
3076                 printf("D   - Add new route entry\n");
3077                 printf("E   - Remove route entry\n");
3078                 printf("F   - Get all IPv6 address\n");
3079                 printf("G   - Get metered state\n");
3080 /* Extension API */
3081                 printf(LOG_BLUE "[Extension API]\n" LOG_END);
3082                 printf("H   - Start TCP Dump\n");
3083                 printf("I   - Stop TCP Dump\n");
3084                 printf("J   - Get TCP Dump State\n");
3085                 printf("K   - Enable MPTCP (internal)\n");
3086                 printf("L   - Disable MPTCP (internal)\n");
3087                 printf("M   - Set MPTCP Path Manager (internal)\n");
3088                 printf("N   - Get MPTCP Path Manager (internal)\n");
3089                 printf("O   - Set MPTCP Scheduler (internal)\n");
3090                 printf("P   - Get MPTCP Scheduler (internal)\n");
3091                 printf(LOG_GREEN "Q   - Create Handle and set callbacks in C# API\n" LOG_END);
3092                 printf("R   - Destroy Handle(unset callbacks automatically in C# API)\n");
3093                 printf("S   - Connect Ethernet EAP)\n");
3094                 printf("T   - Get EAPoL info)\n");
3095                 printf("U   - Get Clock update info)\n");
3096                 printf(LOG_RED "0   - Exit \n" LOG_END);
3097                 printf("ENTER   - Show options menu.......\n");
3098         }
3099
3100         switch (a[0]) {
3101 /* Public API */
3102         case '1':
3103                 rv = test_register_client();
3104                 break;
3105         case '2':
3106                 rv = test_deregister_client();
3107                 break;
3108         case '3':
3109                 rv = test_get_network_state();
3110                 break;
3111         case '4':
3112                 rv = test_get_cellular_state();
3113                 break;
3114         case '5':
3115                 rv = test_get_wifi_state();
3116                 break;
3117         case '6':
3118                 rv = test_get_current_proxy();
3119                 break;
3120         case '7':
3121                 rv = test_get_current_ip();
3122                 break;
3123         case '8':
3124                 rv = test_get_call_statistics_info();
3125                 break;
3126         case '9':
3127                 rv = test_get_wifi_call_statistics_info();
3128                 break;
3129         case 'a':
3130                 rv = test_get_profile_list();
3131                 break;
3132         case 'b':
3133                 rv = test_get_connected_profile_list();
3134                 break;
3135         case 'c':
3136                 rv = test_get_current_profile();
3137                 break;
3138         case 'd':
3139                 rv = test_open_profile();
3140                 break;
3141         case 'e':
3142                 rv = test_get_default_cellular_service_type();
3143                 break;
3144         case 'f':
3145                 rv = test_set_default_cellular_service_type();
3146                 break;
3147         case 'g':
3148                 rv = test_close_profile();
3149                 break;
3150         case 'h':
3151                 rv = test_add_profile();
3152                 break;
3153         case 'i':
3154                 rv = test_remove_profile();
3155                 break;
3156         case 'j':
3157                 rv = test_update_profile();
3158                 break;
3159         case 'k':
3160                 rv = test_get_profile_info();
3161                 break;
3162         case 'l':
3163                 rv = test_refresh_profile_info();
3164                 break;
3165         case 'm':
3166                 rv = test_set_state_changed_callback();
3167                 break;
3168         case 'n':
3169                 rv = test_unset_state_changed_callback();
3170                 break;
3171         case 'o':
3172                 rv = test_reset_call_statistics_info();
3173                 break;
3174         case 'p':
3175                 rv = test_reset_wifi_call_statistics_info();
3176                 break;
3177         case 'q':
3178                 rv = test_add_route();
3179                 break;
3180         case 'r':
3181                 rv = test_remove_route();
3182                 break;
3183         case 's':
3184                 rv = test_get_bt_state();
3185                 break;
3186         case 't':
3187                 rv = test_get_profile_id();
3188                 break;
3189         case 'u':
3190                 rv = test_reset_profile();
3191                 break;
3192         case 'v':
3193                 rv = test_get_default_profile_list();
3194                 break;
3195         case 'w':
3196                 rv = test_get_mac_address();
3197                 break;
3198         case 'x':
3199                 rv = test_get_ethernet_cable_state();
3200                 break;
3201         case 'B':
3202                 rv = test_add_route_ipv6();
3203                 break;
3204         case 'C':
3205                 rv = test_remove_route_ipv6();
3206                 break;
3207         case 'D':
3208                 rv = test_add_route_entry();
3209                 break;
3210         case 'E':
3211                 rv = test_remove_route_entry();
3212                 break;
3213         case 'F':
3214                 rv = test_foreach_ipv6_address();
3215                 break;
3216         case 'G':
3217                 rv = test_is_metered_network();
3218                 break;
3219 /* Extension API */
3220         case 'H':
3221                 rv = test_start_tcpdump();
3222                 break;
3223         case 'I':
3224                 rv = test_stop_tcpdump();
3225                 break;
3226         case 'J':
3227                 rv = test_get_tcpdump_state();
3228                 break;
3229         case 'K':
3230                 rv = test_mptcp_enable();
3231                 break;
3232         case 'L':
3233                 rv = test_mptcp_disable();
3234                 break;
3235         case 'M':
3236                 rv = test_mptcp_set_path_manager();
3237                 break;
3238         case 'N':
3239                 rv = test_mptcp_get_path_manager();
3240                 break;
3241         case 'O':
3242                 rv = test_mptcp_set_scheduler();
3243                 break;
3244         case 'P':
3245                 rv = test_mptcp_get_scheduler();
3246                 break;
3247         case 'Q':
3248                 rv = test_register_client_cs();
3249                 break;
3250         case 'R':
3251                 rv = test_deregister_client_cs();
3252                 break;
3253         case 'S':
3254                 rv = test_ethernet_eap_connect();
3255                 break;
3256         case 'T':
3257                 rv = test_get_eapol_info();
3258                 break;
3259         case 'U':
3260                 rv = test_get_clock_update_info();
3261                 break;
3262         }
3263
3264         if (rv == 1)
3265                 printf("Operation succeeded!\n");
3266         else
3267                 printf("Operation failed!\n");
3268
3269         return TRUE;
3270 }