Merge "Fix build failure" into tizen
[platform/core/api/connection.git] / src / connection.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 <glib.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <vconf/vconf.h>
22 #include <system_info.h>
23
24 #include "net_connection_private.h"
25
26 static __thread GSList *conn_handle_list = NULL;
27 static int tv_profile = -1; // Unknown
28
29 //LCOV_EXCL_START
30 static int __connection_convert_net_state(int status)
31 {
32         switch (status) {
33         case VCONFKEY_NETWORK_CELLULAR:
34                 return CONNECTION_TYPE_CELLULAR;
35         case VCONFKEY_NETWORK_WIFI:
36                 return CONNECTION_TYPE_WIFI;
37         case VCONFKEY_NETWORK_ETHERNET:
38                 return CONNECTION_TYPE_ETHERNET;
39         case VCONFKEY_NETWORK_BLUETOOTH:
40                 return CONNECTION_TYPE_BT;
41         case VCONFKEY_NETWORK_DEFAULT_PROXY:
42                 return CONNECTION_TYPE_NET_PROXY;
43         default:
44                 return CONNECTION_TYPE_DISCONNECTED;
45         }
46 }
47
48 static int __connection_convert_cellular_state(int status)
49 {
50         switch (status) {
51         case VCONFKEY_NETWORK_CELLULAR_ON:
52                 return CONNECTION_CELLULAR_STATE_AVAILABLE;
53         case VCONFKEY_NETWORK_CELLULAR_3G_OPTION_OFF:
54                 return CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE;
55         case VCONFKEY_NETWORK_CELLULAR_ROAMING_OFF:
56                 return CONNECTION_CELLULAR_STATE_ROAMING_OFF;
57         case VCONFKEY_NETWORK_CELLULAR_FLIGHT_MODE:
58                 return CONNECTION_CELLULAR_STATE_FLIGHT_MODE;
59         default:
60                 return CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE;
61         }
62 }
63
64 static bool __connection_check_handle_validity(connection_h connection)
65 {
66         bool ret = false;
67
68         if (connection == NULL)
69                 return false;
70
71         if (g_slist_find(conn_handle_list, connection) != NULL)
72                 ret = true;
73
74         return ret;
75 }
76
77 bool _connection_check_handle_validity(connection_h connection)
78 {
79         return __connection_check_handle_validity(connection);
80 }
81
82 static connection_type_changed_cb
83 __connection_get_type_changed_callback(connection_handle_s *local_handle)
84 {
85         return local_handle->type_changed_callback;
86 }
87
88 static void *__connection_get_type_changed_userdata(
89                                                         connection_handle_s *local_handle)
90 {
91         return local_handle->type_changed_user_data;
92 }
93
94 static void __connection_cb_type_change_cb(int type)
95 {
96         GSList *list;
97         connection_h handle;
98         void *data;
99         connection_type_changed_cb callback;
100         int state;
101
102         if (_connection_is_created() != true) {
103                 CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
104                                 "If multi-threaded, thread integrity be broken.");
105                 return;
106         }
107
108         state = __connection_convert_net_state(type);
109
110         for (list = conn_handle_list; list; list = list->next) {
111                 handle = (connection_h)list->data;
112
113                 callback = __connection_get_type_changed_callback(handle);
114                 data = __connection_get_type_changed_userdata(handle);
115                 if (callback)
116                         callback(state, data);
117         }
118 }
119
120 static void __connection_cb_ethernet_cable_state_changed_cb(connection_ethernet_cable_state_e state)
121 {
122         CONNECTION_LOG(CONNECTION_INFO, "Ethernet Cable state Indication");
123
124         GSList *list;
125
126         for (list = conn_handle_list; list; list = list->next) {
127                 connection_handle_s *local_handle = (connection_handle_s *)list->data;
128                 if (local_handle->ethernet_cable_state_changed_callback)
129                         local_handle->ethernet_cable_state_changed_callback(state,
130                                         local_handle->ethernet_cable_state_changed_user_data);
131         }
132 }
133
134 static int __connection_get_ethernet_cable_state_changed_callback_count(void)
135 {
136         GSList *list;
137         int count = 0;
138
139         for (list = conn_handle_list; list; list = list->next) {
140                 connection_handle_s *local_handle = (connection_handle_s *)list->data;
141                 if (local_handle->ethernet_cable_state_changed_callback) count++;
142         }
143
144         return count;
145 }
146
147 static int __connection_set_type_changed_callback(connection_h connection,
148                                                         void *callback, void *user_data)
149 {
150         static __thread gint refcount = 0;
151         connection_handle_s *local_handle;
152
153         local_handle = (connection_handle_s *)connection;
154
155         if (callback) {
156                 if (refcount == 0)
157                         _connection_libnet_set_type_changed_cb(
158                                                            __connection_cb_type_change_cb);
159
160                 refcount++;
161                 CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
162                                            refcount);
163         } else {
164                 if (refcount > 0 &&
165                                 __connection_get_type_changed_callback(local_handle) != NULL) {
166                         if (--refcount == 0) {
167                                 _connection_libnet_set_type_changed_cb(NULL);
168                                 CONNECTION_LOG(CONNECTION_INFO,
169                                                 "Successfully de-registered(%d)", refcount);
170                         }
171                 }
172         }
173
174         local_handle->type_changed_user_data = user_data;
175         local_handle->type_changed_callback = callback;
176
177         return CONNECTION_ERROR_NONE;
178 }
179
180 static connection_address_changed_cb
181 __connection_get_ip_changed_callback(connection_handle_s *local_handle)
182 {
183         return local_handle->ip_changed_callback;
184 }
185
186 static void *__connection_get_ip_changed_userdata(
187                                                         connection_handle_s *local_handle)
188 {
189         return local_handle->ip_changed_user_data;
190 }
191
192 static void __connection_cb_ip_change_cb(
193                          connection_address_family_e addr_family, char *ip_addr)
194 {
195         GSList *list;
196         connection_h handle;
197         char *ip4_addr = NULL;
198         char *ip6_addr = NULL;
199         void *data;
200         connection_address_changed_cb callback;
201
202         if (_connection_is_created() != true) {
203                 CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
204                                 "If multi-threaded, thread integrity be broken.");
205                 return;
206         }
207
208         switch (addr_family) {
209         case CONNECTION_ADDRESS_FAMILY_IPV4:
210                 ip4_addr = g_strdup(ip_addr);
211
212                 ip6_addr = vconf_get_str(VCONFKEY_NETWORK_IP6);
213                 if (ip6_addr == NULL)
214                         CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
215                                                    "vconf_get_str(VCONFKEY_NETWORK_IP6) failed");
216                 break;
217         case CONNECTION_ADDRESS_FAMILY_IPV6:
218                 ip6_addr = g_strdup(ip_addr);
219
220                 ip4_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
221                 if (ip4_addr == NULL)
222                         CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
223                                                    "vconf_get_str(VCONFKEY_NETWORK_IP) failed");
224                 break;
225         default:
226                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid Address Type");
227                 return;
228         }
229
230         for (list = conn_handle_list; list; list = list->next) {
231                 handle = (connection_h)list->data;
232
233                 callback = __connection_get_ip_changed_callback(handle);
234                 data = __connection_get_ip_changed_userdata(handle);
235
236                 if (callback)
237                         callback(ip4_addr, ip6_addr, data);
238         }
239
240         g_free(ip4_addr);
241         g_free(ip6_addr);
242 }
243
244 static int __connection_set_ip_changed_callback(connection_h connection,
245                                                         void *callback, void *user_data)
246 {
247         static __thread gint refcount = 0;
248         connection_handle_s *local_handle;
249
250         local_handle = (connection_handle_s *)connection;
251
252         if (callback) {
253                 if (refcount == 0)
254                         _connection_libnet_set_ip_changed_cb(
255                                                            __connection_cb_ip_change_cb);
256
257                 refcount++;
258                 CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
259                                            refcount);
260         } else {
261                 if (refcount > 0 &&
262                                 __connection_get_ip_changed_callback(local_handle) != NULL) {
263                         if (--refcount == 0) {
264                                 _connection_libnet_set_ip_changed_cb(NULL);
265                                 CONNECTION_LOG(CONNECTION_INFO,
266                                                            "Successfully de-registered(%d)", refcount);
267                         }
268                 }
269         }
270
271         local_handle->ip_changed_user_data = user_data;
272         local_handle->ip_changed_callback = callback;
273
274         return CONNECTION_ERROR_NONE;
275 }
276
277 static connection_address_changed_cb
278 __connection_get_proxy_changed_callback(connection_handle_s *local_handle)
279 {
280         return local_handle->proxy_changed_callback;
281 }
282
283 static void *__connection_get_proxy_changed_userdata(
284                                                         connection_handle_s *local_handle)
285 {
286         return local_handle->proxy_changed_user_data;
287 }
288
289 static void __connection_cb_proxy_change_cb(char *proxy_addr)
290 {
291         GSList *list;
292         connection_h handle;
293         void *data;
294         connection_address_changed_cb callback;
295
296         if (_connection_is_created() != true) {
297                 CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
298                                 "If multi-threaded, thread integrity be broken.");
299                 return;
300         }
301
302         for (list = conn_handle_list; list; list = list->next) {
303                 handle = (connection_h)list->data;
304
305                 callback = __connection_get_proxy_changed_callback(handle);
306                 data = __connection_get_proxy_changed_userdata(handle);
307                 /* TODO: IPv6 should be supported */
308                 if (callback)
309                         callback(proxy_addr, NULL, data);
310         }
311 }
312
313 static int __connection_set_proxy_changed_callback(connection_h connection,
314                                                         void *callback, void *user_data)
315 {
316         static __thread gint refcount = 0;
317         connection_handle_s *local_handle;
318
319         local_handle = (connection_handle_s *)connection;
320
321         if (callback) {
322                 if (refcount == 0)
323                         _connection_libnet_set_proxy_changed_cb(
324                                 __connection_cb_proxy_change_cb);
325
326                 refcount++;
327                 CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)",
328                                            refcount);
329         } else {
330                 if (refcount > 0 &&
331                                 __connection_get_proxy_changed_callback(local_handle) != NULL) {
332                         if (--refcount == 0) {
333                                 _connection_libnet_set_proxy_changed_cb(NULL);
334                                 CONNECTION_LOG(CONNECTION_INFO,
335                                                 "Successfully de-registered(%d)", refcount);
336                         }
337                 }
338         }
339
340         local_handle->proxy_changed_user_data = user_data;
341         local_handle->proxy_changed_callback = callback;
342
343         return CONNECTION_ERROR_NONE;
344 }
345
346 static int __connection_set_ethernet_cable_state_changed_cb(connection_h connection,
347                 connection_ethernet_cable_state_changed_cb callback, void *user_data)
348 {
349         connection_handle_s *local_handle = (connection_handle_s *)connection;
350
351         if (callback) {
352                 if (__connection_get_ethernet_cable_state_changed_callback_count() == 0)
353                         _connection_libnet_set_ethernet_cable_state_changed_cb(
354                                         __connection_cb_ethernet_cable_state_changed_cb);
355
356         } else {
357                 if (__connection_get_ethernet_cable_state_changed_callback_count() == 1 &&
358                                   local_handle->ethernet_cable_state_changed_callback)
359                         _connection_libnet_set_ethernet_cable_state_changed_cb(NULL);
360         }
361
362         local_handle->ethernet_cable_state_changed_callback = callback;
363         local_handle->ethernet_cable_state_changed_user_data = user_data;
364         return CONNECTION_ERROR_NONE;
365 }
366 //LCOV_EXCL_STOP
367
368 static int __connection_get_handle_count(void)
369 {
370         return ((int)g_slist_length(conn_handle_list));
371 }
372
373 /* Connection Manager ********************************************************/
374 EXPORT_API int connection_create(connection_h *connection)
375 {
376         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
377
378         if (connection == NULL || __connection_check_handle_validity(*connection)) {
379                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
380                 return CONNECTION_ERROR_INVALID_PARAMETER;
381         }
382
383         int rv = _connection_libnet_init();
384         if (rv == NET_ERR_ACCESS_DENIED) {
385                 CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
386                 return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
387         } else if (rv != NET_ERR_NONE) {
388                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to create connection[%d]", rv); //LCOV_EXCL_LINE
389                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
390         }
391
392         *connection = g_try_malloc0(sizeof(connection_handle_s));
393         if (*connection != NULL)
394                 CONNECTION_LOG(CONNECTION_INFO, "New handle created[%p]", *connection);
395         else
396                 return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
397
398         conn_handle_list = g_slist_prepend(conn_handle_list, *connection);
399
400         return CONNECTION_ERROR_NONE;
401 }
402
403 EXPORT_API int connection_destroy(connection_h connection)
404 {
405         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
406
407         if (!(__connection_check_handle_validity(connection))) {
408                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
409                 return CONNECTION_ERROR_INVALID_PARAMETER;
410         }
411
412         CONNECTION_LOG(CONNECTION_INFO, "Destroy handle: %p", connection);
413
414         __connection_set_type_changed_callback(connection, NULL, NULL);
415         __connection_set_ip_changed_callback(connection, NULL, NULL);
416         __connection_set_proxy_changed_callback(connection, NULL, NULL);
417         __connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL);
418
419         conn_handle_list = g_slist_remove(conn_handle_list, connection);
420
421         g_free(connection);
422         connection = NULL;
423
424         if (__connection_get_handle_count() == 0) {
425                 _connection_libnet_deinit();
426                 _connection_callback_cleanup();
427         }
428
429         return CONNECTION_ERROR_NONE;
430 }
431
432 EXPORT_API int connection_create_cs(int tid, connection_h *connection)
433 {
434         int rv;
435
436         rv = connection_create(connection);
437
438         if (rv == CONNECTION_ERROR_NONE)
439                 _connection_set_cs_tid(tid);
440
441         return rv;
442 }
443
444 EXPORT_API int connection_destroy_cs(int tid, connection_h connection)
445 {
446         int rv;
447
448         _connection_unset_cs_tid(tid);
449         rv = connection_destroy(connection);
450
451         return rv;
452 }
453
454 EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type)
455 {
456         int rv = 0;
457         int status = 0;
458
459         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
460
461         if (type == NULL || !(__connection_check_handle_validity(connection))) {
462                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
463                 return CONNECTION_ERROR_INVALID_PARAMETER;
464         }
465
466         rv = vconf_get_int(VCONFKEY_NETWORK_STATUS, &status);
467         if (rv != VCONF_OK) {
468                 CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d", status); //LCOV_EXCL_LINE
469                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
470         }
471
472         CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d", status);
473
474         *type = __connection_convert_net_state(status);
475
476         return CONNECTION_ERROR_NONE;
477 }
478
479 EXPORT_API int connection_get_ip_address(connection_h connection,
480                                 connection_address_family_e address_family, char** ip_address)
481 {
482         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
483
484         if (ip_address == NULL || !(__connection_check_handle_validity(connection))) {
485                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
486                 return CONNECTION_ERROR_INVALID_PARAMETER;
487         }
488
489         switch (address_family) {
490         case CONNECTION_ADDRESS_FAMILY_IPV4:
491                 *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP);
492                 break;
493         case CONNECTION_ADDRESS_FAMILY_IPV6:
494                 *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP6);
495                 break;
496         default:
497                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
498                 return CONNECTION_ERROR_INVALID_PARAMETER;
499         }
500
501         if (*ip_address == NULL) {
502                 CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed"); //LCOV_EXCL_LINE
503                 return CONNECTION_ERROR_OPERATION_FAILED;//LCOV_EXCL_LINE
504         }
505
506         return CONNECTION_ERROR_NONE;
507 }
508
509 EXPORT_API int connection_get_proxy(connection_h connection,
510                                 connection_address_family_e address_family, char** proxy)
511 {
512         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
513
514         if (proxy == NULL || !(__connection_check_handle_validity(connection))) {
515                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
516                 return CONNECTION_ERROR_INVALID_PARAMETER;
517         }
518
519         switch (address_family) {
520         case CONNECTION_ADDRESS_FAMILY_IPV4:
521         case CONNECTION_ADDRESS_FAMILY_IPV6:
522                 *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
523                 break;
524         default:
525                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
526                 return CONNECTION_ERROR_INVALID_PARAMETER;
527         }
528
529         if (*proxy == NULL) {
530                 CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed"); //LCOV_EXCL_LINE
531                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
532         }
533
534         return CONNECTION_ERROR_NONE;
535 }
536
537 EXPORT_API int connection_get_mac_address(connection_h connection, connection_type_e type, char** mac_addr)
538 {
539         FILE *fp;
540         char buf[CONNECTION_MAC_INFO_LENGTH + 1];
541
542         CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, ETHERNET_FEATURE);
543
544         if (type == CONNECTION_TYPE_WIFI)
545                 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
546         else if (type == CONNECTION_TYPE_ETHERNET) //LCOV_EXCL_LINE
547                 CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE); //LCOV_EXCL_LINE
548
549         if (mac_addr == NULL || !(__connection_check_handle_validity(connection))) {
550                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
551                 return CONNECTION_ERROR_INVALID_PARAMETER;
552         }
553
554         switch (type) {
555         case CONNECTION_TYPE_WIFI:
556                 if (__builtin_expect(tv_profile == -1, 0)) {
557                         char *profileName;
558                         system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
559                         if (*profileName == 't' || *profileName == 'T')
560                                 tv_profile = 1;
561                         else
562                                 tv_profile = 0;
563                         free(profileName);
564                 }
565                 if (tv_profile == 1) {
566                         fp = fopen(WIFI_MAC_INFO_FILE, "r");
567                         if (fp == NULL) {
568                                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
569                                 return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
570                         }
571
572                         if (fgets(buf, sizeof(buf), fp) == NULL) {
573                                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE); //LCOV_EXCL_LINE
574                                 fclose(fp); //LCOV_EXCL_LINE
575                                 return CONNECTION_ERROR_OPERATION_FAILED;
576                         }
577
578                         CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
579
580                         *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
581                         if (*mac_addr == NULL) {
582                                 CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed"); //LCOV_EXCL_LINE
583                                 fclose(fp); //LCOV_EXCL_LINE
584                                 return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
585                         }
586                         g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
587                         fclose(fp);
588                 } else {
589                         *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
590
591                         if (*mac_addr == NULL) {
592                                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); //LCOV_EXCL_LINE
593                                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
594                         }
595                 }
596                 break;
597         //LCOV_EXCL_START
598         case CONNECTION_TYPE_ETHERNET:
599                 fp = fopen(ETHERNET_MAC_INFO_FILE, "r");
600                 if (fp == NULL) {
601                         CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", ETHERNET_MAC_INFO_FILE);
602                         return CONNECTION_ERROR_OUT_OF_MEMORY;
603                 }
604
605                 if (fgets(buf, sizeof(buf), fp) == NULL) {
606                         CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", ETHERNET_MAC_INFO_FILE);
607                         fclose(fp);
608                         return CONNECTION_ERROR_OPERATION_FAILED;
609                 }
610
611                 CONNECTION_LOG(CONNECTION_INFO, "%s : %s", ETHERNET_MAC_INFO_FILE, buf);
612
613                 *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
614                 if (*mac_addr == NULL) {
615                         CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed");
616                         fclose(fp);
617                         return CONNECTION_ERROR_OUT_OF_MEMORY;
618                 }
619
620                 g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
621                 fclose(fp);
622
623                 break;
624         //LCOV_EXCL_STOP
625         default:
626                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
627                 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
628         }
629
630         /* Checking Invalid MAC Address */
631         if ((strcmp(*mac_addr, "00:00:00:00:00:00") == 0) ||
632                         (strcmp(*mac_addr, "ff:ff:ff:ff:ff:ff") == 0)) {
633                 CONNECTION_LOG(CONNECTION_ERROR, "MAC Address(%s) is invalid", *mac_addr); //LCOV_EXCL_LINE
634                 return CONNECTION_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE
635         }
636
637         CONNECTION_LOG(CONNECTION_INFO, "MAC Address %s", *mac_addr);
638
639         return CONNECTION_ERROR_NONE;
640 }
641
642
643 EXPORT_API int connection_is_metered_network(connection_h connection, bool* is_metered)
644 {
645         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
646
647         if (is_metered == NULL || !(__connection_check_handle_validity(connection))) {
648                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
649                 return CONNECTION_ERROR_INVALID_PARAMETER;
650         }
651
652         int rv = _connection_libnet_get_metered_state(is_metered);
653         if (rv != CONNECTION_ERROR_NONE) {
654                 CONNECTION_LOG(CONNECTION_ERROR, "Fail to get metered state[%d]", rv); //LCOV_EXCL_LINE
655                 return rv; //LCOV_EXCL_LINE
656         }
657
658         CONNECTION_LOG(CONNECTION_INFO, "metered state: %s", is_metered ? "true" : "false");
659         return CONNECTION_ERROR_NONE;
660 }
661
662
663 EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state)
664 {
665         int rv = 0;
666         int status = 0;
667         int cellular_state = 0;
668 #if defined TIZEN_DUALSIM_ENABLE
669         int sim_id = 0;
670 #endif
671
672         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
673
674         if (state == NULL || !(__connection_check_handle_validity(connection))) {
675                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
676                 return CONNECTION_ERROR_INVALID_PARAMETER;
677         }
678
679         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &status);
680         if (rv != VCONF_OK) {
681                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state"); //LCOV_EXCL_LINE
682                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
683         }
684
685         CONNECTION_LOG(CONNECTION_INFO, "Cellular: %d", status);
686         *state = __connection_convert_cellular_state(status);
687
688         if (*state == CONNECTION_CELLULAR_STATE_AVAILABLE) {
689 #if defined TIZEN_DUALSIM_ENABLE
690                 rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
691                 if (rv != VCONF_OK) {
692                         CONNECTION_LOG(CONNECTION_ERROR,
693                                         "Failed to get default subscriber id", sim_id);
694                         return CONNECTION_ERROR_OPERATION_FAILED;
695                 }
696
697                 switch (sim_id) {
698                 case CONNECTION_CELLULAR_SUBSCRIBER_1:
699 #endif
700                         rv = vconf_get_int(VCONFKEY_DNET_STATE, &cellular_state);
701 #if defined TIZEN_DUALSIM_ENABLE
702                         break;
703
704                 case CONNECTION_CELLULAR_SUBSCRIBER_2:
705                         rv = vconf_get_int(VCONFKEY_DNET_STATE2, &cellular_state);
706                         break;
707
708                 default:
709                         CONNECTION_LOG(CONNECTION_ERROR, "Invalid subscriber id:%d", sim_id);
710                         return CONNECTION_ERROR_OPERATION_FAILED;
711                 }
712 #endif
713                 if (rv != VCONF_OK) {
714                         CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state"); //LCOV_EXCL_LINE
715                         return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
716                 }
717         }
718
719         CONNECTION_LOG(CONNECTION_INFO, "Cellular state: %d", cellular_state);
720
721         if (cellular_state == VCONFKEY_DNET_NORMAL_CONNECTED ||
722                         cellular_state == VCONFKEY_DNET_SECURE_CONNECTED ||
723                         cellular_state == VCONFKEY_DNET_TRANSFER)
724                 *state = CONNECTION_CELLULAR_STATE_CONNECTED;
725
726         return CONNECTION_ERROR_NONE;
727 }
728
729 EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state)
730 {
731         CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
732
733         if (state == NULL || !(__connection_check_handle_validity(connection))) {
734                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
735                 return CONNECTION_ERROR_INVALID_PARAMETER;
736         }
737
738         int rv = _connection_libnet_get_wifi_state(state);
739         if (rv != CONNECTION_ERROR_NONE) {
740                 CONNECTION_LOG(CONNECTION_ERROR, "Fail to get Wi-Fi state[%d]", rv); //LCOV_EXCL_LINE
741                 return rv; //LCOV_EXCL_LINE
742         }
743
744         CONNECTION_LOG(CONNECTION_INFO, "Wi-Fi state: %d", *state);
745
746         return CONNECTION_ERROR_NONE;
747 }
748
749 //LCOV_EXCL_START
750 EXPORT_API int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e *state)
751 {
752         CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
753
754         if (state == NULL || !(__connection_check_handle_validity(connection))) {
755                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
756                 return CONNECTION_ERROR_INVALID_PARAMETER;
757         }
758
759         return _connection_libnet_get_ethernet_state(state);
760 }
761
762 EXPORT_API int connection_get_ethernet_cable_state(connection_h connection, connection_ethernet_cable_state_e *state)
763 {
764         CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
765
766         if (state == NULL || !(__connection_check_handle_validity(connection))) {
767                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
768                 return CONNECTION_ERROR_INVALID_PARAMETER;
769         }
770
771         return _connection_libnet_get_ethernet_cable_state(state);
772 }
773
774 EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connection,
775                           connection_ethernet_cable_state_chaged_cb callback, void *user_data)
776 {
777         DEPRECATED_LOG(__FUNCTION__, "connection_set_ethernet_cable_state_changed_cb");
778         CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
779
780         if (callback == NULL || !(__connection_check_handle_validity(connection))) {
781                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
782                 return CONNECTION_ERROR_INVALID_PARAMETER;
783         }
784
785         DEPRECATED_LOG("connection_ethernet_cable_state_chaged_cb",
786                         "connection_ethernet_cable_state_changed_cb");
787
788         return __connection_set_ethernet_cable_state_changed_cb(connection,
789                         (connection_ethernet_cable_state_changed_cb)callback, user_data);
790 }
791
792 EXPORT_API int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection)
793 {
794         DEPRECATED_LOG(__FUNCTION__, "connection_unset_ethernet_cable_state_changed_cb");
795         CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
796
797         if (!(__connection_check_handle_validity(connection))) {
798                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
799                 return CONNECTION_ERROR_INVALID_PARAMETER;
800         }
801
802         return __connection_set_ethernet_cable_state_changed_cb(connection,
803                                                         NULL, NULL);
804 }
805
806 EXPORT_API int connection_set_ethernet_cable_state_changed_cb(connection_h connection,
807                           connection_ethernet_cable_state_changed_cb callback, void *user_data)
808 {
809         CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
810
811         if (callback == NULL || !(__connection_check_handle_validity(connection))) {
812                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
813                 return CONNECTION_ERROR_INVALID_PARAMETER;
814         }
815
816         return __connection_set_ethernet_cable_state_changed_cb(connection,
817                                                         callback, user_data);
818 }
819
820 EXPORT_API int connection_unset_ethernet_cable_state_changed_cb(connection_h connection)
821 {
822         CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
823
824         if (!(__connection_check_handle_validity(connection))) {
825                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
826                 return CONNECTION_ERROR_INVALID_PARAMETER;
827         }
828
829         return __connection_set_ethernet_cable_state_changed_cb(connection,
830                                                         NULL, NULL);
831 }
832 //LCOV_EXCL_STOP
833
834 EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_state_e *state)
835 {
836         CHECK_FEATURE_SUPPORTED(TETHERING_BLUETOOTH_FEATURE);
837
838         if (state == NULL || !(__connection_check_handle_validity(connection))) {
839                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
840                 return CONNECTION_ERROR_INVALID_PARAMETER;
841         }
842
843         return _connection_libnet_get_bluetooth_state(state);
844 }
845
846 EXPORT_API int connection_set_type_changed_cb(connection_h connection,
847                                         connection_type_changed_cb callback, void* user_data)
848 {
849         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
850
851         if (callback == NULL || !(__connection_check_handle_validity(connection))) {
852                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
853                 return CONNECTION_ERROR_INVALID_PARAMETER;
854         }
855
856         return __connection_set_type_changed_callback(connection, callback, user_data);
857 }
858
859 EXPORT_API int connection_unset_type_changed_cb(connection_h connection)
860 {
861         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
862
863         if (!(__connection_check_handle_validity(connection))) {
864                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
865                 return CONNECTION_ERROR_INVALID_PARAMETER;
866         }
867
868         return __connection_set_type_changed_callback(connection, NULL, NULL);
869 }
870
871 EXPORT_API int connection_set_ip_address_changed_cb(connection_h connection,
872                                 connection_address_changed_cb callback, void* user_data)
873 {
874         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
875
876         if (callback == NULL || !(__connection_check_handle_validity(connection))) {
877                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
878                 return CONNECTION_ERROR_INVALID_PARAMETER;
879         }
880
881         return __connection_set_ip_changed_callback(connection, callback, user_data);
882 }
883
884 EXPORT_API int connection_unset_ip_address_changed_cb(connection_h connection)
885 {
886         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
887
888         if (!(__connection_check_handle_validity(connection))) {
889                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
890                 return CONNECTION_ERROR_INVALID_PARAMETER;
891         }
892
893         return __connection_set_ip_changed_callback(connection, NULL, NULL);
894 }
895
896 EXPORT_API int connection_set_proxy_address_changed_cb(connection_h connection,
897                                 connection_address_changed_cb callback, void* user_data)
898 {
899         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
900
901         if (callback == NULL || !(__connection_check_handle_validity(connection))) {
902                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
903                 return CONNECTION_ERROR_INVALID_PARAMETER;
904         }
905
906         return __connection_set_proxy_changed_callback(connection, callback, user_data);
907 }
908
909 EXPORT_API int connection_unset_proxy_address_changed_cb(connection_h connection)
910 {
911         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
912
913         if (!(__connection_check_handle_validity(connection))) {
914                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
915                 return CONNECTION_ERROR_INVALID_PARAMETER;
916         }
917
918         return __connection_set_proxy_changed_callback(connection, NULL, NULL);
919 }
920
921 EXPORT_API int connection_add_profile(connection_h connection, connection_profile_h profile)
922 {
923         int rv = 0;
924         net_profile_info_t *profile_info = profile;
925
926         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
927
928         if (!(__connection_check_handle_validity(connection)) ||
929             !(_connection_libnet_check_profile_validity(profile))) {
930                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
931                 return CONNECTION_ERROR_INVALID_PARAMETER;
932         }
933
934         if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
935                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
936                 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
937         }
938
939         if (profile_info->ProfileInfo.Pdp.PSModemPath[0] != '/' ||
940                         strlen(profile_info->ProfileInfo.Pdp.PSModemPath) < 2) {
941                 CONNECTION_LOG(CONNECTION_ERROR, "Modem object path is NULL"); //LCOV_EXCL_LINE
942                 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
943         }
944
945         rv = net_add_profile(profile_info->ProfileInfo.Pdp.ServiceType,
946                                                         (net_profile_info_t*)profile);
947         if (rv == NET_ERR_ACCESS_DENIED) {
948                 CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
949                 return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
950         } else if (rv != NET_ERR_NONE) {
951                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to add profile[%d]", rv); //LCOV_EXCL_LINE
952                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
953         }
954
955         return CONNECTION_ERROR_NONE;
956 }
957
958 EXPORT_API int connection_remove_profile(connection_h connection, connection_profile_h profile)
959 {
960         int rv = 0;
961         net_profile_info_t *profile_info = profile;
962
963         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
964
965         if (!(__connection_check_handle_validity(connection)) ||
966                         !(_connection_libnet_check_profile_validity(profile))) {
967                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
968                 return CONNECTION_ERROR_INVALID_PARAMETER;
969         }
970
971         if (profile_info->profile_type != NET_DEVICE_CELLULAR &&
972                 profile_info->profile_type != NET_DEVICE_MESH &&
973             profile_info->profile_type != NET_DEVICE_WIFI) {
974                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
975                 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
976         }
977
978         rv = net_delete_profile(profile_info->ProfileName);
979         if (rv == NET_ERR_ACCESS_DENIED) {
980                 CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
981                 return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
982         } else if (rv != NET_ERR_NONE) {
983                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to delete profile[%d]", rv); //LCOV_EXCL_LINE
984                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
985         }
986
987         return CONNECTION_ERROR_NONE;
988 }
989
990 EXPORT_API int connection_update_profile(connection_h connection, connection_profile_h profile)
991 {
992         int rv = 0;
993         net_profile_info_t *profile_info = profile;
994
995         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
996
997         if (!(__connection_check_handle_validity(connection)) ||
998             !(_connection_libnet_check_profile_validity(profile))) {
999                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1000                 return CONNECTION_ERROR_INVALID_PARAMETER;
1001         }
1002
1003         rv = net_modify_profile(profile_info->ProfileName, (net_profile_info_t*)profile);
1004         if (rv == NET_ERR_ACCESS_DENIED) {
1005                 CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
1006                 return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
1007         } else if (rv != NET_ERR_NONE) {
1008                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to modify profile[%d]", rv); //LCOV_EXCL_LINE
1009                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
1010         }
1011
1012         return CONNECTION_ERROR_NONE;
1013 }
1014
1015 EXPORT_API int connection_get_profile_iterator(connection_h connection,
1016                 connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator)
1017 {
1018         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1019
1020         if (!(__connection_check_handle_validity(connection)) ||
1021             (type != CONNECTION_ITERATOR_TYPE_REGISTERED &&
1022              type != CONNECTION_ITERATOR_TYPE_CONNECTED &&
1023              type != CONNECTION_ITERATOR_TYPE_DEFAULT)) {
1024                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1025                 return CONNECTION_ERROR_INVALID_PARAMETER;
1026         }
1027
1028         return _connection_libnet_get_profile_iterator(type, profile_iterator);
1029 }
1030
1031 EXPORT_API int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator,
1032                                                         connection_profile_h* profile)
1033 {
1034         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1035
1036         return _connection_libnet_get_iterator_next(profile_iterator, profile);
1037 }
1038
1039 EXPORT_API bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator)
1040 {
1041         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1042
1043         return _connection_libnet_iterator_has_next(profile_iterator);
1044 }
1045
1046 EXPORT_API int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator)
1047 {
1048         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1049
1050         return _connection_libnet_destroy_iterator(profile_iterator);
1051 }
1052
1053 EXPORT_API int connection_get_current_profile(connection_h connection, connection_profile_h* profile)
1054 {
1055         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1056
1057         if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
1058                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1059                 return CONNECTION_ERROR_INVALID_PARAMETER;
1060         }
1061
1062         return _connection_libnet_get_current_profile(profile);
1063 }
1064
1065 EXPORT_API int connection_get_default_cellular_service_profile(
1066                 connection_h connection, connection_cellular_service_type_e type,
1067                 connection_profile_h *profile)
1068 {
1069         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
1070
1071         if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
1072                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1073                 return CONNECTION_ERROR_INVALID_PARAMETER;
1074         }
1075
1076         return _connection_libnet_get_cellular_service_profile(type, profile);
1077 }
1078
1079 EXPORT_API int connection_set_default_cellular_service_profile(connection_h connection,
1080                 connection_cellular_service_type_e type, connection_profile_h profile)
1081 {
1082         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
1083
1084         if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
1085                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1086                 return CONNECTION_ERROR_INVALID_PARAMETER;
1087         }
1088
1089         return _connection_libnet_set_cellular_service_profile_sync(type, profile);
1090 }
1091
1092 EXPORT_API int connection_set_default_cellular_service_profile_async(connection_h connection,
1093                 connection_cellular_service_type_e type, connection_profile_h profile,
1094                 connection_set_default_cb callback, void* user_data)
1095 {
1096         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
1097
1098         if (!(__connection_check_handle_validity(connection)) ||
1099             profile == NULL || callback == NULL) {
1100                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1101                 return CONNECTION_ERROR_INVALID_PARAMETER;
1102         }
1103
1104         return _connection_libnet_set_cellular_service_profile_async(type, profile, callback, user_data);
1105 }
1106
1107 EXPORT_API int connection_open_profile(connection_h connection, connection_profile_h profile,
1108                                         connection_opened_cb callback, void* user_data)
1109 {
1110         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE);
1111
1112         if (!(__connection_check_handle_validity(connection)) ||
1113             profile == NULL || callback == NULL) {
1114                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1115                 return CONNECTION_ERROR_INVALID_PARAMETER;
1116         }
1117
1118         return _connection_libnet_open_profile(profile, callback, user_data);
1119 }
1120
1121 EXPORT_API int connection_close_profile(connection_h connection, connection_profile_h profile,
1122                                         connection_closed_cb callback, void* user_data)
1123 {
1124         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE);
1125
1126         if (!(__connection_check_handle_validity(connection)) ||
1127             profile == NULL || callback == NULL) {
1128                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1129                 return CONNECTION_ERROR_INVALID_PARAMETER;
1130         }
1131
1132         return _connection_libnet_close_profile(profile, callback, user_data);
1133 }
1134
1135 EXPORT_API int connection_reset_profile(connection_h connection,
1136                                 connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data)
1137 {
1138         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
1139
1140         if (!(__connection_check_handle_validity(connection))) {
1141                 CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed");
1142                 return CONNECTION_ERROR_INVALID_PARAMETER;
1143         }
1144
1145         if (id < 0 || id > 1) {
1146                 CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed"); //LCOV_EXCL_LINE
1147                 return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
1148         }
1149
1150         return _connection_libnet_reset_profile(type, id, callback, user_data);
1151 }
1152
1153 EXPORT_API int connection_add_route(connection_h connection, const char* interface_name, const char* host_address)
1154 {
1155         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1156
1157         if (!(__connection_check_handle_validity(connection)) ||
1158             interface_name == NULL || host_address == NULL) {
1159                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1160                 return CONNECTION_ERROR_INVALID_PARAMETER;
1161         }
1162
1163         return _connection_libnet_add_route(interface_name, host_address);
1164 }
1165
1166 EXPORT_API int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address)
1167 {
1168         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1169
1170         if (!(__connection_check_handle_validity(connection)) ||
1171             interface_name == NULL || host_address == NULL) {
1172                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1173                 return CONNECTION_ERROR_INVALID_PARAMETER;
1174         }
1175
1176         return _connection_libnet_remove_route(interface_name, host_address);
1177 }
1178
1179 EXPORT_API int connection_add_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
1180 {
1181         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
1182
1183         if (!(__connection_check_handle_validity(connection)) ||
1184             interface_name == NULL || host_address == NULL) {
1185                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1186                 return CONNECTION_ERROR_INVALID_PARAMETER;
1187         }
1188
1189         return _connection_libnet_add_route_ipv6(interface_name, host_address, gateway);
1190 }
1191
1192 EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
1193 {
1194         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
1195
1196         if (!(__connection_check_handle_validity(connection)) ||
1197             interface_name == NULL || host_address == NULL) {
1198                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1199                 return CONNECTION_ERROR_INVALID_PARAMETER;
1200         }
1201
1202         return _connection_libnet_remove_route_ipv6(interface_name, host_address, gateway);
1203 }
1204
1205 EXPORT_API int connection_add_route_entry(connection_h connection,
1206                 connection_address_family_e address_family,     const char *interface_name,
1207                 const char *host_address, const char *gateway)
1208 {
1209         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
1210
1211         if (!(__connection_check_handle_validity(connection)) ||
1212                 (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
1213              address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
1214             interface_name == NULL || host_address == NULL) {
1215                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1216                 return CONNECTION_ERROR_INVALID_PARAMETER;
1217         }
1218
1219         if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
1220                 return _connection_libnet_add_route_entry(CONNECTION_ADDRESS_FAMILY_IPV4,
1221                                                                 interface_name, host_address, gateway);
1222         else
1223                 return _connection_libnet_add_route_entry(CONNECTION_ADDRESS_FAMILY_IPV6,
1224                                                                 interface_name, host_address, gateway);
1225
1226         return CONNECTION_ERROR_NONE;
1227 }
1228
1229 EXPORT_API int connection_remove_route_entry(connection_h connection,
1230                 connection_address_family_e address_family,     const char *interface_name,
1231                 const char *host_address, const char *gateway)
1232 {
1233         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
1234
1235         if (!(__connection_check_handle_validity(connection)) ||
1236                 (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
1237              address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
1238             interface_name == NULL || host_address == NULL) {
1239                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1240                 return CONNECTION_ERROR_INVALID_PARAMETER;
1241         }
1242
1243         if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
1244                 return _connection_libnet_remove_route_entry(CONNECTION_ADDRESS_FAMILY_IPV4,
1245                                                                 interface_name, host_address, gateway);
1246         else
1247                 return _connection_libnet_remove_route_entry(CONNECTION_ADDRESS_FAMILY_IPV6,
1248                                                                 interface_name, host_address, gateway);
1249
1250         return CONNECTION_ERROR_NONE;
1251 }
1252
1253 static int __get_cellular_statistic(connection_statistics_type_e statistics_type, long long *llsize)
1254 {
1255         int rv = VCONF_OK, rv1 = VCONF_OK;
1256         int last_size = 0, size = 0;
1257 #if defined TIZEN_DUALSIM_ENABLE
1258         int sim_id = 0;
1259 #endif
1260
1261         if (llsize == NULL) {
1262                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
1263                 return CONNECTION_ERROR_INVALID_PARAMETER;
1264         }
1265
1266         switch (statistics_type) {
1267         case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
1268         case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
1269         case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
1270         case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
1271                 break;
1272         default:
1273                 return CONNECTION_ERROR_INVALID_PARAMETER;
1274         }
1275
1276 #if defined TIZEN_DUALSIM_ENABLE
1277         rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
1278         if (rv != VCONF_OK) {
1279                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to get default subscriber id");
1280                 *llsize = 0;
1281                 return CONNECTION_ERROR_OPERATION_FAILED;
1282         }
1283
1284         switch (sim_id) {
1285         case 0:
1286 #endif
1287                 switch (statistics_type) {
1288                 case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
1289                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
1290                         break;
1291                 case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
1292                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
1293                         break;
1294                 case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
1295                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
1296                         rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, &size);
1297                         break;
1298                 case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
1299                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
1300                         rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, &size);
1301                         break;
1302                 }
1303 #if defined TIZEN_DUALSIM_ENABLE
1304                 break;
1305         case 1:
1306                 switch (statistics_type) {
1307                 case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
1308                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
1309                         break;
1310                 case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
1311                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
1312                         break;
1313                 case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
1314                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
1315                         rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2, &size);
1316                         break;
1317                 case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
1318                         rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
1319                         rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2, &size);
1320                         break;
1321                 }
1322                 break;
1323         default:
1324                 *llsize = 0;
1325                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid subscriber id:%d", sim_id);
1326                 return CONNECTION_ERROR_OPERATION_FAILED;
1327         }
1328 #endif
1329
1330         if (rv != VCONF_OK || rv1 != VCONF_OK) {
1331                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular statistics"); //LCOV_EXCL_LINE
1332                 return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
1333         }
1334
1335         *llsize = (long long)(last_size * 1000) + (long long)(size * 1000);
1336         CONNECTION_LOG(CONNECTION_INFO, "%lld bytes", *llsize);
1337
1338         return CONNECTION_ERROR_NONE;
1339 }
1340
1341 static int __get_statistic(connection_type_e connection_type,
1342                 connection_statistics_type_e statistics_type, long long *llsize)
1343 {
1344         int rv, stat_type;
1345         unsigned long long ull_size;
1346
1347         if (llsize == NULL) {
1348                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
1349                 return CONNECTION_ERROR_INVALID_PARAMETER;
1350         }
1351
1352         rv  = _connection_libnet_check_get_privilege();
1353         if (rv == CONNECTION_ERROR_PERMISSION_DENIED)
1354                 return rv;
1355         else if (rv != CONNECTION_ERROR_NONE) {
1356                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to get statistics"); //LCOV_EXCL_LINE
1357                 return CONNECTION_ERROR_OPERATION_FAILED;
1358         }
1359
1360         if (connection_type == CONNECTION_TYPE_CELLULAR)
1361                 return __get_cellular_statistic(statistics_type, llsize);
1362         else if (connection_type == CONNECTION_TYPE_WIFI) {
1363                 switch (statistics_type) {
1364                 case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
1365                         stat_type = NET_STATISTICS_TYPE_LAST_SENT_DATA;
1366                         break;
1367                 case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
1368                         stat_type = NET_STATISTICS_TYPE_LAST_RECEIVED_DATA;
1369                         break;
1370                 case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
1371                         stat_type = NET_STATISTICS_TYPE_TOTAL_SENT_DATA;
1372                         break;
1373                 case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
1374                         stat_type = NET_STATISTICS_TYPE_TOTAL_RECEIVED_DATA;
1375                         break;
1376                 default:
1377                         return CONNECTION_ERROR_INVALID_PARAMETER;
1378                 }
1379
1380                 rv  = _connection_libnet_get_statistics(stat_type, &ull_size);
1381                 if (rv == CONNECTION_ERROR_PERMISSION_DENIED)
1382                         return rv;
1383                 else if (rv != CONNECTION_ERROR_NONE) {
1384                         CONNECTION_LOG(CONNECTION_ERROR, "Failed to get Wi-Fi statistics"); //LCOV_EXCL_LINE
1385                         *llsize = 0; //LCOV_EXCL_LINE
1386                         return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
1387                 }
1388
1389                 CONNECTION_LOG(CONNECTION_INFO, "%lld bytes", ull_size);
1390                 *llsize = (long long)ull_size;
1391         } else
1392                 return CONNECTION_ERROR_INVALID_PARAMETER;
1393
1394         return CONNECTION_ERROR_NONE;
1395 }
1396
1397 static int __reset_statistic(connection_type_e connection_type,
1398                 connection_statistics_type_e statistics_type)
1399 {
1400         int conn_type;
1401         int stat_type;
1402         int rv;
1403
1404         if (connection_type == CONNECTION_TYPE_CELLULAR)
1405                 conn_type = NET_DEVICE_CELLULAR;
1406         else if (connection_type == CONNECTION_TYPE_WIFI)
1407                 conn_type = NET_DEVICE_WIFI;
1408         else
1409                 return CONNECTION_ERROR_INVALID_PARAMETER;
1410
1411         switch (statistics_type) {
1412         case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
1413                 stat_type = NET_STATISTICS_TYPE_LAST_SENT_DATA;
1414                 break;
1415         case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
1416                 stat_type = NET_STATISTICS_TYPE_LAST_RECEIVED_DATA;
1417                 break;
1418         case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
1419                 stat_type = NET_STATISTICS_TYPE_TOTAL_SENT_DATA;
1420                 break;
1421         case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
1422                 stat_type = NET_STATISTICS_TYPE_TOTAL_RECEIVED_DATA;
1423                 break;
1424         default:
1425                 return CONNECTION_ERROR_INVALID_PARAMETER;
1426         }
1427
1428         rv = _connection_libnet_set_statistics(conn_type, stat_type);
1429         if (rv != CONNECTION_ERROR_NONE)
1430                 return rv;
1431
1432         CONNECTION_LOG(CONNECTION_INFO, "connection_reset_statistics success");
1433
1434         return CONNECTION_ERROR_NONE;
1435 }
1436
1437 EXPORT_API int connection_get_statistics(connection_h connection,
1438                                 connection_type_e connection_type,
1439                                 connection_statistics_type_e statistics_type, long long* size)
1440 {
1441         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
1442
1443         if (connection_type == CONNECTION_TYPE_CELLULAR)
1444                 CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
1445         else if (connection_type == CONNECTION_TYPE_WIFI)
1446                 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
1447
1448         if (!(__connection_check_handle_validity(connection)) || size == NULL) {
1449                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1450                 return CONNECTION_ERROR_INVALID_PARAMETER;
1451         }
1452
1453         return __get_statistic(connection_type, statistics_type, size);
1454 }
1455
1456 EXPORT_API int connection_reset_statistics(connection_h connection,
1457                                 connection_type_e connection_type,
1458                                 connection_statistics_type_e statistics_type)
1459 {
1460         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
1461
1462         if (connection_type == CONNECTION_TYPE_CELLULAR)
1463                 CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
1464         else if (connection_type == CONNECTION_TYPE_WIFI)
1465                 CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
1466
1467         if (!__connection_check_handle_validity(connection)) {
1468                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1469                 return CONNECTION_ERROR_INVALID_PARAMETER;
1470         }
1471
1472         return __reset_statistic(connection_type, statistics_type);
1473 }
1474
1475 EXPORT_API int connection_foreach_ipv6_address(connection_h connection,
1476                 connection_type_e connection_type, connection_ipv6_address_cb callback,
1477                 void *user_data)
1478 {
1479         CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
1480                         TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
1481
1482         GSList *ipv6_address_list = NULL;
1483
1484         if (!(__connection_check_handle_validity(connection))) {
1485                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1486                 return CONNECTION_ERROR_INVALID_PARAMETER;
1487         }
1488
1489         int rv = CONNECTION_ERROR_NONE;
1490
1491         switch (connection_type) {
1492         case CONNECTION_TYPE_WIFI:
1493                 rv = net_foreach_ipv6_address(NET_DEVICE_WIFI,
1494                                 &ipv6_address_list);
1495                 break;
1496         case CONNECTION_TYPE_CELLULAR:
1497                 rv = net_foreach_ipv6_address(NET_DEVICE_CELLULAR,
1498                                 &ipv6_address_list);
1499                 break;
1500         case CONNECTION_TYPE_ETHERNET:
1501                 rv = net_foreach_ipv6_address(NET_DEVICE_ETHERNET,
1502                                 &ipv6_address_list);
1503                 break;
1504         case CONNECTION_TYPE_BT:
1505                 rv = net_foreach_ipv6_address(NET_DEVICE_BLUETOOTH,
1506                                 &ipv6_address_list);
1507                 break;
1508         default:
1509                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1510                 return CONNECTION_ERROR_INVALID_PARAMETER;
1511         }
1512
1513         if (rv != NET_ERR_NONE) {
1514                 CONNECTION_LOG(CONNECTION_ERROR, "net_get_multiple_id_address"
1515                                 " Failed = %d\n", rv);
1516                 return CONNECTION_ERROR_OPERATION_FAILED;
1517         }
1518
1519         GSList *list;
1520         for (list = ipv6_address_list; list; list = list->next) {
1521                 rv = callback((char *)list->data, user_data);
1522                 if (rv == false)
1523                         break;
1524         }
1525
1526         g_slist_free_full(ipv6_address_list, g_free);
1527         ipv6_address_list = NULL;
1528
1529         return CONNECTION_ERROR_NONE;
1530 }
1531
1532 EXPORT_API int connection_profile_start_tcpdump(connection_h connection)
1533 {
1534         int ret = 0;
1535
1536         if (!(__connection_check_handle_validity(connection))) {
1537                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1538                 return CONNECTION_ERROR_INVALID_PARAMETER;
1539         }
1540
1541         ret = _connection_libnet_start_tcpdump();
1542         if (ret != CONNECTION_ERROR_NONE) {
1543                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to start tcpdump (%d)", ret);
1544                 return ret;
1545         }
1546
1547         return CONNECTION_ERROR_NONE;
1548 }
1549
1550 EXPORT_API int connection_profile_stop_tcpdump(connection_h connection)
1551 {
1552         int ret = 0;
1553
1554         if (!(__connection_check_handle_validity(connection))) {
1555                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1556                 return CONNECTION_ERROR_INVALID_PARAMETER;
1557         }
1558
1559         ret = _connection_libnet_stop_tcpdump();
1560         if (ret != CONNECTION_ERROR_NONE) {
1561                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to stop tcpdump (%d)", ret);
1562                 return ret;
1563         }
1564
1565         return CONNECTION_ERROR_NONE;
1566 }
1567
1568 EXPORT_API int connection_profile_get_tcpdump_state(connection_h connection, gboolean *tcpdump_state)
1569 {
1570         int ret = 0;
1571
1572         if (!(__connection_check_handle_validity(connection)) || !tcpdump_state) {
1573                 CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
1574                 return CONNECTION_ERROR_INVALID_PARAMETER;
1575         }
1576
1577         ret = _connection_libnet_get_tcpdump_state(tcpdump_state);
1578         if (ret != CONNECTION_ERROR_NONE) {
1579                 CONNECTION_LOG(CONNECTION_ERROR, "Failed to get the tcpdump state (%d)", ret);
1580                 return ret;
1581         }
1582
1583         return CONNECTION_ERROR_NONE;
1584 }