Tizen Native API  5.0
Connection Manager

The Connection Manager API provides functions for managing data connections.

Required Header

#include <net_connection.h>

Overview

To use Connection Manager API, first create a connection handle using connection_create(). After that, you can obtain network information. You should destroy the created connection handle if you do not need it anymore. This API is related with libsoup and sockets. It allows you to create a socket on the kernel Linux stack, which can be used directly or by libsoup or any other network library.

Related Features

This API is related with the following features:

Functions

int connection_create (connection_h *connection)
 Creates a handle for managing data connections.
int connection_destroy (connection_h connection)
 Destroys the connection handle.
int connection_get_type (connection_h connection, connection_type_e *type)
 Gets the type of the current profile for data connection.
int connection_get_ip_address (connection_h connection, connection_address_family_e address_family, char **ip_address)
 Gets the IP address of the current connection.
int connection_get_proxy (connection_h connection, connection_address_family_e address_family, char **proxy)
 Gets the proxy address of the current connection.
int connection_get_mac_address (connection_h connection, connection_type_e type, char **mac_addr)
 Gets the MAC address of the Wi-Fi or ethernet.
int connection_is_metered_network (connection_h connection, bool *is_metered)
 Gets if the current connection is metered.
int connection_get_cellular_state (connection_h connection, connection_cellular_state_e *state)
 Gets the state of cellular connection.
int connection_get_wifi_state (connection_h connection, connection_wifi_state_e *state)
 Gets the state of the Wi-Fi.
int connection_get_ethernet_state (connection_h connection, connection_ethernet_state_e *state)
 Gets the state of the Ethernet.
int connection_get_ethernet_cable_state (connection_h connection, connection_ethernet_cable_state_e *state)
 Checks for ethernet cable is attached or not.
int connection_set_ethernet_cable_state_chaged_cb (connection_h connection, connection_ethernet_cable_state_chaged_cb callback, void *user_data) TIZEN_DEPRECATED_API
 Sets callback for ethernet cable is plugged [in/out] event.
int connection_unset_ethernet_cable_state_chaged_cb (connection_h connection) TIZEN_DEPRECATED_API
 Unsets callback for ethernet cable is plugged [in/out] event.
int connection_set_ethernet_cable_state_changed_cb (connection_h connection, connection_ethernet_cable_state_changed_cb callback, void *user_data)
 Sets callback for ethernet cable is plugged [in/out] event.
int connection_unset_ethernet_cable_state_changed_cb (connection_h connection)
 Unsets callback for ethernet cable is plugged [in/out] event.
int connection_get_bt_state (connection_h connection, connection_bt_state_e *state)
 Gets the state of the Bluetooth.
int connection_set_type_changed_cb (connection_h connection, connection_type_changed_cb callback, void *user_data)
 Sets the callback that is called when the type of the current connection is changed.
int connection_unset_type_changed_cb (connection_h connection)
 Unsets the callback that is called when the type of current connection is changed.
int connection_set_ip_address_changed_cb (connection_h connection, connection_address_changed_cb callback, void *user_data)
 Sets the callback that is called when the IP address is changed.
int connection_unset_ip_address_changed_cb (connection_h connection)
 Unsets the callback that is called when the IP address is changed.
int connection_set_proxy_address_changed_cb (connection_h connection, connection_address_changed_cb callback, void *user_data)
 Sets the callback that is called when the proxy address is changed.
int connection_unset_proxy_address_changed_cb (connection_h connection)
 Unsets the callback that is called when the proxy address is changed.
int connection_add_profile (connection_h connection, connection_profile_h profile)
 Adds a new profile which is created by connection_profile_create().
int connection_remove_profile (connection_h connection, connection_profile_h profile)
 Removes an existing profile.
int connection_update_profile (connection_h connection, connection_profile_h profile)
 Updates an existing profile.
int connection_get_profile_iterator (connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h *profile_iterator)
 Gets a profiles iterator.
int connection_profile_iterator_next (connection_profile_iterator_h profile_iterator, connection_profile_h *profile)
 Moves the profile iterator to the next position and gets a profile handle.
bool connection_profile_iterator_has_next (connection_profile_iterator_h profile_iterator)
 Checks whether the next element of a profile iterator exists or not.
