STM32F7 Ethernet interface for nucleo STM32F767

Embed: (wiki syntax)

« Back to documentation index

lwip_ip4.c File Reference

lwip_ip4.c File Reference

This is the IPv4 layer implementation for incoming and outgoing IP traffic. More...

Go to the source code of this file.

Functions

void ip4_set_default_multicast_netif (struct netif *default_multicast_netif)
 Set a default netif for IPv4 multicast.
struct netifip4_route_src (const ip4_addr_t *dest, const ip4_addr_t *src)
 Source based IPv4 routing must be fully implemented in LWIP_HOOK_IP4_ROUTE_SRC().
struct netifip4_route (const ip4_addr_t *dest)
 Finds the appropriate network interface for a given IP address.
static int ip4_canforward (struct pbuf *p)
 Determine whether an IP address is in a reserved set of addresses that may not be forwarded, or whether datagrams to that destination may be forwarded.
static void ip4_forward (struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
 Forwards an IP packet.
err_t ip4_input (struct pbuf *p, struct netif *inp)
 This function is called by the network interface device driver when an IP packet is received.

Variables

static u16_t ip_id
 The IP header ID of the next outgoing IP packet.
static struct netifip4_default_multicast_netif
 The default netif used for multicast.

Detailed Description

This is the IPv4 layer implementation for incoming and outgoing IP traffic.

See also:
ip_frag.c

Definition in file lwip_ip4.c.


Function Documentation

static int ip4_canforward ( struct pbuf p ) [static]

Determine whether an IP address is in a reserved set of addresses that may not be forwarded, or whether datagrams to that destination may be forwarded.

Parameters:
pthe packet to forward
Returns:
1: can forward 0: discard

Definition at line 232 of file lwip_ip4.c.

static void ip4_forward ( struct pbuf p,
struct ip_hdr *  iphdr,
struct netif inp 
) [static]

Forwards an IP packet.

It finds an appropriate route for the packet, decrements the TTL value of the packet, adjusts the checksum and outputs the packet on the appropriate interface.

Parameters:
pthe packet to forward (p->payload points to IP header)
iphdrthe IP header of the input packet
inpthe netif on which this packet was received

Definition at line 268 of file lwip_ip4.c.

err_t ip4_input ( struct pbuf p,
struct netif inp 
)

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.

Parameters:
pthe received IP packet (p->payload points to IP header)
inpthe netif on which this packet was received
Returns:
ERR_OK if the packet was processed (could return ERR_* if it wasn't processed, but currently always returns ERR_OK)

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.

Parameters:
pthe 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)
srcthe 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)
destthe destination IP address to send the packet to
ttlthe TTL value to be set in the IP header
tosthe TOS value to be set in the IP header
protothe PROTOCOL to be set in the IP header
netifthe netif on which to send this packet
Returns:
ERR_OK if the packet was sent OK ERR_BUF if p doesn't have enough space for IP/LINK headers returns errors returned by netif->output
Note:
ip_id: RFC791 "some host may be able to simply use unique identifiers independent of destination"

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

Same as ip_output_if() but 'src' address is not replaced by netif address when it is 'any'.

Same as ip_output_if_opt() but 'src' address is not replaced by netif address when it is 'any'.

Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work.

Parameters:
pthe 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)
srcthe 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)
destthe destination IP address to send the packet to
ttlthe TTL value to be set in the IP header
tosthe TOS value to be set in the IP header
protothe PROTOCOL to be set in the IP header
Returns:
ERR_RTE if no route is found see ip_output_if() for more return values

Like ip_output, but takes and addr_hint pointer that is passed on to netif->addr_hint before calling ip_output_if.

Parameters:
pthe 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)
srcthe 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)
destthe destination IP address to send the packet to
ttlthe TTL value to be set in the IP header
tosthe TOS value to be set in the IP header
protothe PROTOCOL to be set in the IP header
addr_hintaddress hint pointer set to netif->addr_hint before calling ip_output_if()
Returns:
ERR_RTE if no route is found see ip_output_if() for more return values

Definition at line 374 of file lwip_ip4.c.

struct netif* ip4_route ( const ip4_addr_t dest ) [read]

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.

Parameters:
destthe destination IP address for which to find the route
Returns:
the netif on which to send to reach dest

Definition at line 152 of file lwip_ip4.c.

struct netif* ip4_route_src ( const ip4_addr_t dest,
const ip4_addr_t src 
) [read]

Source based IPv4 routing must be fully implemented in LWIP_HOOK_IP4_ROUTE_SRC().

This function only provides he parameters.

Definition at line 129 of file lwip_ip4.c.


Variable Documentation

The default netif used for multicast.

Definition at line 111 of file lwip_ip4.c.

u16_t ip_id [static]

The IP header ID of the next outgoing IP packet.

Definition at line 107 of file lwip_ip4.c.