Microchip® Advanced Software Framework

ip6.h File Reference

IPv6 layer.

#include "lwip/opt.h"
#include "lwip/ip6_addr.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/netif.h"
#include "lwip/err.h"

Data Structures

struct  ip6_frag_hdr
 
struct  ip6_hbh_hdr
 
struct  ip6_hdr
 

Macros

#define ip6_debug_print(p)
 
#define IP6_FRAG_HLEN   8
 
#define IP6_FRAG_MORE_FLAG   0x0001
 
#define IP6_FRAG_OFFSET_MASK   0xfff8
 
#define IP6_HBH_HLEN   8
 
#define IP6_HLEN   40
 
#define ip6_init()   /* TODO should we init current addresses and header pointer? */
 
#define ip6_netif_get_local_ipX(netif, dest)
 
#define IP6_NEXTH_DESTOPTS   60
 
#define IP6_NEXTH_ENCAPS   41
 
#define IP6_NEXTH_FRAGMENT   44
 
#define IP6_NEXTH_HOPBYHOP   0
 
#define IP6_NEXTH_ICMP6   58
 
#define IP6_NEXTH_NONE   59
 
#define IP6_NEXTH_ROUTING   43
 
#define IP6_NEXTH_TCP   6
 
#define IP6_NEXTH_UDP   17
 
#define IP6_NEXTH_UDPLITE   136
 
#define IP6_PAD1_OPTION   0
 
#define IP6_PADN_ALERT_OPTION   1
 
#define IP6_ROUTER_ALERT_OPTION   5
 
#define IP6_ROUTER_ALERT_VALUE_MLD   0
 
#define IP6H_FL(hdr)   (ntohl((hdr)->_v_tc_fl) & 0x000fffff)
 
#define IP6H_HOPLIM(hdr)   ((hdr)->_hoplim)
 
#define IP6H_HOPLIM_SET(hdr, hl)   (hdr)->_hoplim = (u8_t)(hl)
 
#define IP6H_NEXTH(hdr)   ((hdr)->_nexth)
 
#define IP6H_NEXTH_P(hdr)   ((u8_t *)(hdr) + 6)
 
#define IP6H_NEXTH_SET(hdr, nexth)   (hdr)->_nexth = (nexth)
 
#define IP6H_PLEN(hdr)   (ntohs((hdr)->_plen))
 
#define IP6H_PLEN_SET(hdr, plen)   (hdr)->_plen = htons(plen)
 
#define IP6H_TC(hdr)   ((ntohl((hdr)->_v_tc_fl) >> 20) & 0xff)
 
#define IP6H_V(hdr)   ((ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f)
 
#define IP6H_VTCFL_SET(hdr, v, tc, fl)   (hdr)->_v_tc_fl = (htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))
 

Functions

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. More...
 
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. More...
 
err_t ip6_output (struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, u8_t hl, u8_t tc, u8_t nexth)
 
err_t ip6_output_if (struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif)
 
err_t ip6_output_if_src (struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, u8_t hl, u8_t tc, u8_t nexth, struct netif *netif)
 
struct netifip6_route (struct ip6_addr *src, struct ip6_addr *dest)
 Finds the appropriate network interface for a given IPv6 address. More...
 
ip6_addr_tip6_select_source_address (struct netif *netif, ip6_addr_t *dest)
 Select the best IPv6 source address for a given destination IPv6 address. More...
 

Variables

PACK_STRUCT_BEGIN struct ip6_hdr PACK_STRUCT_STRUCT
 

#define ip6_debug_print (   p)

Referenced by ip6_input(), and ip6_output_if_src().

#define IP6_FRAG_HLEN   8

Referenced by ip6_reass().

#define IP6_FRAG_MORE_FLAG   0x0001

Referenced by ip6_input(), and ip6_reass().

#define IP6_FRAG_OFFSET_MASK   0xfff8

Referenced by ip6_input(), and ip6_reass().

