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