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