4.2.0.0R6
Software Development Kit
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules

Data Structures

struct  ltrx_ip_address
 

Macros

#define LTRX_IP_ADDRESS_STATE__ALL_INTERFACES   0xff
 
#define LTRX_IP_ADDRESS_STATE__NON_AP_INTERFACES   0xfe
 

Functions

uint8_t ltrx_ip_address_state (uint8_t zeroBasedInterface)
 Are IP interfaces up? More...
 
void ltrx_ip_addresses_get (uint8_t zeroBasedInterface, struct ltrx_ip_address addressArray[], uint8_t addressCount)
 Get all IP addresses for an interface. More...
 
bool ltrx_ip_and_port_display (char *outputBuffer, size_t bufferLength, const struct ltrx_ip_address *ipAddress, uint16_t port)
 Print an IP address and port. More...
 
bool ltrx_ip_display (char *outputBuffer, size_t bufferLength, const struct ltrx_ip_address *ipAddress)
 Print an IP address. More...
 
size_t ltrx_ip_socket_can_send (struct ltrx_ip_socket *socket)
 How much data can be sent? More...
 
void ltrx_ip_socket_get_local_information (struct ltrx_ip_socket *socket, int32_t *optZeroBasedInterface, uint16_t *optLocalPort)
 Get local information. More...
 
void ltrx_ip_socket_get_peer_information (struct ltrx_ip_socket *socket, struct ltrx_ip_address *optRemoteAddress, uint16_t *optRemotePort)
 Get peer information. More...
 
bool ltrx_ip_socket_has_data (struct ltrx_ip_socket *socket, uint32_t blockTimeMsec)
 Is data available? More...
 
size_t ltrx_ip_socket_receive (struct ltrx_ip_socket *socket, uint8_t **dataPointerLocation, size_t length)
 Receive data. More...
 
bool ltrx_ip_socket_send (struct ltrx_ip_socket *socket, const void *data, size_t length, bool push)
 Send data. More...
 
void ltrx_ip_socket_shutdown (struct ltrx_ip_socket *socket, enum ltrx_network_protocol_shutdown how)
 Socket shutdown. More...
 

Detailed Description

The Internet Protocol (IP) layer comprises addressing and routing.

Macro Definition Documentation

#define LTRX_IP_ADDRESS_STATE__ALL_INTERFACES   0xff

Specifies to count readiness on all interfaces.

#define LTRX_IP_ADDRESS_STATE__NON_AP_INTERFACES   0xfe

Specifies to count readiness on non-AP interfaces.

Function Documentation

uint8_t ltrx_ip_address_state ( uint8_t  zeroBasedInterface)

Are IP interfaces up?

With IPv4, will return 1 when its IP address has been established.

With IPv4 and IPv6, will return 1 if one is established and 2 if both are established.

Typical applications may watch for a non-zero value or an increase in the return value as a cue to attempt a network connection. Otherwise initial application connection attempts will fail.

Returns
Number of IP interfaces that are up.
Parameters
[in]zeroBasedInterfaceSpecifies interface to check.
  • NETS_SOFTAP_START for ap0.
  • NETS_ETHERNET_START for eth0.
  • NETS_WLAN_START for wlan0.
  • LTRX_IP_ADDRESS_STATE__ALL_INTERFACES for sum of all interfaces.
  • LTRX_IP_ADDRESS_STATE__NON_AP_INTERFACES for sum of all non-ap interfaces.
void ltrx_ip_addresses_get ( uint8_t  zeroBasedInterface,
struct ltrx_ip_address  addressArray[],
uint8_t  addressCount 
)

Get all IP addresses for an interface.

Parameters
[in]zeroBasedInterfaceSpecifies interface to check.
  • NETS_SOFTAP_START for ap0.
  • NETS_ETHERNET_START for eth0.
  • NETS_WLAN_START for wlan0.
[out]addressArrayReceives the IP addresses. Check version for LTRX_IP_VERSION__INVALID, LTRX_IP_VERSION__4, or (future) LTRX_IP_VERSION__6.
[in]addressCountNumber of array elements in
  • addressArray to be filled in.
bool ltrx_ip_and_port_display ( char *  outputBuffer,
size_t  bufferLength,
const struct ltrx_ip_address ipAddress,
uint16_t  port 
)

Print an IP address and port.