int connection_destroy_profile_iterator (connection_profile_iterator_h profile_iterator)
 Destroys a profiles iterator.
int connection_get_current_profile (connection_h connection, connection_profile_h *profile)
 Gets the name of the default profile.
int connection_get_default_cellular_service_profile (connection_h connection, connection_cellular_service_type_e type, connection_profile_h *profile)
 Gets the default profile which provides the given cellular service.
int connection_set_default_cellular_service_profile (connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile)
 Sets the default profile which provides the given cellular service.
int connection_set_default_cellular_service_profile_async (connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void *user_data)
 Sets the default profile which provides the given cellular service, asynchronously.
int connection_open_profile (connection_h connection, connection_profile_h profile, connection_opened_cb callback, void *user_data)
 Opens a connection of profile, asynchronously.
int connection_close_profile (connection_h connection, connection_profile_h profile, connection_closed_cb callback, void *user_data)
 Closes a connection of profile.
int connection_reset_profile (connection_h connection, connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data)
 Resets the cellular profile.
int connection_add_route (connection_h connection, const char *interface_name, const char *host_address) TIZEN_DEPRECATED_API
 Adds a IPv4 route to the routing table.
int connection_remove_route (connection_h connection, const char *interface_name, const char *host_address) TIZEN_DEPRECATED_API
 Removes a IPv4 route from the routing table.
int connection_add_route_ipv6 (connection_h connection, const char *interface_name, const char *host_address, const char *gateway) TIZEN_DEPRECATED_API
 Adds a IPv6 route to the routing table.
int connection_remove_route_ipv6 (connection_h connection, const char *interface_name, const char *host_address, const char *gateway) TIZEN_DEPRECATED_API
 Removes a IPV6 route from the routing table.
int connection_add_route_entry (connection_h connection, connection_address_family_e address_family, const char *interface_name, const char *host_address, const char *gateway)
 Adds a route to the routing table.
int connection_remove_route_entry (connection_h connection, connection_address_family_e address_family, const char *interface_name, const char *host_address, const char *gateway)
 Removes a route from the routing table.
int connection_foreach_ipv6_address (connection_h connection, connection_type_e connection_type, connection_ipv6_address_cb callback, void *user_data)
 Gets all IPv6 addresses assigned to the network interface.

Typedefs

typedef void * connection_h
 The connection handle.
typedef void * connection_profile_iterator_h
 The profiles iterator handle.
typedef void(* connection_type_changed_cb )(connection_type_e type, void *user_data)
 Called when the type of a connection is changed.
typedef void(* connection_address_changed_cb )(const char *ipv4_address, const char *ipv6_address, void *user_data)
 Called when the address is changed.
typedef void(* connection_set_default_cb )(connection_error_e result, void *user_data)
 Called when connection_set_default_cellular_service_profile_async() finishes.
typedef bool(* connection_ipv6_address_cb )(char *ipv6_address, void *user_data)
 Called with an IPv6 address.
typedef void(* connection_ethernet_cable_state_chaged_cb )(connection_ethernet_cable_state_e state, void *user_data)
 Called when ethernet cable is plugged [in/out].
typedef void(* connection_ethernet_cable_state_changed_cb )(connection_ethernet_cable_state_e state, void *user_data)
 Called when ethernet cable is plugged [in/out].
typedef void(* connection_opened_cb )(connection_error_e result, void *user_data)
 Called after connection_open_profile() is finished.
typedef void(* connection_closed_cb )(connection_error_e result, void *user_data)
 Called after connection_close_profile() is finished.
typedef void(* connection_reset_cb )(connection_error_e result, void *user_data)
 Called after connection_reset_profile() is finished.

Typedef Documentation

typedef void(* connection_address_changed_cb)(const char *ipv4_address, const char *ipv6_address, void *user_data)

Called when the address is changed.

Since :
2.3.1
Remarks:
ipv4_address ipv6_address should not be freed. ipv4_address ipv6_address is available only in the callback. To use outside the callback, make a copy.
Parameters:
[in]ipv4_addressThe IP address for IPv4
[in]ipv6_addressThe IP address for IPv6
[in]user_dataThe user data passed from the callback registration function
See also:
connection_set_ip_address_changed_cb()
connection_unset_ip_address_changed_cb()
connection_set_proxy_address_changed_cb()
connection_unset_proxy_address_changed_cb()
typedef void(* connection_closed_cb)(connection_error_e result, void *user_data)

