Add new API : connection_set_default_cellular_service_profile_async()
[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 Called after connection_set_default_cellular_service_profile_async() is completed.
202 * @param[in] result  The result
203 * @param[in] user_data The user data passed from connection_open_profile()
204 * @pre connection_set_default_cellular_service_profile_async() will invoke this callback function.
205 * @see connection_set_default_cellular_service_profile_async()
206 */
207 typedef void(*connection_set_default_cb)(connection_error_e result, void* user_data);
208
209 /**
210  * @brief Gets the type of the current profile for data connection.
211  * @param[in] connection  The handle of the connection
212  * @param[out] state  The state of network
213  * @return 0 on success, otherwise negative error value.
214  * @retval #CONNECTION_ERROR_NONE  Successful
215  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
216  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
217  */
218 int connection_get_type(connection_h connection, connection_type_e* type);
219
220 /**
221  * @brief Gets the IP address of the current connection.
222  * @remarks @a ip_address must be released with free() by you.
223  * @param[in] connection  The handle of the connection
224  * @param[in] address_family  The address family
225  * @param[out] ip_address  The pointer to IP address string.
226  * @return 0 on success, otherwise negative error value.
227  * @retval #CONNECTION_ERROR_NONE  Successful
228  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
229  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
230  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
231  */
232 int connection_get_ip_address(connection_h connection, connection_address_family_e address_family, char** ip_address);
233
234 /**
235  * @brief Gets the proxy address of the current connection.
236  * @remarks @a proxy must be released with free() by you.
237  * @param[in] connection  The handle of the connection
238  * @param[in] address_family  The address family
239  * @param[out] proxy  The proxy address
240  * @return 0 on success, otherwise negative error value.
241  * @retval #CONNECTION_ERROR_NONE  Successful
242  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
243  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
244  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
245  */
246 int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy);
247
248 /**
249  * @brief  Gets the state of celluar connection.
250  * @details The returned state is for the cellular connection state.
251  * @param[in] connection  The handle of connection
252  * @param[out] state  The state of cellular connection
253  * @return 0 on success, otherwise negative error value.
254  * @retval #CONNECTION_ERROR_NONE  Successful
255  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
256  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
257  */
258 int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state);
259
260 /**
261  * @brief  Gets the state of Wi-Fi.
262  * @details The returned state is for the Wi-Fi connection state.
263  * @param[in] connection  The handle of connection
264  * @param[out] state  The state of Wi-Fi connection
265  * @return 0 on success, otherwise negative error value.
266  * @retval #CONNECTION_ERROR_NONE  Successful
267  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
268  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
269  */
270 int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state);
271
272 /**
273  * @brief  Gets the state of ethernet.
274  * @details The returned state is for the ethernet connection state.
275  * @param[in] connection  The handle of connection
276  * @param[out] state  The state of Ethernet connection
277  * @return 0 on success, otherwise negative error value.
278  * @retval #CONNECTION_ERROR_NONE  Successful
279  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
280  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
281  */
282 int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state);
283
284 /**
285  * @brief  Gets the state of Bluetooth.
286  * @details The returned state is for the Bluetooth connection state.
287  * @param[in] connection  The handle of connection
288  * @param[out] state  The state of Ethernet connection
289  * @return 0 on success, otherwise negative error value.
290  * @retval #CONNECTION_ERROR_NONE  Successful
291  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
292  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
293  */
294 int connection_get_bt_state(connection_h connection, connection_bt_state_e* state);
295
296 /**
297  * @brief Registers the callback called when the type of current connection is changed.
298  * @param[in] connection  The handle of connection
299  * @param[in] callback  The callback function to be called
300  * @param[in] user_data The user data passed to the callback function
301  * @return 0 on success, otherwise negative error value.
302  * @retval #CONNECTION_ERROR_NONE  Successful
303  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
304  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
305  */
306 int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data);
307
308 /**
309  * @brief Unregisters the callback called when the type of current connection is changed.
310  * @param[in] connection  The handle of connection
311  * @return 0 on success, otherwise negative error value.
312  * @retval #CONNECTION_ERROR_NONE  Successful
313  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
314  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
315  */
316 int connection_unset_type_changed_cb(connection_h connection);
317
318 /**
319  * @brief Registers the callback called when the IP address is changed.
320  * @param[in] connection  The handle of connection
321  * @param[in] callback  The callback function to be called
322  * @param[in] user_data The user data passed to the callback function
323  * @return 0 on success, otherwise negative error value.
324  * @retval #CONNECTION_ERROR_NONE  Successful
325  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
326  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
327  */
328 int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
329
330 /**
331  * @brief Unregisters the callback called when the IP address is changed.
332  * @param[in] connection  The handle of connection
333  * @return 0 on success, otherwise negative error value.
334  * @retval #CONNECTION_ERROR_NONE  Successful
335  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
336  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
337  */
338 int connection_unset_ip_address_changed_cb(connection_h connection);
339
340 /**
341  * @brief Registers the callback called when the proxy address is changed.
342  * @param[in] connection  The handle of connection
343  * @param[in] callback  The callback function to be called
344  * @param[in] user_data The user data passed to the callback function
345  * @return 0 on success, otherwise negative error value.
346  * @retval #CONNECTION_ERROR_NONE  Successful
347  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
348  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
349  */
350 int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
351
352 /**
353  * @brief Unregisters the callback called when the proxy address is changed.
354  * @param[in] connection  The handle of connection
355  * @return 0 on success, otherwise negative error value.
356  * @retval #CONNECTION_ERROR_NONE  Successful
357  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
358  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
359  */
360 int connection_unset_proxy_address_changed_cb(connection_h connection);
361
362 /**
363  * @brief Adds new profile which is created by connection_profile_created().
364  * @remarks You can only add a profile of cellular type.
365  * @param[in] connection  The handle of connection
366  * @param[in] profile  The handle of profile
367  * @return 0 on success, otherwise negative error value.
368  * @retval #CONNECTION_ERROR_NONE  Successful
369  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
370  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
371  */
372 int connection_add_profile(connection_h connection, connection_profile_h profile);
373
374 /**
375  * @brief Removes existing profile.
376  * @param[in] connection  The handle of connection
377  * @param[in] profile  The handle of profile
378  * @return 0 on success, otherwise negative error value.
379  * @retval #CONNECTION_ERROR_NONE  Successful
380  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
381  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
382  */
383 int connection_remove_profile(connection_h connection, connection_profile_h profile);
384
385 /**
386  * @brief Updates existing profile.
387  * @details If you change somethings of a profile, this changes will be not applied to the Connection Manager immediately.
388  * When you call this function, your changes affect the Connection Manager and the existing profile is updated.
389  * In addition, the existing profile will be updated if you call connection_open_profile().
390  * @param[in] connection  The handle of connection
391  * @param[in] profile  The handle of profile
392  * @return 0 on success, otherwise negative error value.
393  * @retval #CONNECTION_ERROR_NONE  Successful
394  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
395  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
396  * @see connection_open_profile()
397  */
398 int connection_update_profile(connection_h connection, connection_profile_h profile);
399
400 /**
401  * @brief Gets a iterator of the profiles.
402  * @remarks @a profile_iterator must be released with connection_destroy().
403  * @param[in] connection  The handle of connection
404  * @param[in] type  The type of connetion iterator
405  * @param[out] profile_iterator  The iterator of profile
406  * @return 0 on success, otherwise negative error value.
407  * @retval #CONNECTION_ERROR_NONE  Successful
408  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
409  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
410  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
411  */
412 int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator);
413
414 /**
415  * @brief Moves the profile iterator to the next position and gets a profile handle.
416  * @param[in] profile_iterator  The iterator of profile
417  * @param[out] profile  The handle of profile
418  * @return 0 on success, otherwise negative error value.
419  * @retval #CONNECTION_ERROR_NONE  Successful
420  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
421  * @retval #CONNECTION_ERROR_ITERATOR_END  End of iteration
422  */
423 int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile);
424
425 /**
426  * @brief Checks whether the next element of profile iterator exists or not.
427  * @param[in] profile_iterator  The iterator of profile
428  * @return @c true if next element exists, \n @c false if next element doesn't exist
429  */
430 bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator);
431
432 /**
433  * @brief Destroys a iterator of the profiles.
434  * @param[in] profile_iterator  The iterator of profile
435  * @return 0 on success, otherwise negative error value.
436  * @retval #CONNECTION_ERROR_NONE  Successful
437  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
438  */
439 int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator);
440
441 /**
442  * @brief Gets the name of default profile.
443  * @remarks @a profile must be released with connection_profile_destroy().
444  * @param[in] connection  The handle of connection
445  * @param[out] profile  The handle of profile
446  * @return 0 on success, otherwise negative error value.
447  * @retval #CONNECTION_ERROR_NONE  Successful
448  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
449  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
450  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
451  * @retval #CONNECTION_ERROR_NO_CONNECTION  There is no connection
452  */
453 int connection_get_current_profile(connection_h connection, connection_profile_h* profile);
454
455 /**
456  * @brief Gets the default profile which provides the given cellular service.
457  * @remarks  @a profile must be released with connection_profile_destroy().
458  * @param[in] connection  The handle of connection
459  * @param[in] type  The type of cellular service. #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted
460  * @param[out] profile  The handle of profile
461  * @return 0 on success, otherwise negative error value.
462  * @retval #CONNECTION_ERROR_NONE  Successful
463  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
464  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
465  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
466  */
467 int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile);
468
469 /**
470  * @brief Sets the default profile which provides the given cellular service.
471  * @param[in] connection  The handle of connection
472  * @param[in] type  The type of cellular service.
473  * #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are only permitted.
474  * @param[in] profile  The handle of profile
475  * @return 0 on success, otherwise negative error value.
476  * @retval #CONNECTION_ERROR_NONE  Successful
477  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
478  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
479  */
480 int connection_set_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile);
481
482 /**
483  * @brief Sets the default profile which provides the given cellular service, asynchronously.
484  * @param[in] connection  The handle of connection
485  * @param[in] type  The type of cellular service.
486  * #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are only permitted.
487  * @param[in] profile  The handle of profile
488  * @param[in] callback  The callback function to be called
489  * @param[in] user_data The user data passed to the callback function
490  * @return 0 on success, otherwise negative error value.
491  * @retval #CONNECTION_ERROR_NONE  Successful
492  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
493  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
494  */
495 int connection_set_default_cellular_service_profile_async(connection_h connection,
496                 connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void* user_data);
497
498 /**
499 * @brief Called after connection_open_profile() is completed.
500 * @param[in] result  The result
501 * @param[in] user_data The user data passed from connection_open_profile()
502 * @pre connection_open_profile() will invoke this callback function.
503 * @see connection_open_profile()
504 */
505 typedef void(*connection_opened_cb)(connection_error_e result, void* user_data);
506
507 /**
508 * @brief Called after connection_close_profile() is completed.
509 * @param[in] result  The result
510 * @param[in] user_data The user data passed from connection_close_profile()
511 * @pre connection_close_profile() will invoke this callback function.
512 * @see connection_close_profile()
513 */
514 typedef void(*connection_closed_cb)(connection_error_e result, void* user_data);
515
516 /**
517  * @brief Opens a connection of profile, asynchronously.
518  * @param[in] connection  The handle of connection
519  * @param[in] profile  The handle of profile
520  * @param[in] callback  The callback function to be called
521  * @param[in] user_data The user data passed to the callback function
522  * @return 0 on success, otherwise negative error value.
523  * @retval #CONNECTION_ERROR_NONE  Successful
524  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
525  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
526  * @post connection_opened_cb() will be invoked.
527  * @see connection_opened_cb()
528  * @see connection_close_profile()
529  * @see connection_profile_set_state_changed_cb()
530  * @see connection_profile_unset_state_changed_cb()
531  * @see connection_profile_state_changed_cb()
532  */
533 int connection_open_profile(connection_h connection, connection_profile_h profile, connection_opened_cb callback, void* user_data);
534
535 /**
536  * @brief Closes a connection of profile.
537  * @param[in] connection  The handle of connection
538  * @param[in] profile  The handle of profile
539  * @param[in] callback  The callback function to be called
540  * @param[in] user_data The user data passed to the callback function
541  * @return 0 on success, otherwise negative error value.
542  * @retval #CONNECTION_ERROR_NONE  Successful
543  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
544  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
545  * @post connection_closed_cb() will be invoked.
546  * @see connection_closed_cb()
547  * @see connection_open_profile()
548  * @see connection_profile_set_state_changed_cb()
549  * @see connection_profile_unset_state_changed_cb()
550  * @see connection_profile_state_changed_cb()
551  */
552 int connection_close_profile(connection_h connection, connection_profile_h profile, connection_closed_cb callback, void* user_data);
553
554 /**
555  * @brief Add a route to routing table.
556  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
557  * @param[in] connection  The handle of connection
558  * @param[in] interface_name  The name of network interface
559  * @param[in] host_address  The IP address of the host
560  * @return 0 on success, otherwise negative error value.
561  * @retval #CONNECTION_ERROR_NONE  Successful
562  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
563  * @retval #CONNECTION_ERROR_ALREADY_EXISTS  Already exists
564  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
565  * @see connection_profile_get_network_interface_name()
566  */
567 int connection_add_route(connection_h connection, const char* interface_name, const char* host_address);
568
569 /**
570  * @}
571 */
572
573 /**
574  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
575  * @{
576 */
577
578 /**
579  * @brief Gets the statistics information.
580  * @param[in] connection_type  The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported.
581  * @param[in] statistics_type  The type of statistics
582  * @param[out] size  The received data size of the last cellular packet data connection (bytes)
583  * @return 0 on success, otherwise negative error value.
584  * @retval #CONNECTION_ERROR_NONE  Successful
585  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
586  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
587  */
588 int connection_get_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size);
589
590 /**
591  * @brief Resets the statistics information
592  * @param[in] connection_type  The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported.
593  * @param[in] statistics_type  The type of statistics
594  * @return 0 on success, otherwise negative error value.
595  * @retval #CONNECTION_ERROR_NONE Successful
596  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
597  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
598  */
599 int connection_reset_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type);
600
601 /**
602  * @}
603  */
604
605
606 #ifdef __cplusplus
607 }
608 #endif /* __cplusplus */
609
610 #endif