Digi XBee(R) ANSI C Host Library
|
Files | |
file | ipv4.h |
file | xbee_ipv4.c |
Data Structures | |
struct | xbee_header_transmit_ipv4_t |
Header of XBee API frame type 0x20 (XBEE_FRAME_TRANSMIT_IPV4); sent from host to XBee. More... | |
struct | xbee_frame_receive_ipv4_t |
Format of XBee API frame type 0xB0 (XBEE_FRAME_RECEIVE_IPV4); received from XBee by host. More... | |
struct | xbee_ipv4_envelope_t |
Macros | |
#define | XBEE_FRAME_TRANSMIT_IPV4 0x20 |
Frame Type: Transmit IPv4 data. [Wi-Fi, Cellular]. | |
#define | XBEE_FRAME_RECEIVE_IPV4 0xB0 |
Frame Type: Sent upon receiving IPv4 data. [Wi-Fi, Cellular]. | |
#define | XBEE_IPV4_MAX_PAYLOAD 1500 |
Maximum number of bytes in the payload of an IPv4 transmit or receive frame. | |
Functions | |
int | xbee_ipv4_envelope_reply (xbee_ipv4_envelope_t FAR *reply, const xbee_ipv4_envelope_t FAR *original) |
Address a reply envelope using fields from a received envelope. More... | |
void | xbee_ipv4_envelope_dump (const xbee_ipv4_envelope_t FAR *envelope, bool_t include_payload) |
Print the contents of an IPv4 envelope to stdout. | |
int | xbee_ipv4_envelope_send (const xbee_ipv4_envelope_t FAR *envelope) |
Send an IPv4 packet. More... | |
int | xbee_ipv4_receive_dump (xbee_dev_t *xbee, const void FAR *raw, uint16_t length, void FAR *context) |
Dump received IPv4 frame to stdout. More... | |
int | xbee_ipv4_ntoa (char buffer[16], uint32_t ip_be) |
Format a big-endian IP address from an XBee frame as a "dotted quad", four decimal numbers separated by '. More... | |
int | xbee_ipv4_aton (const char *cp, uint32_t *ip_be) |
Takes an address separated by '. More... | |
char * | xbee_ipv4_protocol_str (char buffer[8], uint8_t protocol) |
A string description of the "protocol" byte from an XBee IPv4 frame. More... | |
XBEE_IPV4_PROTOCOL_xxx | |
Values for | |
#define | XBEE_IPV4_PROTOCOL_UDP 0 |
UDP. | |
#define | XBEE_IPV4_PROTOCOL_TCP 1 |
TCP. | |
#define | XBEE_IPV4_PROTOCOL_SSL 4 |
SSL. | |
XBEE_IPV4_TX_OPT_xxx | |
Values for | |
#define | XBEE_IPV4_TX_OPT_NONE 0 |
None. | |
#define | XBEE_IPV4_TX_OPT_TCP_CLOSE (1<<1) |
TCP Close. | |
int xbee_ipv4_aton | ( | const char * | cp, |
uint32_t * | ip_be | ||
) |
Takes an address separated by '.
' (e.g., "192.0.2.31") and outputs a 32-bit big-endian address
[in] | cp | A NULL terminated string containing a dotted quad |
[out] | ip_be | IP address in big-endian byte order |
0 | IP address successfully converted |
-EINVAL | Malformed string/ipv4 address |
References EINVAL.
int xbee_ipv4_envelope_reply | ( | xbee_ipv4_envelope_t FAR * | reply, |
const xbee_ipv4_envelope_t FAR * | original | ||
) |
Address a reply envelope using fields from a received envelope.
[out] | reply | envelope structure to fill |
[in] | original | received envelope we're replying to |
0 | envelope addressed |
-EINVAL | invalid parameter passed to function |
References EINVAL.
int xbee_ipv4_envelope_send | ( | const xbee_ipv4_envelope_t FAR * | envelope | ) |
Send an IPv4 packet.
[in] | envelope | Structure with information to send. |
>0 | Frame ID of message, to correlate with Transmit Status frame received from XBee module. |
-EINVAL | Invalid parameter passed to function. |
-E2BIG | Payload too large to send. |
References E2BIG, EINVAL, htobe16, XBEE_FRAME_TRANSMIT_IPV4, xbee_frame_write(), XBEE_IPV4_MAX_PAYLOAD, xbee_ipv4_ntoa(), xbee_ipv4_protocol_str(), and xbee_next_frame_id().
int xbee_ipv4_ntoa | ( | char | buffer[16], |
uint32_t | ip_be | ||
) |
Format a big-endian IP address from an XBee frame as a "dotted quad", four decimal numbers separated by '.
' (e.g., "192.0.2.31").
[out] | buffer | buffer at least 16-bytes long to hold dotted quad |
[in] | ip_be | IP address in big-endian byte order |
0 | IP address successfully converted |
-EINVAL | NULL pointer passed for buffer |
References EINVAL.
Referenced by xbee_ipv4_envelope_dump(), and xbee_ipv4_envelope_send().
char * xbee_ipv4_protocol_str | ( | char | buffer[8], |
uint8_t | protocol | ||
) |
A string description of the "protocol" byte from an XBee IPv4 frame.
Copies a string to the output buffer (e.g., "TCP") or the pattern "[P99]" for unknown protocol values (99 or 0x63) in this example). Doesn't do anything if buffer is NULL.
[out] | buffer | buffer at least 8-bytes long to hold description |
[in] | protocol | protocol byte from an XBee IPv4 frame |
buffer | passed to function |
References XBEE_IPV4_PROTOCOL_SSL, XBEE_IPV4_PROTOCOL_TCP, and XBEE_IPV4_PROTOCOL_UDP.
Referenced by xbee_ipv4_envelope_dump(), and xbee_ipv4_envelope_send().
int xbee_ipv4_receive_dump | ( | xbee_dev_t * | xbee, |
const void FAR * | raw, | ||
uint16_t | length, | ||
void FAR * | context | ||
) |
Dump received IPv4 frame to stdout.
This is a sample frame handler that simply prints received IPv4 frame to the screen. Include it in your frame handler table as:
{ XBEE_FRAME_RECEIVE_IPV4, 0, xbee_ipv4_receive_dump, NULL }
See the function help for xbee_frame_handler_fn() for full documentation on this function's API.
References be16toh, FAR, xbee_ipv4_envelope_t::length, xbee_ipv4_envelope_t::local_port, xbee_ipv4_envelope_t::payload, xbee_ipv4_envelope_t::protocol, xbee_ipv4_envelope_t::remote_addr_be, xbee_ipv4_envelope_t::remote_port, xbee_ipv4_envelope_t::xbee, and xbee_ipv4_envelope_dump().