Called after connection_close_profile() is finished.

Since :
2.3.1
Parameters:
[in]resultThe result
[in]user_dataThe user data passed from connection_close_profile()
Precondition:
connection_close_profile() will invoke this callback function.
See also:
connection_close_profile()

Called when ethernet cable is plugged [in/out].

Deprecated:
Deprecated since 4.0. Use connection_ethernet_cable_state_changed_cb() instead.
Since :
3.0
Parameters:
[in]stateThe state of ethernet cable
[in]user_dataThe user data passed to callback registration function

Called when ethernet cable is plugged [in/out].

Since :
4.0
Parameters:
[in]stateThe state of ethernet cable
[in]user_dataThe user data passed to callback registration function
typedef void* connection_h

The connection handle.

Since :
2.3.1
typedef bool(* connection_ipv6_address_cb)(char *ipv6_address, void *user_data)

Called with an IPv6 address.

Since :
4.0
Remarks:
If ipv6_address is needed outside the callback, a copy should be made.
ipv6_address will be freed automatically after the execution of this callback.
Parameters:
[in]ipv6_addressThe IPv6 address
[in]user_dataThe user data passed from the foreach function
Returns:
true to continue with the next iteration of the loop,
false to break out of the loop
Precondition:
connection_foreach_ipv6_addresses() will invoke this callback.
See also:
connection_foreach_ipv6_addresses()
typedef void(* connection_opened_cb)(connection_error_e result, void *user_data)

Called after connection_open_profile() is finished.

Since :
2.3.1
Parameters:
[in]resultThe result
[in]user_dataThe user data passed from connection_open_profile()
Precondition:
connection_open_profile() will invoke this callback function.
See also:
connection_open_profile()

The profiles iterator handle.

Since :
2.3.1
typedef void(* connection_reset_cb)(connection_error_e result, void *user_data)

Called after connection_reset_profile() is finished.

Since :
2.3.1
Parameters:
[in]resultThe result
[in]user_dataThe user data passed from connection_reset_profile()
Precondition:
connection_reset_profile() will invoke this callback function.
See also:
connection_reset_profile()
typedef void(* connection_set_default_cb)(connection_error_e result, void *user_data)

Called when connection_set_default_cellular_service_profile_async() finishes.

Since :
2.3.1
Parameters:
[in]resultThe result
[in]user_dataThe user data passed from connection_open_profile()
Precondition:
connection_set_default_cellular_service_profile_async() will invoke this callback function.
See also:
connection_set_default_cellular_service_profile_async()
typedef void(* connection_type_changed_cb)(connection_type_e type, void *user_data)

Called when the type of a connection is changed.

Since :
2.3.1
Parameters:
[in]typeThe type of the current network connection
[in]user_dataThe user data passed from the callback registration function
See also:
connection_set_type_changed_cb()
connection_unset_type_changed_cb()

Enumeration Type Documentation

Enumeration for Bluetooth state.

Since :
2.3.1
Enumerator:
CONNECTION_BT_STATE_DEACTIVATED 

There is no Bluetooth profile to open

CONNECTION_BT_STATE_DISCONNECTED 

Disconnected

CONNECTION_BT_STATE_CONNECTED 

Connected

Enumeration for cellular network state.

Since :
2.3.1
Enumerator:
CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE 

Out of service

CONNECTION_CELLULAR_STATE_FLIGHT_MODE 

Flight mode

CONNECTION_CELLULAR_STATE_ROAMING_OFF 

Roaming is turned off

CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE 

Call is only available

CONNECTION_CELLULAR_STATE_AVAILABLE 

Available but not connected yet

CONNECTION_CELLULAR_STATE_CONNECTED 

Connected

Enumeration for connection errors.

Since :
2.3.1
Enumerator:
CONNECTION_ERROR_NONE 

Successful

CONNECTION_ERROR_INVALID_PARAMETER 

Invalid parameter

CONNECTION_ERROR_OUT_OF_MEMORY 

Out of memory error

CONNECTION_ERROR_INVALID_OPERATION 

