4a1ab413bae28024c1bb9f4a8417c3edb7b2f795
[platform/core/api/connection.git] / include / net_connection_private.h
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
18
19 #ifndef __NET_CONNECTION_PRIVATE_H__        /* To prevent inclusion of a header file twice */
20 #define __NET_CONNECTION_PRIVATE_H__
21
22 #include <dlog.h>
23 #include <network-cm-intf.h>
24 #include <network-wifi-intf.h>
25 #include "net_connection.h"
26
27 #undef LOG_TAG
28 #define LOG_TAG "CAPI_NETWORK_CONNECTION"
29
30 #define CONNECTION_INFO         1
31 #define CONNECTION_ERROR        2
32 #define CONNECTION_WARN         3
33
34 #define CONNECTION_LOG(log_level, format, args...) \
35         do { \
36                 switch (log_level) { \
37                 case CONNECTION_ERROR: \
38                         LOGE(format, ## args); \
39                         break; \
40                 case CONNECTION_WARN: \
41                         LOGW(format, ## args); \
42                         break; \
43                 default: \
44                         LOGI(format, ## args); \
45                 } \
46         } while(0)
47
48 #define CONNECTION_MUTEX_LOCK _connection_inter_mutex_lock()
49 #define CONNECTION_MUTEX_UNLOCK _connection_inter_mutex_unlock()
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif /* __cplusplus */
54
55 typedef struct _connection_handle_s
56 {
57         connection_type_changed_cb type_changed_callback;
58         connection_address_changed_cb ip_changed_callback;
59         connection_address_changed_cb proxy_changed_callback;
60         void *state_changed_user_data;
61         void *ip_changed_user_data;
62         void *proxy_changed_user_data;
63 } connection_handle_s;
64
65
66 bool _connection_libnet_init(void);
67 bool _connection_libnet_deinit(void);
68 bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state);
69 bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e *state);
70 bool _connection_libnet_get_bluetooth_state(connection_bt_state_e* state);
71 bool _connection_libnet_check_profile_validity(connection_profile_h profile);
72 bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile);
73 int _connection_libnet_get_profile_iterator(connection_iterator_type_e type,
74                                 connection_profile_iterator_h *profile_iterator);
75 bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_iterator);
76 int _connection_libnet_get_iterator_next(connection_profile_iterator_h profile_iter_h, connection_profile_h *profile);
77 int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h);
78 int _connection_libnet_get_current_profile(connection_profile_h *profile);
79 int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void *user_data);
80 int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile);
81 int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile);
82 int _connection_libnet_set_cellular_service_profile_async(connection_cellular_service_type_e type,
83                         connection_profile_h profile, connection_set_default_cb callback, void* user_data);
84 int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data);
85 int _connection_libnet_add_route(const char *interface_name, const char *host_address);
86 void _connection_libnet_add_to_profile_list(connection_profile_h profile);
87 void _connection_libnet_remove_from_profile_list(connection_profile_h profile);
88 bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
89                 connection_profile_state_changed_cb callback, void *user_data);
90 void _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile);
91 int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type);
92 int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size);
93
94 connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type);
95 connection_profile_state_e _profile_convert_to_cp_state(net_state_type_t state);
96 net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type);
97 net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state);
98
99 void _connection_inter_mutex_lock(void);
100 void _connection_inter_mutex_unlock(void);
101
102 #ifdef __cplusplus
103 }
104 #endif /* __cplusplus */
105
106 #endif