Tizen Native API  8.0

The Network Monitoring API provides functions for getting network interface related information.

Required Header

#include <inm.h>

Overview

This set of functions are used to get network interface related information. To use this kind of APIs, You should create a inm handle using inm_initialize(). After that, you need to get link handle using inm_connection_get_link(), inm_link_clone(), inm_foreach_link(). You should destroy the created link 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.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_link_destroy (inm_link_h link)
 Destroys a link handle.
int inm_link_clone (inm_link_h *cloned, inm_link_h origin)
 Clones a link handle.
int inm_link_get_interface_name (inm_link_h link, char **interface_name)
 Gets the link interface name.
int inm_link_get_flags (inm_link_h link, int *flags)
 Gets the link flags.
int inm_link_get_operation_state (inm_link_h link, inm_link_oper_state_e *operation_state)
 Gets the link operation status.
int inm_link_get_received_bytes (inm_link_h link, unsigned long long *bytes)
 Gets the bytes received by the link.
int inm_link_get_sent_bytes (inm_link_h link, unsigned long long *bytes)
 Gets the bytes sent by the link.
int inm_link_foreach_address (inm_link_h link, inm_link_address_cb callback, void *user_data)
 Gets all addresses of the link.
int inm_link_address_destroy (inm_link_address_h address)
 Destroys a link address handle.
int inm_link_address_clone (inm_link_address_h *cloned, inm_link_address_h origin)
 Clones a link address handle.
int inm_link_address_get_family (inm_link_address_h address, inm_address_family_e *family)
 Gets the address family.
int inm_link_address_get_prefix_length (inm_link_address_h address, int *prefix_length)
 Gets the address prefix length.
int inm_link_address_get_scope (inm_link_address_h address, inm_link_scope_e *scope)
 Gets the address scope.
int inm_link_address_get_string (inm_link_address_h address, char **address_string)
 Gets the address string.
int inm_link_foreach_route (inm_link_h link, inm_link_route_cb callback, void *user_data)
 Gets all route tables of the link.
int inm_link_route_destroy (inm_link_route_h route)
 Destroys a link route handle.
int inm_link_route_clone (inm_link_route_h *cloned, inm_link_route_h origin)
 Clones a link route handle.
int inm_link_route_get_destination (inm_link_route_h route, char **destination)
 Gets the route destination.
int inm_link_route_get_gateway (inm_link_route_h route, char **gateway)
 Gets the route gateway.
int inm_link_route_get_interface (inm_link_route_h route, char **interface)
 Gets the route interface.
int inm_link_route_is_default (inm_link_route_h route, bool *is_default)
 Checks whether the route is default or not.
int inm_link_route_get_type (inm_link_route_h route, inm_link_route_type_e *type)
 Gets the route type.

Typedefs

typedef bool(* inm_link_address_cb )(inm_link_address_h address, void *user_data)
 Called with handle of the link address.
typedef bool(* inm_link_route_cb )(inm_link_route_h route, void *user_data)
 Called with handle of the link route table.

Typedef Documentation

typedef bool(* inm_link_address_cb)(inm_link_address_h address, void *user_data)

Called with handle of the link address.