Invalid operation

CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED 

Address family not supported

CONNECTION_ERROR_OPERATION_FAILED 

Operation failed

CONNECTION_ERROR_ITERATOR_END 

End of iteration

CONNECTION_ERROR_NO_CONNECTION 

There is no connection

CONNECTION_ERROR_NOW_IN_PROGRESS 

Now inprogress

CONNECTION_ERROR_ALREADY_EXISTS 

Already exists

CONNECTION_ERROR_OPERATION_ABORTED 

Operation is aborted

CONNECTION_ERROR_DHCP_FAILED 

DHCP failed

CONNECTION_ERROR_INVALID_KEY 

Invalid key

CONNECTION_ERROR_NO_REPLY 

No reply

CONNECTION_ERROR_PERMISSION_DENIED 

Permission denied

CONNECTION_ERROR_NOT_SUPPORTED 

Not supported

CONNECTION_ERROR_ALREADY_INITIALIZED 

Already initialized (Since 5.0)

CONNECTION_ERROR_NOT_INITIALIZED 

Not initialized (Sinece 5.0)

Enumeration for the attached or detached state of ethernet cable.

Since :
3.0
Enumerator:
CONNECTION_ETHERNET_CABLE_DETACHED 

Ethernet cable is detached

CONNECTION_ETHERNET_CABLE_ATTACHED 

Ethernet cable is attached

Enumeration for ethernet state.

Since :
3.0
Enumerator:
CONNECTION_ETHERNET_STATE_DEACTIVATED 

There is no Ethernet profile to open

CONNECTION_ETHERNET_STATE_DISCONNECTED 

Disconnected

CONNECTION_ETHERNET_STATE_CONNECTED 

Connected

Enumeration for connection iterator type.

Since :
2.3.1
Enumerator:
CONNECTION_ITERATOR_TYPE_REGISTERED 

The iterator of the registered profile

CONNECTION_ITERATOR_TYPE_CONNECTED 

The iterator of the connected profile

CONNECTION_ITERATOR_TYPE_DEFAULT 

The iterator of the default profile

Enumeration for reset profile type.

Since :
2.3.1
Enumerator:
CONNECTION_RESET_DEFAULT_PROFILE 

Initialized with the default profile defined by csc

CONNECTION_RESET_CLEAR_PROFILE 

Remove all profiles

Enumeration for connection type.

Since :
2.3.1
Enumerator:
CONNECTION_TYPE_DISCONNECTED 

Disconnected

CONNECTION_TYPE_WIFI 

Wi-Fi type

CONNECTION_TYPE_CELLULAR 

Cellular type

CONNECTION_TYPE_ETHERNET 

Ethernet type

CONNECTION_TYPE_BT 

Bluetooth type

CONNECTION_TYPE_NET_PROXY 

Proxy type for internet connection (Since 3.0)

Enumeration for Wi-Fi state.

Since :
2.3.1
Enumerator:
CONNECTION_WIFI_STATE_DEACTIVATED 

Wi-Fi is deactivated

CONNECTION_WIFI_STATE_DISCONNECTED 

Disconnected

CONNECTION_WIFI_STATE_CONNECTED 

Connected


Function Documentation

int connection_add_profile ( connection_h  connection,
connection_profile_h  profile 
)

Adds a new profile which is created by connection_profile_create().

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.profile
Remarks:
You can only add a profile of the cellular type.
Parameters:
[in]connectionThe connection handle
[in]profileThe profile handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
int connection_add_route ( connection_h  connection,
const char *  interface_name,
const char *  host_address 
)

Adds a IPv4 route to the routing table.

Deprecated:
Deprecated since 4.0. Use connection_add_route_entry() instead.

You can get the interface_name from connection_profile_get_network_interface_name() of opened profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]connectionThe connection handle
[in]interface_nameThe name of network interface
[in]host_addressThe IP address of the host
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_ALREADY_EXISTSAlready exists
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
See also:
connection_profile_get_network_interface_name()
int connection_add_route_entry ( connection_h  connection,
connection_address_family_e  address_family,
const char *  interface_name,
const char *  host_address,
const char *  gateway 
)

Adds a route to the routing table.

You can get the interface_name from
connection_profile_get_network_interface_name() of opened profile.

