Rtos API example

Embed: (wiki syntax)

« Back to documentation index

lwip_ip6.c File Reference

lwip_ip6.c File Reference

IPv6 layer. More...

Go to the source code of this file.

Functions

struct netifip6_route (const ip6_addr_t *src, const ip6_addr_t *dest)
 Finds the appropriate network interface for a given IPv6 address.
const ip_addr_tip6_select_source_address (struct netif *netif, const ip6_addr_t *dest)
 Select the best IPv6 source address for a given destination IPv6 address.
static void ip6_forward (struct pbuf *p, struct ip6_hdr *iphdr, struct netif *inp)
 Forwards an IPv6 packet.
err_t ip6_input (struct pbuf *p, struct netif *inp)
 This function is called by the network interface device driver when an IPv6 packet is received.
err_t ip6_output_if (struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif)
 Sends an IPv6 packet on a network interface.
err_t ip6_output_if_src (struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif)
 Same as ip6_output_if() but 'src' address is not replaced by netif address when it is 'any'.
err_t ip6_output (struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, u8_t hl, u8_t tc, u8_t nexth)
 Simple interface to ip6_output_if.
err_t ip6_output_hinted (struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint)
 Like ip6_output, but takes and addr_hint pointer that is passed on to netif->addr_hint before calling ip6_output_if.
err_t ip6_options_add_hbh_ra (struct pbuf *p, u8_t nexth, u8_t value)
 Add a hop-by-hop options header with a router alert option and padding.

Detailed Description

IPv6 layer.

Definition in file lwip_ip6.c.


Function Documentation

static void ip6_forward ( struct pbuf p,
struct ip6_hdr iphdr,
struct netif inp 
) [static]

Forwards an IPv6 packet.

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

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

Definition at line 308 of file lwip_ip6.c.

err_t ip6_input ( struct pbuf p,
struct netif inp 
)

This function is called by the network interface device driver when an IPv6 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 ip6_forward).

Finally, the packet is sent to the upper layer protocol input function.

Parameters:
pthe received IPv6 packet (p->payload points to IPv6 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)

Definition at line 410 of file lwip_ip6.c.

err_t ip6_options_add_hbh_ra ( struct pbuf p,
u8_t  nexth,
u8_t  value 
)

Add a hop-by-hop options header with a router alert option and padding.

Used by MLD when sending a Multicast listener report/done message.

Parameters:
pthe packet to which we will prepend the options header
nexththe next header protocol number (e.g. IP6_NEXTH_ICMP6)
valuethe value of the router alert option data (e.g. IP6_ROUTER_ALERT_VALUE_MLD)
Returns:
ERR_OK if hop-by-hop header was added, ERR_* otherwise

Definition at line 1069 of file lwip_ip6.c.

err_t ip6_output ( struct pbuf p,
const ip6_addr_t src,
const ip6_addr_t dest,
u8_t  hl,
u8_t  tc,
u8_t  nexth 
)

Simple interface to ip6_output_if.

It finds the outgoing network interface and calls upon ip6_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 IPv6 header and p->payload points to that IPv6 header)
srcthe source IPv6 address to send from (if src == IP6_ADDR_ANY, an IP address of the netif is selected and used as source address. if src == NULL, IP6_ADDR_ANY is used as source)
destthe destination IPv6 address to send the packet to
hlthe Hop Limit value to be set in the IPv6 header
tcthe Traffic Class value to be set in the IPv6 header
nexththe Next Header to be set in the IPv6 header
Returns:
ERR_RTE if no route is found see ip_output_if() for more return values

Definition at line 957 of file lwip_ip6.c.

err_t ip6_output_hinted ( struct pbuf p,
const ip6_addr_t src,
const ip6_addr_t dest,
u8_t  hl,
u8_t  tc,
u8_t  nexth,
u8_t *  addr_hint 
)

Like ip6_output, but takes and addr_hint pointer that is passed on to netif->addr_hint before calling ip6_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 IPv6 header and p->payload points to that IPv6 header)
srcthe source IPv6 address to send from (if src == IP6_ADDR_ANY, an IP address of the netif is selected and used as source address. if src == NULL, IP6_ADDR_ANY is used as source)
destthe destination IPv6 address to send the packet to
hlthe Hop Limit value to be set in the IPv6 header
tcthe Traffic Class value to be set in the IPv6 header
nexththe Next Header to be set in the IPv6 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 1015 of file lwip_ip6.c.

err_t ip6_output_if ( struct pbuf p,
const ip6_addr_t src,
const ip6_addr_t dest,
u8_t  hl,
u8_t  tc,
u8_t  nexth,
struct netif netif 
)

Sends an IPv6 packet on a network interface.

This function constructs the IPv6 header. If the source IPv6 address is NULL, the IPv6 "ANY" address is used as source (usually during network startup). If the source IPv6 address it IP6_ADDR_ANY, the most appropriate IPv6 address of the outgoing network interface is filled in as source address. If the destination IPv6 address is LWIP_IP_HDRINCL, p is assumed to already include an IPv6 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 IPv6 header and p->payload points to that IPv6 header)
srcthe source IPv6 address to send from (if src == IP6_ADDR_ANY, an IP address of the netif is selected and used as source address. if src == NULL, IP6_ADDR_ANY is used as source)
destthe destination IPv6 address to send the packet to
hlthe Hop Limit value to be set in the IPv6 header
tcthe Traffic Class value to be set in the IPv6 header
nexththe Next Header to be set in the IPv6 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 IPv6/LINK headers returns errors returned by netif->output

Definition at line 836 of file lwip_ip6.c.

err_t ip6_output_if_src ( struct pbuf p,
const ip6_addr_t src,
const ip6_addr_t dest,
u8_t  hl,
u8_t  tc,
u8_t  nexth,
struct netif netif 
)

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

Definition at line 860 of file lwip_ip6.c.

struct netif* ip6_route ( const ip6_addr_t src,
const ip6_addr_t dest 
) [read]

Finds the appropriate network interface for a given IPv6 address.

It tries to select a netif following a sequence of heuristics: 1) if there is only 1 netif, return it 2) if the destination is a link-local address, try to match the src address to a netif. this is a tricky case because with multiple netifs, link-local addresses only have meaning within a particular subnet/link. 3) tries to match the destination subnet to a configured address 4) tries to find a router-announced route 5) tries to match the source address to the netif 6) returns the default netif, if configured

Parameters:
srcthe source IPv6 address, if known
destthe destination IPv6 address for which to find the route
Returns:
the netif on which to send to reach dest

Definition at line 84 of file lwip_ip6.c.