2 * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __NET_CONNECTION_PRIVATE_H__
18 #define __NET_CONNECTION_PRIVATE_H__
21 #include <network-cm-intf.h>
22 #include <network-wifi-intf.h>
24 #include "net_connection.h"
28 #endif /* __cplusplus */
31 #define LOG_TAG "CAPI_NETWORK_CONNECTION"
33 #define CONNECTION_INFO 1
34 #define CONNECTION_ERROR 2
35 #define CONNECTION_WARN 3
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"
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"
47 CONNECTION_CELLULAR_SUBSCRIBER_1 = 0x00,
48 CONNECTION_CELLULAR_SUBSCRIBER_2 = 0x01,
49 } connection_cellular_subscriber_id_e;
52 CONNECTION_SUPPORTED_FEATURE_TELEPHONY,
53 CONNECTION_SUPPORTED_FEATURE_WIFI,
54 CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH,
55 CONNECTION_SUPPORTED_FEATURE_ETHERNET,
56 CONNECTION_SUPPORTED_FEATURE_MAX,
57 } connection_supported_feature_e;
66 _connection_unlock(); \
69 #define CHECK_FEATURE_SUPPORTED(...) \
71 int rv = _connection_check_feature_supported(__VA_ARGS__, NULL); \
72 if (rv != CONNECTION_ERROR_NONE) { \
78 #define DEPRECATED_LOG(origin, substitution) \
80 LOGW("DEPRECATION WARNING: %s() is deprecated and will be removed " \
81 "from next release. Use %s() instead", origin, substitution); \
84 #define CONNECTION_LOG(log_level, format, args...) \
86 switch (log_level) { \
87 case CONNECTION_ERROR: \
88 LOGE(format, ## args); \
90 case CONNECTION_WARN: \
91 LOGW(format, ## args); \
94 LOGI(format, ## args); \
98 #define SECURE_CONNECTION_LOG(log_level, format, args...) \
100 switch (log_level) { \
101 case CONNECTION_ERROR: \
102 SECURE_LOGE(format, ## args); \
104 case CONNECTION_WARN: \
105 SECURE_LOGW(format, ## args); \
108 SECURE_LOGI(format, ## args); \
112 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE \
113 "db/telephony/dualsim/default_data_service"
115 typedef struct _connection_handle_s {
116 connection_type_changed_cb type_changed_callback;
117 connection_address_changed_cb ip_changed_callback;
118 connection_address_changed_cb proxy_changed_callback;
119 connection_internet_state_changed_cb internet_state_changed_callback;
120 connection_ethernet_cable_state_changed_cb ethernet_cable_state_changed_callback;
121 connection_set_default_cb set_default_callback;
122 connection_opened_cb opened_callback;
123 connection_closed_cb closed_callback;
124 connection_opened_cb reset_callback;
125 void *type_changed_user_data;
126 void *ip_changed_user_data;
127 void *proxy_changed_user_data;
128 void *internet_state_changed_user_data;
129 void *ethernet_cable_state_changed_user_data;
130 void *set_default_user_data;
131 void *opened_user_data;
132 void *closed_user_data;
133 void *reset_user_data;
135 void *network_info_handle;
136 } connection_handle_s;
138 int _connection_libnet_init(connection_handle_s *conn_handle);
139 bool _connection_libnet_deinit(connection_handle_s *conn_handle);
140 void _connection_set_cs_tid(int tid, connection_handle_s *conn_handle);
141 void _connection_unset_cs_tid(int tid, connection_handle_s *conn_handle);
142 int _connection_libnet_get_metered_state(connection_handle_s *conn_handle, bool* is_metered);
143 int _connection_libnet_get_wifi_state(connection_handle_s *conn_handle, connection_wifi_state_e *state);
144 int _connection_libnet_get_ethernet_state(connection_handle_s *conn_handle,
145 connection_ethernet_state_e *state);
146 int _connection_libnet_get_ethernet_cable_state(connection_handle_s *conn_handle,
147 connection_ethernet_cable_state_e* state);
148 int _connection_libnet_get_bluetooth_state(connection_handle_s *conn_handle, connection_bt_state_e* state);
149 bool _connection_libnet_check_profile_validity(connection_profile_h profile);
150 int _connection_libnet_get_profile_iterator(connection_handle_s *conn_handle,
151 connection_iterator_type_e type, connection_profile_iterator_h *profile_iterator);
152 bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_iterator);
153 int _connection_libnet_get_iterator_next(connection_profile_iterator_h profile_iter_h,
154 connection_profile_h *profile);
155 int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h);
156 int _connection_libnet_get_current_profile(connection_handle_s *conn_handle,
157 connection_profile_h *profile);
158 int _connection_libnet_reset_profile(connection_handle_s *conn_handle,
159 connection_reset_option_e type, connection_cellular_subscriber_id_e id);
160 int _connection_libnet_open_profile(connection_handle_s *conn_handle,
161 connection_profile_h profile);
162 int _connection_libnet_get_cellular_service_profile(connection_handle_s *conn_handle,
163 connection_cellular_service_type_e type, connection_profile_h *profile);
164 int _connection_libnet_set_cellular_service_profile_sync(connection_handle_s *conn_handle,
165 connection_cellular_service_type_e type, connection_profile_h profile);
166 int _connection_libnet_set_cellular_service_profile_async(connection_handle_s *conn_handle,
167 connection_cellular_service_type_e type, connection_profile_h profile);
168 int _connection_libnet_close_profile(connection_handle_s *conn_handle, connection_profile_h profile);
169 int _connection_libnet_add_route(connection_handle_s *conn_handle,
170 const char *interface_name, const char *host_address);
171 int _connection_libnet_remove_route(connection_handle_s *conn_handle,
172 const char *interface_name, const char *host_address);
173 int _connection_libnet_add_route_ipv6(connection_handle_s *conn_handle,
174 const char *interface_name, const char *host_address, const char * gateway);
175 int _connection_libnet_remove_route_ipv6(connection_handle_s *conn_handle,
176 const char *interface_name, const char *host_address, const char * gateway);
177 int _connection_libnet_add_route_entry(connection_handle_s *conn_handle,
178 connection_address_family_e address_family, const char *interface_name,
179 const char *host_address, const char * gateway);
180 int _connection_libnet_remove_route_entry(connection_handle_s *conn_handle,
181 connection_address_family_e address_family, const char *interface_name,
182 const char *host_address, const char * gateway);
183 void _connection_libnet_add_to_profile_list(connection_profile_h profile);
184 void _connection_libnet_remove_from_profile_list(connection_profile_h profile);
185 bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
186 connection_profile_state_changed_cb callback, void *user_data);
187 bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile);
188 int _connection_libnet_set_statistics(connection_handle_s *conn_handle,
189 net_device_t device_type, net_statistics_type_e statistics_type);
190 int _connection_libnet_get_statistics(connection_handle_s *conn_handle,
191 net_statistics_type_e statistics_type, unsigned long long *size);
192 int _connection_libnet_check_get_privilege(void);
193 int _connection_libnet_check_profile_privilege(void);
195 int _connection_check_feature_supported(const char *feature_name, ...);
197 connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type);
198 connection_profile_state_e _profile_convert_to_cp_state(net_state_type_t state);
199 net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type);
200 net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state);
202 int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile,
203 connection_cellular_subscriber_id_e sim_id);
205 int _connection_libnet_start_tcpdump(connection_handle_s *conn_handle);
206 int _connection_libnet_stop_tcpdump(connection_handle_s *conn_handle);
207 int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
208 gboolean *tcpdump_state);
210 void _connection_lock(void);
211 void _connection_unlock(void);
213 bool _connection_check_handle_validity(connection_h connection);
216 #endif /* __cplusplus */