lwIP
2.1.0
Lightweight IP stack
|
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/ip4_addr.h"
#include "lwip/err.h"
#include "lwip/netif.h"
#include "lwip/prot/ip4.h"
Macros | |
#define | IP_OPTIONS_SEND (LWIP_IPV4 && LWIP_IGMP) |
Functions | |
struct netif * | ip4_route (const ip4_addr_t *dest) |
struct netif * | ip4_route_src (const ip4_addr_t *src, const ip4_addr_t *dest) |
err_t | ip4_input (struct pbuf *p, struct netif *inp) |
err_t | ip4_output (struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto) |
err_t | ip4_output_if (struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif) |
err_t | ip4_output_if_src (struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif) |
err_t | ip4_output_if_opt (struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, u16_t optlen) |
err_t | ip4_output_if_opt_src (struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, u16_t optlen) |
void | ip4_set_default_multicast_netif (struct netif *default_multicast_netif) |
IPv4 API
Currently, the function ip_output_if_opt() is only used with IGMP
This function is called by the network interface device driver when an IP packet is received. The function does the basic checks of the IP header such as packet size being at least larger than the header size etc. If the packet was not destined for us, the packet is forwarded (using ip_forward). The IP checksum is always checked.
Finally, the packet is sent to the upper layer protocol input function.
p | the received IP packet (p->payload points to IP header) |
inp | the netif on which this packet was received |
err_t ip4_output | ( | struct pbuf * | p, |
const ip4_addr_t * | src, | ||
const ip4_addr_t * | dest, | ||
u8_t | ttl, | ||
u8_t | tos, | ||
u8_t | proto | ||
) |
Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work.
p | the packet to send (p->payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) |
src | the source IP address to send from (if src == IP4_ADDR_ANY, the IP address of the netif used to send is used as source address) |
dest | the destination IP address to send the packet to |
ttl | the TTL value to be set in the IP header |
tos | the TOS value to be set in the IP header |
proto | the PROTOCOL to be set in the IP header |
err_t ip4_output_if | ( | struct pbuf * | p, |
const ip4_addr_t * | src, | ||
const ip4_addr_t * | dest, | ||
u8_t | ttl, | ||
u8_t | tos, | ||
u8_t | proto, | ||
struct netif * | netif | ||
) |
Sends an IP packet on a network interface. This function constructs the IP header and calculates the IP header checksum. If the source IP address is NULL, the IP address of the outgoing network interface is filled in as source address. If the destination IP address is LWIP_IP_HDRINCL, p is assumed to already include an IP header and p->payload points to it instead of the data.
p | the packet to send (p->payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p->payload points to that IP header) |
src | the source IP address to send from (if src == IP4_ADDR_ANY, the IP address of the netif used to send is used as source address) |
dest | the destination IP address to send the packet to |
ttl | the TTL value to be set in the IP header |
tos | the TOS value to be set in the IP header |
proto | the PROTOCOL to be set in the IP header |
netif | the netif on which to send this packet |
err_t ip4_output_if_opt | ( | struct pbuf * | p, |
const ip4_addr_t * | src, | ||
const ip4_addr_t * | dest, | ||
u8_t | ttl, | ||
u8_t | tos, | ||
u8_t | proto, | ||
struct netif * | netif, | ||
void * | ip_options, | ||
u16_t | optlen | ||
) |
Same as ip_output_if() but with the possibility to include IP options:
@ param ip_options pointer to the IP options, copied into the IP header @ param optlen length of ip_options
err_t ip4_output_if_opt_src | ( | struct pbuf * | p, |
const ip4_addr_t * | src, | ||
const ip4_addr_t * | dest, | ||
u8_t | ttl, | ||
u8_t | tos, | ||
u8_t | proto, | ||
struct netif * | netif, | ||
void * | ip_options, | ||
u16_t | optlen | ||
) |
Same as ip_output_if_opt() but 'src' address is not replaced by netif address when it is 'any'.
err_t ip4_output_if_src | ( | struct pbuf * | p, |
const ip4_addr_t * | src, | ||
const ip4_addr_t * | dest, | ||
u8_t | ttl, | ||
u8_t | tos, | ||
u8_t | proto, | ||
struct netif * | netif | ||
) |
Same as ip_output_if() but 'src' address is not replaced by netif address when it is 'any'.
struct netif* ip4_route | ( | const ip4_addr_t * | dest | ) |
Finds the appropriate network interface for a given IP address. It searches the list of network interfaces linearly. A match is found if the masked IP address of the network interface equals the masked IP address given to the function.
dest | the destination IP address for which to find the route |
struct netif* ip4_route_src | ( | const ip4_addr_t * | src, |
const ip4_addr_t * | dest | ||
) |
Source based IPv4 routing must be fully implemented in LWIP_HOOK_IP4_ROUTE_SRC(). This function only provides the parameters.