#define IP6_HBH_HLEN   8

Referenced by mld6_send().

#define ip6_init ( )    /* TODO should we init current addresses and header pointer? */

Referenced by lwip_init().

#define ip6_netif_get_local_ipX (   netif,
  dest 
)
Value:
(((netif) != NULL) ? \
#define ip6_2_ipX(ip6addr)
Definition: ip_addr.h:67
Generic data structure used for all lwIP network interfaces.
Definition: netif.h:160
#define NULL
Definition: nm_bsp.h:70
ip6_addr_t * ip6_select_source_address(struct netif *netif, ip6_addr_t *dest)
Select the best IPv6 source address for a given destination IPv6 address.
Definition: ip6.c:159
#define IP6_NEXTH_DESTOPTS   60

Referenced by ip6_input().

#define IP6_NEXTH_ENCAPS   41
#define IP6_NEXTH_FRAGMENT   44

Referenced by ip6_input().

#define IP6_NEXTH_HOPBYHOP   0

Referenced by ip6_input(), and mld6_send().

#define IP6_NEXTH_ICMP6   58
#define IP6_NEXTH_NONE   59

Referenced by ip6_input().

#define IP6_NEXTH_ROUTING   43

Referenced by ip6_input().

#define IP6_NEXTH_TCP   6

Referenced by ip6_input().

#define IP6_NEXTH_UDP   17

Referenced by ip6_input().

#define IP6_NEXTH_UDPLITE   136

Referenced by ip6_input().

#define IP6_PAD1_OPTION   0
#define IP6_PADN_ALERT_OPTION   1

Referenced by ip6_options_add_hbh_ra().

#define IP6_ROUTER_ALERT_OPTION   5

Referenced by ip6_options_add_hbh_ra().

#define IP6_ROUTER_ALERT_VALUE_MLD   0

Referenced by mld6_send().

#define IP6H_FL (   hdr)    (ntohl((hdr)->_v_tc_fl) & 0x000fffff)
#define IP6H_HOPLIM (   hdr)    ((hdr)->_hoplim)
#define IP6H_HOPLIM_SET (   hdr,
  hl 
)    (hdr)->_hoplim = (u8_t)(hl)

Referenced by ip6_output_if_src().

#define IP6H_NEXTH (   hdr)    ((hdr)->_nexth)

Referenced by ip6_input(), and raw_input().

#define IP6H_NEXTH_P (   hdr)    ((u8_t *)(hdr) + 6)
#define IP6H_NEXTH_SET (   hdr,
  nexth 
)    (hdr)->_nexth = (nexth)

Referenced by ip6_output_if_src().

#define IP6H_PLEN (   hdr)    (ntohs((hdr)->_plen))

Referenced by ip6_input().

#define IP6H_PLEN_SET (   hdr,
  plen 
)    (hdr)->_plen = htons(plen)

Referenced by ip6_output_if_src().

#define IP6H_TC (   hdr)    ((ntohl((hdr)->_v_tc_fl) >> 20) & 0xff)
#define IP6H_V (   hdr)    ((ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f)

Referenced by ip6_input().

#define IP6H_VTCFL_SET (   hdr,
  v,
  tc,
  fl 
)    (hdr)->_v_tc_fl = (htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))

Referenced by ip6_output_if_src().

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)