Since :
5.5
Remarks:
If address is needed outside the callback, a copy should be made. address will be freed automatically after the execution of this callback.
Parameters:
[in]addressThe link address handle
[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:
inm_link_foreach_address() will invoke this callback.
See also:
inm_link_foreach_address().
typedef bool(* inm_link_route_cb)(inm_link_route_h route, void *user_data)

Called with handle of the link route table.

Since :
5.0
Remarks:
If route is needed outside the callback, a copy should be made. route will be freed automatically after the execution of this callback.
Parameters:
[in]routeThe link route handle
[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:
inm_link_foreach_route() will invoke this callback.
See also:
inm_link_foreach_route().

Enumeration Type Documentation

Enumeration for link flag.

Since :
5.5
Enumerator:
INM_LINK_FLAG_UP 

Interface is up

INM_LINK_FLAG_BROADCAST 

Broadcast address is valid

INM_LINK_FLAG_DEBUG 

Debugging

INM_LINK_FLAG_LOOPBACK 

link is a loopback

INM_LINK_FLAG_P2P 

Interface is has p-p link

INM_LINK_FLAG_NOTRAILERS 

Avoid use of trailers

INM_LINK_FLAG_RUNNING 

Interface RFC2863 OPER_UP

INM_LINK_FLAG_NOARP 

No ARP protocol

INM_LINK_FLAG_PROMISC 

Receive all packets

INM_LINK_FLAG_ALLMULTI 

Receive all multicast packets

INM_LINK_FLAG_MULTICAST 

Supports multicast

INM_LINK_FLAG_DYNAMIC 

Dialup device with changing addresses

INM_LINK_FLAG_LOWER_UP 

Driver signals L1 up

INM_LINK_FLAG_DORMANT 

Driver signals dormant

Enumeration for link RFC 2863 operation status.

Since :
5.5
Enumerator:
INM_LINK_OPER_UNKNOWN 

UNKNOWN

INM_LINK_OPER_NOT_PRESENT 

NOT PRESENT

INM_LINK_OPER_DOWN 

DOWN

INM_LINK_OPER_LOWER_LAYER_DOWN 

LOWER LAYER DOWN

INM_LINK_OPER_TESTING 

TESTING

INM_LINK_OPER_DORMANT 

DORMANT

INM_LINK_OPER_UP 

UP

Enumeration for link route scope.

Since :
5.5
Enumerator:
INM_LINK_ROUTE_TYPE_UNSPEC 

Unspecified

INM_LINK_ROUTE_TYPE_UNICAST 

Gateway or direct

INM_LINK_ROUTE_TYPE_LOCAL 

Accept locally

INM_LINK_ROUTE_TYPE_BROADCAST 

Accept locally as broadcast, send as broadcast

INM_LINK_ROUTE_TYPE_ANYCAST 

Accept locally as broadcast, but send as unicast

INM_LINK_ROUTE_TYPE_MULTICAST 

Multicast

INM_LINK_ROUTE_TYPE_BLACKHOLE 

Drop

INM_LINK_ROUTE_TYPE_UNREACHABLE 

Destination is unreachable

INM_LINK_ROUTE_TYPE_PROHIBIT 

Administratively prohibited

INM_LINK_ROUTE_TYPE_THROW 

Not in this table

INM_LINK_ROUTE_TYPE_NAT 

Translate this address

INM_LINK_ROUTE_TYPE_XRESOLVE 

Use external resolver

Enumeration for link scope.

Since :
5.5
Enumerator:
INM_LINK_SCOPE_NOWHERE 

Scope nowhere

INM_LINK_SCOPE_HOST 

A route has host scope when it leads to a destination address on the local host

INM_LINK_SCOPE_LINK 

A route has host scope when it leads to a destination address on the local network

INM_LINK_SCOPE_SITE 

Valid only within this site (IPv6)

INM_LINK_SCOPE_UNIVERSE 

A route has universe scope when it leads to addresses more than one hop away


Function Documentation

Clones a link address handle.

Since :
5.5
Remarks:
You must release cloned link address using inm_link_address_destroy().
Parameters:
[out]clonedThe handle of the cloned link address
[in]originThe handle of the origin link 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
See also:
inm_link_address_destroy()

Destroys a link address handle.

Since :
5.5
Parameters:
[in]addressThe link address 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:
inm_link_address_clone()
inm_link_foreach_address()

Gets the address family.

Since :
5.5
Parameters:
[in]addressThe address handle
[out]familyThe address family
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:
inm_link_foreach_address()
int inm_link_address_get_prefix_length ( inm_link_address_h  address,
int *  prefix_length 
)

Gets the address prefix length.

Since :
5.5
Parameters:
[in]addressThe address handle
[out]prefix_lengthThe prefix length of address
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:
inm_link_foreach_address()

Gets the address scope.

Since :
5.5
Parameters:
[in]addressThe address handle
[out]scopeThe address scope
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:
inm_link_foreach_address()
int inm_link_address_get_string ( inm_link_address_h  address,
char **  address_string 
)

Gets the address string.

Since :
5.5
Remarks:
You must release address_string using free().
Parameters:
[in]addressThe address handle
[out]address_stringThe address string
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
INM_ERROR_DATA_NOT_FOUNDData not found
See also:
inm_link_foreach_address()
int inm_link_clone ( inm_link_h cloned,
inm_link_h  origin 
)

Clones a link handle.

Since :
5.5
Remarks:
You must release cloned link using inm_link_destroy().
Parameters:
[out]clonedThe handle of the cloned link
[in]originThe handle of the origin link
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_destroy()

Destroys a link handle.

Since :
5.5
Parameters:
[out]linkThe link 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:
inm_link_clone()
inm_foreach_link()
int inm_link_foreach_address ( inm_link_h  link,
inm_link_address_cb  callback,
void *  user_data 
)

Gets all addresses of the link.

Since :
5.5
Parameters:
[in]linkThe link handle
[in]callbackThe callback to be called for each address of link
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise 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_OPERATION_FAILEDOperation failed
int inm_link_foreach_route ( inm_link_h  link,
inm_link_route_cb  callback,
void *  user_data 
)

Gets all route tables of the link.

Since :
5.0
Parameters:
[in]linkThe link handle
[in]callbackThe callback to be called for each route table of link
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise 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_OPERATION_FAILEDOperation failed
int inm_link_get_flags ( inm_link_h  link,
int *  flags 
)

Gets the link flags.

Since :
5.5
Parameters:
[in]linkThe link handle
[out]flagsThe flags, values of inm_link_flag_e combined with bitwise 'or'
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:
inm_foreach_link()
int inm_link_get_interface_name ( inm_link_h  link,
char **  interface_name 
)

Gets the link interface name.

Since :
5.5
Remarks:
You must release interface_name using free().
Parameters:
[in]linkThe link handle
[out]interface_nameThe interface name of the link
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_foreach_link()
int inm_link_get_operation_state ( inm_link_h  link,
inm_link_oper_state_e operation_state 
)

Gets the link operation status.

Since :
5.5
Parameters:
[in]linkThe link handle
[out]operation_stateThe operation status of the link
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:
inm_foreach_link()
int inm_link_get_received_bytes ( inm_link_h  link,
unsigned long long *  bytes 
)

Gets the bytes received by the link.

Since :
5.5
Parameters:
[in]linkThe link handle
[out]bytesThe bytes received by the link
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:
inm_foreach_link()
int inm_link_get_sent_bytes ( inm_link_h  link,
unsigned long long *  bytes 
)

Gets the bytes sent by the link.

Since :
5.5
Parameters:
[in]linkThe link handle
[out]bytesThe bytes sent by the link
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:
inm_foreach_link()
int inm_link_route_clone ( inm_link_route_h cloned,
inm_link_route_h  origin 
)

Clones a link route handle.

Since :
5.5
Remarks:
You must release cloned link route using inm_link_route_destroy().
Parameters:
[out]clonedThe handle of the cloned link route
[in]originThe handle of the origin link route
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_route_destroy()

Destroys a link route handle.

Since :
5.5
Parameters:
[in]routeThe link route 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:
inm_link_route_clone()
inm_link_foreach_route()
int inm_link_route_get_destination ( inm_link_route_h  route,
char **  destination 
)

Gets the route destination.

Since :
5.5
Remarks:
You must release destination using free().
Parameters:
[in]routeThe route handle
[out]destinationThe route destination
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
INM_ERROR_DATA_NOT_FOUNDData not found
See also:
inm_link_foreach_route()
int inm_link_route_get_gateway ( inm_link_route_h  route,
char **  gateway 
)

Gets the route gateway.

Since :
5.5
Remarks:
You must release gateway using free().
Parameters:
[in]routeThe route handle
[out]gatewayThe route gateway
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
INM_ERROR_DATA_NOT_FOUNDData not found
See also:
inm_link_foreach_route()
int inm_link_route_get_interface ( inm_link_route_h  route,
char **  interface 
)

Gets the route interface.

Since :
5.5
Remarks:
You must release interface using free().
Parameters:
[in]routeThe route handle
[out]interfaceThe route 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
INM_ERROR_DATA_NOT_FOUNDData not found
See also:
inm_link_foreach_route()

Gets the route type.

Since :
5.5
Parameters:
[in]routeThe route handle
[out]typeThe route 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
See also:
inm_link_foreach_route()
int inm_link_route_is_default ( inm_link_route_h  route,
bool *  is_default 
)

Checks whether the route is default or not.

Since :
5.5
Parameters:
[in]routeThe route handle
[out]is_defaulttrue if route is default, otherwise false if route is not default
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:
inm_link_foreach_route()