Since :
4.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[in]interface_nameThe name of network interface
[in]host_addressThe IP address of the host (e.g., single IP address such as 163.152.10.2,192.168.1.2), group's IP address (e.g., 163.152.10.0, 192.168.0.0) is not allowed
[in]gatewayThe gateway address
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_ALREADY_EXISTSAlready exists
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
See also:
connection_profile_get_network_interface_name()
int connection_add_route_ipv6 ( connection_h  connection,
const char *  interface_name,
const char *  host_address,
const char *  gateway 
)

Adds a IPv6 route to the routing table.

Deprecated:
Deprecated since 4.0. Use connection_add_route_entry() instead.

You can get the interface_name from connection_profile_get_network_interface_name() of opened profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]connectionThe connection handle
[in]interface_nameThe name of network interface
[in]host_addressThe IP address of the host
[in]gatewayThe gateway address
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_ALREADY_EXISTSAlready exists
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
See also:
connection_profile_get_network_interface_name()
int connection_close_profile ( connection_h  connection,
connection_profile_h  profile,
connection_closed_cb  callback,
void *  user_data 
)

Closes a connection of profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]connectionThe connection handle
[in]profileThe profile handle
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
Postcondition:
connection_closed_cb() will be invoked.
See also:
connection_closed_cb()
connection_open_profile()
connection_profile_set_state_changed_cb()
connection_profile_unset_state_changed_cb()
connection_profile_state_changed_cb()
int connection_create ( connection_h connection)

Creates a handle for managing data connections.

If you do not use this function and use other functions, you will get the CONNECTION_ERROR_NOT_INITIALIZED error. If you put an invalid handle, you will get the CONNECTION_ERROR_INVALID_PARAMETER error.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Remarks:
You must release connection using connection_destroy().
Parameters:
[out]connectionThe connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_ALREADY_INITIALIZEDAlready initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OUT_OF_MEMORYOut of memory
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
See also:
connection_destroy()
int connection_destroy ( connection_h  connection)

Destroys the connection handle.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
See also:
connection_create()

Destroys a profiles iterator.

Since :
2.3.1
Parameters:
[in]profile_iteratorThe iterator of the profile
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
int connection_foreach_ipv6_address ( connection_h  connection,
connection_type_e  connection_type,
connection_ipv6_address_cb  callback,
void *  user_data 
)

Gets all IPv6 addresses assigned to the network interface.

Since :
4.0
Parameters:
[in]connectionThe connection handle
[in]connection_typeThe connection type
[in]callbackThe callback to be called for each IPv6 address
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise negative error value.
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
int connection_get_bt_state ( connection_h  connection,
connection_bt_state_e state 
)

Gets the state of the Bluetooth.

The returned state is for the Bluetooth connection state.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Parameters:
[in]connectionThe connection handle
[out]stateThe state of the Bluetooth connection
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Gets the state of cellular connection.

The returned state is for the cellular connection state.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
[out]stateThe state of the cellular connection
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Gets the name of the default profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Remarks:
You must release profile using connection_profile_destroy().
Parameters:
[in]connectionThe connection handle
[out]profileThe profile handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OUT_OF_MEMORYOut of memory
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NO_CONNECTIONThere is no connection
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied

Gets the default profile which provides the given cellular service.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Remarks:
You must release profile using connection_profile_destroy().
Parameters:
[in]connectionThe connection handle
[in]typeThe type of cellular service
CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted
[out]profileThe profile handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OUT_OF_MEMORYOut of memory
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Checks for ethernet cable is attached or not.

The returned state is for the ethernet cable state.

Since :
3.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Parameters:
[in]connectionThe handle of the connection
[in]stateThe state of ethernet cable
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied

Gets the state of the Ethernet.

The returned state is for the Ethernet connection state.

Since :
3.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Parameters:
[in]connectionThe connection handle
[out]stateThe state of Ethernet connection
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
int connection_get_ip_address ( connection_h  connection,
connection_address_family_e  address_family,
char **  ip_address 
)

Gets the IP address of the current connection.

Since :
2.3.1
Remarks:
You must release ip_address using free().
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]ip_addressThe pointer to the IP address string
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTEDNot supported address family
int connection_get_mac_address ( connection_h  connection,
connection_type_e  type,
char **  mac_addr 
)

