Tizen Native API  8.0
Network Monitoring Connection

The Network Monitoring API provides functions for getting connection information.

Required Header

#include <inm.h>

Overview

This set of functions is used to get connection information. To use This kind of APIs, You should create a inm handle using inm_initialize(). After that, you need to get connection handle using inm_get_current_connection(), inm_connection_clone(), inm_connection_iterator_next. You should destroy the created connection handle if you do not need it anymore. You should destroy the created inm handle if you do not need it anymore.

Related Features

This API is related with the following features:

  • http://tizen.org/feature/network.ethernet
  • http://tizen.org/feature/network.wifi
  • http://tizen.org/feature/network.telephony
  • http://tizen.org/feature/network.tethering.bluetooth
  • http://tizen.org/feature/network.inm
    It is recommended to design feature related codes in your application for reliability.
    You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
    To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
    More details on featuring your application can be found from Feature Element.

Functions

int inm_connection_get_id (inm_connection_h connection, char **id)
 Gets the connection ID.
int inm_connection_get_name (inm_connection_h connection, char **name)
 Gets the connection name.
int inm_connection_get_type (inm_connection_h connection, inm_connection_type_e *type)
 Gets the network type.
int inm_connection_get_network_interface_name (inm_connection_h connection, char **interface_name)
 Gets the name of the network interface, e.g. eth0 and pdp0.
int inm_connection_refresh (inm_connection_h connection)
 Refreshes the connection information.
int inm_connection_get_state (inm_connection_h connection, inm_connection_state_e *state)
 Gets the network state.
int inm_connection_get_ipv6_state (inm_connection_h connection, inm_connection_state_e *state)
 Gets the IPv6 network state.
int inm_connection_get_ip_config_type (inm_connection_h connection, inm_address_family_e address_family, inm_ip_config_type_e *type)
 Gets the IP config type.
int inm_connection_get_ip_address (inm_connection_h connection, inm_address_family_e address_family, char **ip_address)
 Gets the IP address.
int inm_connection_get_subnet_mask (inm_connection_h connection, inm_address_family_e address_family, char **subnet_mask)
 Gets the Subnet Mask.
int inm_connection_get_gateway_address (inm_connection_h connection, inm_address_family_e address_family, char **gateway_address)
 Gets the Gateway address.
int inm_connection_get_dhcp_server_address (inm_connection_h connection, inm_address_family_e address_family, char **dhcp_server)
 Gets the DHCP Server address.
int inm_connection_get_dhcp_lease_duration (inm_connection_h connection, inm_address_family_e address_family, int *dhcp_lease_duration)
 Gets the DHCP lease duration.
int inm_connection_get_dns_address (inm_connection_h connection, int order, inm_address_family_e address_family, char **dns_address)
 Gets the DNS address.
int inm_connection_get_proxy_type (inm_connection_h connection, inm_proxy_type_e *type)
 Gets the Proxy type.
int inm_connection_get_proxy_address (inm_connection_h connection, inm_address_family_e address_family, char **proxy_address)
 Gets the Proxy address.
int inm_connection_get_dns_config_type (inm_connection_h connection, inm_address_family_e address_family, inm_dns_config_type_e *type)
 Gets the DNS config type.
int inm_connection_get_prefix_length (inm_connection_h connection, inm_address_family_e address_family, int *prefix_len)
 Gets the network prefix length.
int inm_connection_set_state_changed_cb (inm_connection_h connection, connection_state_changed_cb callback, void *user_data)
 Sets the callback that is called when the state of connection is changed.
int inm_connection_unset_state_changed_cb (inm_connection_h connection)
 Unsets the callback that is called when the state of connection is changed.
int inm_connection_get_link (inm_connection_h connection, inm_link_h *link)
 Gets the link handle for this connection.

Typedefs

typedef void(* connection_state_changed_cb )(inm_connection_state_e state, void *user_data)
 Called when the state of the connection is changed.

Typedef Documentation

