Microchip® Advanced Software Framework

uip-nd6.c File Reference

    Neighbor discovery (RFC 4861)
Author
Mathilde Durvy mdurv.nosp@m.y@ci.nosp@m.sco.c.nosp@m.om
Julien Abeille jabei.nosp@m.lle@.nosp@m.cisco.nosp@m..com
#include <string.h>
#include "uip.h"
#include "uip-icmp6.h"
#include "uip-nd6.h"
#include "uip-ds6.h"
#include "random.h"
#include "net/ip/uip-debug.h"

Macros

#define _DEBUG_   0
 
#define UIP_LOG(m)
 
#define UIP_ND6_OPT_HDR_BUF   ((uip_nd6_opt_hdr *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
 Pointer to ND option. More...
 
#define UIP_ND6_OPT_MTU_BUF   ((uip_nd6_opt_mtu *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
 
#define UIP_ND6_OPT_PREFIX_BUF   ((uip_nd6_opt_prefix_info *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
 
Pointers to the header structures.

All pointers except UIP_IP_BUF depend on uip_ext_len, which at packet reception, is the total length of the extension headers.

The pointer to ND6 options header also depends on nd6_opt_offset, which we set in each function.

Care should be taken when manipulating these buffers about the value of these length variables

#define UIP_IP_BUF   ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
 Pointer to IP header. More...
 
#define UIP_ICMP_BUF   ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
 Pointer to ICMP header. More...
 
#define UIP_ND6_RS_BUF   ((uip_nd6_rs *)&uip_buf[uip_l2_l3_icmp_hdr_len])
 
#define UIP_ND6_RA_BUF   ((uip_nd6_ra *)&uip_buf[uip_l2_l3_icmp_hdr_len])
 
#define UIP_ND6_NS_BUF   ((uip_nd6_ns *)&uip_buf[uip_l2_l3_icmp_hdr_len])
 
#define UIP_ND6_NA_BUF   ((uip_nd6_na *)&uip_buf[uip_l2_l3_icmp_hdr_len])
 

Functions

static void create_llao (uint8_t *llao, uint8_t type)
 Pointer to an interface address. More...
 
static void na_input (void)
 Neighbor Advertisement Processing. More...
 
static void ns_input (void)
 
void ra_input (void)
 
 UIP_ICMP6_HANDLER (ns_input_handler, ICMP6_NS, UIP_ICMP6_HANDLER_CODE_ANY, ns_input)
 
 UIP_ICMP6_HANDLER (na_input_handler, ICMP6_NA, UIP_ICMP6_HANDLER_CODE_ANY, na_input)
 
 UIP_ICMP6_HANDLER (ra_input_handler, ICMP6_RA, UIP_ICMP6_HANDLER_CODE_ANY, ra_input)
 
void uip_nd6_init ()
 Initialise the uIP ND core. More...
 
void uip_nd6_ns_output (uip_ipaddr_t *src, uip_ipaddr_t *dest, uip_ipaddr_t *tgt)
 Send a neighbor solicitation, send a Neighbor Advertisement. More...
 
void uip_nd6_rs_output (void)
 Send a Router Solicitation. More...
 

Variables

static uip_ds6_addr_taddr
 Pointer to a router list entry. More...
 
static uip_ds6_defrt_tdefrt
 Pointer to a nbr cache entry. More...
 
static uip_ipaddr_t ipaddr
 Pointer to prefix information option in uip_buf. More...
 
static uip_ds6_nbr_tnbr
 Pointer to a prefix list entry. More...
 
static uint8_t * nd6_opt_llao
 Offset from the end of the icmpv6 header to the option in uip_buf. More...
 
static uint8_t nd6_opt_offset
 
static uip_nd6_opt_prefix_infond6_opt_prefix_info
 Pointer to llao option in uip_buf. More...
 
static uip_ds6_prefix_tprefix
 

static void create_llao ( uint8_t *  llao,
uint8_t  type 
)
static
static void na_input ( void  )
static

Neighbor Advertisement Processing.

we might have to send a pkt that had been buffered while address resolution was performed (if we support buffering, see UIP_CONF_QUEUE_PKT)

As per RFC 4861, on link layer that have addresses, TLLAO options MUST be included when responding to multicast solicitations, SHOULD be included in response to unicast (here we assume it is for now)

NA can be received after sending NS for DAD, Address resolution or NUD. Can be unsolicited as well. It can trigger update of the state of the neighbor in the neighbor cache, router in the router list. If the NS was for DAD, it means DAD failed

