Files | |
file | ip.c |
IP implementation (license: GPLv2). | |
file | ip.h |
IP header (license: GPLv2). | |
Defines | |
#define | IP_PROTOCOL_ICMP |
Protocol identifier of the ICMP protocol. | |
#define | IP_PROTOCOL_TCP |
Protocol identifier of the TCP protocol. | |
#define | IP_PROTOCOL_UDP |
Protocol identifier of the UDP protocol. | |
#define | ip_get_buffer() |
Retrieves a pointer to the IP transmit buffer. | |
#define | ip_get_buffer_size() |
Retrieves the maximum payload size of the transmit buffer. | |
Functions | |
void | ip_init (const uint8_t *ip, const uint8_t *netmask, const uint8_t *gateway) |
Initializes the IP layer and optionally assigns IP address, netmask and gateway. | |
bool | ip_handle_packet (const struct ip_header *packet, uint16_t packet_len) |
Forwards incoming packets to the appropriate higher-level protocol. | |
bool | ip_send_packet (const uint8_t *ip_dest, uint8_t protocol, uint16_t data_len) |
Sends data from the transmit buffer to a remote host. | |
const uint8_t * | ip_get_address () |
Retrieves the current IP address. | |
void | ip_set_address (const uint8_t *ip_local) |
Configures a new IP address. | |
const uint8_t * | ip_get_netmask () |
Retrieves the current IP netmask. | |
void | ip_set_netmask (const uint8_t *netmask) |
Configures a new IP netmask. | |
const uint8_t * | ip_get_gateway () |
Retrieves the current IP gateway. | |
void | ip_set_gateway (const uint8_t *gateway) |
Configures a new IP gateway. | |
const uint8_t * | ip_get_broadcast () |
Retrieves the broadcast address. |
#define IP_PROTOCOL_ICMP |
Protocol identifier of the ICMP protocol.
#define IP_PROTOCOL_TCP |
Protocol identifier of the TCP protocol.
#define IP_PROTOCOL_UDP |
Protocol identifier of the UDP protocol.
#define ip_get_buffer | ( | ) |
Retrieves a pointer to the IP transmit buffer.
For sending IP packets, write your data to the buffer returned by this function and call ip_send_packet() afterwards.
#define ip_get_buffer_size | ( | ) |
Retrieves the maximum payload size of the transmit buffer.
You may not send more bytes per IP packet than returned by this function.
void ip_init | ( | const uint8_t * | ip, | |
const uint8_t * | netmask, | |||
const uint8_t * | gateway | |||
) |
Initializes the IP layer and optionally assigns IP address, netmask and gateway.
[in] | ip | Buffer which contains an IP address. May be NULL. |
[in] | netmask | Buffer which contains the netmask. May be NULL. |
[in] | gateway | Buffer which contains the gateway. May be NULL. |
bool ip_handle_packet | ( | const struct ip_header * | packet, | |
uint16_t | packet_len | |||
) |
Forwards incoming packets to the appropriate higher-level protocol.
[in] | packet | The packet to be forwarded. |
[in] | packet_len | The length of the packet. |
true
if the packet has successfully been handled, false
on failure. bool ip_send_packet | ( | const uint8_t * | ip_dest, | |
uint8_t | protocol, | |||
uint16_t | data_len | |||
) |
Sends data from the transmit buffer to a remote host.
[in] | ip_dest | The IP address of the remote host to which the packet gets sent. |
[in] | protocol | The protocol identifier of the upper layer protocol. |
[in] | data_len | The length of the packet payload which is read from the transmit buffer. |
true
on success, false
on failure. const uint8_t * ip_get_address | ( | ) |
Retrieves the current IP address.
void ip_set_address | ( | const uint8_t * | ip_local | ) |
Configures a new IP address.
[in] | ip_local | The buffer containing the new IP address. May be NULL to accept broadcasts only. |
const uint8_t * ip_get_netmask | ( | ) |
Retrieves the current IP netmask.
void ip_set_netmask | ( | const uint8_t * | netmask | ) |
Configures a new IP netmask.
[in] | netmask | The buffer containing the new IP netmask. |
const uint8_t * ip_get_gateway | ( | ) |
Retrieves the current IP gateway.
void ip_set_gateway | ( | const uint8_t * | gateway | ) |
Configures a new IP gateway.
[in] | gateway | The buffer containing the new IP gateway. |
const uint8_t * ip_get_broadcast | ( | ) |
Retrieves the broadcast address.