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) |
static void | rs_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 (rs_input_handler, ICMP6_RS, UIP_ICMP6_HANDLER_CODE_ANY, rs_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_ra_output (uip_ipaddr_t *dest) |
send a Router Advertisement 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_ds6_nbr_t * | nbr |
Pointer to llao option in uip_buf. 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 |
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_ra_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, 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 |
do we do something here? we both are using the same address. If we are doing dad, we could cancel it, though we should receive a NA in response of DAD NS we sent, hence DAD will fail anyway. If we were not doing DAD, it means there is a duplicate in the network!
References ADDR_TENTATIVE, create_llao(), ICMP6_NA, uip_ds6_addr::ipaddr, 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_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.
|
static |
References uip_ds6_nbr::isrouter, nbr, NBR_STALE, nd6_opt_llao, nd6_opt_offset, uip_ds6_nbr::nscount, NULL, PRINT6ADDR, PRINTF, uip_ds6_nbr::reachable, uip_ds6_nbr::sendns, uip_ds6_nbr_add(), uip_ds6_nbr_get_ll(), uip_ds6_nbr_lookup(), uip_ds6_nbr_rm(), uip_ds6_send_ra_sollicited(), UIP_ICMP_BUF, UIP_IP_BUF, uip_is_addr_unspecified, uip_l3_icmp_hdr_len, uip_len, UIP_LLADDR_LEN, UIP_ND6_HOP_LIMIT, UIP_ND6_OPT_DATA_OFFSET, UIP_ND6_OPT_HDR_BUF, UIP_ND6_OPT_SLLAO, UIP_ND6_RS_LEN, and UIP_STAT.
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 | ( | rs_input_handler | , |
ICMP6_RS | , | ||
UIP_ICMP6_HANDLER_CODE_ANY | , | ||
rs_input | |||
) |
|
static |
Pointer to a router list entry.
Referenced by _spi_check_config(), dhcpc_init(), dio_output(), mdns_lookup(), packetbuf_attr_clear(), resolv_lookup(), send_packet(), set_link_addr(), slip_poll_handler(), udp_broadcast_new(), and uip_ds6_defrt_choose().
|
static |
Pointer to a nbr cache entry.
|
static |
Pointer to llao option in uip_buf.
Referenced by dao_input(), dio_input(), rs_input(), 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 rs_input().
|
static |
Referenced by na_input(), ns_input(), rs_input(), and uip_nd6_ra_output().