fd5c96dc00068f6d30b55538ddb00e6e9999ceaa
[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 __TIZEN_NETWORK_NET_CONNECTION_H__
19 #define __TIZEN_NETWORK_NET_CONNECTION_H__
20
21
22 #include <connection_profile.h>
23
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
28
29
30 /**
31  * @file net_connection.h
32  */
33
34
35 /**
36  * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
37  * @{
38  */
39
40
41 /**
42  * @brief The connection handle.
43  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
44 */
45 typedef void* connection_h;
46
47
48 /**
49  * @brief The profiles iterator handle.
50  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
51 */
52 typedef void* connection_profile_iterator_h;
53
54
55 /**
56  * @brief Enumeration for connection type.
57  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
58  */
59 typedef enum {
60         CONNECTION_TYPE_DISCONNECTED = 0,  /**< Disconnected */
61         CONNECTION_TYPE_WIFI = 1,          /**< Wi-Fi type */
62         CONNECTION_TYPE_CELLULAR = 2,      /**< Cellular type */
63         CONNECTION_TYPE_ETHERNET = 3,      /**< Ethernet type */
64         CONNECTION_TYPE_BT = 4,            /**< Bluetooth type */
65         CONNECTION_TYPE_NET_PROXY,         /**< Proxy type for internet connection (Since 3.0) */
66 } connection_type_e;
67
68
69 /**
70  * @brief Enumeration for cellular network state.
71  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
72  */
73 typedef enum {
74         CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE = 0,      /**< Out of service */
75         CONNECTION_CELLULAR_STATE_FLIGHT_MODE = 1,         /**< Flight mode */
76         CONNECTION_CELLULAR_STATE_ROAMING_OFF = 2,         /**< Roaming is turned off */
77         CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE = 3, /**< Call is only available */
78         CONNECTION_CELLULAR_STATE_AVAILABLE = 4,           /**< Available but not connected yet */
79         CONNECTION_CELLULAR_STATE_CONNECTED = 5,           /**< Connected */
80 } connection_cellular_state_e;
81
82
83 /**
84  * @brief Enumeration for Wi-Fi state.
85  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
86  */
87 typedef enum {
88         CONNECTION_WIFI_STATE_DEACTIVATED = 0,   /**< Wi-Fi is deactivated */
89         CONNECTION_WIFI_STATE_DISCONNECTED = 1,  /**< Disconnected */
90         CONNECTION_WIFI_STATE_CONNECTED = 2,     /**< Connected */
91 } connection_wifi_state_e;
92
93
94 /**
95  * @brief Enumeration for ethernet state.
96  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
97  */
98 typedef enum {
99         CONNECTION_ETHERNET_STATE_DEACTIVATED = 0,  /**< There is no Ethernet profile to open */
100         CONNECTION_ETHERNET_STATE_DISCONNECTED = 1, /**< Disconnected */
101         CONNECTION_ETHERNET_STATE_CONNECTED = 2,    /**< Connected */
102 } connection_ethernet_state_e;
103
104
105 /**
106  * @brief Enumeration for Bluetooth state.
107  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
108  */
109 typedef enum {
110         CONNECTION_BT_STATE_DEACTIVATED = 0,   /**< There is no Bluetooth profile to open */
111         CONNECTION_BT_STATE_DISCONNECTED = 1,  /**< Disconnected */
112         CONNECTION_BT_STATE_CONNECTED = 2,     /**< Connected */
113 } connection_bt_state_e;
114
115
116 /**
117  * @brief Enumeration for connection iterator type.
118  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
119  */
120 typedef enum {
121         CONNECTION_ITERATOR_TYPE_REGISTERED = 0, /**< The iterator of the registered profile */
122         CONNECTION_ITERATOR_TYPE_CONNECTED = 1,  /**< The iterator of the connected profile */
123         CONNECTION_ITERATOR_TYPE_DEFAULT = 2,    /**< The iterator of the default profile */
124 } connection_iterator_type_e;
125
126
127 /**
128  * @brief Enumeration for reset profile type.
129  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
130 */
131 typedef enum {
132         /**
133          * Initialized with the default profile defined by csc
134          */
135         CONNECTION_RESET_DEFAULT_PROFILE = 0,
136
137         /**
138          * Remove all profiles
139          */
140         CONNECTION_RESET_CLEAR_PROFILE = 1,
141
142 } connection_reset_option_e;
143
144
145 /**
146  * @brief Enumeration for the attached or detached state of ethernet cable.
147  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
148  */
149 typedef enum {
150         CONNECTION_ETHERNET_CABLE_DETACHED = 0,   /**< Ethernet cable is detached */
151         CONNECTION_ETHERNET_CABLE_ATTACHED = 1,   /**< Ethernet cable is attached */
152 } connection_ethernet_cable_state_e;
153
154
155 /**
156  * @brief Enumeration for connection errors.
157  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
158  */
159 typedef enum {
160         /**
161          * Successful
162          */
163         CONNECTION_ERROR_NONE = TIZEN_ERROR_NONE,
164
165         /**
166          * Invalid parameter
167          */
168         CONNECTION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,
169
170         /**
171          * Out of memory error
172          */
173         CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,
174
175         /**
176          * Invalid operation
177          */
178         CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION,
179
180         /**
181          * Address family not supported
182          */
183         CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED,
184
185         /**
186          * Operation failed
187          */
188         CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_CONNECTION|0x0401,
189
190         /**
191          * End of iteration
192          */
193         CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_CONNECTION|0x0402,
194
195         /**
196          * There is no connection
197          */
198         CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_CONNECTION|0x0403,
199
200         /**
201          * Now inprogress
202          */
203         CONNECTION_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS,
204
205         /**
206          * Already exists
207          */
208         CONNECTION_ERROR_ALREADY_EXISTS = TIZEN_ERROR_CONNECTION|0x0404,
209
210         /**
211          * Operation is aborted
212          */
213         CONNECTION_ERROR_OPERATION_ABORTED = TIZEN_ERROR_CONNECTION|0x0405,
214
215         /**
216          * DHCP failed
217          */
218         CONNECTION_ERROR_DHCP_FAILED = TIZEN_ERROR_CONNECTION|0x0406,
219
220         /**
221          * Invalid key
222          */
223         CONNECTION_ERROR_INVALID_KEY = TIZEN_ERROR_CONNECTION|0x0407,
224
225         /**
226          * No reply
227          */
228         CONNECTION_ERROR_NO_REPLY = TIZEN_ERROR_CONNECTION|0x0408,
229
230         /**
231          * Permission denied
232          */
233         CONNECTION_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,
234
235         /**
236          * Not supported
237          */
238         CONNECTION_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,
239
240         /**
241          * Already initialized (Since 5.0)
242          */
243         CONNECTION_ERROR_ALREADY_INITIALIZED = TIZEN_ERROR_CONNECTION|0x0409,
244
245         /**
246          * Not initialized (Sinece 5.0)
247          */
248         CONNECTION_ERROR_NOT_INITIALIZED = TIZEN_ERROR_CONNECTION|0x040A,
249
250 } connection_error_e;
251
252 /**
253  * @}
254 */
255
256
257 /**
258  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
259  * @{
260 */
261
262
263 /**
264  * @brief Enumeration for statistics type.
265  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
266  */
267 typedef enum {
268         CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0,  /**< Last received data */
269         CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA = 1,      /**< Last sent data */
270         CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2, /**< Total received data */
271         CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA = 3,     /**< Total sent data */
272 } connection_statistics_type_e;
273
274
275 /**
276  * @}
277 */
278
279
280 /**
281  * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
282  * @{
283 */
284
285
286 /**
287  * @brief Creates a handle for managing data connections.
288  * @details If you do not use this function and use other functions,
289  *          you will get the #CONNECTION_ERROR_NOT_INITIALIZED error.
290  *          If you put an invalid handle, you will get the #CONNECTION_ERROR_INVALID_PARAMETER error.
291  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
292  * @privlevel public
293  * @privilege %http://tizen.org/privilege/network.get
294  * @remarks You must release @a connection using connection_destroy().
295  * @param[out] connection       The connection handle
296  * @return @c 0 on success,
297  *         otherwise a negative error value
298  * @retval #CONNECTION_ERROR_NONE                  Successful
299  * @retval #CONNECTION_ERROR_ALREADY_INITIALIZED   Already initialized
300  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
301  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY         Out of memory
302  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
303  * @see connection_destroy()
304  */
305 int connection_create(connection_h* connection);
306
307
308 /**
309  * @brief Destroys the connection handle.
310  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
311  * @param[in] connection        The connection handle
312  * @return @c 0 on success,
313  *         otherwise a negative error value
314  * @retval #CONNECTION_ERROR_NONE                  Successful
315  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
316  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
317  * @see connection_create()
318  */
319 int connection_destroy(connection_h connection);
320
321
322 /**
323  * @brief Called when the type of a connection is changed.
324  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
325  * @param[in] type              The type of the current network connection
326  * @param[in] user_data         The user data passed from the callback registration function
327  * @see connection_set_type_changed_cb()
328  * @see connection_unset_type_changed_cb()
329  */
330 typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data);
331
332
333 /**
334  * @brief Called when the address is changed.
335  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
336  * @remarks @a ipv4_address @a ipv6_address should not be freed.
337  *          @a ipv4_address @a ipv6_address is available only in the callback.
338  *          To use outside the callback, make a copy.
339  * @param[in] ipv4_address      The IP address for IPv4
340  * @param[in] ipv6_address      The IP address for IPv6
341  * @param[in] user_data         The user data passed from the callback registration function
342  * @see connection_set_ip_address_changed_cb()
343  * @see connection_unset_ip_address_changed_cb()
344  * @see connection_set_proxy_address_changed_cb()
345  * @see connection_unset_proxy_address_changed_cb()
346  */
347 typedef void(*connection_address_changed_cb)(const char* ipv4_address,
348                 const char* ipv6_address, void* user_data);
349
350
351 /**
352  * @brief Called when connection_set_default_cellular_service_profile_async() finishes.
353  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
354  * @param[in] result            The result
355  * @param[in] user_data         The user data passed from connection_open_profile()
356  * @pre connection_set_default_cellular_service_profile_async() will invoke this callback function.
357  * @see connection_set_default_cellular_service_profile_async()
358 */
359 typedef void(*connection_set_default_cb)(connection_error_e result, void* user_data);
360
361 /**
362  * @brief Called with an IPv6 address.
363  * @since_tizen 4.0
364  * @remarks   If @a ipv6_address is needed outside the callback, a copy should be made. \n
365  *            @a ipv6_address will be freed automatically after the execution of this callback.
366  * @param[in]  ipv6_address     The IPv6 address
367  * @param[in]  user_data        The user data passed from the foreach function
368  * @return  @c true to continue with the next iteration of the loop, \n
369  *          @c false to break out of the loop
370  * @pre  connection_foreach_ipv6_addresses() will invoke this callback.
371  * @see  connection_foreach_ipv6_addresses()
372  */
373 typedef bool(*connection_ipv6_address_cb)(char *ipv6_address, void *user_data);
374
375 /**
376  * @brief Gets the type of the current profile for data connection.
377  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
378  * @param[in] connection        The connection handle
379  * @param[out] type             The type of the network
380  * @return @c 0 on success,
381  *         otherwise a negative error value
382  * @retval #CONNECTION_ERROR_NONE                  Successful
383  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
384  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
385  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
386  */
387 int connection_get_type(connection_h connection, connection_type_e* type);
388
389
390 /**
391  * @brief Gets the IP address of the current connection.
392  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
393  * @remarks You must release @a ip_address using free().
394  * @param[in] connection        The connection handle
395  * @param[in] address_family    The address family
396  * @param[out] ip_address       The pointer to the IP address string
397  * @return @c 0 on success,
398  *         otherwise a negative error value
399  * @retval #CONNECTION_ERROR_NONE                           Successful
400  * @retval #CONNECTION_ERROR_NOT_INITIALIZED                Not initialized
401  * @retval #CONNECTION_ERROR_INVALID_PARAMETER              Invalid parameter
402  * @retval #CONNECTION_ERROR_OPERATION_FAILED               Operation failed
403  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED   Not supported address family
404  */
405 int connection_get_ip_address(connection_h connection,
406                 connection_address_family_e address_family, char** ip_address);
407
408
409 /**
410  * @brief Gets the proxy address of the current connection.
411  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
412  * @remarks You must release @a proxy using free().
413  * @param[in] connection        The connection handle
414  * @param[in] address_family    The address family
415  * @param[out] proxy            The proxy address
416  * @return @c 0 on success,
417  *         otherwise a negative error value
418  * @retval #CONNECTION_ERROR_NONE                           Successful
419  * @retval #CONNECTION_ERROR_NOT_INITIALIZED                Not initialized
420  * @retval #CONNECTION_ERROR_INVALID_PARAMETER              Invalid parameter
421  * @retval #CONNECTION_ERROR_OPERATION_FAILED               Operation failed
422  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED   Not supported address family
423  */
424 int connection_get_proxy(connection_h connection,
425                 connection_address_family_e address_family, char** proxy);
426
427
428 /**
429  * @brief Gets the MAC address of the Wi-Fi or ethernet.
430  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
431  * @remarks @a mac_addr must be released with free() by you.
432  * @param[in] connection        The handle of the connection
433  * @param[in] type              The type of current network connection
434  * @param[out] mac_addr         The MAC address
435  * @return @c 0 on success,
436  *         otherwise a negative error value
437  * @retval #CONNECTION_ERROR_NONE                  Successful
438  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
439  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
440  * @retval #CONNECTION_ERROR_INVALID_OPERATION     Invalid operation
441  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
442  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
443  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY         Out of memory
444  */
445 int connection_get_mac_address(connection_h connection,
446                 connection_type_e type, char** mac_addr);
447
448
449 /**
450  * @brief Gets if the current connection is metered.
451  * @since_tizen 4.0
452  * @privlevel public
453  * @privilege %http://tizen.org/privilege/network.get
454  * @param[in] connection        The connection handle
455  * @param[out] is_metered       The value indicating whether it is metered
456  * @return @c 0 on success,
457  *         otherwise a negative error value
458  * @retval #CONNECTION_ERROR_NONE                  Successful
459  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
460  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
461  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
462  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
463  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
464  */
465 int connection_is_metered_network(connection_h connection, bool* is_metered);
466
467
468 /**
469  * @brief Gets the state of cellular connection.
470  * @details The returned state is for the cellular connection state.
471  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
472  * @param[in] connection        The connection handle
473  * @param[out] state            The state of the cellular connection
474  * @return @c 0 on success,
475  *         otherwise a negative error value
476  * @retval #CONNECTION_ERROR_NONE                  Successful
477  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
478  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
479  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
480  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
481  */
482 int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state);
483
484
485 /**
486  * @brief Gets the state of the Wi-Fi.
487  * @details The returned state is for the Wi-Fi connection state.
488  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
489  * @privlevel public
490  * @privilege %http://tizen.org/privilege/network.get
491  * @param[in] connection        The connection handle
492  * @param[out] state            The state of Wi-Fi connection
493  * @return @c 0 on success,
494  *         otherwise a negative error value
495  * @retval #CONNECTION_ERROR_NONE                  Successful
496  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
497  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
498  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
499  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
500  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
501  */
502 int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state);
503
504
505 /**
506  * @brief Gets the state of the Ethernet.
507  * @details The returned state is for the Ethernet connection state.
508  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
509  * @privlevel public
510  * @privilege %http://tizen.org/privilege/network.get
511  * @param[in] connection        The connection handle
512  * @param[out] state            The state of Ethernet connection
513  * @return @c 0 on success,
514  *         otherwise a negative error value
515  * @retval #CONNECTION_ERROR_NONE                  Successful
516  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
517  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
518  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
519  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
520  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
521  */
522 int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state);
523
524
525 /**
526  * @brief Checks for ethernet cable is attached or not.
527  * @details The returned state is for the ethernet cable state.
528  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
529  * @privlevel public
530  * @privilege %http://tizen.org/privilege/network.get
531  * @param[in] connection        The handle of the connection
532  * @param[in] state             The state of ethernet cable
533  * @return @c 0 on success,
534  *         otherwise a negative error value
535  * @retval #CONNECTION_ERROR_NONE                  Successful
536  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
537  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
538  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
539  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
540  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
541  */
542 int connection_get_ethernet_cable_state(connection_h connection,
543                 connection_ethernet_cable_state_e *state);
544
545
546 /**
547  * @deprecated Deprecated since 4.0. Use connection_ethernet_cable_state_changed_cb() instead.
548  * @brief Called when ethernet cable is plugged [in/out].
549  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
550  * @param[in] state             The state of ethernet cable
551  * @param[in] user_data         The user data passed to callback registration function
552  */
553 typedef void(*connection_ethernet_cable_state_chaged_cb)
554                 (connection_ethernet_cable_state_e state, void* user_data);
555
556
557 /**
558  * @deprecated Deprecated since 4.0. Use connection_set_ethernet_cable_state_changed_cb() instead.
559  * @brief Sets callback for ethernet cable is plugged [in/out] event.
560  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
561  * @param[in] connection        The handle of connection
562  * @param[in] callback          The callback function to be called
563  * @param[in] user_data         The user data passed to the callback function
564  * @return @c 0 on success,
565  *         otherwise a negative error value
566  * @retval #CONNECTION_ERROR_NONE                  Successful
567  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
568  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
569  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
570  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
571  */
572 int connection_set_ethernet_cable_state_chaged_cb(connection_h connection,
573                 connection_ethernet_cable_state_chaged_cb callback, void *user_data) TIZEN_DEPRECATED_API;
574
575
576 /**
577  * @deprecated Deprecated since 4.0. Use connection_unset_ethernet_cable_state_changed_cb() instead.
578  * @brief Unsets callback for ethernet cable is plugged [in/out] event.
579  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
580  * @param[in] connection        The handle of connection
581  * @return @c 0 on success,
582  *         otherwise a negative error value
583  * @retval #CONNECTION_ERROR_NONE                  Successful
584  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
585  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
586  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
587  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
588  */
589 int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection) TIZEN_DEPRECATED_API;
590
591 /**
592  * @brief Called when ethernet cable is plugged [in/out].
593  * @since_tizen 4.0
594  * @param[in] state             The state of ethernet cable
595  * @param[in] user_data         The user data passed to callback registration function
596  */
597 typedef void(*connection_ethernet_cable_state_changed_cb)(
598                 connection_ethernet_cable_state_e state, void* user_data);
599
600
601 /**
602  * @brief Sets callback for ethernet cable is plugged [in/out] event.
603  * @since_tizen 4.0
604  * @param[in] connection        The handle of connection
605  * @param[in] callback          The callback function to be called
606  * @param[in] user_data         The user data passed to the callback function
607  * @return @c 0 on success,
608  *         otherwise a negative error value
609  * @retval #CONNECTION_ERROR_NONE                  Successful
610  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
611  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
612  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
613  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
614  */
615 int connection_set_ethernet_cable_state_changed_cb(connection_h connection,
616                 connection_ethernet_cable_state_changed_cb callback, void *user_data);
617
618
619 /**
620  * @brief Unsets callback for ethernet cable is plugged [in/out] event.
621  * @since_tizen 4.0
622  * @param[in] connection        The handle of connection
623  * @return @c 0 on success,
624  *         otherwise a negative error value
625  * @retval #CONNECTION_ERROR_NONE                  Successful
626  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
627  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
628  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
629  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
630  */
631 int connection_unset_ethernet_cable_state_changed_cb(connection_h connection);
632
633
634 /**
635  * @brief Gets the state of the Bluetooth.
636  * @details The returned state is for the Bluetooth connection state.
637  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
638  * @privlevel public
639  * @privilege %http://tizen.org/privilege/network.get
640  * @param[in] connection        The connection handle
641  * @param[out] state            The state of the Bluetooth connection
642  * @return @c 0 on success,
643  *         otherwise a negative error value
644  * @retval #CONNECTION_ERROR_NONE                  Successful
645  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
646  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
647  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
648  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
649  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
650  */
651 int connection_get_bt_state(connection_h connection, connection_bt_state_e* state);
652
653
654 /**
655  * @brief Sets the callback that is called when the type of the current connection is changed.
656  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
657  * @param[in] connection        The connection handle
658  * @param[in] callback          The callback function to be called
659  * @param[in] user_data         The user data passed to the callback function
660  * @return @c 0 on success,
661  *         otherwise a negative error value
662  * @retval #CONNECTION_ERROR_NONE                  Successful
663  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
664  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
665  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
666  */
667 int connection_set_type_changed_cb(connection_h connection,
668                 connection_type_changed_cb callback, void* user_data);
669
670
671 /**
672  * @brief Unsets the callback that is called when the type of current connection is changed.
673  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
674  * @param[in] connection        The connection handle
675  * @return @c 0 on success,
676  *         otherwise a negative error value
677  * @retval #CONNECTION_ERROR_NONE                  Successful
678  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
679  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
680  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
681  */
682 int connection_unset_type_changed_cb(connection_h connection);
683
684
685 /**
686  * @brief Sets the callback that is called when the IP address is changed.
687  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
688  * @param[in] connection        The connection handle
689  * @param[in] callback          The callback function to be called
690  * @param[in] user_data         The user data passed to the callback function
691  * @return @c 0 on success,
692  *         otherwise a negative error value
693  * @retval #CONNECTION_ERROR_NONE                  Successful
694  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
695  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
696  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
697  */
698 int connection_set_ip_address_changed_cb(connection_h connection,
699                 connection_address_changed_cb callback, void* user_data);
700
701
702 /**
703  * @brief Unsets the callback that is called when the IP address is changed.
704  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
705  * @param[in] connection        The connection handle
706  * @return @c 0 on success,
707  *         otherwise a negative error value
708  * @retval #CONNECTION_ERROR_NONE                  Successful
709  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
710  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
711  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
712  */
713 int connection_unset_ip_address_changed_cb(connection_h connection);
714
715
716 /**
717  * @brief Sets the callback that is called when the proxy address is changed.
718  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
719  * @param[in] connection        The connection handle
720  * @param[in] callback          The callback function to be called
721  * @param[in] user_data         The user data passed to the callback function
722  * @return @c 0 on success,
723  *         otherwise a negative error value
724  * @retval #CONNECTION_ERROR_NONE                  Successful
725  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
726  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
727  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
728  */
729 int connection_set_proxy_address_changed_cb(connection_h connection,
730                 connection_address_changed_cb callback, void* user_data);
731
732
733 /**
734  * @brief Unsets the callback that is called when the proxy address is changed.
735  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
736  * @param[in] connection        The connection handle
737  * @return @c 0 on success,
738  *         otherwise a negative error value
739  * @retval #CONNECTION_ERROR_NONE                  Successful
740  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
741  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
742  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
743  */
744 int connection_unset_proxy_address_changed_cb(connection_h connection);
745
746
747 /**
748  * @brief Adds a new profile which is created by connection_profile_create().
749  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
750  * @privlevel public
751  * @privilege %http://tizen.org/privilege/network.profile
752  * @remarks You can only add a profile of the cellular type.
753  * @param[in] connection        The connection handle
754  * @param[in] profile           The profile handle
755  * @return @c 0 on success,
756  *         otherwise a negative error value
757  * @retval #CONNECTION_ERROR_NONE                  Successful
758  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
759  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
760  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
761  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
762  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
763  */
764 int connection_add_profile(connection_h connection, connection_profile_h profile);
765
766
767 /**
768  * @brief Removes an existing profile.
769  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
770  * @privlevel public
771  * @privilege %http://tizen.org/privilege/network.profile \n
772  *            %http://tizen.org/privilege/network.get
773  * @remarks This function needs both privileges.
774  * @param[in] connection        The connection handle
775  * @param[in] profile           The profile handle
776  * @return @c 0 on success,
777  *         otherwise a negative error value
778  * @retval #CONNECTION_ERROR_NONE                  Successful
779  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
780  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
781  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
782  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
783  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
784  */
785 int connection_remove_profile(connection_h connection, connection_profile_h profile);
786
787
788 /**
789  * @brief Updates an existing profile.
790  * @details When a profile is changed, these changes will be not applied to the
791  *          Connection Manager immediately.
792  *          When you call this function, your changes affect the Connection Manager
793  *          and the existing profile is updated.
794  *          In addition, the existing profile will be updated if you call connection_open_profile().
795  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
796  * @privlevel public
797  * @privilege %http://tizen.org/privilege/network.profile \n
798  *            %http://tizen.org/privilege/network.get
799  * @remarks This function needs both privileges.
800  * @param[in] connection        The connection handle
801  * @param[in] profile           The profile handle
802  * @return @c 0 on success,
803  *         otherwise a negative error value
804  * @retval #CONNECTION_ERROR_NONE                  Successful
805  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
806  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
807  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
808  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
809  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
810  * @see connection_open_profile()
811  */
812 int connection_update_profile(connection_h connection, connection_profile_h profile);
813
814
815 /**
816  * @brief Gets a profiles iterator.
817  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
818  * @privlevel public
819  * @privilege %http://tizen.org/privilege/network.get
820  * @remarks You must release @a profile_iterator using connection_destroy().
821  * @param[in] connection        The connection handle
822  * @param[in] type              The type of the connection iterator
823  * @param[out] profile_iterator The iterator of profile
824  * @return @c 0 on success,
825  *         otherwise a negative error value
826  * @retval #CONNECTION_ERROR_NONE                  Successful
827  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
828  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
829  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY         Out of memory
830  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
831  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
832  */
833 int connection_get_profile_iterator(connection_h connection,
834                 connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator);
835
836
837 /**
838  * @brief Moves the profile iterator to the next position and gets a profile handle.
839  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
840  * @param[in] profile_iterator  The iterator of profile
841  * @param[out] profile          The profile handle
842  * @return @c 0 on success,
843  *         otherwise a negative error value
844  * @retval #CONNECTION_ERROR_NONE                  Successful
845  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
846  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
847  * @retval #CONNECTION_ERROR_ITERATOR_END          End of iteration
848  */
849 int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator,
850                 connection_profile_h* profile);
851
852
853 /**
854  * @brief Checks whether the next element of a profile iterator exists or not.
855  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
856  * @remarks The specific error code can be obtained using the get_last_result() method.
857  *          Error codes are described in Exception section.
858  * @param[in] profile_iterator  The iterator of profile
859  * @return @c true if next element exists,
860  *         otherwise @c false if next element doesn't exist
861  * @exception #CONNECTION_ERROR_NONE                  Successful
862  * @retval #CONNECTION_ERROR_NOT_INITIALIZED          Not initialized
863  * @exception #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
864  * @see get_last_result()
865  */
866 bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator);
867
868
869 /**
870  * @brief Destroys a profiles iterator.
871  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
872  * @param[in] profile_iterator  The iterator of the profile
873  * @return @c 0 on success,
874  *         otherwise a negative error value
875  * @retval #CONNECTION_ERROR_NONE                  Successful
876  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
877  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
878  */
879 int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator);
880
881
882 /**
883  * @brief Gets the name of the default profile.
884  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
885  * @privlevel public
886  * @privilege %http://tizen.org/privilege/network.get
887  * @remarks You must release @a profile using connection_profile_destroy().
888  * @param[in] connection        The connection handle
889  * @param[out] profile          The profile handle
890  * @return @c 0 on success,
891  *         otherwise a negative error value
892  * @retval #CONNECTION_ERROR_NONE                  Successful
893  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
894  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
895  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY         Out of memory
896  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
897  * @retval #CONNECTION_ERROR_NO_CONNECTION         There is no connection
898  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
899  */
900 int connection_get_current_profile(connection_h connection, connection_profile_h* profile);
901
902
903 /**
904  * @brief Gets the default profile which provides the given cellular service.
905  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
906  * @privlevel public
907  * @privilege %http://tizen.org/privilege/network.get
908  * @remarks You must release @a profile using connection_profile_destroy().
909  * @param[in] connection        The connection handle
910  * @param[in] type              The type of cellular service \n
911  *            #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted
912  * @param[out] profile          The profile handle
913  * @return @c 0 on success,
914  *         otherwise a negative error value
915  * @retval #CONNECTION_ERROR_NONE                  Successful
916  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
917  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
918  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY         Out of memory
919  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
920  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
921  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
922  */
923 int connection_get_default_cellular_service_profile(connection_h connection,
924                 connection_cellular_service_type_e type, connection_profile_h* profile);
925
926
927 /**
928  * @brief Sets the default profile which provides the given cellular service.
929  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
930  * @privlevel public
931  * @privilege %http://tizen.org/privilege/network.profile \n
932  *            %http://tizen.org/privilege/network.get
933  * @remarks This function needs both privileges.
934  * @param[in] connection        The connection handle
935  * @param[in] type              The type of cellular service \n
936  *            Only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and
937  *            #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted
938  * @param[in] profile           The profile handle
939  * @return @c 0 on success,
940  *         otherwise a negative error value
941  * @retval #CONNECTION_ERROR_NONE                  Successful
942  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
943  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
944  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
945  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
946  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
947  */
948 int connection_set_default_cellular_service_profile(connection_h connection,
949                 connection_cellular_service_type_e type, connection_profile_h profile);
950
951
952 /**
953  * @brief Sets the default profile which provides the given cellular service, asynchronously.
954  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
955  * @privlevel public
956  * @privilege %http://tizen.org/privilege/network.profile \n
957  *                %http://tizen.org/privilege/network.get
958  * @remarks This function needs both privileges.
959  * @param[in] connection        The connection handle
960  * @param[in] type              The type of cellular service \n
961  *            Only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and
962  *            #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted
963  * @param[in] profile The profile handle
964  * @param[in] callback The callback function to be called
965  * @param[in] user_data The user data passed to the callback function
966  * @return @c 0 on success,
967  *         otherwise a negative error value
968  * @retval #CONNECTION_ERROR_NONE                  Successful
969  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
970  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
971  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
972  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
973  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
974  */
975 int connection_set_default_cellular_service_profile_async(connection_h connection,
976                 connection_cellular_service_type_e type, connection_profile_h profile,
977                 connection_set_default_cb callback, void* user_data);
978
979
980 /**
981  * @brief Called after connection_open_profile() is finished.
982  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
983  * @param[in] result            The result
984  * @param[in] user_data         The user data passed from connection_open_profile()
985  * @pre connection_open_profile() will invoke this callback function.
986  * @see connection_open_profile()
987 */
988 typedef void(*connection_opened_cb)(connection_error_e result, void* user_data);
989
990
991 /**
992  * @brief Called after connection_close_profile() is finished.
993  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
994  * @param[in] result            The result
995  * @param[in] user_data         The user data passed from connection_close_profile()
996  * @pre connection_close_profile() will invoke this callback function.
997  * @see connection_close_profile()
998 */
999 typedef void(*connection_closed_cb)(connection_error_e result, void* user_data);
1000
1001
1002 /**
1003  * @brief Called after connection_reset_profile() is finished.
1004  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1005  * @param[in] result            The result
1006  * @param[in] user_data         The user data passed from connection_reset_profile()
1007  * @pre connection_reset_profile() will invoke this callback function.
1008  * @see connection_reset_profile()
1009 */
1010 typedef void(*connection_reset_cb)(connection_error_e result, void* user_data);
1011
1012
1013 /**
1014  * @brief Opens a connection of profile, asynchronously.
1015  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1016  * @privlevel public
1017  * @privilege %http://tizen.org/privilege/network.set \n
1018  *            %http://tizen.org/privilege/network.get
1019  * @remarks This function needs both privileges.
1020  * @param[in] connection        The connection handle
1021  * @param[in] profile           The profile handle
1022  * @param[in] callback          The callback function to be called
1023  * @param[in] user_data         The user data passed to the callback function
1024  * @return @c 0 on success,
1025  *         otherwise a negative error value
1026  * @retval #CONNECTION_ERROR_NONE                  Successful
1027  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1028  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1029  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1030  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1031  * @post connection_opened_cb() will be invoked.
1032  * @see connection_opened_cb()
1033  * @see connection_close_profile()
1034  * @see connection_profile_set_state_changed_cb()
1035  * @see connection_profile_unset_state_changed_cb()
1036  * @see connection_profile_state_changed_cb()
1037  */
1038 int connection_open_profile(connection_h connection, connection_profile_h profile,
1039                 connection_opened_cb callback, void* user_data);
1040
1041
1042 /**
1043  * @brief Closes a connection of profile.
1044  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1045  * @privlevel public
1046  * @privilege %http://tizen.org/privilege/network.set
1047  * @param[in] connection        The connection handle
1048  * @param[in] profile           The profile handle
1049  * @param[in] callback          The callback function to be called
1050  * @param[in] user_data         The user data passed to the callback function
1051  * @return @c 0 on success,
1052  *         otherwise a negative error value
1053  * @retval #CONNECTION_ERROR_NONE                  Successful
1054  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1055  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1056  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1057  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1058  * @post connection_closed_cb() will be invoked.
1059  * @see connection_closed_cb()
1060  * @see connection_open_profile()
1061  * @see connection_profile_set_state_changed_cb()
1062  * @see connection_profile_unset_state_changed_cb()
1063  * @see connection_profile_state_changed_cb()
1064  */
1065 int connection_close_profile(connection_h connection, connection_profile_h profile,
1066                 connection_closed_cb callback, void* user_data);
1067
1068
1069 /**
1070  * @brief Resets the cellular profile.
1071  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1072  * @privlevel public
1073  * @privilege %http://tizen.org/privilege/network.profile \n
1074  *                %http://tizen.org/privilege/network.get
1075  * @remarks This function needs both privileges.
1076  * @param[in] connection        The connection handle
1077  * @param[in] type              The type of reset
1078  * @param[in] id                The subscriber identity module ID to reset
1079  *                              (The sim index starts from 0.)
1080  * @param[in] callback          The callback function to be called
1081  * @param[in] user_data         The user data passed to the callback function
1082  * @return @c 0 on success,
1083  *         otherwise a negative error value
1084  * @retval #CONNECTION_ERROR_NONE                  Successful
1085  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1086  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1087  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1088  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1089  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
1090  * @post connection_reset_cb() will be invoked.
1091 */
1092 int connection_reset_profile(connection_h connection, connection_reset_option_e type,
1093                 int id, connection_reset_cb callback, void *user_data);
1094
1095
1096 /**
1097  * @deprecated Deprecated since 4.0. Use connection_add_route_entry() instead.
1098  * @brief Adds a IPv4 route to the routing table.
1099  * @details You can get the @a interface_name from
1100  *          connection_profile_get_network_interface_name() of opened profile.
1101  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1102  * @privlevel public
1103  * @privilege %http://tizen.org/privilege/network.set
1104  * @param[in] connection        The connection handle
1105  * @param[in] interface_name    The name of network interface
1106  * @param[in] host_address      The IP address of the host
1107  * @return @c 0 on success,
1108  *         otherwise a negative error value
1109  * @retval #CONNECTION_ERROR_NONE                  Successful
1110  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1111  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1112  * @retval #CONNECTION_ERROR_ALREADY_EXISTS        Already exists
1113  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1114  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1115  * @see connection_profile_get_network_interface_name()
1116  */
1117 int connection_add_route(connection_h connection, const char* interface_name,
1118                 const char* host_address) TIZEN_DEPRECATED_API;
1119
1120
1121 /**
1122  * @deprecated Deprecated since 4.0. Use connection_remove_route_entry() instead.
1123  * @brief Removes a IPv4 route from the routing table.
1124  * @details You can get the @a interface_name from
1125  *          connection_profile_get_network_interface_name() of opened profile.
1126  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1127  * @privlevel public
1128  * @privilege %http://tizen.org/privilege/network.set
1129  * @param[in] connection        The connection handle
1130  * @param[in] interface_name    The name of network interface
1131  * @param[in] host_address      The IP address of the host
1132  * @return @c 0 on success,
1133  *         otherwise a negative error value
1134  * @retval #CONNECTION_ERROR_NONE                  Successful
1135  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1136  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1137  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1138  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1139  * @see connection_profile_get_network_interface_name()
1140  */
1141 int connection_remove_route(connection_h connection, const char* interface_name,
1142                 const char* host_address) TIZEN_DEPRECATED_API;
1143
1144
1145 /**
1146  * @deprecated Deprecated since 4.0. Use connection_add_route_entry() instead.
1147  * @brief Adds a IPv6 route to the routing table.
1148  * @details You can get the @a interface_name from
1149  *          connection_profile_get_network_interface_name() of opened profile.
1150  * @since_tizen 2.3.1
1151  * @privlevel public
1152  * @privilege %http://tizen.org/privilege/network.set
1153  * @param[in] connection        The connection handle
1154  * @param[in] interface_name    The name of network interface
1155  * @param[in] host_address      The IP address of the host
1156  * @param[in] gateway           The gateway address
1157  * @return @c 0 on success,
1158  *         otherwise a negative error value
1159  * @retval #CONNECTION_ERROR_NONE                  Successful
1160  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1161  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1162  * @retval #CONNECTION_ERROR_ALREADY_EXISTS        Already exists
1163  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1164  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1165  * @see connection_profile_get_network_interface_name()
1166  */
1167 int connection_add_route_ipv6(connection_h connection, const char *interface_name,
1168                 const char *host_address, const char * gateway) TIZEN_DEPRECATED_API;
1169
1170
1171 /**
1172  * @deprecated Deprecated since 4.0. Use connection_remove_route_entry() instead.
1173  * @brief Removes a IPV6 route from the routing table.
1174  * @details You can get the @a interface_name from
1175  *          connection_profile_get_network_interface_name() of opened profile.
1176  * @since_tizen 2.3.1
1177  * @privlevel public
1178  * @privilege %http://tizen.org/privilege/network.set
1179  * @param[in] connection        The connection handle
1180  * @param[in] interface_name    The name of network interface
1181  * @param[in] host_address      The IP address of the host
1182  * @param[in] gateway           The gateway address
1183  * @return @c 0 on success,
1184  *         otherwise a negative error value
1185  * @retval #CONNECTION_ERROR_NONE                  Successful
1186  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1187  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1188  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1189  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1190  * @see connection_profile_get_network_interface_name()
1191  */
1192 int connection_remove_route_ipv6(connection_h connection, const char *interface_name,
1193                 const char *host_address, const char * gateway) TIZEN_DEPRECATED_API;
1194
1195 /**
1196  * @brief Adds a route to the routing table.
1197  * @details You can get the @a interface_name from \n
1198  *          connection_profile_get_network_interface_name() of opened profile.
1199  * @since_tizen 4.0
1200  * @privlevel public
1201  * @privilege %http://tizen.org/privilege/network.set
1202  * @param[in] connection        The connection handle
1203  * @param[in] address_family    The address family
1204  * @param[in] interface_name    The name of network interface
1205  * @param[in] host_address      The IP address of the host (e.g., single IP address such as
1206  *            163.152.10.2,192.168.1.2), group's IP address (e.g., 163.152.10.0, 192.168.0.0)
1207  *            is not allowed
1208  * @param[in] gateway           The gateway address
1209  * @return @c 0 on success,
1210  *         otherwise a negative error value
1211  * @retval #CONNECTION_ERROR_NONE                  Successful
1212  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1213  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1214  * @retval #CONNECTION_ERROR_ALREADY_EXISTS        Already exists
1215  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1216  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1217  * @see connection_profile_get_network_interface_name()
1218  */
1219 int connection_add_route_entry(connection_h connection,
1220                 connection_address_family_e address_family, const char *interface_name,
1221                 const char *host_address, const char *gateway);
1222
1223 /**
1224  * @brief Removes a route from the routing table.
1225  * @details You can get the @a interface_name from \n
1226  *          connection_profile_get_network_interface_name() of opened profile.
1227  * @since_tizen 4.0
1228  * @privlevel public
1229  * @privilege %http://tizen.org/privilege/network.set
1230  * @param[in] connection        The connection handle
1231  * @param[in] address_family    The address family
1232  * @param[in] interface_name    The name of network interface
1233  * @param[in] host_address      The IP address of the host (e.g., single IP address such as
1234  *            163.152.10.2,192.168.1.2), group's IP address (e.g., 163.152.10.0, 192.168.0.0)
1235  *            is not allowed
1236  * @param[in] gateway           The gateway address
1237  * @return @c 0 on success,
1238  *         otherwise a negative error value
1239  * @retval #CONNECTION_ERROR_NONE                  Successful
1240  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1241  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1242  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1243  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1244  * @see connection_profile_get_network_interface_name()
1245  */
1246 int connection_remove_route_entry(connection_h connection,
1247                 connection_address_family_e address_family, const char *interface_name,
1248                 const char *host_address, const char *gateway);
1249
1250 /**
1251  * @brief Gets all IPv6 addresses assigned to the network interface.
1252  * @since_tizen 4.0
1253  * @param[in] connection       The connection handle
1254  * @param[in] connection_type  The connection type
1255  * @param[in] callback         The callback to be called for each IPv6 address
1256  * @param[in] user_data        The user data passed to the callback function
1257  * @return 0 on success, otherwise negative error value.
1258  * @retval #CONNECTION_ERROR_NONE               Successful
1259  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1260  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
1261  * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
1262  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
1263  */
1264 int connection_foreach_ipv6_address(connection_h connection, connection_type_e connection_type,
1265                 connection_ipv6_address_cb callback, void *user_data);
1266
1267 /**
1268  * @}
1269 */
1270
1271
1272 /**
1273  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
1274  * @{
1275 */
1276
1277
1278 /**
1279  * @brief Gets the statistics information.
1280  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1281  * @privlevel public
1282  * @privilege %http://tizen.org/privilege/network.get
1283  * @param[in] connection The connection handle
1284  * @param[in] connection_type   The type of connection \n
1285  *            Only #CONNECTION_TYPE_WIFI and #CONNECTION_TYPE_CELLULAR are supported
1286  * @param[in] statistics_type   The type of statistics
1287  * @param[out] size             The received data size of the last cellular packet data connection (bytes)
1288  * @return @c 0 on success,
1289  *         otherwise a negative error value
1290  * @retval #CONNECTION_ERROR_NONE                  Successful
1291  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1292  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1293  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1294  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1295  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
1296  */
1297 int connection_get_statistics(connection_h connection, connection_type_e connection_type,
1298                 connection_statistics_type_e statistics_type, long long* size);
1299
1300
1301 /**
1302  * @brief Resets the statistics information.
1303  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1304  * @privlevel public
1305  * @privilege %http://tizen.org/privilege/network.set
1306  * @param[in] connection        The connection handle
1307  * @param[in] connection_type   The type of connection \n
1308  *            Only #CONNECTION_TYPE_WIFI and #CONNECTION_TYPE_CELLULAR are supported
1309  * @param[in] statistics_type   The type of statistics
1310  * @return @c 0 on success,
1311  *         otherwise a negative error value
1312  * @retval #CONNECTION_ERROR_NONE                  Successful
1313  * @retval #CONNECTION_ERROR_NOT_INITIALIZED       Not initialized
1314  * @retval #CONNECTION_ERROR_INVALID_PARAMETER     Invalid parameter
1315  * @retval #CONNECTION_ERROR_OPERATION_FAILED      Operation failed
1316  * @retval #CONNECTION_ERROR_PERMISSION_DENIED     Permission denied
1317  * @retval #CONNECTION_ERROR_NOT_SUPPORTED         Not supported
1318  */
1319 int connection_reset_statistics(connection_h connection, connection_type_e connection_type,
1320                 connection_statistics_type_e statistics_type);
1321 /**
1322  * @}
1323 */
1324
1325
1326 #ifdef __cplusplus
1327 }
1328 #endif /* __cplusplus */
1329
1330
1331 #endif /* __TIZEN_NETWORK_NET_CONNECTION_H__ */