Takes the internal from ipAddress and port number, outputs them.

IP v4 addresses take the form 1.2.3.4:80, each ip number 0 to 255.

IP v6 addresses take the form [0001:0002:0003:0004:0005:0006:0007:0008]:80 or [0001:0002:0003:0004:0005:0006:0007:0008eth0]:80 each ip number 0000 to ffff.

Return values
trueSuccess.
falseFailed.
Parameters
[out]outputBufferPrints to this buffer.
[in]bufferLengthLength of the buffer.
[in]ipAddressThe IP address to print.
[in]portThe port to print.
bool ltrx_ip_display ( char *  outputBuffer,
size_t  bufferLength,
const struct ltrx_ip_address ipAddress 
)

Print an IP address.

Takes the internal from ipAddress, outputs it.

IP v4 addresses take the form 1.2.3.4, each number 0 to 255.

IP v6 addresses take the form 0001:0002:0003:0004:0005:0006:0007:0008 or 0001:0002:0003:0004:0005:0006:0007:0008eth0, each number 0000 to ffff.

Return values
trueSuccess.
falseFailed.
Parameters
[out]outputBufferPrints to this buffer.
[in]bufferLengthLength of the buffer.
[in]ipAddressThe IP address to print.
size_t ltrx_ip_socket_can_send ( struct ltrx_ip_socket *  socket)

How much data can be sent?

Checks how many bytes can now be accepted for sending.

Returns
Number of bytes that may be sent.
Parameters
[in]socketthe socket.
void ltrx_ip_socket_get_local_information ( struct ltrx_ip_socket *  socket,
int32_t *  optZeroBasedInterface,
uint16_t *  optLocalPort 
)

Get local information.

Fills in the Interface index and port of the local device.

Parameters
[in]socketThe socket.
[out]optZeroBasedInterfaceIf present, gets set to the local Interface index or -1 if failed. Otherwise, set to NULL.
[out]optLocalPortIf present, gets set to the local port number. Otherwise, set to NULL.
void ltrx_ip_socket_get_peer_information ( struct ltrx_ip_socket *  socket,
struct ltrx_ip_address optRemoteAddress,
uint16_t *  optRemotePort 
)

Get peer information.

Fills in the IP address and port of the remote device.

Parameters
[in]socketThe socket.
[out]optRemoteAddressIf present, gets set to the remote IP address. Otherwise, set to NULL.
[out]optRemotePortIf present, gets set to the remote port number. Otherwise, set to NULL.
bool ltrx_ip_socket_has_data ( struct ltrx_ip_socket *  socket,
uint32_t  blockTimeMsec 
)

Is data available?

Checks if any data is available for receive. This may be called after the TCP connection has been established.

Blocks until it has data to read.

Return values
trueOne or more bytes are available or socket is disconnected.
falseNo data is available, possibly timed out.
Parameters
[in]socketThe socket.
[in]blockTimeMsecTime to wait in milliseconds. Use 0 for non-blocking operation. Use TIME_WAIT_FOREVER for no timeout.
size_t ltrx_ip_socket_receive ( struct ltrx_ip_socket *  socket,
uint8_t **  dataPointerLocation,
size_t  length 
)

Receive data.

Note: Any data under the returned dataPointerLocation will remain intact until the next call to ltrx_ip_socket_has_data(), ltrx_ip_socket_receive() or ltrx_tcp_socket_close().

Returns
Number of bytes that have been received.
Parameters
[in,out]socketThe socket.
[out]dataPointerLocationPoints to data pointer that will be filled in if any bytes have been received.
[in]lengthMaximum number of bytes that may be read by this operation.
bool ltrx_ip_socket_send ( struct ltrx_ip_socket *  socket,
const void *  data,
size_t  length,
bool  push 
)

Send data.

This is called after the connection has been established.

Caution: This function may block until it either succeeds or fails.

Return values
trueSuccess.
falseFailed.
Parameters
[in,out]socketThe socket.
[in]dataData to send.
[in]lengthLength of data to send.
[in]pushIf true, forces packet to be sent now, unless no data has been buffered.
void ltrx_ip_socket_shutdown ( struct ltrx_ip_socket *  socket,
enum ltrx_network_protocol_shutdown  how 
)

Socket shutdown.

Parameters
[in,out]socketThe socket.
[in]howDirections to shut down.