Neighbor discovery (RFC 4861)
#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_t * | addr |
Pointer to a router list entry. More... | |
static uip_ds6_defrt_t * | defrt |
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_t * | nbr |
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_info * | nd6_opt_prefix_info |
Pointer to llao option in uip_buf. More... | |
static uip_ds6_prefix_t * | prefix |
|
static |
Pointer to an interface address.
References uip_lladdr, UIP_LLADDR_LEN, UIP_ND6_OPT_DATA_OFFSET, UIP_ND6_OPT_LEN_OFFSET, UIP_ND6_OPT_LLAO_LEN, and UIP_ND6_OPT_TYPE_OFFSET.
Referenced by ns_input(), uip_nd6_ns_output(), and uip_nd6_rs_output().
|
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.
|
static |
References ADDR_TENTATIVE, create_llao(), ICMP6_NA, uip_ds6_addr::ipaddr, lladdr, NBR_INCOMPLETE, NBR_STALE, nd6_opt_llao, nd6_opt_offset, NULL, PRINT6ADDR, PRINTF, uip_ds6_nbr::state, uip_ds6_addr::state, uip_buf, uip_create_linklocal_allnodes_mcast, uip_ds6_addr_lookup(), uip_ds6_is_my_addr, uip_ds6_nbr_add(), uip_ds6_nbr_get_ll(), uip_ds6_nbr_lookup(), uip_ds6_select_src(), uip_ext_len, uip_icmp6chksum(), UIP_ICMP_BUF, UIP_ICMPH_LEN, UIP_IP_BUF, uip_ipaddr_copy, UIP_IPH_LEN, uip_is_addr_mcast, uip_is_addr_solicited_node, uip_is_addr_unspecified, uip_l2_l3_icmp_hdr_len, 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_NS_BUF, UIP_ND6_NS_LEN, UIP_ND6_OPT_DATA_OFFSET, UIP_ND6_OPT_HDR_BUF, UIP_ND6_OPT_LLAO_LEN, UIP_ND6_OPT_SLLAO, UIP_ND6_OPT_TLLAO, UIP_PROTO_ICMP6, 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 | |||
) |
|
static |
Pointer to a router list entry.
|
static |
Pointer to a nbr cache entry.
|
static |
Pointer to prefix information option in uip_buf.
Referenced by check_prefix(), create_dag_callback(), dhcpc_request(), ip64_arp_check_cache(), ip64_arp_create_arp_request(), ip64_arp_create_ethhdr(), ip64_arp_init(), ip64_dhcpc_request(), main(), PROCESS_THREAD(), rpl_link_neighbor_callback(), set_global_address(), simple_rpl_global_address(), simple_rpl_init_dag_immediately(), and websocket_http_client_get().
|
static |
Pointer to a prefix list entry.
Referenced by dao_input(), dio_input(), make_neighbor(), make_neighbor_roomfor(), tcpip_ipv6_output(), uip_ds6_get_least_lifetime_neighbor(), uip_ds6_link_neighbor_callback(), uip_ds6_nbr_add(), uip_ds6_nbr_ipaddr_from_lladdr(), uip_ds6_nbr_lladdr_from_ipaddr(), uip_ds6_nbr_lookup(), uip_ds6_nbr_num(), and uip_ds6_neighbor_periodic().
|
static |
Offset from the end of the icmpv6 header to the option in uip_buf.
Referenced by na_input(), ns_input(), and ra_input().
|
static |
Referenced by na_input(), ns_input(), and ra_input().
|
static |
Pointer to llao option in uip_buf.
|
static |