Gets the MAC address of the Wi-Fi or ethernet.

Since :
3.0
Remarks:
mac_addr must be released with free() by you.
Parameters:
[in]connectionThe handle of the connection
[in]typeThe type of current network connection
[out]mac_addrThe MAC address
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_INVALID_OPERATIONInvalid operation
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
CONNECTION_ERROR_OUT_OF_MEMORYOut of memory

Gets a profiles iterator.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Remarks:
You must release profile_iterator using connection_destroy().
Parameters:
[in]connectionThe connection handle
[in]typeThe type of the connection iterator
[out]profile_iteratorThe iterator of profile
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OUT_OF_MEMORYOut of memory
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
int connection_get_proxy ( connection_h  connection,
connection_address_family_e  address_family,
char **  proxy 
)

Gets the proxy address of the current connection.

Since :
2.3.1
Remarks:
You must release proxy using free().
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]proxyThe proxy address
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTEDNot supported address family
int connection_get_type ( connection_h  connection,
connection_type_e type 
)

Gets the type of the current profile for data connection.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
[out]typeThe type of the network
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed

Gets the state of the Wi-Fi.

The returned state is for the Wi-Fi connection state.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Parameters:
[in]connectionThe connection handle
[out]stateThe state of Wi-Fi connection
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
int connection_is_metered_network ( connection_h  connection,
bool *  is_metered 
)

Gets if the current connection is metered.

Since :
4.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Parameters:
[in]connectionThe connection handle
[out]is_meteredThe value indicating whether it is metered
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
int connection_open_profile ( connection_h  connection,
connection_profile_h  profile,
connection_opened_cb  callback,
void *  user_data 
)

Opens a connection of profile, asynchronously.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
http://tizen.org/privilege/network.get
Remarks:
This function needs both privileges.
Parameters:
[in]connectionThe connection handle
[in]profileThe profile handle
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
Postcondition:
connection_opened_cb() will be invoked.
See also:
connection_opened_cb()
connection_close_profile()
connection_profile_set_state_changed_cb()
connection_profile_unset_state_changed_cb()
connection_profile_state_changed_cb()

Checks whether the next element of a profile iterator exists or not.

Since :
2.3.1
Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
Parameters:
[in]profile_iteratorThe iterator of profile
Returns:
true if next element exists, otherwise false if next element doesn't exist
Exceptions:
CONNECTION_ERROR_NONESuccessful
Return values:
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
Exceptions:
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
See also:
get_last_result()

Moves the profile iterator to the next position and gets a profile handle.

Since :
2.3.1
Parameters:
[in]profile_iteratorThe iterator of profile
[out]profileThe profile handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_ITERATOR_ENDEnd of iteration
int connection_remove_profile ( connection_h  connection,
connection_profile_h  profile 
)

Removes an existing profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.profile
http://tizen.org/privilege/network.get
Remarks:
This function needs both privileges.
Parameters:
[in]connectionThe connection handle
[in]profileThe profile handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
int connection_remove_route ( connection_h  connection,
const char *  interface_name,
const char *  host_address 
)

Removes a IPv4 route from the routing table.

Deprecated:
Deprecated since 4.0. Use connection_remove_route_entry() instead.

You can get the interface_name from connection_profile_get_network_interface_name() of opened profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]connectionThe connection handle
[in]interface_nameThe name of network interface
[in]host_addressThe IP address of the host
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
See also:
connection_profile_get_network_interface_name()
int connection_remove_route_entry ( connection_h  connection,
connection_address_family_e  address_family,
const char *  interface_name,
const char *  host_address,
const char *  gateway 
)

Removes a route from the routing table.

You can get the interface_name from
connection_profile_get_network_interface_name() of opened profile.

Since :
4.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[in]interface_nameThe name of network interface
[in]host_addressThe IP address of the host (e.g., single IP address such as 163.152.10.2,192.168.1.2), group's IP address (e.g., 163.152.10.0, 192.168.0.0) is not allowed
[in]gatewayThe gateway address
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
See also:
connection_profile_get_network_interface_name()
int connection_remove_route_ipv6 ( connection_h  connection,
const char *  interface_name,
const char *  host_address,
const char *  gateway 
)

