Digi XBee(R) ANSI C Host Library
Files | Data Structures | Macros | Functions

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 protocol member of xbee_header_transmit_ipv4_t and xbee_header_receive_ipv4_t.

#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 options member of xbee_header_transmit_ipv4_t.

#define XBEE_IPV4_TX_OPT_NONE   0
 None.
 
#define XBEE_IPV4_TX_OPT_TCP_CLOSE   (1<<1)
 TCP Close.
 

Detailed Description

Function Documentation

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

Parameters
[in]cpA NULL terminated string containing a dotted quad
[out]ip_beIP address in big-endian byte order
Return values
0IP address successfully converted
-EINVALMalformed 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.

Parameters
[out]replyenvelope structure to fill
[in]originalreceived envelope we're replying to
Return values
0envelope addressed
-EINVALinvalid parameter passed to function

References EINVAL.

int xbee_ipv4_envelope_send ( const xbee_ipv4_envelope_t FAR envelope)

Send an IPv4 packet.

Parameters
[in]envelopeStructure with information to send.
Return values
>0Frame ID of message, to correlate with Transmit Status frame received from XBee module.
-EINVALInvalid parameter passed to function.
-E2BIGPayload too large to send.
See also
xbee_ipv4_envelope_reply()

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").

Parameters
[out]bufferbuffer at least 16-bytes long to hold dotted quad
[in]ip_beIP address in big-endian byte order
Return values
0IP address successfully converted
-EINVALNULL 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.

Parameters
[out]bufferbuffer at least 8-bytes long to hold description
[in]protocolprotocol byte from an XBee IPv4 frame
Return values
bufferpassed 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().