Add supported features check
[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 #ifndef __NET_CONNECTION_PRIVATE_H__
18 #define __NET_CONNECTION_PRIVATE_H__
19
20 #include <dlog.h>
21 #include <network-cm-intf.h>
22 #include <network-wifi-intf.h>
23
24 #include "net_connection.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
29
30 #undef LOG_TAG
31 #define LOG_TAG "CAPI_NETWORK_CONNECTION"
32
33 #define CONNECTION_INFO         1
34 #define CONNECTION_ERROR        2
35 #define CONNECTION_WARN         3
36
37 #define CONNECTION_MAC_INFO_LENGTH      17
38 #define ETHERNET_MAC_INFO_FILE          "/sys/class/net/eth0/address"
39 #define WIFI_MAC_INFO_FILE                      "/sys/class/net/wlan0/address"
40
41 #define TELEPHONY_FEATURE                       "http://tizen.org/feature/network.telephony"
42 #define WIFI_FEATURE                            "http://tizen.org/feature/network.wifi"
43 #define TETHERING_BLUETOOTH_FEATURE     "http://tizen.org/feature/network.tethering.bluetooth"
44 #define ETHERNET_FEATURE                        "http://tizen.org/feature/network.ethernet"
45
46 typedef enum
47 {
48         CONNECTION_CELLULAR_SUBSCRIBER_1 = 0x00,
49         CONNECTION_CELLULAR_SUBSCRIBER_2 = 0x01,
50 } connection_cellular_subscriber_id_e;
51
52 #define CHECK_FEATURE_SUPPORTED(...) \
53         do { \
54                 int rv = _connection_check_feature_supported(__VA_ARGS__, NULL); \
55                 if( rv != CONNECTION_ERROR_NONE ) \
56                         return rv; \
57         } while(0)
58
59 #define CONNECTION_LOG(log_level, format, args...) \
60         do { \
61                 switch (log_level) { \
62                 case CONNECTION_ERROR: \
63                         LOGE(format, ## args); \
64                         break; \
65                 case CONNECTION_WARN: \
66                         LOGW(format, ## args); \
67                         break; \
68                 default: \
69                         LOGI(format, ## args); \
70                 } \
71         } while(0)
72
73 #define CONNECTION_MUTEX_LOCK _connection_inter_mutex_lock()
74 #define CONNECTION_MUTEX_UNLOCK _connection_inter_mutex_unlock()
75
76 #define SECURE_CONNECTION_LOG(log_level, format, args...) \
77         do { \
78                 switch (log_level) { \
79                 case CONNECTION_ERROR: \
80                         SECURE_LOGE(format, ## args); \
81                         break; \
82                 case CONNECTION_WARN: \
83                         SECURE_LOGW(format, ## args); \
84                         break; \
85                 default: \
86                         SECURE_LOGI(format, ## args); \
87                 } \
88         } while(0)
89
90 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE \
91                         "db/telephony/dualsim/default_data_service"
92
93 typedef struct _connection_handle_s {
94         connection_type_changed_cb type_changed_callback;
95         connection_address_changed_cb ip_changed_callback;
96         connection_address_changed_cb proxy_changed_callback;
97         connection_ethernet_cable_state_chaged_cb ethernet_cable_state_changed_callback;
98         void *type_changed_user_data;
99         void *ip_changed_user_data;
100         void *proxy_changed_user_data;
101         void *ethernet_cable_state_changed_user_data;
102 } connection_handle_s;
103
104 typedef void(*libnet_ethernet_cable_state_changed_cb)
105                 (connection_ethernet_cable_state_e state);
106
107 bool _connection_is_created(void);
108
109 int _connection_libnet_init(void);
110 bool _connection_libnet_deinit(void);
111 int _connection_libnet_get_wifi_state(connection_wifi_state_e *state);
112 int _connection_libnet_get_ethernet_state(connection_ethernet_state_e *state);
113 int _connection_libnet_get_ethernet_cable_state(connection_ethernet_cable_state_e* state);
114 int _connection_libnet_set_ethernet_cable_state_changed_cb(
115                                 libnet_ethernet_cable_state_changed_cb callback);
116 int _connection_libnet_get_bluetooth_state(connection_bt_state_e* state);
117 bool _connection_libnet_check_profile_validity(connection_profile_h profile);
118 bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile);
119 int _connection_libnet_get_profile_iterator(connection_iterator_type_e type,
120                                 connection_profile_iterator_h *profile_iterator);
121 bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_iterator);
122 int _connection_libnet_get_iterator_next(connection_profile_iterator_h profile_iter_h, connection_profile_h *profile);
123 int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h);
124 int _connection_libnet_get_current_profile(connection_profile_h *profile);
125 int _connection_libnet_reset_profile(connection_reset_option_e type, connection_cellular_subscriber_id_e id, connection_reset_cb callback, void *user_data);
126 int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void *user_data);
127 int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile);
128 int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile);
129 int _connection_libnet_set_cellular_service_profile_async(connection_cellular_service_type_e type,
130                         connection_profile_h profile, connection_set_default_cb callback, void* user_data);
131 int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data);
132 int _connection_libnet_add_route(const char *interface_name, const char *host_address);
133 int _connection_libnet_remove_route(const char *interface_name, const char *host_address);
134 int _connection_libnet_add_route_ipv6(const char *interface_name, const char *host_address, const char * gateway);
135 int _connection_libnet_remove_route_ipv6(const char *interface_name, const char *host_address, const char * gateway);
136 void _connection_libnet_add_to_profile_list(connection_profile_h profile);
137 void _connection_libnet_remove_from_profile_list(connection_profile_h profile);
138 bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
139                 connection_profile_state_changed_cb callback, void *user_data);
140 bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile);
141 int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type);
142 int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size);
143 int _connection_libnet_check_get_privilege();
144 int _connection_libnet_check_profile_privilege();
145
146 int _connection_check_feature_supported(const char *feature_name, ...);
147
148 guint _connection_callback_add(GSourceFunc func, gpointer user_data);
149 void _connection_callback_cleanup(void);
150
151 connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type);
152 connection_profile_state_e _profile_convert_to_cp_state(net_state_type_t state);
153 net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type);
154 net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state);
155
156 int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile, connection_cellular_subscriber_id_e sim_id);
157 void _connection_inter_mutex_lock(void);
158 void _connection_inter_mutex_unlock(void);
159
160 #ifdef __cplusplus
161 }
162 #endif /* __cplusplus */
163
164 #endif