typedef void(* connection_state_changed_cb)(inm_connection_state_e state, void *user_data)

Called when the state of the connection is changed.

Since :
5.0
Parameters:
[in]stateThe state
[in]user_dataThe user data passed from the callback registration function
See also:
inm_connection_set_state_changed_cb()
inm_connection_unset_state_changed_cb()

Enumeration Type Documentation

Enumeration for address family.

Since :
5.0
Enumerator:
INM_ADDRESS_FAMILY_IPV4 

IPV4 Address type

INM_ADDRESS_FAMILY_IPV6 

IPV6 Address type

Enumeration for connection state type.

Since :
5.0
Enumerator:
INM_CONNECTION_STATE_DISCONNECTED 

Disconnected state

INM_CONNECTION_STATE_ASSOCIATION 

Association state

INM_CONNECTION_STATE_CONFIGURATION 

Configuration state

INM_CONNECTION_STATE_CONNECTED 

Connected state

Enumeration for DNS configuration type.

Since :
5.0
Enumerator:
INM_DNS_CONFIG_TYPE_NONE 

Not defined

INM_DNS_CONFIG_TYPE_STATIC 

Manual DNS configuration

INM_DNS_CONFIG_TYPE_DYNAMIC 

Config DNS using DHCP client

Enumeration for IP configuration type.

Since :
5.0
Enumerator:
INM_IP_CONFIG_TYPE_NONE 

Not defined

INM_IP_CONFIG_TYPE_STATIC 

Manual IP configuration

INM_IP_CONFIG_TYPE_DYNAMIC 

Config IP using DHCP client

INM_IP_CONFIG_TYPE_AUTO 

Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available

INM_IP_CONFIG_TYPE_FIXED 

Indicates an IP address that can not be modified

Enumeration for proxy method type.

Since :
5.0
Enumerator:
INM_PROXY_TYPE_DIRECT 

Direct connection

INM_PROXY_TYPE_AUTO 

Auto configuration (use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried

INM_PROXY_TYPE_MANUAL 

Manual configuration


Function Documentation

int inm_connection_get_dhcp_lease_duration ( inm_connection_h  connection,
inm_address_family_e  address_family,
int *  dhcp_lease_duration 
)

Gets the DHCP lease duration.

Since :
5.0
Remarks:
This function is supported only for IPv4 address family.
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]dhcp_lease_durationThe DHCP lease duration in seconds
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_dhcp_server_address ( inm_connection_h  connection,
inm_address_family_e  address_family,
char **  dhcp_server 
)

Gets the DHCP Server address.

Since :
5.0
Remarks:
You must release dhcp_server using free(). This function is supported only for IPv4 address family.
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]dhcp_serverThe DHCP Server address
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_dns_address ( inm_connection_h  connection,
int  order,
inm_address_family_e  address_family,
char **  dns_address 
)

Gets the DNS address.

Since :
5.0
Remarks:
The allowance of the DNS address is 2. You must release dns_address using free().
Parameters:
[in]connectionThe connection handle
[in]orderThe order of DNS address
It starts from 1, which means first DNS address
[in]address_familyThe address family
[out]dns_addressThe DNS address
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed

Gets the DNS config type.

Since :
5.0
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]typeThe DNS config type
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_gateway_address ( inm_connection_h  connection,
inm_address_family_e  address_family,
char **  gateway_address 
)

Gets the Gateway address.

Since :
5.0
Remarks:
You must release gateway_address using free().
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]gateway_addressThe gateway address
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_id ( inm_connection_h  connection,
char **  id 
)

Gets the connection ID.

Two different connections can have the same name. So, you must use this function instead of inm_connection_get_name() if you want to get the unique identification.

Since :
5.0
Remarks:
You must release id using free().
Parameters:
[in]connectionThe connection handle
[out]idThe ID of the connection
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
See also:
inm_connection_get_name()
int inm_connection_get_ip_address ( inm_connection_h  connection,
inm_address_family_e  address_family,
char **  ip_address 
)

