2015-04-30 21:27:17 +02:00
|
|
|
/*
|
2015-05-22 21:47:37 +02:00
|
|
|
* Copyright (C) 2013 - 2014 INRIA.
|
2015-04-30 21:27:17 +02:00
|
|
|
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
|
2015-05-22 21:47:37 +02:00
|
|
|
* Copyright (C) 2015 Cenk Gündoğan <cnkgndgn@gmail.com>
|
2015-04-30 21:27:17 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-08-20 16:17:37 +02:00
|
|
|
* @defgroup net_gnrc_rpl RPL
|
|
|
|
* @ingroup net_gnrc
|
|
|
|
* @brief RPL implementation for GNRC
|
2016-02-03 13:32:26 +01:00
|
|
|
*
|
|
|
|
* Configuration
|
|
|
|
* =============
|
|
|
|
*
|
|
|
|
* USEMODULE
|
|
|
|
* ---------
|
|
|
|
*
|
|
|
|
* - RPL (Storing Mode)
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
|
|
|
|
* USEMODULE += gnrc_rpl
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
*
|
|
|
|
* CFLAGS
|
|
|
|
* ------
|
|
|
|
*
|
2016-03-15 16:34:06 +01:00
|
|
|
* - Exclude Prefix Information Options from DIOs
|
2016-02-03 13:32:26 +01:00
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
|
|
|
|
* CFLAGS += -DGNRC_RPL_WITHOUT_PIO
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
*
|
2016-03-15 00:13:29 +01:00
|
|
|
* - Modify trickle parameters
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
|
|
|
|
* CFLAGS += -DGNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS=20
|
|
|
|
* CFLAGS += -DGNRC_RPL_DEFAULT_DIO_INTERVAL_MIN=3
|
|
|
|
* CFLAGS += -DGNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT=10
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
*
|
2016-03-15 16:34:06 +01:00
|
|
|
* - Make reception of DODAG_CONF optional when joining a DODAG.
|
|
|
|
* This will use the default trickle parameters until a
|
|
|
|
* DODAG_CONF is received from the parent. The DODAG_CONF is
|
|
|
|
* requested once from the parent while joining the DODAG.
|
|
|
|
* The standard behaviour is to request a DODAG_CONF and join
|
|
|
|
* only a DODAG once a DODAG_CONF is received.
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
|
|
|
|
* CFLAGS += -DGNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
*
|
2015-04-30 21:27:17 +02:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
2015-05-22 21:47:37 +02:00
|
|
|
* @brief RPL header. Declaration of global variables and functions needed for
|
|
|
|
* core functionality of RPL.
|
2015-04-30 21:27:17 +02:00
|
|
|
*
|
2015-05-22 21:47:37 +02:00
|
|
|
* Header which includes all core RPL-functions.
|
|
|
|
*
|
|
|
|
* @author Eric Engel <eric.engel@fu-berlin.de>
|
|
|
|
* @author Fabian Brandt <fabianbr@zedat.fu-berlin.de>
|
|
|
|
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
|
|
|
* @author Cenk Gündoğan <cnkgndgn@gmail.com>
|
2015-04-30 21:27:17 +02:00
|
|
|
*/
|
2015-05-22 21:47:37 +02:00
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
#ifndef GNRC_RPL_H_
|
|
|
|
#define GNRC_RPL_H_
|
2015-04-30 21:27:17 +02:00
|
|
|
|
2015-05-22 21:47:37 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdint.h>
|
2015-08-23 18:33:51 +02:00
|
|
|
#include "net/gnrc.h"
|
2016-03-22 18:27:28 +01:00
|
|
|
#include "net/gnrc/ipv6.h"
|
2015-08-17 15:41:29 +02:00
|
|
|
#include "net/ipv6/addr.h"
|
|
|
|
#include "net/gnrc/nettype.h"
|
|
|
|
#include "net/gnrc/rpl/structs.h"
|
|
|
|
#include "net/gnrc/rpl/dodag.h"
|
|
|
|
#include "net/gnrc/rpl/of_manager.h"
|
2015-05-22 21:47:37 +02:00
|
|
|
#include "net/fib.h"
|
|
|
|
#include "vtimer.h"
|
|
|
|
#include "trickle.h"
|
2015-04-30 21:27:17 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-05-22 21:47:37 +02:00
|
|
|
/**
|
2015-12-16 09:42:37 +01:00
|
|
|
* @brief Default stack size to use for the RPL thread
|
2015-05-22 21:47:37 +02:00
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#ifndef GNRC_RPL_STACK_SIZE
|
|
|
|
#define GNRC_RPL_STACK_SIZE (THREAD_STACKSIZE_DEFAULT)
|
2015-05-22 21:47:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default priority for the RPL thread
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#ifndef GNRC_RPL_PRIO
|
2016-03-22 18:27:28 +01:00
|
|
|
#define GNRC_RPL_PRIO (GNRC_IPV6_PRIO + 1)
|
2015-05-22 21:47:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default message queue size to use for the RPL thread.
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#ifndef GNRC_RPL_MSG_QUEUE_SIZE
|
|
|
|
#define GNRC_RPL_MSG_QUEUE_SIZE (8U)
|
2015-05-22 21:47:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Static initializer for the all-RPL-nodes multicast IPv6
|
|
|
|
* address (ff02::1a)
|
|
|
|
*
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-6">
|
|
|
|
* RFC 6550, section 6
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_ALL_NODES_ADDR {{ 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1a }}
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Message type for lifetime updates
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_MSG_TYPE_LIFETIME_UPDATE (0x0900)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Message type for trickle intervals
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL (0x0901)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Message type for trickle callbacks
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK (0x0902)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Message type for handling DAO sending
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_MSG_TYPE_DAO_HANDLE (0x0903)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Infinite rank
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-17">
|
|
|
|
* RFC 6550, section 17
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_INFINITE_RANK (0xFFFF)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default minimum hop rank increase
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-17">
|
|
|
|
* RFC 6550, section 17
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE (256)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Maximum rank increase
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_MAX_RANK_INCREASE (0)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Number of implemented Objective Functions
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_IMPLEMENTED_OFS_NUMOF (1)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default Objective Code Point (OF0)
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_OCP (0)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
2015-08-23 18:07:49 +02:00
|
|
|
/**
|
|
|
|
* @brief Default Instance ID
|
|
|
|
*/
|
|
|
|
#define GNRC_RPL_DEFAULT_INSTANCE (0)
|
|
|
|
|
2015-05-22 21:47:37 +02:00
|
|
|
/**
|
|
|
|
* @name RPL Mode of Operations
|
|
|
|
* @{
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_MOP_NO_DOWNWARD_ROUTES (0x00)
|
|
|
|
#define GNRC_RPL_MOP_NON_STORING_MODE (0x01)
|
|
|
|
#define GNRC_RPL_MOP_STORING_MODE_NO_MC (0x02)
|
|
|
|
#define GNRC_RPL_MOP_STORING_MODE_MC (0x03)
|
2015-05-22 21:47:37 +02:00
|
|
|
/** default MOP set on compile time */
|
2015-08-17 15:41:29 +02:00
|
|
|
#ifndef GNRC_RPL_DEFAULT_MOP
|
|
|
|
# define GNRC_RPL_DEFAULT_MOP GNRC_RPL_MOP_STORING_MODE_NO_MC
|
2015-05-22 21:47:37 +02:00
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Sequence counter handling
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-7.2">
|
|
|
|
* Sequence Counter Operation
|
|
|
|
* </a>
|
|
|
|
* @{
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_COUNTER_MAX (255)
|
|
|
|
#define GNRC_RPL_COUNTER_LOWER_REGION (127)
|
|
|
|
#define GNRC_RPL_COUNTER_SEQ_WINDOW (16)
|
|
|
|
#define GNRC_RPL_COUNTER_INIT (GNRC_RPL_COUNTER_MAX - GNRC_RPL_COUNTER_SEQ_WINDOW + 1)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
static inline uint8_t GNRC_RPL_COUNTER_INCREMENT(uint8_t counter)
|
2015-05-22 21:47:37 +02:00
|
|
|
{
|
2015-08-17 15:41:29 +02:00
|
|
|
return ((counter > GNRC_RPL_COUNTER_LOWER_REGION) ?
|
|
|
|
((counter == GNRC_RPL_COUNTER_MAX) ? counter = 0 : ++counter) :
|
|
|
|
((counter == GNRC_RPL_COUNTER_LOWER_REGION) ? counter = 0 : ++counter));
|
2015-05-22 21:47:37 +02:00
|
|
|
}
|
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
static inline bool GNRC_RPL_COUNTER_IS_INIT(uint8_t counter)
|
2015-05-22 21:47:37 +02:00
|
|
|
{
|
2015-08-17 15:41:29 +02:00
|
|
|
return (counter > GNRC_RPL_COUNTER_LOWER_REGION);
|
2015-05-22 21:47:37 +02:00
|
|
|
}
|
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
static inline bool GNRC_RPL_COUNTER_GREATER_THAN_LOCAL(uint8_t A, uint8_t B)
|
2015-05-22 21:47:37 +02:00
|
|
|
{
|
2015-08-17 15:41:29 +02:00
|
|
|
return (((A < B) && (GNRC_RPL_COUNTER_LOWER_REGION + 1 - B + A < GNRC_RPL_COUNTER_SEQ_WINDOW))
|
|
|
|
|| ((A > B) && (A - B < GNRC_RPL_COUNTER_SEQ_WINDOW)));
|
2015-05-22 21:47:37 +02:00
|
|
|
}
|
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
2015-05-22 21:47:37 +02:00
|
|
|
{
|
2015-08-17 15:41:29 +02:00
|
|
|
return ((A > GNRC_RPL_COUNTER_LOWER_REGION) ? ((B > GNRC_RPL_COUNTER_LOWER_REGION) ?
|
|
|
|
GNRC_RPL_COUNTER_GREATER_THAN_LOCAL(A, B) : 0) :
|
|
|
|
((B > GNRC_RPL_COUNTER_LOWER_REGION) ? 1 : GNRC_RPL_COUNTER_GREATER_THAN_LOCAL(A, B)));
|
2015-05-22 21:47:37 +02:00
|
|
|
}
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Trickle parameters
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-8.3.1">
|
|
|
|
* Trickle Parameters
|
|
|
|
* </a>
|
|
|
|
* @{
|
|
|
|
*/
|
2016-03-15 00:13:29 +01:00
|
|
|
#ifndef GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS (20)
|
2016-03-15 00:13:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN (3)
|
2016-03-15 00:13:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT (10)
|
2016-03-15 00:13:29 +01:00
|
|
|
#endif
|
2015-05-22 21:47:37 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Default parent and route entry lifetime
|
|
|
|
* default lifetime will be multiplied by the lifetime unit to obtain the resulting lifetime
|
|
|
|
* @{
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_LIFETIME (60)
|
|
|
|
#define GNRC_RPL_LIFETIME_UNIT (2)
|
2015-05-22 21:47:37 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Interval of the void _update_lifetime() function
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_LIFETIME_STEP (2)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
2015-07-23 13:23:42 +02:00
|
|
|
/**
|
|
|
|
* @brief Default prefix length for the DODAG id
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_PREFIX_LEN (64)
|
2015-07-23 13:23:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default prefix valid and preferred time for the DODAG id
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DEFAULT_PREFIX_LIFETIME (0xFFFFFFFF)
|
2015-07-23 13:23:42 +02:00
|
|
|
|
2015-05-22 21:47:37 +02:00
|
|
|
/**
|
|
|
|
* @brief A DODAG can be grounded or floating
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-3.2.4">
|
|
|
|
* Grounded and Floating DODAGs
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_GROUNDED (1)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Parameters used for DAO handling
|
|
|
|
* @{
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_DAO_SEND_RETRIES (4)
|
|
|
|
#define GNRC_RPL_DEFAULT_WAIT_FOR_DAO_ACK (3)
|
|
|
|
#define GNRC_RPL_REGULAR_DAO_INTERVAL (60)
|
|
|
|
#define GNRC_RPL_DEFAULT_DAO_DELAY (5)
|
2015-05-22 21:47:37 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Cleanup timeout in seconds
|
|
|
|
*/
|
2015-08-22 08:38:31 +02:00
|
|
|
#define GNRC_RPL_CLEANUP_TIME (5)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Node Status
|
|
|
|
* @{
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_NORMAL_NODE (0)
|
|
|
|
#define GNRC_RPL_ROOT_NODE (1)
|
|
|
|
#define GNRC_RPL_LEAF_NODE (2)
|
2015-05-22 21:47:37 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name RPL Control Message Options
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-6.7">
|
|
|
|
* RPL Control Message Options
|
|
|
|
* </a>
|
|
|
|
* @{
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_OPT_PAD1 (0)
|
|
|
|
#define GNRC_RPL_OPT_PADN (1)
|
|
|
|
#define GNRC_RPL_OPT_DAG_METRIC_CONTAINER (2)
|
|
|
|
#define GNRC_RPL_OPT_ROUTE_INFO (3)
|
|
|
|
#define GNRC_RPL_OPT_DODAG_CONF (4)
|
|
|
|
#define GNRC_RPL_OPT_TARGET (5)
|
|
|
|
#define GNRC_RPL_OPT_TRANSIT (6)
|
|
|
|
#define GNRC_RPL_OPT_SOLICITED_INFO (7)
|
|
|
|
#define GNRC_RPL_OPT_PREFIX_INFO (8)
|
|
|
|
#define GNRC_RPL_OPT_TARGET_DESC (9)
|
2015-05-22 21:47:37 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Rank of the root node
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_ROOT_RANK (256)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief DIS ICMPv6 code
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-6">
|
|
|
|
* RFC 6550, section 6
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_ICMPV6_CODE_DIS (0x00)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief DIO ICMPv6 code
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-6">
|
|
|
|
* RFC 6550, section 6
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_ICMPV6_CODE_DIO (0x01)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief DAO ICMPv6 code
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-6">
|
|
|
|
* RFC 6550, section 6
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_ICMPV6_CODE_DAO (0x02)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief DAO ACK ICMPv6 code
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-6">
|
|
|
|
* RFC 6550, section 6
|
|
|
|
* </a>
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_ICMPV6_CODE_DAO_ACK (0x03)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Update interval of the lifetime update function
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
#define GNRC_RPL_LIFETIME_UPDATE_STEP (2)
|
2015-05-22 21:47:37 +02:00
|
|
|
|
2015-08-27 22:29:08 +02:00
|
|
|
/**
|
|
|
|
* @brief Rank part of the DODAG
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-3.5.1">
|
|
|
|
* RFC 6550, section 3.5.1, Rank Comparison (DAGRank())
|
|
|
|
* </a>
|
|
|
|
*/
|
|
|
|
#define DAGRANK(rank,mhri) (rank/mhri)
|
|
|
|
|
2015-08-18 21:13:53 +02:00
|
|
|
/**
|
|
|
|
* @name Global / Local instance id masks
|
|
|
|
* @see <a href="https://tools.ietf.org/html/rfc6550#section-5.1">
|
|
|
|
* RFC 6550, section 5.1, RPL Instance ID
|
|
|
|
* </a>
|
|
|
|
* @{
|
|
|
|
*/
|
2015-08-23 18:26:00 +02:00
|
|
|
#define GNRC_RPL_INSTANCE_ID_MSB (1 << 7)
|
|
|
|
#define GNRC_RPL_GLOBAL_INSTANCE_MASK (0x7F)
|
|
|
|
#define GNRC_RPL_LOCAL_INSTANCE_MASK (0x3F)
|
|
|
|
#define GNRC_RPL_INSTANCE_D_FLAG_MASK (1 << 6)
|
2015-08-18 21:13:53 +02:00
|
|
|
/** @} */
|
|
|
|
|
2015-05-22 21:47:37 +02:00
|
|
|
/**
|
|
|
|
* @brief PID of the RPL thread.
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
extern kernel_pid_t gnrc_rpl_pid;
|
2015-05-22 21:47:37 +02:00
|
|
|
|
2016-03-22 10:17:32 +01:00
|
|
|
/**
|
|
|
|
* @brief @see @ref GNRC_RPL_ALL_NODES_ADDR
|
|
|
|
*/
|
|
|
|
extern const ipv6_addr_t ipv6_addr_all_rpl_nodes;
|
|
|
|
|
2015-05-22 21:47:37 +02:00
|
|
|
/**
|
|
|
|
* @brief Initialization of the RPL thread.
|
|
|
|
*
|
|
|
|
* @param[in] if_pid PID of the interface
|
|
|
|
*
|
|
|
|
* @return The PID of the RPL thread, on success.
|
|
|
|
* @return a negative errno on error.
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-23 18:33:51 +02:00
|
|
|
* @brief Initialization of a node as root.
|
2015-05-22 21:47:37 +02:00
|
|
|
*
|
|
|
|
* @param[in] instance_id Id of the instance
|
|
|
|
* @param[in] dodag_id Id of the DODAG
|
2015-08-23 18:07:49 +02:00
|
|
|
* @param[in] gen_inst_id Flag indicating whether to generate an instance id.
|
|
|
|
* If true, @p instance_id will be ignored
|
|
|
|
* @param[in] local_inst_id Flag indicating whether a local or global instance id
|
|
|
|
* should be generatad
|
2015-05-22 21:47:37 +02:00
|
|
|
*
|
2015-08-27 22:29:08 +02:00
|
|
|
* @return Pointer to the new RPL Instance, on success.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @return NULL, otherwise.
|
|
|
|
*/
|
2015-08-27 22:29:08 +02:00
|
|
|
gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_id,
|
|
|
|
bool gen_inst_id, bool local_inst_id);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-27 22:29:08 +02:00
|
|
|
* @brief Send a DIO of the @p instance to the @p destination.
|
2015-05-22 21:47:37 +02:00
|
|
|
*
|
2015-08-27 22:29:08 +02:00
|
|
|
* @param[in] instance Pointer to the RPL instance.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @param[in] destination IPv6 addres of the destination.
|
|
|
|
*/
|
2015-08-27 22:29:08 +02:00
|
|
|
void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *instance, ipv6_addr_t *destination);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-27 22:29:08 +02:00
|
|
|
* @brief Send a DIS of the @p instace to the @p destination.
|
2015-05-22 21:47:37 +02:00
|
|
|
*
|
2015-08-27 22:29:08 +02:00
|
|
|
* @param[in] instance Pointer to the RPL instance, optional.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @param[in] destination IPv6 addres of the destination.
|
|
|
|
*/
|
2015-08-27 22:29:08 +02:00
|
|
|
void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *instance, ipv6_addr_t *destination);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Send a DAO of the @p dodag to the @p destination.
|
|
|
|
*
|
2015-08-27 22:29:08 +02:00
|
|
|
* @param[in] instance Pointer to the instance.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @param[in] destination IPv6 addres of the destination.
|
|
|
|
* @param[in] lifetime Lifetime of the route to announce.
|
|
|
|
*/
|
2015-08-27 22:29:08 +02:00
|
|
|
void gnrc_rpl_send_DAO(gnrc_rpl_instance_t *instance, ipv6_addr_t *destination, uint8_t lifetime);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-27 22:29:08 +02:00
|
|
|
* @brief Send a DAO-ACK of the @p instance to the @p destination.
|
2015-05-22 21:47:37 +02:00
|
|
|
*
|
2015-08-27 22:29:08 +02:00
|
|
|
* @param[in] instance Pointer to the RPL instance.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @param[in] destination IPv6 addres of the destination.
|
|
|
|
* @param[in] seq Sequence number to be acknowledged.
|
|
|
|
*/
|
2015-08-27 22:29:08 +02:00
|
|
|
void gnrc_rpl_send_DAO_ACK(gnrc_rpl_instance_t *instance, ipv6_addr_t *destination, uint8_t seq);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Parse a DIS.
|
|
|
|
*
|
|
|
|
* @param[in] dis Pointer to the DIS message.
|
2016-03-22 14:58:23 +01:00
|
|
|
* @param[in] iface Interface PID of the incoming DIS.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @param[in] src Pointer to the source address of the IPv6 packet.
|
|
|
|
* @param[in] dst Pointer to the destination address of the IPv6 packet.
|
|
|
|
* @param[in] len Length of the IPv6 packet.
|
|
|
|
*/
|
2016-03-22 14:58:23 +01:00
|
|
|
void gnrc_rpl_recv_DIS(gnrc_rpl_dis_t *dis, kernel_pid_t iface, ipv6_addr_t *src,
|
|
|
|
ipv6_addr_t *dst, uint16_t len);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Parse a DIO.
|
|
|
|
*
|
|
|
|
* @param[in] dio Pointer to the DIO message.
|
2016-03-22 14:58:23 +01:00
|
|
|
* @param[in] iface Interface PID of the incoming DIO.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @param[in] src Pointer to the source address of the IPv6 packet.
|
|
|
|
* @param[in] len Length of the IPv6 packet.
|
|
|
|
*/
|
2016-03-22 14:58:23 +01:00
|
|
|
void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src, uint16_t len);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Parse a DAO.
|
|
|
|
*
|
|
|
|
* @param[in] dao Pointer to the DAO message.
|
2016-03-22 14:58:23 +01:00
|
|
|
* @param[in] iface Interface PID of the incoming DIO.
|
2015-05-22 21:47:37 +02:00
|
|
|
* @param[in] src Pointer to the source address of the IPv6 packet.
|
|
|
|
* @param[in] len Length of the IPv6 packet.
|
|
|
|
*/
|
2016-03-22 14:58:23 +01:00
|
|
|
void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, kernel_pid_t iface, ipv6_addr_t *src, uint16_t len);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Parse a DAO-ACK.
|
|
|
|
*
|
|
|
|
* @param[in] dao_ack Pointer to the DAO-ACK message.
|
2016-03-22 14:58:23 +01:00
|
|
|
* @param[in] iface Interface PID of the incoming DIO.
|
2015-08-19 19:29:17 +02:00
|
|
|
* @param[in] len Length of the IPv6 packet.
|
2015-05-22 21:47:37 +02:00
|
|
|
*/
|
2016-03-22 14:58:23 +01:00
|
|
|
void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack, kernel_pid_t iface, uint16_t len);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Delay the DAO sending interval
|
|
|
|
*
|
|
|
|
* @param[in] dodag The DODAG of the DAO
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
void gnrc_rpl_delay_dao(gnrc_rpl_dodag_t *dodag);
|
2015-05-22 21:47:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Long delay the DAO sending interval
|
|
|
|
*
|
|
|
|
* @param[in] dodag The DODAG of the DAO
|
|
|
|
*/
|
2015-08-17 15:41:29 +02:00
|
|
|
void gnrc_rpl_long_delay_dao(gnrc_rpl_dodag_t *dodag);
|
2015-08-23 18:33:51 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-27 22:29:08 +02:00
|
|
|
* @brief Create a new RPL instance and RPL DODAG.
|
2015-08-23 18:33:51 +02:00
|
|
|
*
|
|
|
|
* @param[in] instance_id Id of the instance
|
|
|
|
* @param[in] dodag_id Id of the DODAG
|
|
|
|
* @param[in] mop Mode of Operation
|
|
|
|
*
|
2015-08-27 22:29:08 +02:00
|
|
|
* @return Pointer to the new RPL instance, on success.
|
2015-08-23 18:33:51 +02:00
|
|
|
* @return NULL, otherwise.
|
|
|
|
*/
|
2015-08-27 22:29:08 +02:00
|
|
|
gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_t *dodag_id,
|
|
|
|
uint8_t mop);
|
2015-08-23 18:33:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Send a control message
|
|
|
|
*
|
|
|
|
* @param[in] pkt gnrc_pktnsip_t to send
|
2016-03-22 14:58:23 +01:00
|
|
|
* @param[in] iface Interface PID to send this pkt to
|
2015-08-23 18:33:51 +02:00
|
|
|
* @param[in] src Source address of the packet
|
|
|
|
* @param[in] dst Destination address of the packet
|
|
|
|
* @param[in] dodag_id Id of the DODAG
|
|
|
|
*/
|
2016-03-22 14:58:23 +01:00
|
|
|
void gnrc_rpl_send(gnrc_pktsnip_t *pkt, kernel_pid_t iface, ipv6_addr_t *src, ipv6_addr_t *dst,
|
|
|
|
ipv6_addr_t *dodag_id);
|
2015-08-23 18:07:49 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Generate a local or global instance id
|
|
|
|
*
|
|
|
|
* @param[in] local flag to indicate whether a local or global instance id is requested
|
|
|
|
*
|
|
|
|
* @return Local instance id, if @p local is true
|
|
|
|
* @return Global instance id, otherwise.
|
|
|
|
*/
|
|
|
|
uint8_t gnrc_rpl_gen_instance_id(bool local);
|
2016-02-03 07:32:40 +01:00
|
|
|
|
2016-02-03 08:37:59 +01:00
|
|
|
#ifndef GNRC_RPL_WITHOUT_PIO
|
2016-02-03 07:32:40 +01:00
|
|
|
/**
|
|
|
|
* @brief (De-)Activate the transmission of Prefix Information Options within DIOs
|
|
|
|
* for a particular DODAG
|
|
|
|
*
|
|
|
|
* @param[in] dodag Pointer to the DODAG
|
|
|
|
* @param[in] status true for activating PIOs and false for deactivating them
|
|
|
|
*/
|
|
|
|
static inline void gnrc_rpl_config_pio(gnrc_rpl_dodag_t *dodag, bool status)
|
|
|
|
{
|
2016-03-15 15:17:46 +01:00
|
|
|
dodag->dio_opts = (dodag->dio_opts & ~GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) |
|
|
|
|
(status << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT);
|
2016-02-03 07:32:40 +01:00
|
|
|
}
|
2016-02-03 08:37:59 +01:00
|
|
|
#endif
|
|
|
|
|
2015-04-30 21:27:17 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
#endif /* GNRC_RPL_H_ */
|
|
|
|
/** @} */
|