Skip to content

Commit

Permalink
Merge branch 'gnrc_ipv6_nib/feat/ndp-link-local' (RIOT-OS#7014) into R…
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Aug 21, 2017
2 parents 768459d + 92c2d79 commit d2e065f
Show file tree
Hide file tree
Showing 45 changed files with 6,855 additions and 19 deletions.
24 changes: 24 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ ifneq (,$(filter gnrc_ndp,$(USEMODULE)))
USEMODULE += xtimer
endif

ifneq (,$(filter gnrc_ndp2,$(USEMODULE)))
USEMODULE += gnrc_icmpv6
endif

ifneq (,$(filter gnrc_icmpv6_echo,$(USEMODULE)))
USEMODULE += gnrc_icmpv6
endif
Expand Down Expand Up @@ -315,7 +319,27 @@ ifneq (,$(filter gnrc_ipv6_nc,$(USEMODULE)))
USEMODULE += ipv6_addr
endif

ifneq (,$(filter gnrc_ipv6_nib_6lbr,$(USEMODULE)))
USEMODULE += gnrc_ipv6_nib_6lr
endif

ifneq (,$(filter gnrc_ipv6_nib_6lr,$(USEMODULE)))
USEMODULE += gnrc_ipv6_nib_6ln
USEMODULE += gnrc_ipv6_nib_router
endif

ifneq (,$(filter gnrc_ipv6_nib_6ln,$(USEMODULE)))
USEMODULE += gnrc_ipv6_nib
USEMODULE += gnrc_sixlowpan_nd
endif

ifneq (,$(filter gnrc_ipv6_nib_router,$(USEMODULE)))
USEMODULE += gnrc_ipv6_nib
endif

ifneq (,$(filter gnrc_ipv6_nib,$(USEMODULE)))
USEMODULE += evtimer
USEMODULE += gnrc_ndp2
USEMODULE += ipv6_addr
USEMODULE += random
endif
Expand Down
4 changes: 4 additions & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ PSEUDOMODULES += emb6_router
PSEUDOMODULES += gnrc_ipv6_default
PSEUDOMODULES += gnrc_ipv6_router
PSEUDOMODULES += gnrc_ipv6_router_default
PSEUDOMODULES += gnrc_ipv6_nib_6lbr
PSEUDOMODULES += gnrc_ipv6_nib_6ln
PSEUDOMODULES += gnrc_ipv6_nib_6lr
PSEUDOMODULES += gnrc_ipv6_nib_router
PSEUDOMODULES += gnrc_netdev_default
PSEUDOMODULES += gnrc_neterr
PSEUDOMODULES += gnrc_netapi_callbacks
Expand Down
9 changes: 9 additions & 0 deletions sys/auto_init/auto_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
#include "net/gcoap.h"
#endif

#ifdef MODULE_GNRC_IPV6_NIB
#include "net/gnrc/ipv6/nib.h"
#endif


#define ENABLE_DEBUG (0)
#include "debug.h"

Expand Down Expand Up @@ -157,6 +162,10 @@ void auto_init(void)
extern void auto_init_devfs(void);
auto_init_devfs();
#endif
#ifdef MODULE_GNRC_IPV6_NIB
DEBUG("Auto init gnrc_ipv6_nib module.\n");
gnrc_ipv6_nib_init();
#endif

/* initialize network devices */
#ifdef MODULE_AUTO_INIT_GNRC_NETIF
Expand Down
2 changes: 2 additions & 0 deletions sys/include/net/gnrc/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#include "net/ipv6.h"
#include "net/gnrc/ipv6/ext.h"
#include "net/gnrc/ipv6/hdr.h"
#ifndef MODULE_GNRC_IPV6_NIB
#include "net/gnrc/ipv6/nc.h"
#endif
#include "net/gnrc/ipv6/netif.h"

#ifdef MODULE_FIB
Expand Down
109 changes: 109 additions & 0 deletions sys/include/net/gnrc/ipv6/nib.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
#ifndef NET_GNRC_IPV6_NIB_H
#define NET_GNRC_IPV6_NIB_H

#include "net/gnrc/ipv6/nib/nc.h"

#include "net/icmpv6.h"
#include "net/ipv6/addr.h"
#include "net/ipv6/hdr.h"
#include "net/gnrc/ipv6/nib/nc.h"
#include "net/gnrc/pkt.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -176,8 +184,109 @@ extern "C" {
* context is a valid default router entry representing the router.
*/
#define GNRC_IPV6_NIB_RTR_TIMEOUT (0x4fcdU)

/**
* @brief Recalculate reachability timeout time.
*
* This message type is for the event of recalculating the reachability timeout
* time. The expected message context is a valid [interface](_nib_iface_t).
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_ARSM != 0
*/
#define GNRC_IPV6_NIB_RECALC_REACH_TIME (0x4fceU)
/** @} */

/**
* @brief Initialize NIB
*/
void gnrc_ipv6_nib_init(void);

/**
* @brief Adds an interface to be managed by the NIB.
*
* @pre `(KERNEL_PID_UNDEF < iface)`
*
* @param[in] iface The interface to be managed by the NIB
*/
void gnrc_ipv6_nib_init_iface(kernel_pid_t iface);

/**
* @brief Get link-layer address of next hop to a destination address
*
* @pre `(dst != NULL) && (nce != NULL)`
*
* @param[in] dst Destination address of a packet.
* @param[in] iface Restrict search to this interface. May be
* `KERNEL_PID_UNDEF` for any interface.
* @param[in] pkt The IPv6 packet in sending order for which the next hop
* is searched. Needed for queuing for with reactive
* routing or address resolution. May be `NULL`.
* Will be released properly on error.
* @param[out] nce The neighbor cache entry of the next hop to @p dst.
*
* @return 0, on success.
* @return -ENETUNREACH if there is no route to host.
* @return -EHOSTUNREACH if the next hop is not reachable or if @p dst was
* link-local, but @p iface was @ref KERNEL_PID_UNDEF (no neighbor
* cache entry will be created in this case and no neighbor
* solicitation sent).
*/
int gnrc_ipv6_nib_get_next_hop_l2addr(const ipv6_addr_t *dst,
kernel_pid_t iface, gnrc_pktsnip_t *pkt,
gnrc_ipv6_nib_nc_t *nce);

/**
* @brief Handle a received ICMPv6 packet
*
* @pre `iface != KERNEL_PID_UNDEF`
* @pre `ipv6 != NULL`
* @pre `icmpv6 != NULL`
* @pre `icmpv6_len > sizeof(icmpv6_hdr_t)`
*
* @attention The ICMPv6 checksum is supposed to be checked externally!
*
* @note @p ipv6 is just used for the addresses and hop limit. The next
* header field will not be checked for correctness (but should be
* @ref PROTNUM_ICMPV6)
*
* @see [RFC 4861, section 6.1](https://tools.ietf.org/html/rfc4861#section-6.1)
* @see [RFC 4861, section 6.2.6](https://tools.ietf.org/html/rfc4861#section-6.2.6)
* @see [RFC 4861, section 6.3.4](https://tools.ietf.org/html/rfc4861#section-6.3.4)
* @see [RFC 4861, section 7.1](https://tools.ietf.org/html/rfc4861#section-7.1)
* @see [RFC 4861, section 7.2.3](https://tools.ietf.org/html/rfc4861#section-7.2.3)
* @see [RFC 4861, section 7.2.5](https://tools.ietf.org/html/rfc4861#section-7.2.5)
* @see [RFC 4861, section 8.1](https://tools.ietf.org/html/rfc4861#section-8.1)
* @see [RFC 4861, section 8.3](https://tools.ietf.org/html/rfc4861#section-8.3)
* @see [RFC 4862, section 5.4.3](https://tools.ietf.org/html/rfc4862#section-5.4.3)
* @see [RFC 4862, section 5.4.4](https://tools.ietf.org/html/rfc4862#section-5.4.4)
* @see [RFC 4862, section 5.5.3](https://tools.ietf.org/html/rfc4862#section-5.5.3)
* @see [RFC 6775, section 5.5.2](https://tools.ietf.org/html/rfc6775#section-5.5.2)
* @see [RFC 6775, section 5.4](https://tools.ietf.org/html/rfc6775#section-5.4)
* @see [RFC 6775, section 6.3](https://tools.ietf.org/html/rfc6775#section-6.3)
* @see [RFC 6775, section 6.5](https://tools.ietf.org/html/rfc6775#section-6.5)
* @see [RFC 6775, section 8.1.3](https://tools.ietf.org/html/rfc6775#section-8.1.3)
* @see [RFC 6775, section 8.2.1](https://tools.ietf.org/html/rfc6775#section-8.2.1)
* @see [RFC 6775, section 8.2.4](https://tools.ietf.org/html/rfc6775#section-8.2.4)
* @see [RFC 6775, section 8.2.5](https://tools.ietf.org/html/rfc6775#section-8.2.5)
*
* @param[in] iface The interface the packet came over.
* @param[in] ipv6 The IPv6 header of the received packet.
* @param[in] icmpv6 The ICMPv6 header and payload of the received
* packet.
* @param[in] icmpv6_len The number of bytes at @p icmpv6.
*/
void gnrc_ipv6_nib_handle_pkt(kernel_pid_t iface, const ipv6_hdr_t *ipv6,
const icmpv6_hdr_t *icmpv6, size_t icmpv6_len);

/**
* @brief Handle a timer event
*
* @param[in] ctx Context of the timer event.
* @param[in] type Type of the timer event (see [timer event
* types](@ref net_gnrc_ipv6_nib_msg))
*/
void gnrc_ipv6_nib_handle_timer_event(void *ctx, uint16_t type);

#ifdef __cplusplus
}
#endif
Expand Down
41 changes: 41 additions & 0 deletions sys/include/net/gnrc/ipv6/nib/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,47 @@
extern "C" {
#endif

/* some pseudo-module based configuration, doc: see below */
#ifdef MODULE_GNRC_IPV6_NIB_6LBR
#ifndef GNRC_IPV6_NIB_CONF_6LBR
#define GNRC_IPV6_NIB_CONF_6LBR (1)
#endif
#endif

#ifdef MODULE_GNRC_IPV6_NIB_6LR
#ifndef GNRC_IPV6_NIB_CONF_6LR
#define GNRC_IPV6_NIB_CONF_6LR (1)
#endif
#ifndef GNRC_IPV6_NIB_CONF_SLAAC
#define GNRC_IPV6_NIB_CONF_SLAAC (0)
#endif
#endif

#ifdef MODULE_GNRC_IPV6_NIB_6LN
#ifndef GNRC_IPV6_NIB_CONF_6LN
#define GNRC_IPV6_NIB_CONF_6LN (1)
#endif
#ifndef GNRC_IPV6_NIB_CONF_SLAAC
#define GNRC_IPV6_NIB_CONF_SLAAC (0)
#endif
#ifndef GNRC_IPV6_NIB_CONF_QUEUE_PKT
#define GNRC_IPV6_NIB_CONF_QUEUE_PKT (0)
#endif
#if !GNRC_IPV6_NIB_CONF_6LR
# ifndef GNRC_IPV6_NIB_CONF_ARSM
# define GNRC_IPV6_NIB_CONF_ARSM (0)
# endif
# ifndef GNRC_IPV6_NIB_NUMOF
/* only needs to store default router */
# define GNRC_IPV6_NIB_NUMOF (1)
# endif
#endif
#endif

#ifdef MODULE_GNRC_IPV6_NIB_ROUTER
#define GNRC_IPV6_NIB_CONF_ROUTER (1)
#endif

/**
* @name Compile flags
* @brief Compile flags to (de-)activate certain features for NIB
Expand Down
Loading

0 comments on commit d2e065f

Please sign in to comment.