References ip_globals::current_ip6_header, ip_globals::current_ip_header_tot_len, ip_globals::current_iphdr_dest, ip_globals::current_iphdr_src, ip_globals::current_netif, ERR_OK, icmp6_input(), icmp6_param_problem(), ICMP6_PP_HEADER, if(), ipX_addr_t::ip6, ip6_addr_cmp, ip6_addr_cmp_solicitednode, ip6_addr_copy, ip6_addr_isallnodes_iflocal, ip6_addr_isallnodes_linklocal, ip6_addr_isany, ip6_addr_islinklocal, ip6_addr_ismulticast, ip6_addr_issolicitednode, ip6_addr_isvalid, ip6_addr_set_any, ip6_current_dest_addr, ip6_current_src_addr, ip6_debug_print, IP6_FRAG_MORE_FLAG, IP6_FRAG_OFFSET_MASK, IP6_FRAG_STATS_INC, IP6_HLEN, IP6_NEXTH_DESTOPTS, IP6_NEXTH_FRAGMENT, IP6_NEXTH_HOPBYHOP, IP6_NEXTH_ICMP6, IP6_NEXTH_NONE, IP6_NEXTH_ROUTING, IP6_NEXTH_TCP, IP6_NEXTH_UDP, IP6_NEXTH_UDPLITE, ip6_reass(), IP6_STATS_INC, IP6H_NEXTH, IP6H_PLEN, IP6H_V, ip_data, pbuf::len, LWIP_DBG_LEVEL_SERIOUS, LWIP_DBG_LEVEL_WARNING, LWIP_DBG_TRACE, LWIP_DEBUGF, mld6_lookfor_group(), netif::name, netif_ip6_addr, netif_ip6_addr_state, netif_is_up, netif_list, netif::next, NULL, pbuf::payload, pbuf_free(), pbuf_header(), pbuf_realloc(), raw_input(), tcp_input(), pbuf::tot_len, U16_F, U32_F, and udp_input().

Referenced by ethernet_input(), and tcpip_thread().

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

References ERR_BUF, ERR_OK, IP6_PADN_ALERT_OPTION, IP6_ROUTER_ALERT_OPTION, IP6_STATS_INC, LWIP_DEBUGF, pbuf::payload, and pbuf_header().

Referenced by mld6_send().

err_t ip6_output ( struct pbuf p,
struct ip6_addr src,
struct ip6_addr dest,
u8_t  hl,
u8_t  tc,
u8_t  nexth 
)
err_t ip6_output_if ( struct pbuf p,
struct ip6_addr src,
struct ip6_addr dest,
u8_t  hl,
u8_t  tc,
u8_t  nexth,
struct netif netif 
)
err_t ip6_output_if_src ( struct pbuf p,
struct ip6_addr src,
struct ip6_addr dest,
u8_t  hl,
u8_t  tc,
u8_t  nexth,
struct netif netif 
)
struct netif* ip6_route ( struct ip6_addr src,
struct ip6_addr dest 
)

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 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

References default_router_list, ip6_addr_cmp, ip6_addr_isany, ip6_addr_islinklocal, ip6_addr_isvalid, ip6_addr_netcmp, nd6_select_router(), nd6_router_list_entry::neighbor_entry, nd6_neighbor_cache_entry::netif, netif_default, netif_ip6_addr, netif_ip6_addr_state, netif_list, netif::next, and NULL.

Referenced by icmp6_send_response(), and ip6_output().

ip6_addr_t* ip6_select_source_address ( struct netif netif,
ip6_addr_t dest 
)

Select the best IPv6 source address for a given destination IPv6 address.

Loosely follows RFC 3484. "Strong host" behavior is assumed.

Parameters
netifthe netif on which to send a packet
destthe destination we are trying to reach
Returns
the most suitable source address to use, or NULL if no suitable source address is found

References ip6_addr_isglobal, ip6_addr_islinklocal, ip6_addr_ismulticast_global, ip6_addr_ismulticast_iflocal, ip6_addr_ismulticast_linklocal, ip6_addr_ismulticast_orglocal, ip6_addr_ismulticast_sitelocal, ip6_addr_issitelocal, ip6_addr_isuniquelocal, ip6_addr_isvalid, ip6_addr_netcmp, netif_ip6_addr, netif_ip6_addr_state, and NULL.

Referenced by icmp6_input(), icmp6_send_response(), and ip6_output_if().

PACK_STRUCT_BEGIN struct ip6_frag_hdr PACK_STRUCT_STRUCT