Tizen 2.1 base
[platform/core/api/connection.git] / include / net_connection.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 #ifndef __NET_CONNECTION_INTF_H__        /* To prevent inclusion of a header file twice */
19 #define __NET_CONNECTION_INTF_H__
20
21 #include "connection_profile.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26
27 /**
28  * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
29  * @{
30  */
31
32 /**
33  * @brief  The connection handle for all connection functions.
34 */
35 typedef void* connection_h;
36
37 /**
38  * @brief  The iterator handle for profiles.
39 */
40 typedef void* connection_profile_iterator_h;
41
42 /**
43  * @brief Enumerations of connection type.
44  */
45 typedef enum
46 {
47     CONNECTION_TYPE_DISCONNECTED = 0,  /**< Disconnected */
48     CONNECTION_TYPE_WIFI = 1,  /**< Wi-Fi type */
49     CONNECTION_TYPE_CELLULAR = 2,  /**< Cellular type */
50     CONNECTION_TYPE_ETHERNET = 3,  /**< Ethernet type */
51     CONNECTION_TYPE_BT = 4,  /**< Bluetooth type */
52 } connection_type_e;
53
54 /**
55  * @brief Enumerations of cellular network state.
56  */
57 typedef enum
58 {
59     CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE = 0,  /**< Out of service */
60     CONNECTION_CELLULAR_STATE_FLIGHT_MODE = 1,  /**< Flight mode */
61     CONNECTION_CELLULAR_STATE_ROAMING_OFF = 2,  /**< Roaming is turned off */
62     CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE = 3,  /**< Call is only available */
63     CONNECTION_CELLULAR_STATE_AVAILABLE = 4,  /**< Available but not connected yet */
64     CONNECTION_CELLULAR_STATE_CONNECTED = 5,  /**< Connected */
65 } connection_cellular_state_e;
66
67 /**
68  * @brief This enumeration defines the Wi-Fi state.
69  */
70 typedef enum
71 {
72     CONNECTION_WIFI_STATE_DEACTIVATED = 0,  /**< Wi-Fi is deactivated */
73     CONNECTION_WIFI_STATE_DISCONNECTED = 1,  /**< Disconnected */
74     CONNECTION_WIFI_STATE_CONNECTED = 2,  /**< Connected */
75 } connection_wifi_state_e;
76
77 /**
78  * @brief This enumeration defines the ethernet state.
79  */
80 typedef enum
81 {
82     CONNECTION_ETHERNET_STATE_DEACTIVATED = 0,  /**< There is no Ethernet profile to open */
83     CONNECTION_ETHERNET_STATE_DISCONNECTED = 1,  /**< Disconnected */
84     CONNECTION_ETHERNET_STATE_CONNECTED = 2,  /**< Connected */
85 } connection_ethernet_state_e;
86
87 /**
88  * @brief This enumeration defines the Bluetooth state.
89  */
90 typedef enum
91 {
92     CONNECTION_BT_STATE_DEACTIVATED = 0,  /**< There is no Bluetooth profile to open */
93     CONNECTION_BT_STATE_DISCONNECTED = 1,  /**< Disconnected */
94     CONNECTION_BT_STATE_CONNECTED = 2,  /**< Connected */
95 } connection_bt_state_e;
96
97 /**
98  * @brief This enumeration defines the type of connection iterator.
99  */
100 typedef enum
101 {
102     CONNECTION_ITERATOR_TYPE_REGISTERED = 0,  /**< The iterator of registered profile  */
103     CONNECTION_ITERATOR_TYPE_CONNECTED = 1,  /**< The iterator of connected profile  */
104 } connection_iterator_type_e;
105
106 /**
107  * @brief Enumerations of connection errors.
108  */
109 typedef enum
110 {
111     CONNECTION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
112     CONNECTION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
113     CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */
114     CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */
115     CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */
116     CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0401, /**< Operation failed */
117     CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_NETWORK_CLASS|0x0402, /**< End of iteration */
118     CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_NETWORK_CLASS|0x0403, /**< There is no connection */
119     CONNECTION_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /** Now in progress */
120     CONNECTION_ERROR_ALREADY_EXISTS = TIZEN_ERROR_NETWORK_CLASS|0x0404, /**< Already exists */
121     CONNECTION_ERROR_OPERATION_ABORTED = TIZEN_ERROR_NETWORK_CLASS|0x0405, /**< Operation is aborted */
122     CONNECTION_ERROR_DHCP_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0406, /**< DHCP failed  */
123     CONNECTION_ERROR_INVALID_KEY = TIZEN_ERROR_NETWORK_CLASS|0x0407, /**< Invalid key  */
124     CONNECTION_ERROR_NO_REPLY = TIZEN_ERROR_NETWORK_CLASS|0x0408, /**< No reply */
125 } connection_error_e;
126
127 /**
128  * @}
129 */
130
131 /**
132  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
133  * @{
134 */
135
136 /**
137  * @brief Enumerations of statistics type.
138  */
139 typedef enum
140 {
141     CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0,  /**< Last received data */
142     CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA = 1,  /**< Last sent data */
143     CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2,  /**< Total received data */
144     CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA = 3,  /**< Total sent data */
145 } connection_statistics_type_e;
146
147 /**
148  * @}
149 */
150
151 /**
152  * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
153  * @{
154 */
155
156
157 /**
158  * @brief Creates a handle for managing data connections.
159  * @remarks @a handle must be released with connection_destroy().
160  * @param[out] connection  The handle of the connection
161  * @return 0 on success, otherwise negative error value.
162  * @retval #CONNECTION_ERROR_NONE  Successful
163  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
164  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
165  * @see connection_destroy()
166  */
167 int connection_create(connection_h* connection);
168
169 /**
170  * @brief Destroys the connection handle.
171  * @param[in] connection  The handle of the connection
172  * @return 0 on success, otherwise negative error value.
173  * @retval #CONNECTION_ERROR_NONE  Successful
174  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
175  * @see connection_create()
176  */
177 int connection_destroy(connection_h connection);
178
179 /**
180  * @brief Called when the type of connection is changed.
181  * @param[in] type  The type of current network connection
182  * @param[in] user_data The user data passed from the callback registration function
183  * @see connection_set_network_type_changed_cb()
184  * @see connection_unset_network_type_changed_cb()
185  */
186 typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data);
187
188 /**
189  * @brief Called when the address is changed.
190  * @param[in] ipv4_address  The IP address for IPv4
191  * @param[in] ipv6_address  The IP address for IPv6
192  * @param[in] user_data The user data passed from the callback registration function
193  * @see connection_set_ip_address_changed_cb()
194  * @see connection_unset_ip_address_changed_cb()
195  * @see connection_set_proxy_address_changed_cb()
196  * @see connection_unset_proxy_address_changed_cb()
197  */
198 typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data);
199
200 /**
201  * @brief Gets the type of the current profile for data connection.
202  * @param[in] connection  The handle of the connection
203  * @param[out] state  The state of network
204  * @return 0 on success, otherwise negative error value.
205  * @retval #CONNECTION_ERROR_NONE  Successful
206  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
207  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
208  */
209 int connection_get_type(connection_h connection, connection_type_e* type);
210
211 /**
212  * @brief Gets the IP address of the current connection.
213  * @remarks @a ip_address must be released with free() by you.
214  * @param[in] connection  The handle of the connection
215  * @param[in] address_family  The address family
216  * @param[out] ip_address  The pointer to IP address string.
217  * @return 0 on success, otherwise negative error value.
218  * @retval #CONNECTION_ERROR_NONE  Successful
219  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
220  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
221  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
222  */
223 int connection_get_ip_address(connection_h connection, connection_address_family_e address_family, char** ip_address);
224
225 /**
226  * @brief Gets the proxy address of the current connection.
227  * @remarks @a proxy must be released with free() by you.
228  * @param[in] connection  The handle of the connection
229  * @param[in] address_family  The address family
230  * @param[out] proxy  The proxy address
231  * @return 0 on success, otherwise negative error value.
232  * @retval #CONNECTION_ERROR_NONE  Successful
233  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
234  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
235  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
236  */
237 int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy);
238
239 /**
240  * @brief  Gets the state of celluar connection.
241  * @details The returned state is for the cellular connection state.
242  * @param[in] connection  The handle of connection
243  * @param[out] state  The state of cellular connection
244  * @return 0 on success, otherwise negative error value.
245  * @retval #CONNECTION_ERROR_NONE  Successful
246  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
247  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
248  */
249 int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state);
250
251 /**
252  * @brief  Gets the state of Wi-Fi.
253  * @details The returned state is for the Wi-Fi connection state.
254  * @param[in] connection  The handle of connection
255  * @param[out] state  The state of Wi-Fi connection
256  * @return 0 on success, otherwise negative error value.
257  * @retval #CONNECTION_ERROR_NONE  Successful
258  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
259  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
260  */
261 int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state);
262
263 /**
264  * @brief  Gets the state of ethernet.
265  * @details The returned state is for the ethernet connection state.
266  * @param[in] connection  The handle of connection
267  * @param[out] state  The state of Ethernet connection
268  * @return 0 on success, otherwise negative error value.
269  * @retval #CONNECTION_ERROR_NONE  Successful
270  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
271  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
272  */
273 int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state);
274
275 /**
276  * @brief  Gets the state of Bluetooth.
277  * @details The returned state is for the Bluetooth connection state.
278  * @param[in] connection  The handle of connection
279  * @param[out] state  The state of Ethernet connection
280  * @return 0 on success, otherwise negative error value.
281  * @retval #CONNECTION_ERROR_NONE  Successful
282  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
283  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
284  */
285 int connection_get_bt_state(connection_h connection, connection_bt_state_e* state);
286
287 /**
288  * @brief Registers the callback called when the type of current connection is changed.
289  * @param[in] connection  The handle of connection
290  * @param[in] callback  The callback function to be called
291  * @param[in] user_data The user data passed to the callback function
292  * @return 0 on success, otherwise negative error value.
293  * @retval #CONNECTION_ERROR_NONE  Successful
294  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
295  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
296  */
297 int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data);
298
299 /**
300  * @brief Unregisters the callback called when the type of current connection is changed.
301  * @param[in] connection  The handle of connection
302  * @return 0 on success, otherwise negative error value.
303  * @retval #CONNECTION_ERROR_NONE  Successful
304  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
305  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
306  */
307 int connection_unset_type_changed_cb(connection_h connection);
308
309 /**
310  * @brief Registers the callback called when the IP address is changed.
311  * @param[in] connection  The handle of connection
312  * @param[in] callback  The callback function to be called
313  * @param[in] user_data The user data passed to the callback function
314  * @return 0 on success, otherwise negative error value.
315  * @retval #CONNECTION_ERROR_NONE  Successful
316  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
317  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
318  */
319 int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
320
321 /**
322  * @brief Unregisters the callback called when the IP address is changed.
323  * @param[in] connection  The handle of connection
324  * @return 0 on success, otherwise negative error value.
325  * @retval #CONNECTION_ERROR_NONE  Successful
326  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
327  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
328  */
329 int connection_unset_ip_address_changed_cb(connection_h connection);
330
331 /**
332  * @brief Registers the callback called when the proxy address is changed.
333  * @param[in] connection  The handle of connection
334  * @param[in] callback  The callback function to be called
335  * @param[in] user_data The user data passed to the callback function
336  * @return 0 on success, otherwise negative error value.
337  * @retval #CONNECTION_ERROR_NONE  Successful
338  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
339  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
340  */
341 int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
342
343 /**
344  * @brief Unregisters the callback called when the proxy address is changed.
345  * @param[in] connection  The handle of connection
346  * @return 0 on success, otherwise negative error value.
347  * @retval #CONNECTION_ERROR_NONE  Successful
348  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
349  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
350  */
351 int connection_unset_proxy_address_changed_cb(connection_h connection);
352
353 /**
354  * @brief Adds new profile which is created by connection_profile_created().
355  * @remarks You can only add a profile of cellular type.
356  * @param[in] connection  The handle of connection
357  * @param[in] profile  The handle of profile
358  * @return 0 on success, otherwise negative error value.
359  * @retval #CONNECTION_ERROR_NONE  Successful
360  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
361  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
362  */
363 int connection_add_profile(connection_h connection, connection_profile_h profile);
364
365 /**
366  * @brief Removes existing profile.
367  * @param[in] connection  The handle of connection
368  * @param[in] profile  The handle of profile
369  * @return 0 on success, otherwise negative error value.
370  * @retval #CONNECTION_ERROR_NONE  Successful
371  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
372  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
373  */
374 int connection_remove_profile(connection_h connection, connection_profile_h profile);
375
376 /**
377  * @brief Updates existing profile.
378  * @details If you change somethings of a profile, this changes will be not applied to the Connection Manager immediately.
379  * When you call this function, your changes affect the Connection Manager and the existing profile is updated.
380  * In addition, the existing profile will be updated if you call connection_open_profile().
381  * @param[in] connection  The handle of connection
382  * @param[in] profile  The handle of profile
383  * @return 0 on success, otherwise negative error value.
384  * @retval #CONNECTION_ERROR_NONE  Successful
385  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
386  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
387  * @see connection_open_profile()
388  */
389 int connection_update_profile(connection_h connection, connection_profile_h profile);
390
391 /**
392  * @brief Gets a iterator of the profiles.
393  * @remarks @a profile_iterator must be released with connection_destroy().
394  * @param[in] connection  The handle of connection
395  * @param[in] type  The type of connetion iterator
396  * @param[out] profile_iterator  The iterator of profile
397  * @return 0 on success, otherwise negative error value.
398  * @retval #CONNECTION_ERROR_NONE  Successful
399  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
400  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
401  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
402  */
403 int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator);
404
405 /**
406  * @brief Moves the profile iterator to the next position and gets a profile handle.
407  * @param[in] profile_iterator  The iterator of profile
408  * @param[out] profile  The handle of profile
409  * @return 0 on success, otherwise negative error value.
410  * @retval #CONNECTION_ERROR_NONE  Successful
411  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
412  * @retval #CONNECTION_ERROR_ITERATOR_END  End of iteration
413  */
414 int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile);
415
416 /**
417  * @brief Checks whether the next element of profile iterator exists or not.
418  * @param[in] profile_iterator  The iterator of profile
419  * @return @c true if next element exists, \n @c false if next element doesn't exist
420  */
421 bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator);
422
423 /**
424  * @brief Destroys a iterator of the profiles.
425  * @param[in] profile_iterator  The iterator of profile
426  * @return 0 on success, otherwise negative error value.
427  * @retval #CONNECTION_ERROR_NONE  Successful
428  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
429  */
430 int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator);
431
432 /**
433  * @brief Gets the name of default profile.
434  * @remarks @a profile must be released with connection_profile_destroy().
435  * @param[in] connection  The handle of connection
436  * @param[out] profile  The handle of profile
437  * @return 0 on success, otherwise negative error value.
438  * @retval #CONNECTION_ERROR_NONE  Successful
439  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
440  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
441  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
442  * @retval #CONNECTION_ERROR_NO_CONNECTION  There is no connection
443  */
444 int connection_get_current_profile(connection_h connection, connection_profile_h* profile);
445
446 /**
447  * @brief Gets the default profile which provides the given cellular service.
448  * @remarks  @a profile must be released with connection_profile_destroy().
449  * @param[in] connection  The handle of connection
450  * @param[in] type  The type of cellular service. #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted
451  * @param[out] profile  The handle of profile
452  * @return 0 on success, otherwise negative error value.
453  * @retval #CONNECTION_ERROR_NONE  Successful
454  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
455  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
456  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
457  */
458 int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile);
459
460 /**
461  * @brief Sets the default profile which provides the given cellular service.
462  * @param[in] connection  The handle of connection
463  * @param[in] type  The type of cellular service.
464  * #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are only permitted.
465  * @param[in] profile  The handle of profile
466  * @return 0 on success, otherwise negative error value.
467  * @retval #CONNECTION_ERROR_NONE  Successful
468  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
469  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
470  */
471 int connection_set_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile);
472
473 /**
474 * @brief Called after connection_open_profile() is completed.
475 * @param[in] result  The result
476 * @param[in] user_data The user data passed from connection_open_profile()
477 * @pre connection_open_profile() will invoke this callback function.
478 * @see connection_open_profile()
479 */
480 typedef void(*connection_opened_cb)(connection_error_e result, void* user_data);
481
482 /**
483 * @brief Called after connection_close_profile() is completed.
484 * @param[in] result  The result
485 * @param[in] user_data The user data passed from connection_close_profile()
486 * @pre connection_close_profile() will invoke this callback function.
487 * @see connection_close_profile()
488 */
489 typedef void(*connection_closed_cb)(connection_error_e result, void* user_data);
490
491 /**
492  * @brief Opens a connection of profile, asynchronously.
493  * @param[in] connection  The handle of connection
494  * @param[in] profile  The handle of profile
495  * @param[in] callback  The callback function to be called
496  * @param[in] user_data The user data passed to the callback function
497  * @return 0 on success, otherwise negative error value.
498  * @retval #CONNECTION_ERROR_NONE  Successful
499  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
500  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
501  * @post connection_opened_cb() will be invoked.
502  * @see connection_opened_cb()
503  * @see connection_close_profile()
504  * @see connection_profile_set_state_changed_cb()
505  * @see connection_profile_unset_state_changed_cb()
506  * @see connection_profile_state_changed_cb()
507  */
508 int connection_open_profile(connection_h connection, connection_profile_h profile, connection_opened_cb callback, void* user_data);
509
510 /**
511  * @brief Closes a connection of profile.
512  * @param[in] connection  The handle of connection
513  * @param[in] profile  The handle of profile
514  * @param[in] callback  The callback function to be called
515  * @param[in] user_data The user data passed to the callback function
516  * @return 0 on success, otherwise negative error value.
517  * @retval #CONNECTION_ERROR_NONE  Successful
518  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
519  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
520  * @post connection_closed_cb() will be invoked.
521  * @see connection_closed_cb()
522  * @see connection_open_profile()
523  * @see connection_profile_set_state_changed_cb()
524  * @see connection_profile_unset_state_changed_cb()
525  * @see connection_profile_state_changed_cb()
526  */
527 int connection_close_profile(connection_h connection, connection_profile_h profile, connection_closed_cb callback, void* user_data);
528
529 /**
530  * @brief Add a route to routing table.
531  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
532  * @param[in] connection  The handle of connection
533  * @param[in] interface_name  The name of network interface
534  * @param[in] host_address  The IP address of the host
535  * @return 0 on success, otherwise negative error value.
536  * @retval #CONNECTION_ERROR_NONE  Successful
537  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
538  * @retval #CONNECTION_ERROR_ALREADY_EXISTS  Already exists
539  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
540  * @see connection_profile_get_network_interface_name()
541  */
542 int connection_add_route(connection_h connection, const char* interface_name, const char* host_address);
543
544 /**
545  * @}
546 */
547
548 /**
549  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
550  * @{
551 */
552
553 /**
554  * @brief Gets the statistics information.
555  * @param[in] connection_type  The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported.
556  * @param[in] statistics_type  The type of statistics
557  * @param[out] size  The received data size of the last cellular packet data connection (bytes)
558  * @return 0 on success, otherwise negative error value.
559  * @retval #CONNECTION_ERROR_NONE  Successful
560  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
561  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
562  */
563 int connection_get_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size);
564
565 /**
566  * @brief Resets the statistics information
567  * @param[in] connection_type  The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported.
568  * @param[in] statistics_type  The type of statistics
569  * @return 0 on success, otherwise negative error value.
570  * @retval #CONNECTION_ERROR_NONE Successful
571  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
572  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
573  */
574 int connection_reset_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type);
575
576 /**
577  * @}
578  */
579
580
581 #ifdef __cplusplus
582 }
583 #endif /* __cplusplus */
584
585 #endif