Removes a IPV6 route from the routing table.

Deprecated:
Deprecated since 4.0. Use connection_remove_route_entry() instead.

You can get the interface_name from connection_profile_get_network_interface_name() of opened profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]connectionThe connection handle
[in]interface_nameThe name of network interface
[in]host_addressThe IP address of the host
[in]gatewayThe gateway address
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
See also:
connection_profile_get_network_interface_name()
int connection_reset_profile ( connection_h  connection,
connection_reset_option_e  type,
int  id,
connection_reset_cb  callback,
void *  user_data 
)

Resets the cellular profile.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.profile
http://tizen.org/privilege/network.get
Remarks:
This function needs both privileges.
Parameters:
[in]connectionThe connection handle
[in]typeThe type of reset
[in]idThe subscriber identity module ID to reset (The sim index starts from 0.)
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
Postcondition:
connection_reset_cb() will be invoked.

Sets the default profile which provides the given cellular service.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.profile
http://tizen.org/privilege/network.get
Remarks:
This function needs both privileges.
Parameters:
[in]connectionThe connection handle
[in]typeThe type of cellular service
Only CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted
[in]profileThe profile handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Sets the default profile which provides the given cellular service, asynchronously.

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.profile
http://tizen.org/privilege/network.get
Remarks:
This function needs both privileges.
Parameters:
[in]connectionThe connection handle
[in]typeThe type of cellular service
Only CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted
[in]profileThe profile handle
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Sets callback for ethernet cable is plugged [in/out] event.

Deprecated:
Deprecated since 4.0. Use connection_set_ethernet_cable_state_changed_cb() instead.
Since :
3.0
Parameters:
[in]connectionThe handle of connection
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Sets callback for ethernet cable is plugged [in/out] event.

Since :
4.0
Parameters:
[in]connectionThe handle of connection
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
int connection_set_ip_address_changed_cb ( connection_h  connection,
connection_address_changed_cb  callback,
void *  user_data 
)

Sets the callback that is called when the IP address is changed.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
int connection_set_proxy_address_changed_cb ( connection_h  connection,
connection_address_changed_cb  callback,
void *  user_data 
)

Sets the callback that is called when the proxy address is changed.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
int connection_set_type_changed_cb ( connection_h  connection,
connection_type_changed_cb  callback,
void *  user_data 
)

Sets the callback that is called when the type of the current connection is changed.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
[in]callbackThe callback function to be called
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed

Unsets callback for ethernet cable is plugged [in/out] event.

Deprecated:
Deprecated since 4.0. Use connection_unset_ethernet_cable_state_changed_cb() instead.
Since :
3.0
Parameters:
[in]connectionThe handle of connection
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Unsets callback for ethernet cable is plugged [in/out] event.

Since :
4.0
Parameters:
[in]connectionThe handle of connection
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_NOT_SUPPORTEDNot supported

Unsets the callback that is called when the IP address is changed.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed

Unsets the callback that is called when the proxy address is changed.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed

Unsets the callback that is called when the type of current connection is changed.

Since :
2.3.1
Parameters:
[in]connectionThe connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
int connection_update_profile ( connection_h  connection,
connection_profile_h  profile 
)

Updates an existing profile.

When a profile is changed, these changes will be not applied to the Connection Manager immediately. When you call this function, your changes affect the Connection Manager and the existing profile is updated. In addition, the existing profile will be updated if you call connection_open_profile().

Since :
2.3.1
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.profile
http://tizen.org/privilege/network.get
Remarks:
This function needs both privileges.
Parameters:
[in]connectionThe connection handle
[in]profileThe profile handle
Returns:
0 on success, otherwise a negative error value
Return values:
CONNECTION_ERROR_NONESuccessful
CONNECTION_ERROR_NOT_INITIALIZEDNot initialized
CONNECTION_ERROR_INVALID_PARAMETERInvalid parameter
CONNECTION_ERROR_OPERATION_FAILEDOperation failed
CONNECTION_ERROR_PERMISSION_DENIEDPermission denied
CONNECTION_ERROR_NOT_SUPPORTEDNot supported
See also:
connection_open_profile()