Skip to content

Commit

Permalink
Merge branch 'gnrc_ipv6_nib/feat/internal' (RIOT-OS#6325) into RIOT-O…
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Jun 9, 2017
2 parents 2f5d010 + c4a5fd5 commit b0d384a
Show file tree
Hide file tree
Showing 13 changed files with 2,675 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ ifneq (,$(filter gnrc_ipv6_nc,$(USEMODULE)))
USEMODULE += ipv6_addr
endif

ifneq (,$(filter gnrc_ipv6_nib,$(USEMODULE)))
USEMODULE += ipv6_addr
USEMODULE += random
endif

ifneq (,$(filter gnrc_ipv6_netif,$(USEMODULE)))
USEMODULE += ipv6_addr
USEMODULE += gnrc_netif
Expand Down
186 changes: 186 additions & 0 deletions sys/include/net/gnrc/ipv6/nib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* Copyright (C) 2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @defgroup net_gnrc_ipv6_nib Neighbor Information Base for IPv6
* @ingroup net_gnrc_ipv6
* @brief Neighbor Information Base (NIB) for IPv6
*
* @todo Add detailed description
* @{
*
* @file
* @brief NIB definitions
*
* @author Martine Lenders <[email protected]>
*/
#ifndef NET_GNRC_IPV6_NIB_H
#define NET_GNRC_IPV6_NIB_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name Timer event message types
* @anchor net_gnrc_ipv6_nib_msg
* @{
*/
/**
* @brief (Re-)transmit unicast Neighbor Solicitation event.
*
* This message type is for the event of (re-)transmitting of unicast Neighbor
* Solicitation. The expected message context is a pointer to a valid on-link
* entry representing the neighbor to which the Neighbor Solicitation is
* supposed to be sent.
*/
#define GNRC_IPV6_NIB_SND_UC_NS (0x4fc0U)

/**
* @brief (Re-)transmit multicast Neighbor Solicitation event.
*
* This message type is for the event of (re-)transmitting of multicast Neighbor
* Solicitation. The expected message context is a pointer to a valid on-link
* entry representing the neighbor to which [solicited
* nodes](https://tools.ietf.org/html/rfc4291#section-2.7.1) group
* the Neighbor Solicitation is supposed to be sent.
*/
#define GNRC_IPV6_NIB_SND_MC_NS (0x4fc1U)

/**
* @brief Send delayed Neighbor Advertisement event.
*
* This message type is for the event of sending delayed Neighbor
* Advertisements. The expected message context is a pointer to a valid
* [packet snip](@ref gnrc_pktsnip_t) in *sending order*, representing the
* Neighbor Advertisement.
*/
#define GNRC_IPV6_NIB_SND_NA (0x4fc2U)

/**
* @brief Search router event.
*
* This message type is for the event of searching a (new) router (which
* implies sending a multicast Router Solicitation). The expected message
* context is a pointer to a valid interface behind which the router is
* searched.
*/
#define GNRC_IPV6_NIB_SEARCH_RTR (0x4fc3U)

/**
* @brief Reconfirm router event.
*
* This message type is for the event the reconfirmation of a router (which
* implies sending a unicast Router Solicitation). The expected message context
* is a pointer to a valid on-link entry representing the router that is to be
* confirmed.
*/
#define GNRC_IPV6_NIB_RECONFIRM_RTR (0x4fc4U)

/**
* @brief Reply Router Solicitation event.
*
* This message type is for the event of the delayed reply to a Router
* Solicitaion with a Router Advertisement. The expected message context is a
* pointer to a valid on-link entry representing the neighbor that sent the
* Router Solicitation.
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_ROUTER != 0
*/
#define GNRC_IPV6_NIB_REPLY_RS (0x4fc5U)

/**
* @brief (Re-)transmit multicast Router Advertisement event.
*
* This message type is for the event of (Re)transmit Advertisements
* event. The expected message context is a pointer to a valid interface over
* which the Router Advertisement will be sent and by which parameters it will
* be configured.
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_ROUTER != 0
*/
#define GNRC_IPV6_NIB_SND_MC_RA (0x4fc6U)

/**
* @brief Reachability timeout event.
*
* This message type is for the event of a REACHABLE state timeout.
* The expected message context is a pointer to a valid on-link entry
* representing the neighbor cache entry that faces a state change.
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_ARSM != 0
*/
#define GNRC_IPV6_NIB_REACH_TIMEOUT (0x4fc7U)

/**
* @brief Delay timeout event.
*
* This message type is for the event of the DELAY state timeout.
* The expected message context is a pointer to a valid on-link entry
* representing the neighbor cache entry that faces a state change.
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_ARSM != 0
*/
#define GNRC_IPV6_NIB_DELAY_TIMEOUT (0x4fc8U)

/**
* @brief Address registration timeout event.
*
* This message type is for the event of a 6LoWPAN address registration state
* timeout. The expected message context is a pointer to a valid on-link entry
* representing the neighbor which faces a timeout of its address registration.
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_6LR != 0
*/
#define GNRC_IPV6_NIB_ADDR_REG_TIMEOUT (0x4fc9U)

/**
* @brief 6LoWPAN context timeout event.
*
* This message type is for the event of a 6LoWPAN compression context timeout.
* The expected message context is the compression context's numerical
* identifier.
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_6LN != 0
*/
#define GNRC_IPV6_NIB_6LO_CTX_TIMEOUT (0x4fcaU)

/**
* @brief Authoritative border router timeout event.
*
* This message type is for the event of an Authoritative border router timeout.
* The expected message context is the NIB-internal state of the authoritative
* border router.
*
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_MULTIHOP_P6C != 0
*/
#define GNRC_IPV6_NIB_ABR_TIMEOUT (0x4fcbU)

/**
* @brief Prefix timeout event.
*
* This message type is for the event of a prefix timeout. The expected message
* context is a valid off-link entry representing the prefix.
*/
#define GNRC_IPV6_NIB_PFX_TIMEOUT (0x4fccU)

/**
* @brief Router timeout event.
*
* This message type is for the event of a router timeout. The expected message
* context is a valid default router entry representing the router.
*/
#define GNRC_IPV6_NIB_RTR_TIMEOUT (0x4fcdU)
/** @} */

#ifdef __cplusplus
}
#endif

#endif /* NET_GNRC_IPV6_NIB_H */
/** @} */
192 changes: 192 additions & 0 deletions sys/include/net/gnrc/ipv6/nib/conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/*
* Copyright (C) 2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @defgroup net_gnrc_ipv6_nib_conf Configuration macros
* @ingroup net_gnrc_ipv6_nib
* @brief Configuration macros for network information base
* @{
*
* @file
* @brief Configuration macro definitions for network information base
*
* @author Martine Lenders <[email protected]>
*/
#ifndef NET_GNRC_IPV6_NIB_CONF_H
#define NET_GNRC_IPV6_NIB_CONF_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name Compile flags
* @brief Compile flags to (de-)activate certain features for NIB
* @{
*/
/**
* @brief enable features for 6Lo border router
*/
#ifndef GNRC_IPV6_NIB_CONF_6LBR
#define GNRC_IPV6_NIB_CONF_6LBR (0)
#endif

/**
* @brief enable features for 6Lo router
*/
#ifndef GNRC_IPV6_NIB_CONF_6LR
#if GNRC_IPV6_NIB_CONF_6LBR
#define GNRC_IPV6_NIB_CONF_6LR (1)
#else
#define GNRC_IPV6_NIB_CONF_6LR (0)
#endif
#endif

/**
* @brief enable features for 6Lo node
*/
#ifndef GNRC_IPV6_NIB_CONF_6LN
#if GNRC_IPV6_NIB_CONF_6LR
#define GNRC_IPV6_NIB_CONF_6LN (1)
#else
#define GNRC_IPV6_NIB_CONF_6LN (0)
#endif
#endif

/**
* @brief enable features for IPv6 routers
*/
#ifndef GNRC_IPV6_NIB_CONF_ROUTER
#if GNRC_IPV6_NIB_CONF_6LR
#define GNRC_IPV6_NIB_CONF_ROUTER (1)
#else
#define GNRC_IPV6_NIB_CONF_ROUTER (0)
#endif
#endif

/**
* @brief (de-)activate router advertising at interface start-up
*/
#ifndef GNRC_IPV6_NIB_CONF_ADV_ROUTER
#if GNRC_IPV6_NIB_CONF_ROUTER && \
(!GNRC_IPV6_NIB_CONF_6LR || GNRC_IPV6_NIB_CONF_6LBR)
#define GNRC_IPV6_NIB_CONF_ADV_ROUTER (1)
#else
#define GNRC_IPV6_NIB_CONF_ADV_ROUTER (0)
#endif
#endif

/**
* @brief (de-)activate NDP address resolution state-machine
*/
#ifndef GNRC_IPV6_NIB_CONF_ARSM
#define GNRC_IPV6_NIB_CONF_ARSM (1)
#endif

/**
* @brief queue packets for address resolution
*/
#ifndef GNRC_IPV6_NIB_CONF_QUEUE_PKT
#if GNRC_IPV6_NIB_CONF_6LN
#define GNRC_IPV6_NIB_CONF_QUEUE_PKT (0)
#else
#define GNRC_IPV6_NIB_CONF_QUEUE_PKT (1)
#endif
#endif

/**
* @brief handle NDP messages according for stateless address
* auto-configuration (if activated on interface)
*
* @see [RFC 4862](https://tools.ietf.org/html/rfc4862)
*/
#ifndef GNRC_IPV6_NIB_CONF_SLAAC
#define GNRC_IPV6_NIB_CONF_SLAAC (1)
#endif

/**
* @brief handle Redirect Messages
*/
#ifndef GNRC_IPV6_NIB_CONF_REDIRECT
#define GNRC_IPV6_NIB_CONF_REDIRECT (0)
#endif

/**
* @brief (de-)activate destination cache
*/
#ifndef GNRC_IPV6_NIB_CONF_DC
#if GNRC_IPV6_NIB_CONF_REDIRECT
#define GNRC_IPV6_NIB_CONF_DC (1)
#else
#define GNRC_IPV6_NIB_CONF_DC (0)
#endif
#endif

/**
* @brief Multihop prefix and 6LoWPAN context distribution
*
* @see [RFC 6775, section 8.1](https://tools.ietf.org/html/rfc6775#section-8.1)
*/
#ifndef GNRC_IPV6_NIB_CONF_MULTIHOP_P6C
#define GNRC_IPV6_NIB_CONF_MULTIHOP_P6C (0)
#endif

/**
* @brief Multihop duplicate address detection
*
* @see [RFC 6775, section 8.2](https://tools.ietf.org/html/rfc6775#section-8.2)
*/
#ifndef GNRC_IPV6_NIB_CONF_MULTIHOP_DAD
#define GNRC_IPV6_NIB_CONF_MULTIHOP_DAD (0)
#endif
/** @} */

/**
* @brief Reset time in milliseconds for the reachability time
*
* @see [RFC 4861, section 6.3.4](https://tools.ietf.org/html/rfc4861#section-6.3.4)
*/
#ifndef GNRC_IPV6_NIB_CONF_REACH_TIME_RESET
#define GNRC_IPV6_NIB_CONF_REACH_TIME_RESET (7200000U)
#endif

/**
* @brief Maximum link-layer address length (aligned)
*/
#if (GNRC_NETIF_HDR_L2ADDR_MAX_LEN % 8)
#define GNRC_IPV6_NIB_L2ADDR_MAX_LEN (((GNRC_NETIF_HDR_L2ADDR_MAX_LEN >> 3) + 1) << 3)
#else
#define GNRC_IPV6_NIB_L2ADDR_MAX_LEN (GNRC_NETIF_HDR_L2ADDR_MAX_LEN)
#endif

/**
* @brief Number of default routers in the default router list.
*
* @note **This number has direct influence on the maximum number of
* default routers**
*/
#ifndef GNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF
#define GNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF (1)
#endif

/**
* @brief Number of entries in NIB
*
* @note **This number has direct influence on the maximum number of
* neighbors and duplicate address detection table entries**
*/
#ifndef GNRC_IPV6_NIB_NUMOF
#define GNRC_IPV6_NIB_NUMOF (4)
#endif

#ifdef __cplusplus
}
#endif

#endif /* NET_GNRC_IPV6_NIB_CONF_H */
/** @} */
Loading

0 comments on commit b0d384a

Please sign in to comment.