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... | |
The Internet Protocol (IP) layer comprises addressing and routing.
#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.
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.
[in] | zeroBasedInterface | Specifies interface to check.
|
void ltrx_ip_addresses_get | ( | uint8_t | zeroBasedInterface, |
struct ltrx_ip_address | addressArray[], | ||
uint8_t | addressCount | ||
) |
Get all IP addresses for an interface.
[in] | zeroBasedInterface | Specifies interface to check.
|
[out] | addressArray | Receives the IP addresses. Check version for LTRX_IP_VERSION__INVALID , LTRX_IP_VERSION__4 , or (future) LTRX_IP_VERSION__6 . |
[in] | addressCount | Number of array elements 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.
true | Success. |
false | Failed. |
[out] | outputBuffer | Prints to this buffer. |
[in] | bufferLength | Length of the buffer. |
[in] | ipAddress | The IP address to print. |
[in] | port | The 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.
true | Success. |
false | Failed. |
[out] | outputBuffer | Prints to this buffer. |
[in] | bufferLength | Length of the buffer. |
[in] | ipAddress | The 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.
[in] | socket | the 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.
[in] | socket | The socket. |
[out] | optZeroBasedInterface | If present, gets set to the local Interface index or -1 if failed. Otherwise, set to NULL . |
[out] | optLocalPort | If 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.
[in] | socket | The socket. |
[out] | optRemoteAddress | If present, gets set to the remote IP address. Otherwise, set to NULL . |
[out] | optRemotePort | If 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.
true | One or more bytes are available or socket is disconnected. |
false | No data is available, possibly timed out. |
[in] | socket | The socket. |
[in] | blockTimeMsec | Time 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().
[in,out] | socket | The socket. |
[out] | dataPointerLocation | Points to data pointer that will be filled in if any bytes have been received. |
[in] | length | Maximum 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.
true | Success. |
false | Failed. |
[in,out] | socket | The socket. |
[in] | data | Data to send. |
[in] | length | Length of data to send. |
[in] | push | If 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.
[in,out] | socket | The socket. |
[in] | how | Directions to shut down. |