Merge "Add new feature for wifi-direct type" into tizen
[platform/core/api/tethering.git] / test / tethering_test.c
1 /*
2 * Copyright (c) 2011 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 <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21 #include <glib.h>
22 #include <glib-object.h>
23 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <arpa/inet.h>
26
27 #include <vconf.h>
28
29 #include "tethering.h"
30
31 #define DISABLE_REASON_TEXT_LEN 64
32 #define COMMON_STR_BUF_LEN      32
33
34 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
35
36 typedef struct {
37         tethering_enabled_cb enabled_cb;
38         tethering_disabled_cb disabled_cb;
39         tethering_connection_state_changed_cb changed_cb;
40         tethering_wifi_security_type_changed_cb security_type_changed_cb;
41         tethering_wifi_ssid_visibility_changed_cb ssid_visibility_changed_cb;
42         tethering_wifi_passphrase_changed_cb passphrase_changed_cb;
43 } __tethering_cbs;
44
45 tethering_h th = NULL;
46
47 static bool __is_err(tethering_error_e ret)
48 {
49         char *err_msg = NULL;
50
51         switch (ret) {
52         case TETHERING_ERROR_INVALID_PARAMETER:
53                 err_msg = "Wrong parameter is used";
54                 break;
55
56         case TETHERING_ERROR_OUT_OF_MEMORY:
57                 err_msg = "Memory is not enough";
58                 break;
59
60         case TETHERING_ERROR_NONE:
61                 return false;
62
63         case TETHERING_ERROR_NOT_ENABLED:
64                 err_msg = "Tethering is not enabled";
65                 break;
66
67         case TETHERING_ERROR_OPERATION_FAILED:
68                 err_msg = "Operation is failed";
69                 break;
70
71         case TETHERING_ERROR_RESOURCE_BUSY:
72                 err_msg = "Resource is busy";
73                 break;
74
75         case TETHERING_ERROR_NOT_PERMITTED:
76                 err_msg = "Operation is not permitted";
77                 break;
78
79         case TETHERING_ERROR_NOT_SUPPORT_API:
80                 err_msg = "Not supported";
81                 break;
82
83         default:
84                 err_msg = "This should not be happened";
85                 break;
86         }
87
88         g_print("##ERR: %s\n", err_msg);
89
90         return true;
91 }
92
93 static const char *__convert_tethering_type_to_str(const tethering_type_e type)
94 {
95         static char str_buf[COMMON_STR_BUF_LEN] = {0, };
96
97         switch (type) {
98         case TETHERING_TYPE_USB:
99                 g_strlcpy(str_buf, "USB Tethering", sizeof(str_buf));
100                 break;
101
102         case TETHERING_TYPE_WIFI:
103                 g_strlcpy(str_buf, "Wi-Fi Tethering", sizeof(str_buf));
104                 break;
105
106         case TETHERING_TYPE_BT:
107                 g_strlcpy(str_buf, "Bluetooth Tethering", sizeof(str_buf));
108                 break;
109
110         default:
111                 g_strlcpy(str_buf, "Unknown", sizeof(str_buf));
112                 break;
113         }
114
115         return str_buf;
116 }
117
118 static const char *__convert_disabled_code_to_str(const tethering_disabled_cause_e code)
119 {
120         static char str_buf[DISABLE_REASON_TEXT_LEN] = {0, };
121
122         switch (code) {
123         case TETHERING_DISABLED_BY_USB_DISCONNECTION:
124                 strncpy(str_buf, "disabled due to usb disconnection", sizeof(str_buf));
125                 break;
126
127         case TETHERING_DISABLED_BY_FLIGHT_MODE:
128                 strncpy(str_buf, "disabled due to flight mode on", sizeof(str_buf));
129                 break;
130
131         case TETHERING_DISABLED_BY_LOW_BATTERY:
132                 strncpy(str_buf, "disabled due to low battery", sizeof(str_buf));
133                 break;
134
135         case TETHERING_DISABLED_BY_NETWORK_CLOSE:
136                 strncpy(str_buf, "disabled due to pdp network close", sizeof(str_buf));
137                 break;
138
139         case TETHERING_DISABLED_BY_TIMEOUT:
140                 strncpy(str_buf, "disabled due to timeout", sizeof(str_buf));
141                 break;
142
143         case TETHERING_DISABLED_BY_OTHERS:
144                 strncpy(str_buf, "disabled by other apps", sizeof(str_buf));
145                 break;
146
147         case TETHERING_DISABLED_BY_REQUEST:
148                 strncpy(str_buf, "disabled by my request", sizeof(str_buf));
149                 break;
150
151         case TETHERING_DISABLED_BY_WIFI_ON:
152                 strncpy(str_buf, "disabled by Wi-Fi station on", sizeof(str_buf));
153                 break;
154
155         case TETHERING_DISABLED_BY_BT_OFF:
156                 strncpy(str_buf, "disabled by bluetooth off", sizeof(str_buf));
157                 break;
158
159         default:
160                 strncpy(str_buf, "disabled by unknown reason", sizeof(str_buf));
161                 break;
162         }
163
164         return str_buf;
165 }
166
167 static void __register_cbs(tethering_h th, __tethering_cbs *cbs, void *user_data)
168 {
169         tethering_error_e ret = TETHERING_ERROR_NONE;
170
171         ret = tethering_set_enabled_cb(th, TETHERING_TYPE_ALL,
172                         cbs->enabled_cb, user_data);
173         if (__is_err(ret) == true)
174                 g_print("tethering_set_enabled_cb is failed\n");
175
176         ret = tethering_set_disabled_cb(th, TETHERING_TYPE_ALL,
177                         cbs->disabled_cb, user_data);
178         if (__is_err(ret) == true)
179                 g_print("tethering_set_disabled_cb is failed\n");
180
181         ret = tethering_set_connection_state_changed_cb(th, TETHERING_TYPE_ALL,
182                         cbs->changed_cb, user_data);
183         if (__is_err(ret) == true)
184                 g_print("tethering_set_connection_state_changed_cb is failed\n");
185
186         ret = tethering_wifi_set_security_type_changed_cb(th,
187                         cbs->security_type_changed_cb, user_data);
188         if (__is_err(ret) == true)
189                 g_print("tethering_wifi_set_security_type_changed_cb is failed\n");
190
191         ret = tethering_wifi_set_ssid_visibility_changed_cb(th,
192                         cbs->ssid_visibility_changed_cb, user_data);
193         if (__is_err(ret) == true)
194                 g_print("tethering_wifi_set_ssid_visibility_changed_cb is failed\n");
195
196         ret = tethering_wifi_set_passphrase_changed_cb(th,
197                         cbs->passphrase_changed_cb, user_data);
198         if (__is_err(ret) == true)
199                 g_print("tethering_wifi_set_passphrase_changed_cb is failed\n");
200
201         return;
202 }
203
204 static void __deregister_cbs(tethering_h th)
205 {
206         tethering_error_e ret = TETHERING_ERROR_NONE;
207
208         ret = tethering_unset_enabled_cb(th, TETHERING_TYPE_ALL);
209         if (__is_err(ret) == true)
210                 g_print("tethering_unset_enabled_cb is failed\n");
211
212         ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_ALL);
213         if (__is_err(ret) == true)
214                 g_print("tethering_unset_disabled_cb is failed\n");
215
216         ret = tethering_unset_connection_state_changed_cb(th, TETHERING_TYPE_ALL);
217         if (__is_err(ret) == true)
218                 g_print("tethering_unset_connection_state_changed_cb is failed\n");
219
220         ret = tethering_wifi_unset_security_type_changed_cb(th);
221         if (__is_err(ret) == true)
222                 g_print("tethering_wifi_unset_security_type_changed_cb is failed\n");
223
224         ret = tethering_wifi_unset_ssid_visibility_changed_cb(th);
225         if (__is_err(ret) == true)
226                 g_print("tethering_wifi_unset_ssid_visibility_changed_cb is failed\n");
227
228         ret = tethering_wifi_unset_passphrase_changed_cb(th);
229         if (__is_err(ret) == true)
230                 g_print("tethering_wifi_unset_passphrase_changed_cb is failed\n");
231
232         return;
233 }
234
235 /* Tethering callbacks */
236 static void __enabled_cb(tethering_error_e error, tethering_type_e type, bool is_requested, void *data)
237 {
238         if (__is_err(error)) {
239                 if (!is_requested)
240                         return;
241
242                 g_print("## %s is not enabled. error code[0x%X]\n",
243                                 __convert_tethering_type_to_str(type),
244                                 error);
245                 return;
246         }
247
248         if (is_requested)
249                 g_print("## %s is enabled successfully\n",
250                                 __convert_tethering_type_to_str(type));
251         else
252                 g_print("## %s is enabled by other app\n",
253                                 __convert_tethering_type_to_str(type));
254
255         return;
256 }
257
258 static void __disabled_cb(tethering_error_e error, tethering_type_e type, tethering_disabled_cause_e code, void *data)
259 {
260         if (__is_err(error)) {
261                 if (code != TETHERING_DISABLED_BY_REQUEST)
262                         return;
263
264                 g_print("## %s is not disabled. error code[0x%X]\n",
265                                 __convert_tethering_type_to_str(type), error);
266                 return;
267         }
268
269         g_print("## %s is %s\n",
270                         __convert_tethering_type_to_str(type),
271                         __convert_disabled_code_to_str(code));
272
273         return;
274 }
275
276 static void __connection_state_changed_cb(tethering_client_h client, bool open, void *data)
277 {
278         tethering_client_h clone = NULL;
279         tethering_type_e type;
280         char *ip_address = NULL;
281         char *mac_address = NULL;
282         char *hostname = NULL;
283
284         tethering_client_clone(&clone, client);
285         if (clone == NULL) {
286                 g_print("tetheirng_client_clone is failed\n");
287                 return;
288         }
289
290         tethering_client_get_tethering_type(clone, &type);
291         tethering_client_get_ip_address(clone,
292                         TETHERING_ADDRESS_FAMILY_IPV4, &ip_address);
293         tethering_client_get_mac_address(clone, &mac_address);
294         tethering_client_get_name(clone, &hostname);
295
296         if (open) {
297                 g_print("## New station Type [%s], IP [%s], MAC [%s], hostname [%s]\n",
298                                 __convert_tethering_type_to_str(type),
299                                 ip_address, mac_address, hostname);
300         } else {
301                 g_print("## Disconnected station Type [%s], IP [%s], MAC [%s], hostname [%s]\n",
302                                 __convert_tethering_type_to_str(type),
303                                 ip_address, mac_address, hostname);
304         }
305
306         if (ip_address)
307                 free(ip_address);
308         if (mac_address)
309                 free(mac_address);
310         if (hostname)
311                 free(hostname);
312
313         tethering_client_destroy(clone);
314
315         return;
316 }
317
318 static void __data_usage_cb(tethering_error_e result, unsigned long long received_data,
319                 unsigned long long sent_data, void *user_data)
320 {
321         g_print("__data_usage_cb\n");
322
323         if (result != TETHERING_ERROR_NONE) {
324                 g_print("tethering_get_data_usage is failed. error[0x%X]\n", result);
325                 return;
326         }
327
328         g_print("## Received data : %llu bytes\n", received_data);
329         g_print("## Sent data : %llu bytes\n", sent_data);
330
331         return;
332 }
333
334 static void __settings_reloaded_cb(tethering_error_e result, void *user_data)
335 {
336         g_print("__settings_reloaded_cb\n");
337
338         if (result != TETHERING_ERROR_NONE) {
339                 g_print("tethering_wifi_reload_settings is failed. error[0x%X]\n", result);
340                 return;
341         }
342
343         g_print("## Wi-Fi tethering setting is reloaded\n");
344
345         return;
346 }
347
348 static bool __clients_foreach_cb(tethering_client_h client, void *data)
349 {
350         tethering_client_h clone = NULL;
351         tethering_type_e type;
352         char *ip_address = NULL;
353         char *mac_address = NULL;
354         char *hostname = NULL;
355
356         /* Clone internal information */
357         if (tethering_client_clone(&clone, client) != TETHERING_ERROR_NONE) {
358                 g_print("tethering_client_clone is failed\n");
359                 return false;
360         }
361
362         /* Get information */
363         if (tethering_client_get_tethering_type(clone, &type) != TETHERING_ERROR_NONE)
364                 g_print("tethering_client_get_type is failed\n");
365
366         if (tethering_client_get_ip_address(clone, TETHERING_ADDRESS_FAMILY_IPV4, &ip_address) != TETHERING_ERROR_NONE)
367                 g_print("tethering_client_get_ip_address is failed\n");
368
369         if (tethering_client_get_mac_address(clone, &mac_address) != TETHERING_ERROR_NONE)
370                 g_print("tethering_client_get_mac_address is failed\n");
371
372         if (tethering_client_get_name(clone, &hostname) != TETHERING_ERROR_NONE)
373                 g_print("tethering_client_get_hostname is failed\n");
374
375         /* End of getting information */
376
377         g_print("\n< Client Info. >\n");
378         g_print("\tType %s\n", __convert_tethering_type_to_str(type));
379         g_print("\tIP Address %s\n", ip_address);
380         g_print("\tMAC Address : %s\n", mac_address);
381         g_print("\tHostname : %s\n", hostname);
382
383         /* Destroy cloned objects */
384         if (ip_address)
385                 free(ip_address);
386         if (mac_address)
387                 free(mac_address);
388         if (hostname)
389                 free(hostname);
390
391         tethering_client_destroy(clone);
392
393         /* Continue iteration */
394         return true;
395 }
396
397 static void __security_type_changed_cb(tethering_wifi_security_type_e changed_type, void *user_data)
398 {
399
400         char *sec_str = NULL;
401
402         switch (changed_type) {
403         case TETHERING_WIFI_SECURITY_TYPE_NONE:
404                 sec_str = "open";
405                 break;
406         case TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK:
407                 sec_str = "wpa2-psk";
408                 break;
409         case TETHERING_WIFI_SECURITY_TYPE_WPS:
410                 sec_str = "wps";
411                 break;
412         default:
413                 sec_str = "unknown";
414                 break;
415         }
416         g_print("Wi-Fi Tethering Security type is changed to [%s]\n", sec_str);
417
418         return;
419 }
420
421 static void __ssid_visibility_changed_cb(bool changed_visible, void *user_data)
422 {
423         g_print("SSID visibility for Wi-Fi tethering changed to [%s]\n",
424                         changed_visible ? "visible" : "invisible");
425         return;
426 }
427
428 static void __passphrase_changed_cb(void *user_data)
429 {
430         g_print("Wi-Fi Tethering passphrase is changed\n");
431         return;
432 }
433 /* End of tethering callbacks */
434
435 static void __print_interface_info(tethering_h th, tethering_type_e type)
436 {
437         char *interface = NULL;
438         char *mac_address = NULL;
439         char *ip_address = NULL;
440         char *ip6_address = NULL;
441         char *gateway_address = NULL;
442         char *gateway6_address = NULL;
443         char *subnet_mask = NULL;
444         char *prefix = NULL;
445
446         if (tethering_is_enabled(th, type) == FALSE) {
447                 g_print("%s is not enabled\n",
448                                 __convert_tethering_type_to_str(type));
449                 return;
450         }
451
452         tethering_get_network_interface_name(th, type, &interface);
453         tethering_get_mac_address(th, type, &mac_address);
454         tethering_get_ip_address(th, type, TETHERING_ADDRESS_FAMILY_IPV4,
455                         &ip_address);
456         tethering_get_ip_address(th, type, TETHERING_ADDRESS_FAMILY_IPV6,
457                         &ip6_address);
458         tethering_get_gateway_address(th, type, TETHERING_ADDRESS_FAMILY_IPV4,
459                         &gateway_address);
460         tethering_get_gateway_address(th, type, TETHERING_ADDRESS_FAMILY_IPV6,
461                         &gateway6_address);
462         tethering_get_subnet_mask(th, type, TETHERING_ADDRESS_FAMILY_IPV4,
463                         &subnet_mask);
464         tethering_get_subnet_mask(th, type, TETHERING_ADDRESS_FAMILY_IPV6,
465                         &prefix);
466
467         g_print("interface name : %s\n", interface);
468         g_print("mac address : %s\n", mac_address);
469         g_print("IPv4 address : %s\n", ip_address);
470         g_print("IPv6 address : %s\n", ip6_address);
471         g_print("gateway address: %s\n", gateway_address);
472         g_print("IPv6 gateway address: %s\n", gateway6_address);
473         g_print("subnet mask : %s\n", subnet_mask);
474         g_print("IPv6 prefix : %s\n", prefix);
475
476         if (interface)
477                 free(interface);
478         if (mac_address)
479                 free(mac_address);
480         if (ip_address)
481                 free(ip_address);
482         if (ip6_address)
483                 free(ip6_address);
484         if (gateway_address)
485                 free(gateway_address);
486         if (subnet_mask)
487                 free(subnet_mask);
488         if (gateway6_address)
489                 free(gateway6_address);
490         if (prefix)
491                 free(prefix);
492
493         return;
494 }
495
496 static void __print_wifi_tethering_setting(tethering_h th)
497 {
498         char *ssid = NULL;
499         char *passphrase = NULL;
500         char *sec_str = NULL;
501         bool visibility = false;
502         bool mac_filter = 0;
503         bool forwarding_enabled = false;
504         bool filtering_enabled = false;
505         int channel = 0;
506         int max_connected = 0;
507         tethering_wifi_security_type_e security_type = TETHERING_WIFI_SECURITY_TYPE_NONE;
508         tethering_wifi_mode_type_e hw_mode = TETHERING_WIFI_MODE_TYPE_G;
509
510         int error = TETHERING_ERROR_NONE;
511
512         error = tethering_wifi_get_ssid(th, &ssid);
513         if (error != TETHERING_ERROR_NONE)
514                 __is_err(error);
515         else
516                 g_print("\n\t** WiFi tethering SSID : %s\n", ssid);
517
518         error = tethering_wifi_get_passphrase(th, &passphrase);
519         if (error != TETHERING_ERROR_NONE)
520                 __is_err(error);
521         else
522                 g_print("\t** WiFi tethering passphrase : %s\n", passphrase);
523
524         error = tethering_wifi_get_ssid_visibility(th, &visibility);
525         if (error != TETHERING_ERROR_NONE)
526                 __is_err(error);
527         else
528                 g_print("\t** WiFi tethering ssid visibility : %s\n",
529                                 visibility ? "visible" : "invisible");
530
531         error = tethering_wifi_get_security_type(th, &security_type);
532         if (error != TETHERING_ERROR_NONE)
533                 __is_err(error);
534         else {
535                 switch (security_type) {
536                 case TETHERING_WIFI_SECURITY_TYPE_NONE:
537                         sec_str = "open";
538                         break;
539                 case TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK:
540                         sec_str = "wpa2-psk";
541                         break;
542                 case TETHERING_WIFI_SECURITY_TYPE_WPS:
543                         sec_str = "wps";
544                         break;
545                 default:
546                         sec_str = "unknown";
547                         break;
548                 }
549                 g_print("\t** WiFi tethering security_type : %s\n", sec_str);
550         }
551
552         error = tethering_wifi_get_mode(th, &hw_mode);
553         if (error != TETHERING_ERROR_NONE)
554                 __is_err(error);
555         else
556                  g_print("\t** WiFi tethering mode : %d\n", hw_mode);
557
558         error = tethering_wifi_get_channel(th, &channel);
559         if (error != TETHERING_ERROR_NONE)
560                 __is_err(error);
561         else
562                  g_print("\t** WiFi tethering channel : %d\n", channel);
563
564         error = tethering_wifi_get_max_connected_device(th, &max_connected);
565         if (error != TETHERING_ERROR_NONE)
566                 __is_err(error);
567         else
568                  g_print("\t** WiFi tethering max connected device : %d\n", max_connected);
569
570         error = tethering_wifi_get_mac_filter(th, &mac_filter);
571         if (error != TETHERING_ERROR_NONE)
572                 __is_err(error);
573         else
574                 g_print("\t** WiFi tethering mac filter : %s\n",
575                                 mac_filter ? "enable" : "disable");
576
577         error = tethering_wifi_is_port_filtering_enabled(th, &filtering_enabled);
578         if (error != TETHERING_ERROR_NONE)
579                 __is_err(error);
580         else
581                 g_print("\t** WiFi tethering port filtering : %s\n",
582                                 filtering_enabled ? "enable" : "disable");
583
584         error = tethering_wifi_is_port_forwarding_enabled(th, &forwarding_enabled);
585         if (error != TETHERING_ERROR_NONE)
586                 __is_err(error);
587         else
588                 g_print("\t** WiFi tethering port forwarding : %s\n",
589                                 forwarding_enabled ? "enable" : "disable");
590
591         if (ssid)
592                 free(ssid);
593         if (passphrase)
594                 free(passphrase);
595
596         return;
597 }
598
599 void __display_list(GSList *list)
600 {
601         GSList *iterator = NULL;
602
603         for (iterator = list; iterator; iterator = iterator->next)
604                 printf("%s\n", (char*)iterator->data);
605 }
606
607 bool __get_tethering_type(tethering_type_e *type)
608 {
609         int sel;
610         int ret;
611
612         printf("Select tethering type (1:Wi-Fi, 2:BT, 3:USB 4:ALL)\n");
613         ret = scanf("%9d", &sel);
614         if (ret < 0) {
615                 printf("scanf is failed!!\n");
616                 return false;
617         }
618
619         switch (sel) {
620         case 1:
621                 *type = TETHERING_TYPE_WIFI;
622                 break;
623         case 2:
624                 *type = TETHERING_TYPE_BT;
625                 break;
626         case 3:
627                 *type = TETHERING_TYPE_USB;
628                 break;
629         case 4:
630                 *type = TETHERING_TYPE_ALL;
631                 break;
632         default:
633                 printf("Invalid input!!\n");
634                 return false;
635         }
636
637         return true;
638 }
639
640 static int test_tethering_create(void)
641 {
642         int ret = tethering_create(&th);
643         __tethering_cbs cbs = {
644                 __enabled_cb, __disabled_cb,
645                 __connection_state_changed_cb, __security_type_changed_cb,
646                 __ssid_visibility_changed_cb, __passphrase_changed_cb};
647
648         if (__is_err(ret) == false) __register_cbs(th, &cbs, NULL);
649         else {
650                 printf("Tethering create is failed\n");
651                 return -1;
652         }
653         printf("Tethering create and register callback success\n");
654
655         return 1;
656 }
657
658 static int test_tethering_destroy(void)
659 {
660         int ret = TETHERING_ERROR_NONE;
661
662         __deregister_cbs(th);
663
664         ret = tethering_destroy(th);
665         if (__is_err(ret) == true) {
666                 printf("Tethering destroy is failed\n");
667                 return -1;
668         }
669
670         return 1;
671 }
672
673 static int test_tethering_enable(void)
674 {
675         int ret = TETHERING_ERROR_NONE;
676         tethering_type_e type;
677         int address_type = 0;
678
679         printf("IPv4: 0, IPv6: 1\n");
680         ret = scanf("%d", &address_type);
681
682         if (!__get_tethering_type(&type))
683                 return -1;
684
685         if (address_type)
686                 ret = tethering_ipv6_enable(th, type);
687         else
688                 ret = tethering_enable(th, type);
689
690         if (__is_err(ret) == true) {
691                 printf("Fail to enable tethering\n");
692                 return -1;
693         }
694         return 1;
695 }
696
697 static int test_tethering_disable(void)
698 {
699         int ret = TETHERING_ERROR_NONE;
700         tethering_type_e type;
701         int address_type = 0;
702
703         printf("IPv4: 0, IPv6: 1\n");
704         ret = scanf("%d", &address_type);
705
706         if (!__get_tethering_type(&type))
707                 return -1;
708
709         if (address_type)
710                 ret = tethering_ipv6_disable(th, type);
711         else
712                 ret = tethering_disable(th, type);
713
714         if (__is_err(ret) == true) {
715                 printf("Fail to disable tethering\n");
716                 return -1;
717         }
718         return 1;
719 }
720
721 static int test_tethering_get_client_info(void)
722 {
723         int ret;
724         tethering_type_e type;
725
726         if (!__get_tethering_type(&type))
727                 return -1;
728
729         ret = tethering_foreach_connected_clients(th, type,
730                                         __clients_foreach_cb, NULL);
731         if (__is_err(ret) == true) {
732                 printf("Fail to disable tethering\n");
733                 return -1;
734         }
735
736         return 1;
737 }
738
739 static int test_tethering_get_interface_info(void)
740 {
741         tethering_type_e type;
742
743         if (!__get_tethering_type(&type))
744                 return -1;
745
746         __print_interface_info(th, type);
747
748         return 1;
749 }
750
751 static int test_tethering_get_data_usage(void)
752 {
753         int ret = tethering_get_data_usage(th, __data_usage_cb, NULL);
754
755         if (__is_err(ret) == true) {
756                 printf("Fail to get data usage!!\n");
757                 return -1;
758         }
759
760         return 1;
761 }
762
763 static int test_tethering_wifi_get_setting(void)
764 {
765         __print_wifi_tethering_setting(th);
766         return 1;
767 }
768
769 static int test_tethering_wifi_set_ssid(void)
770 {
771         int ret;
772         char ssid[100];
773
774         printf("Input SSID for Wi-Fi tethering: ");
775         ret = scanf("%99s", ssid);
776         if (ret < 0) {
777                 printf("scanf is failed!!\n");
778                 return -1;
779         }
780
781         ret = tethering_wifi_set_ssid(th, ssid);
782         if (__is_err(ret) == true) {
783                 printf("Fail to set wifi ssid!!\n");
784                 return -1;
785         }
786
787         return 1;
788 }
789
790 static int test_tethering_wifi_set_security_type(void)
791 {
792         int ret;
793         int security_type;
794
795         printf("Input security type for Wi-Fi tethering (0:NONE, 1:WPA2_PSK, 2:WPS)");
796         ret = scanf("%9d", &security_type);
797         if (ret < 0) {
798                 printf("scanf is failed!!\n");
799                 return -1;
800         }
801
802         ret = tethering_wifi_set_security_type(th, security_type);
803         if (__is_err(ret) == true) {
804                 printf("Fail to set security type!!\n");
805                 return -1;
806         }
807
808         return 1;
809 }
810
811 int test_tethering_wifi_set_visibility(void)
812 {
813         int ret;
814         int visibility;
815
816         printf("Input security type for Wi-Fi tethering (0:invisible, 1:visible)");
817         ret = scanf("%9d", &visibility);
818         if (ret < 0) {
819                 printf("scanf is failed!!\n");
820                 return -1;
821         }
822
823         ret = tethering_wifi_set_ssid_visibility(th, visibility);
824         if (__is_err(ret) == true) {
825                 printf("Fail to set visibility!!\n");
826                 return -1;
827         }
828
829         return 1;
830 }
831
832 static int test_tethering_wifi_set_passphrase(void)
833 {
834         int ret;
835         char passphrase[100];
836
837         printf("Input passphrase for Wi-Fi tethering: ");
838         ret = scanf("%99s", passphrase);
839         if (ret < 0) {
840                 printf("scanf is failed!!\n");
841                 return -1;
842         }
843
844         ret = tethering_wifi_set_passphrase(th, passphrase);
845         if (__is_err(ret) == true) {
846                 printf("Fail to set passphrase!!\n");
847                 return -1;
848         }
849
850         return 1;
851 }
852
853 static int test_tethering_wifi_set_channel(void)
854 {
855         int ret;
856         int channel;
857
858         printf("Input channel for Wi-Fi tethering: ");
859         ret = scanf("%d", &channel);
860
861         ret = tethering_wifi_set_channel(th, channel);
862         if (__is_err(ret) == true) {
863                 printf("Fail to set channel!!\n");
864                 return -1;
865         }
866
867         return 1;
868 }
869
870 static int test_tethering_wifi_set_mode(void)
871 {
872         int ret;
873         int type;
874
875         printf("Input hw_mode for Wi-Fi tethering(0-b, 1-g, 2-a, 3-ad): ");
876         ret = scanf("%d", &type);
877
878         ret = tethering_wifi_set_mode(th, type);
879         if (__is_err(ret) == true) {
880                 printf("Fail to set mode!!\n");
881                 return -1;
882         }
883
884         return 1;
885 }
886
887 static int test_tethering_wifi_enable_dhcp(void)
888 {
889         int ret;
890         int enable;
891
892         printf("Input (0-Disable, 1-Enable): ");
893         ret = scanf("%d", &enable);
894
895         ret = tethering_wifi_enable_dhcp(th, enable);
896         if (__is_err(ret) == true) {
897                 printf("Fail to enable dhcp server!!\n");
898                 return -1;
899         }
900
901         return 1;
902 }
903
904 static int test_tethering_wifi_set_dhcp_range(void)
905 {
906         int ret;
907         char rangestart[16], rangestop[16];
908
909         printf("Input range (ex: 192.168.0.50 192.168.0.150): ");
910
911         ret = scanf("%15s %15s", rangestart, rangestop);
912
913         ret = tethering_wifi_set_dhcp_range(th, rangestart, rangestop);
914         if (__is_err(ret) == true) {
915                 printf("Fail to set dhcp range and enable dhcp server!!\n");
916                 return -1;
917         }
918
919         return 1;
920 }
921
922 static int test_tethering_wifi_is_dhcp_enabled(void)
923 {
924         int ret;
925         bool enabled;
926
927         ret = tethering_wifi_is_dhcp_enabled(th, &enabled);
928
929         if (__is_err(ret) == true) {
930                 printf("Fail to get dhcp server status!!\n");
931                 return -1;
932         } else {
933                 printf("DHCP server is %s\n", enabled ? "enabled" : "disabled");
934         }
935
936         return 1;
937 }
938
939 static int test_tethering_wifi_set_mac_filtering(void)
940 {
941         int ret;
942         int enable;
943
944         printf("Input mac filtering option (0: disable, 1: enable): ");
945         ret = scanf("%d", &enable);
946
947         ret = tethering_wifi_set_mac_filter(th, enable);
948         if (__is_err(ret) == true) {
949                 printf("Fail to set mac filtering!!\n");
950                 return -1;
951         }
952
953         return 1;
954 }
955
956 static int test_tethering_manage_mac_list(void)
957 {
958         int ret = 0;
959         int list, option;
960         char mac[100];
961
962         printf("Select MAC list to modify (0: allowed mac list, 1: blocked mac list): ");
963         ret = scanf("%d", &list);
964
965         printf("Select option (0: Add, 1: Remove): ");
966         ret = scanf("%d", &option);
967
968         printf("Input MAC Address to add/remove allowed/blocked mac list: ");
969         ret = scanf("%99s", mac);
970         if (ret < 0) {
971                 printf("scanf is failed!!\n");
972                 return -1;
973         }
974
975         if (!list && !option) {
976                 /* Add to allowed mac list*/
977                 ret = tethering_wifi_add_allowed_mac_list(th, mac);
978         } else if (!list && option) {
979                 /* Remove from allowed mac list */
980                 ret = tethering_wifi_remove_allowed_mac_list(th, mac);
981         } else if (list && !option) {
982                 /* Add to blocked mac list */
983                 ret = tethering_wifi_add_blocked_mac_list(th, mac);
984         } else if (list && option) {
985                 /* Remove from blocked mac list */
986                 ret = tethering_wifi_remove_blocked_mac_list(th, mac);
987         } else {
988                 printf("Input failed!!\n");
989                 return -1;
990         }
991
992         if (ret < 0)
993                 return -1;
994
995         return 1;
996 }
997
998 static int test_tethering_get_mac_list(void)
999 {
1000         int ret = 0;
1001         int list = 0;
1002         void *mac_list = NULL;
1003
1004         printf("Select MAC list to get (0: allowed mac list, 1: blocked mac list): ");
1005         ret = scanf("%d", &list);
1006
1007         switch (list) {
1008         case 0:
1009                 ret = tethering_wifi_get_allowed_mac_list(th, &mac_list);
1010                 break;
1011         case 1:
1012                 ret = tethering_wifi_get_blocked_mac_list(th, &mac_list);
1013                 break;
1014         default:
1015                 printf("Input failed!!\n");
1016                 break;
1017         }
1018
1019         if (ret < 0)
1020                 return -1;
1021
1022         __display_list(mac_list);
1023
1024         return 1;
1025 }
1026
1027 static int test_tethering_wifi_reload_settings(void)
1028 {
1029         int ret = tethering_wifi_reload_settings(th, __settings_reloaded_cb, NULL);
1030
1031         if (__is_err(ret) == true) {
1032                 printf("Fail to reload wifi tethering!!\n");
1033                 return -1;
1034         }
1035         return 1;
1036 }
1037
1038 static int test_tethering_wifi_get_txpower(void)
1039 {
1040         int ret = TETHERING_ERROR_NONE;
1041
1042         unsigned int txpower = 0;
1043         ret = tethering_wifi_get_txpower(th, &txpower);
1044         if (__is_err(ret) == true) {
1045                 printf("Fail to get txpower!!\n");
1046                 return -1;
1047         }
1048         g_print("tethering_hostapd_get_txpower received [%d]\n", txpower);
1049         return 1;
1050 }
1051
1052 static int test_tethering_wifi_set_txpower(void)
1053 {
1054         int ret;
1055         unsigned int txpower = 0;
1056
1057         printf("Input tx power for Wi-Fi tethering: ");
1058         ret = scanf("%d", &txpower);
1059
1060         ret = tethering_wifi_set_txpower(th, txpower);
1061         if (__is_err(ret) == true) {
1062                 printf("Fail to set txpower!!\n");
1063                 return -1;
1064         }
1065
1066         return 1;
1067 }
1068
1069 static int test_tethering_wifi_set_mtu(void)
1070 {
1071         int ret;
1072         unsigned int mtu = 0;
1073
1074         printf("Input mtu for Wi-Fi tethering: ");
1075         ret = scanf("%d", &mtu);
1076
1077         ret = tethering_wifi_set_mtu(th, mtu);
1078         if (__is_err(ret) == true) {
1079                 printf("Fail to set mtu!!\n");
1080                 return -1;
1081         }
1082
1083         return 1;
1084 }
1085
1086 static int test_tethering_wifi_change_mac(void)
1087 {
1088         int ret;
1089         char mac[18];
1090
1091         printf("Input mac address: ");
1092         ret = scanf("%17s", mac);
1093
1094         ret = tethering_wifi_change_mac(th, mac);
1095         if (__is_err(ret) == true) {
1096                 printf("Fail to change mac!\n");
1097                 return -1;
1098         }
1099
1100         return 1;
1101 }
1102
1103 static int test_tethering_wifi_set_max_connected_device(void)
1104 {
1105         int ret;
1106         int max_connected;
1107
1108         printf("Input max connected device: ");
1109         ret = scanf("%d", &max_connected);
1110
1111         ret = tethering_wifi_set_max_connected_device(th, max_connected);
1112         if (__is_err(ret) == true) {
1113                 printf("Fail to set max connected device!\n");
1114                 return -1;
1115         }
1116
1117         return 1;
1118
1119 }
1120
1121 static int test_tethering_wifi_enable_port_forwarding(void)
1122 {
1123         int ret;
1124         int enable = false;
1125
1126         printf("Wi-Fi tethring port forwarding(0:disable 1:enable): ");
1127         ret = scanf("%d", &enable);
1128
1129         ret = tethering_wifi_enable_port_forwarding(th, enable);
1130         if (__is_err(ret) == true) {
1131                 printf("Fail to enable port forwarding!\n");
1132                 return -1;
1133         }
1134
1135         return 1;
1136 }
1137
1138 static int test_tethering_wifi_add_port_forwarding_rule(void)
1139 {
1140         int ret;
1141         char ifname[20];
1142         char proto[20];
1143         char org_ip[16];
1144         char final_ip[16];
1145         int org_port, final_port;
1146
1147         printf("Input ifname, protocol, original ip/port, final ip/port: ");
1148         ret = scanf("%19s", ifname);
1149         ret = scanf("%19s", proto);
1150         ret = scanf("%15s", org_ip);
1151         ret = scanf("%d", &org_port);
1152         ret = scanf("%15s", final_ip);
1153         ret = scanf("%d", &final_port);
1154
1155         ret = tethering_wifi_add_port_forwarding_rule(th, ifname, proto, org_ip, org_port, final_ip, final_port);
1156         if (__is_err(ret) == true) {
1157                 printf("Fail to add port forwarding rule!\n");
1158                 return -1;
1159         }
1160
1161         return 1;
1162 }
1163
1164 static int test_tethering_wifi_reset_port_forwarding_rule(void)
1165 {
1166         int ret;
1167
1168         ret = tethering_wifi_reset_port_forwarding_rule(th);
1169         if (__is_err(ret) == true) {
1170                 printf("Fail to reset port forwarding rule!\n");
1171                 return -1;
1172         }
1173
1174         return 1;
1175 }
1176
1177 static int test_tethering_wifi_get_port_forwarding_rule(void)
1178 {
1179         int ret = 0;
1180         void *pf_list = NULL;
1181
1182         ret = tethering_wifi_get_port_forwarding_rule(th, &pf_list);
1183         if (__is_err(ret) == true) {
1184                 printf("Fail to get port forwarding rule!\n");
1185                 return -1;
1186         }
1187
1188         __display_list(pf_list);
1189
1190         return 1;
1191 }
1192
1193 static int test_tethering_wifi_enable_port_filtering(void)
1194 {
1195         int ret;
1196         int enable = false;
1197
1198         printf("Wi-Fi tethring port filtering(0:disable 1:enable): ");
1199         ret = scanf("%d", &enable);
1200
1201         ret = tethering_wifi_enable_port_filtering(th, enable);
1202         if (__is_err(ret) == true) {
1203                 printf("Fail to enable port filtering!\n");
1204                 return -1;
1205         }
1206
1207         return 1;
1208 }
1209
1210 static int test_tethering_wifi_add_port_filtering_rule(void)
1211 {
1212         int ret;
1213         char proto[20];
1214         int port;
1215         int allow;
1216
1217         printf("Input protocol, port, allow: ");
1218         ret = scanf("%19s", proto);
1219         ret = scanf("%d", &port);
1220         ret = scanf("%d", &allow);
1221
1222         ret = tethering_wifi_add_port_filtering_rule(th, port, proto, allow);
1223         if (__is_err(ret) == true) {
1224                 printf("Fail to add port forwarding rule!\n");
1225                 return -1;
1226         }
1227
1228         return 1;
1229 }
1230
1231 static int test_tethering_wifi_add_custom_port_filtering_rule(void)
1232 {
1233         int ret;
1234         char proto[20];
1235         int port1, port2;
1236         int allow;
1237
1238         printf("Input protocol, port1, port2, allow: ");
1239         ret = scanf("%19s", proto);
1240         ret = scanf("%d", &port1);
1241         ret = scanf("%d", &port2);
1242         ret = scanf("%d", &allow);
1243
1244         ret = tethering_wifi_add_custom_port_filtering_rule(th, port1, port2, proto, allow);
1245         if (__is_err(ret) == true) {
1246                 printf("Fail to add custom port forwarding rule!\n");
1247                 return -1;
1248         }
1249
1250         return 1;
1251 }
1252
1253 static int test_tethering_wifi_get_port_filtering_rule(void)
1254 {
1255         int ret = 0;
1256         void *pf_list = NULL;
1257
1258         ret = tethering_wifi_get_port_filtering_rule(th, &pf_list);
1259         if (__is_err(ret) == true) {
1260                 printf("Fail to get port filtering rule!\n");
1261                 return -1;
1262         }
1263
1264         __display_list(pf_list);
1265
1266         return 1;
1267 }
1268
1269 static int test_tethering_wifi_get_custom_port_filtering_rule(void)
1270 {
1271         int ret = 0;
1272         void *pf_list = NULL;
1273
1274         ret = tethering_wifi_get_custom_port_filtering_rule(th, &pf_list);
1275         if (__is_err(ret) == true) {
1276                 printf("Fail to get port filtering rule!\n");
1277                 return -1;
1278         }
1279
1280         __display_list(pf_list);
1281
1282         return 1;
1283 }
1284
1285 static int test_tethering_wifi_set_vpn_passthrough_rule(void)
1286 {
1287         int ret = 0;
1288         int type;
1289
1290         printf("Select vpn passthrough type (0:IPSEC 1:PPTP 2:L2TP): ");
1291         ret = scanf("%d", &type);
1292
1293         ret = tethering_wifi_set_vpn_passthrough_rule(th, (tethering_vpn_passthrough_type_e)type, true);
1294         if (__is_err(ret) == true) {
1295                 printf("Fail to get port filtering rule!\n");
1296                 return -1;
1297         }
1298
1299         return 1;
1300 }
1301
1302 static int test_tethering_wifi_push_wps_button(void)
1303 {
1304         int ret = 0;
1305
1306         ret = tethering_wifi_push_wps_button(th);
1307         if (__is_err(ret) == true) {
1308                 printf("Fail to get port filtering rule!\n");
1309                 return -1;
1310         }
1311
1312         return 1;
1313 }
1314
1315 static int test_tethering_wifi_set_wps_pin(void)
1316 {
1317         int ret = 0;
1318         char wps_pin[128];
1319
1320         printf("Input WPS PIN: ");
1321         ret = scanf("%127s", wps_pin);
1322
1323         ret = tethering_wifi_set_wps_pin(th, wps_pin);
1324         if (__is_err(ret) == true) {
1325                 printf("Fail to get port filtering rule!\n");
1326                 return -1;
1327         }
1328
1329         return 1;
1330 }
1331
1332 int main(int argc, char **argv)
1333 {
1334         GMainLoop *mainloop;
1335
1336 #if !GLIB_CHECK_VERSION(2, 36, 0)
1337         g_type_init();
1338 #endif
1339         mainloop = g_main_loop_new(NULL, false);
1340
1341         GIOChannel *channel = g_io_channel_unix_new(0);
1342         g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
1343         printf("Test Thread created...\n");
1344         g_main_loop_run(mainloop);
1345
1346         return 0;
1347 }
1348
1349 gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
1350 {
1351         int rv;
1352         char a[10];
1353
1354         printf("Event received from stdin\n");
1355
1356         rv = read(0, a, 10);
1357
1358         if (rv <= 0 || a[0] == '0')
1359                 exit(1);
1360
1361         if (a[0] == '\n' || a[0] == '\r') {
1362                 printf("\n\n Network Connection API Test App\n\n");
1363                 printf("Options..\n");
1364                 printf("1       - Tethering create and set callbacks\n");
1365                 printf("2       - Tethering destroy\n");
1366                 printf("3       - Enable Tethering\n");
1367                 printf("4       - Disable Tethering\n");
1368                 printf("5       - Get client information\n");
1369                 printf("6       - Get interface information\n");
1370                 printf("7       - Get data usage\n");
1371                 printf("8       - Get Wi-Fi tethering setting\n");
1372                 printf("a       - Set Wi-Fi tethering SSID\n");
1373                 printf("b       - Set Wi-Fi tethering security type\n");
1374                 printf("c       - Set Wi-Fi tethering visibility\n");
1375                 printf("d       - Set Wi-Fi tethering passphrase\n");
1376                 printf("e       - Set Wi-Fi tethering mac filtering\n");
1377                 printf("f       - Add/Remove MAC adress to/from allowed/blocked list\n");
1378                 printf("g       - Get allowed/blocked list\n");
1379                 printf("k       - Reload Wi-Fi tethering\n");
1380                 printf("m       - Set Wi-Fi channel\n");
1381                 printf("n       - Set Wi-Fi hw_mode\n");
1382                 printf("o       - Enable dhcp server\n");
1383                 printf("p       - Enable dhcp server with range\n");
1384                 printf("q       - Is dhcp server enabled?\n");
1385                 printf("r       - Get Wi-Fi txpower\n");
1386                 printf("s       - Set Wi-Fi txpower\n");
1387                 printf("t       - Set Wi-Fi mtu\n");
1388                 printf("u       - Change mac address\n");
1389                 printf("v       - Set max connected device(Wi-Fi tethering)\n");
1390                 printf("w       - Enable port forwarding\n");
1391                 printf("x       - Add port forwarding rule\n");
1392                 printf("y       - Reset port forwarding rule\n");
1393                 printf("z       - Get port forwarding rule\n");
1394                 printf("A       - Enable port filtering\n");
1395                 printf("B       - Add port filtering rule\n");
1396                 printf("C       - Add custom port filtering rule\n");
1397                 printf("D       - Get port filtering rule\n");
1398                 printf("E       - Get custom port filtering rule\n");
1399                 printf("F       - Set vpn passthrough rule\n");
1400                 printf("G       - Push WPS button\n");
1401                 printf("H       - Set WPS PIN\n");
1402                 printf("0       - \n");
1403                 printf("ENTER  - Show options menu.......\n");
1404         }
1405
1406         switch (a[0]) {
1407         case '1':
1408                 rv = test_tethering_create();
1409                 break;
1410         case '2':
1411                 rv = test_tethering_destroy();
1412                 break;
1413         case '3':
1414                 rv = test_tethering_enable();
1415                 break;
1416         case '4':
1417                 rv = test_tethering_disable();
1418                 break;
1419         case '5':
1420                 rv = test_tethering_get_client_info();
1421                 break;
1422         case '6':
1423                 rv = test_tethering_get_interface_info();
1424                 break;
1425         case '7':
1426                 rv = test_tethering_get_data_usage();
1427                 break;
1428         case '8':
1429                 rv = test_tethering_wifi_get_setting();
1430                 break;
1431         case 'a':
1432                 rv = test_tethering_wifi_set_ssid();
1433                 break;
1434         case 'b':
1435                 rv = test_tethering_wifi_set_security_type();
1436                 break;
1437         case 'c':
1438                 rv = test_tethering_wifi_set_visibility();
1439                 break;
1440         case 'd':
1441                 rv = test_tethering_wifi_set_passphrase();
1442                 break;
1443         case 'e':
1444                 rv = test_tethering_wifi_set_mac_filtering();
1445                 break;
1446         case 'f':
1447                 rv = test_tethering_manage_mac_list();
1448                 break;
1449         case 'g':
1450                 rv = test_tethering_get_mac_list();
1451                 break;
1452         case 'k':
1453                 rv = test_tethering_wifi_reload_settings();
1454                 break;
1455         case 'm':
1456                 rv = test_tethering_wifi_set_channel();
1457                 break;
1458         case 'n':
1459                 rv = test_tethering_wifi_set_mode();
1460                 break;
1461         case 'o':
1462                 rv = test_tethering_wifi_enable_dhcp();
1463                 break;
1464         case 'p':
1465                 rv = test_tethering_wifi_set_dhcp_range();
1466                 break;
1467         case 'q':
1468                 rv = test_tethering_wifi_is_dhcp_enabled();
1469                 break;
1470         case 'r':
1471                 rv = test_tethering_wifi_get_txpower();
1472                 break;
1473         case 's':
1474                 rv = test_tethering_wifi_set_txpower();
1475                 break;
1476         case 't':
1477                 rv = test_tethering_wifi_set_mtu();
1478                 break;
1479         case 'u':
1480                 rv = test_tethering_wifi_change_mac();
1481                 break;
1482         case 'v':
1483                 rv = test_tethering_wifi_set_max_connected_device();
1484                 break;
1485         case 'w':
1486                 rv = test_tethering_wifi_enable_port_forwarding();
1487                 break;
1488         case 'x':
1489                 rv = test_tethering_wifi_add_port_forwarding_rule();
1490                 break;
1491         case 'y':
1492                 rv = test_tethering_wifi_reset_port_forwarding_rule();
1493                 break;
1494         case 'z':
1495                 rv = test_tethering_wifi_get_port_forwarding_rule();
1496                 break;
1497         case 'A':
1498                 rv = test_tethering_wifi_enable_port_filtering();
1499                 break;
1500         case 'B':
1501                 rv = test_tethering_wifi_add_port_filtering_rule();
1502                 break;
1503         case 'C':
1504                 rv = test_tethering_wifi_add_custom_port_filtering_rule();
1505                 break;
1506         case 'D':
1507                 rv = test_tethering_wifi_get_port_filtering_rule();
1508                 break;
1509         case 'E':
1510                 rv = test_tethering_wifi_get_custom_port_filtering_rule();
1511                 break;
1512         case 'F':
1513                 rv = test_tethering_wifi_set_vpn_passthrough_rule();
1514                 break;
1515         case 'G':
1516                 rv = test_tethering_wifi_push_wps_button();
1517                 break;
1518         case 'H':
1519                 rv = test_tethering_wifi_set_wps_pin();
1520                 break;
1521         }
1522
1523         if (rv == 1)
1524                 printf("Operation succeeded!\n");
1525         else
1526                 printf("Operation failed!\n");
1527
1528         return true;
1529 }