References ADDR_TENTATIVE, uip_ds6_nbr::isrouter, lladdr, NBR_INCOMPLETE, NBR_REACHABLE, NBR_STALE, nd6_opt_llao, nd6_opt_offset, uip_ds6_nbr::nscount, NULL, PRINT6ADDR, PRINTF, uip_ds6_nbr::reachable, uip_ds6_netif::reachable_time, uip_ds6_nbr::state, uip_ds6_addr::state, stimer_set(), uip_ds6_addr_lookup(), uip_ds6_defrt_lookup(), uip_ds6_defrt_rm(), uip_ds6_if, uip_ds6_nbr_get_ll(), uip_ds6_nbr_lookup(), UIP_ICMP_BUF, UIP_IP_BUF, uip_is_addr_mcast, uip_l3_icmp_hdr_len, uip_len, UIP_LLADDR_LEN, UIP_ND6_HOP_LIMIT, UIP_ND6_NA_BUF, UIP_ND6_NA_FLAG_OVERRIDE, UIP_ND6_NA_FLAG_ROUTER, UIP_ND6_NA_FLAG_SOLICITED, UIP_ND6_NA_LEN, UIP_ND6_OPT_DATA_OFFSET, UIP_ND6_OPT_HDR_BUF, UIP_ND6_OPT_TLLAO, uip_packetqueue_buf(), uip_packetqueue_buflen(), uip_packetqueue_free(), and UIP_STAT.

void ra_input ( void  )

References ADDR_AUTOCONF, uip_ds6_netif::base_reachable_time, uip_ds6_netif::cur_hop_limit, uip_nd6_opt_prefix_info::flagsreserved1, uip_ds6_prefix::ipaddr, uip_ds6_addr::ipaddr, uip_ds6_prefix::isinfinite, uip_ds6_addr::isinfinite, uip_ds6_nbr::isrouter, uip_ds6_defrt::lifetime, uip_ds6_netif::link_mtu, lladdr, NBR_INCOMPLETE, NBR_STALE, nd6_opt_llao, nd6_opt_offset, NULL, uip_nd6_opt_prefix_info::preferredlt, uip_nd6_opt_prefix_info::prefix, uip_nd6_opt_prefix_info::preflen, PRINT6ADDR, PRINTF, uip_ds6_netif::reachable_time, uip_ds6_netif::retrans_timer, uip_ds6_nbr::state, stimer_remaining(), stimer_set(), uip_ds6_addr::type, UIP_DEFAULT_PREFIX_LEN, uip_ds6_addr_add(), uip_ds6_addr_lookup(), uip_ds6_compute_reachable_time(), uip_ds6_defrt_add(), uip_ds6_defrt_lookup(), uip_ds6_defrt_rm(), uip_ds6_if, uip_ds6_nbr_add(), uip_ds6_nbr_get_ll(), uip_ds6_nbr_lookup(), uip_ds6_prefix_add(), uip_ds6_prefix_lookup(), uip_ds6_prefix_rm(), uip_ds6_set_addr_iid(), UIP_ICMP_BUF, UIP_IP_BUF, uip_ipaddr_copy, uip_is_addr_link_local, uip_l3_icmp_hdr_len, uip_len, uip_lladdr, UIP_LLADDR_LEN, UIP_ND6_HOP_LIMIT, UIP_ND6_INFINITE_LIFETIME, UIP_ND6_OPT_DATA_OFFSET, UIP_ND6_OPT_HDR_BUF, UIP_ND6_OPT_MTU, UIP_ND6_OPT_PREFIX_INFO, UIP_ND6_OPT_SLLAO, UIP_ND6_RA_BUF, UIP_ND6_RA_FLAG_AUTONOMOUS, UIP_ND6_RA_FLAG_ONLINK, UIP_ND6_RA_LEN, uip_ntohl, uip_ntohs, uip_packetqueue_buf(), uip_packetqueue_buflen(), uip_packetqueue_free(), UIP_STAT, uip_nd6_opt_prefix_info::validlt, uip_ds6_prefix::vlifetime, and uip_ds6_addr::vlifetime.

UIP_ICMP6_HANDLER ( ns_input_handler  ,
ICMP6_NS  ,
UIP_ICMP6_HANDLER_CODE_ANY  ,
ns_input   
)
UIP_ICMP6_HANDLER ( na_input_handler  ,
ICMP6_NA  ,
UIP_ICMP6_HANDLER_CODE_ANY  ,
na_input   
)
UIP_ICMP6_HANDLER ( ra_input_handler  ,
ICMP6_RA  ,
UIP_ICMP6_HANDLER_CODE_ANY  ,
ra_input   
)

uip_ds6_addr_t* addr
static

Pointer to a router list entry.

uip_ds6_defrt_t* defrt
static

Pointer to a nbr cache entry.

uint8_t* nd6_opt_llao
static

Offset from the end of the icmpv6 header to the option in uip_buf.

Referenced by na_input(), ns_input(), and ra_input().

uint8_t nd6_opt_offset
static

Referenced by na_input(), ns_input(), and ra_input().

uip_nd6_opt_prefix_info* nd6_opt_prefix_info
static

Pointer to llao option in uip_buf.