Gets the IP address.

Since :
5.0
Remarks:
You must release ip_address using free().
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]ip_addressThe IP address
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed

Gets the IP config type.

Since :
5.0
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]typeThe type of the IP config
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed

Gets the IPv6 network state.

Since :
5.0
Parameters:
[in]connectionThe connection handle
[out]stateThe connection state
Returns:
0 on success, otherwise negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_link ( inm_connection_h  connection,
inm_link_h link 
)

Gets the link handle for this connection.

Since :
5.5
Remarks:
You must release link using inm_link_destroy().
Parameters:
[in]connectionThe connection handle
[out]linkThe link of the connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
See also:
inm_link_clone()
int inm_connection_get_name ( inm_connection_h  connection,
char **  name 
)

Gets the connection name.

Since :
5.0
Remarks:
You must release name using free().
Parameters:
[in]connectionThe connection handle
[out]nameThe name of the connection
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
See also:
inm_connection_get_id()
int inm_connection_get_network_interface_name ( inm_connection_h  connection,
char **  interface_name 
)

Gets the name of the network interface, e.g. eth0 and pdp0.

Since :
5.0
Remarks:
You must release interface_name using free().
Parameters:
[in]connectionThe connection handle
[out]interface_nameThe name of the network interface
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_prefix_length ( inm_connection_h  connection,
inm_address_family_e  address_family,
int *  prefix_len 
)

Gets the network prefix length.

Since :
5.0
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]prefix_lenThe network prefix length
In case of IPv4, it means netmask length (also called a prefix, e.g. 8, 16, 24, 32)
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_proxy_address ( inm_connection_h  connection,
inm_address_family_e  address_family,
char **  proxy_address 
)

Gets the Proxy address.

Since :
5.0
Remarks:
You must release proxy_address using free().
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]proxy_addressThe proxy address
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed

Gets the Proxy type.

Since :
5.0
Parameters:
[in]connectionThe connection handle
[out]typeThe type of the proxy
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed

Gets the network state.

Since :
5.0
Parameters:
[in]connectionThe connection handle
[out]stateThe state of the connection
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_get_subnet_mask ( inm_connection_h  connection,
inm_address_family_e  address_family,
char **  subnet_mask 
)

Gets the Subnet Mask.

Since :
5.0
Remarks:
You must release subnet_mask using free(). This function is supported only for IPv4 address family.
Parameters:
[in]connectionThe connection handle
[in]address_familyThe address family
[out]subnet_maskThe subnet mask
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed

Gets the network type.

Since :
5.0
Parameters:
[in]connectionThe connection handle
[out]typeThe type of the connection
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed

Refreshes the connection information.

Since :
5.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.get
Remarks:
You should call this function in order to get the current information because the connection information can be changed.
Parameters:
[in]connectionThe connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_OUT_OF_MEMORYOut of memory
INM_ERROR_PERMISSION_DENIEDPermission Denied
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
int inm_connection_set_state_changed_cb ( inm_connection_h  connection,
connection_state_changed_cb  callback,
void *  user_data 
)

Sets the callback that is called when the state of connection is changed.

Since :
5.0
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:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
Postcondition:
connection_opened_cb() is invoked when the state of connection is changed.
See also:
connection_state_changed_cb()
inm_connection_unset_state_changed_cb()

Unsets the callback that is called when the state of connection is changed.

Since :
5.0
Parameters:
[in]connectionThe connection handle
Returns:
0 on success, otherwise a negative error value
Return values:
INM_ERROR_NONESuccessful
INM_ERROR_INVALID_PARAMETERInvalid parameter
INM_ERROR_NOT_SUPPORTEDNot supported
INM_ERROR_NOT_INITIALIZEDNot initialized
INM_ERROR_OPERATION_FAILEDOperation failed
See also:
connection_state_changed_cb()
inm_connection_set_state_changed_cb()