le_net API Reference

Data Structures

struct  le_net_DnsServerAddresses_t
 
struct  le_net_DefaultGatewayAddresses_t
 

Files

file  le_net_common.h
 
file  le_net_interface.h
 

Macros

#define LE_NET_INTERFACE_NAME_MAX_LEN   100
 
#define LE_NET_IPV4ADDR_MAX_LEN   16
 
#define LE_NET_IPV6ADDR_MAX_LEN   46
 
#define LE_NET_IPADDR_MAX_LEN   46
 

Typedefs

typedef void(* le_net_DisconnectHandler_t) (void *)
 

Functions

void le_net_ConnectService (void)
 
le_result_t le_net_TryConnectService (void)
 
LE_FULL_API void le_net_SetServerDisconnectHandler (le_net_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
void le_net_DisconnectService (void)
 
le_result_t le_net_ChangeRoute (le_dcs_ChannelRef_t channelRef, const char *LE_NONNULL destAddr, const char *LE_NONNULL prefixLength, bool isAdd)
 
le_result_t le_net_SetDefaultGW (le_dcs_ChannelRef_t channelRef)
 
le_result_t le_net_GetDefaultGW (le_dcs_ChannelRef_t channelRef, le_net_DefaultGatewayAddresses_t *addrPtr)
 
void le_net_BackupDefaultGW (void)
 
le_result_t le_net_RestoreDefaultGW (void)
 
le_result_t le_net_SetDNS (le_dcs_ChannelRef_t channelRef)
 
le_result_t le_net_GetDNS (le_dcs_ChannelRef_t channelRef, le_net_DnsServerAddresses_t *addrPtr)
 
void le_net_RestoreDNS (void)
 

Detailed Description

Macro Definition Documentation

◆ LE_NET_INTERFACE_NAME_MAX_LEN

#define LE_NET_INTERFACE_NAME_MAX_LEN   100

Interface name string length.

◆ LE_NET_IPADDR_MAX_LEN

#define LE_NET_IPADDR_MAX_LEN   46

IP addr string's max length

◆ LE_NET_IPV4ADDR_MAX_LEN

#define LE_NET_IPV4ADDR_MAX_LEN   16

IPv4 addr string's max length

◆ LE_NET_IPV6ADDR_MAX_LEN

#define LE_NET_IPV6ADDR_MAX_LEN   46

IPv6 addr string's max length

Typedef Documentation

◆ le_net_DisconnectHandler_t

typedef void(* le_net_DisconnectHandler_t) (void *)

Type for handler called when a server disconnects.

Function Documentation

◆ le_net_BackupDefaultGW()

void le_net_BackupDefaultGW ( void  )

Backup the current default GW configs of the system, including both IPv4 and IPv6 as applicable. For each client application using this API to back up this system setting, only one backup copy is kept. When a client application makes a second call to this API, its first backup copy will be overwritten by the newer. Thus, le_net keeps one single backup copy per client application, and, thus, multiple backup copies altogether. They are kept in their LIFO (last-in-first-out) chronological order that the sequence for client applications to call le_net_RestoreDefaltGW() should be in the exact reverse order of their calling le_net_BackupDefaultGW() such that config backups and restorations happen in the correct LIFO manner.

◆ le_net_ChangeRoute()

le_result_t le_net_ChangeRoute ( le_dcs_ChannelRef_t  channelRef,
const char *LE_NONNULL  destAddr,
const char *LE_NONNULL  prefixLength,
bool  isAdd 
)

Structure used to communitcate a channel's DNS Server address Structure used to communitcate a channel's Default Gateway Add or remove a route on the given channel according to the input flag in the last argument for the given destination address its given subnet's mask prefix length.

The channel reference in the first input argument identifies the network interface which a route is to be added onto or removed from. Whether the operation is an add or a remove depends on the isAdd boolean value of the last API input argument.

The IP address and subnet input arguments specify the destination address and subnet for the route. If it is a network route, the formats used for them are the same as used in the Linux command "route add -net <ipAddr>/<prefixLength> dev <netInterface>". If the route is a host route, the prefixLength input argument should be given as "" (i.e. a null string).

Note
The prefixLength parameter used to take a subnet mask (255.255.255.0) for IPv4 and prefix length for IPv6. Now it only takes prefix length, although compatibility code is present to make it compatible with previous API declaration. Providing a subnet mask is however deprecated and the compatibility code will be removed in a latter version.
Returns
  • LE_OK upon success, otherwise another le_result_t failure code
Parameters
[in]channelRefthe channel onto which the route change is made
[in]destAddrDestination IP address for the route
[in]prefixLengthDestination's subnet prefix length
[in]isAddthe change is to add (true) or delete (false)

◆ le_net_ConnectService()

void le_net_ConnectService ( void  )

Connect the current client thread to the service providing this API. Block until the service is available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client Specific Functions.

This function is created automatically.

◆ le_net_DisconnectService()

void le_net_DisconnectService ( void  )

Disconnect the current client thread from the service providing this API.

Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see Client Specific Functions.

This function is created automatically.

◆ le_net_GetDefaultGW()

le_result_t le_net_GetDefaultGW ( le_dcs_ChannelRef_t  channelRef,
le_net_DefaultGatewayAddresses_t addrPtr 
)

Get the default GW address for the given data channel.

Note
Accomodates dual-stack IPv4/IPv6 addresses. If the default GW address only is only IPv4 or IPv6, but not both, the unused field of "addr" will be nulled.
Returns
  • LE_OK upon success, otherwise LE_FAULT
Parameters
[in]channelRefChannel to retrieve GW addresses
[out]addrPtrChannel's Default GW addresses

◆ le_net_GetDNS()

le_result_t le_net_GetDNS ( le_dcs_ChannelRef_t  channelRef,
le_net_DnsServerAddresses_t addrPtr 
)

Get the DNS server addresses for the given data channel retrieved from its technology

Note
Can accomodate up to two dual-stack DNS server addresses. In the case that there are more than two server addresses, the first two addresses of each IP version will be returned. If there are fewer than two dual-stack addresses, or contain only one type of IPv4 or IPv6 addresses, the unused portions of the passed structure will be nulled and returned.
Returns
  • LE_OK upon success, otherwise LE_FAULT
Parameters
[in]channelRefChannel to retrieve DNS server addresses
[out]addrPtrDNS server addresses

◆ le_net_RestoreDefaultGW()

le_result_t le_net_RestoreDefaultGW ( void  )

Restore the default GW configs of the system to the last backed up ones, including IPv4 and/or IPv6 depending on whether this same client application has called le_net_SetDefaultGW() to change the system's IPv4 and/or IPv6 configs or not. The le_net interface remembers it and perform config restoration only as necessary when le_net_RestoreDefaultGW() is called. When le_net_BackupDefaultGW() is called, both IPv4 and IPv6 default GW configs are archived when present. As le_net keeps one single backup copy per client application, and, thus, multiple backup copies altogether, they are kept in their LIFO (last-in-first-out) chronological order that the sequence for client applications to call le_net_RestoreDefaltGW() should be in the exact reverse order of their calling le_net_BackupDefaultGW() such that config backups and restorations happen in the correct LIFO manner. If these applications do not follow this order, the le_net interface will first generate a warning in the system log and then still go ahead to restore the configs as directed. These applications hold the responsibility for the resulting routing configs on the device.

◆ le_net_RestoreDNS()

void le_net_RestoreDNS ( void  )

Remove the last added DNS addresses via the le_dcs_SetDNS API

◆ le_net_SetDefaultGW()

le_result_t le_net_SetDefaultGW ( le_dcs_ChannelRef_t  channelRef)

Set the default GW addr for the given data channel retrieved from its technology

Returns
  • LE_OK upon success, otherwise LE_FAULT
Parameters
[in]channelRefthe channel on which interface its default GW addr is to be set

◆ le_net_SetDNS()

le_result_t le_net_SetDNS ( le_dcs_ChannelRef_t  channelRef)

Set the DNS addresses for the given data channel retrieved from its technology

Returns
  • LE_OK upon success, otherwise LE_FAULT
Parameters
[in]channelRefthe channel from which the DNS addresses retrieved will be set into the system config

◆ le_net_SetServerDisconnectHandler()

LE_FULL_API void le_net_SetServerDisconnectHandler ( le_net_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected.

When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants to continue without exiting, it should call longjmp() from inside the handler.

◆ le_net_TryConnectService()

le_result_t le_net_TryConnectService ( void  )

Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client Specific Functions.

This function is created automatically.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.