2.0.0.4R9
Software Development Kit
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules

Data Structures

struct  ltrx_udp_socket_options
 Contains parameters for ltrx_udp_socket_open_with_options(). More...
 

Functions

void ltrx_udp_socket_close (struct ltrx_ip_socket *sock)
 Close socket. More...
 
bool ltrx_udp_socket_get_received_packet_information (struct ltrx_ip_socket *sock, struct ltrx_ip_address *optRemoteAddress, uint16_t *optRemotePort)
 Get received packet information. More...
 
bool ltrx_udp_socket_is_active (struct ltrx_ip_socket *sock)
 Check if the UDP socket is active. More...
 
bool ltrx_udp_socket_multicast_join (uint8_t zeroBasedInterface, struct ltrx_ip_address *groupAddress)
 Multicast join. More...
 
struct ltrx_ip_socket * ltrx_udp_socket_open (uint8_t zeroBasedInterface, uint16_t optLocalPort)
 Open socket. More...
 
struct ltrx_ip_socket * ltrx_udp_socket_open_with_options (const struct ltrx_udp_socket_options *luso)
 Open socket with options. More...
 
bool ltrx_udp_socket_reply (struct ltrx_ip_socket *socket, size_t length)
 Send reply. More...
 
bool ltrx_udp_socket_send (struct ltrx_ip_socket *sock, const struct ltrx_ip_address *address, uint16_t port, const void *data, size_t length)
 Send data. More...
 

Detailed Description

The User Datagram Protocol (UDP) layer provides connectionless best effort data block delivery.

Function Documentation

void ltrx_udp_socket_close ( struct ltrx_ip_socket *  sock)

Close socket.

Parameters
[in,out]sockThe socket.
bool ltrx_udp_socket_get_received_packet_information ( struct ltrx_ip_socket *  sock,
struct ltrx_ip_address optRemoteAddress,
uint16_t *  optRemotePort 
)

Get received packet information.

Return values
trueSuccess.
falseFailed.
Parameters
[in]sockThe socket.
[out]optRemoteAddressIf present, gets filled in with the remote IP address. Otherwise, set to NULL.
[out]optRemotePortIf present, gets filled in with the remote IP port. Otherwise, set to NULL.
bool ltrx_udp_socket_is_active ( struct ltrx_ip_socket *  sock)

Check if the UDP socket is active.

Return values
trueYes, it is active.
falseNo, it is not active.
Parameters
[in]sockThe socket.
bool ltrx_udp_socket_multicast_join ( uint8_t  zeroBasedInterface,
struct ltrx_ip_address groupAddress 
)

Multicast join.

Return values
trueSuccess.
falseFailed.
Parameters
[in]zeroBasedInterfaceIndex for the desired interface.
  • NETS_SOFTAP_START for ap0.
  • NETS_ETHERNET_START for eth0.
  • NETS_WLAN_START for wlan0.
[in]groupAddressThe group address to join.
struct ltrx_ip_socket* ltrx_udp_socket_open ( uint8_t  zeroBasedInterface,
uint16_t  optLocalPort 
)

Open socket.

Returns
Socket pointer.
Return values
NULLFailed.
Parameters
[in]zeroBasedInterfaceIndex for the desired interface.
  • NETS_SOFTAP_START for ap0.
  • NETS_ETHERNET_START for eth0.
  • NETS_WLAN_START for wlan0.
[in]optLocalPortIf non-zero, specifies the local port. If 0, a random unused UDP port number will be assigned.
struct ltrx_ip_socket* ltrx_udp_socket_open_with_options ( const struct ltrx_udp_socket_options luso)

Open socket with options.

Returns
Socket pointer.
Return values
NULLFailed.
Parameters
[in]lusoSpecifies the options.
bool ltrx_udp_socket_reply ( struct ltrx_ip_socket *  socket,
size_t  length 
)

Send reply.

Prior to this call, user has received a UDP packet via ltrx_ip_socket_receive(), learning the buffer location and receive length. The user modifies the buffer, then calls ltrx_udp_socket_reply() providing the length to send.

The reply may be longer than the received packet, up to the maximum UDP packet length. The user must take care not to write the buffer beyond the maximum length. It is possible to call ltrx_ip_socket_receive() more than once in a single packet if the receive length is limited. To avoid confusion regarding the beginning (and hence the end) of the buffer, it is recommended to call ltrx_ip_socket_receive() exclusively with the maximum length of 0xffffffff on any socket that may call ltrx_udp_socket_reply().

Return values
trueSuccess.
falseFailed.
Parameters
[in,out]socketThe socket.
[in]lengthLength of data to send.
bool ltrx_udp_socket_send ( struct ltrx_ip_socket *  sock,
const struct ltrx_ip_address address,
uint16_t  port,
const void *  data,
size_t  length 
)

Send data.

Return values
trueSuccess.
falseFailed.
Parameters
[in,out]sockThe socket.
[in]addressDestination IP address.
[in]portDestination IP port.
[in]dataData to send.
[in]lengthLength of data to send.