2013-11-27 17:54:30 +01:00
|
|
|
/*
|
2014-08-21 23:52:42 +02:00
|
|
|
* Copyright (C) 2013, 2014 INRIA.
|
2013-06-22 05:11:53 +02:00
|
|
|
*
|
2014-08-21 23:52:42 +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.
|
2013-11-27 17:54:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-07-08 16:54:54 +02:00
|
|
|
* @ingroup rpl
|
2013-06-22 05:11:53 +02:00
|
|
|
* @{
|
2013-11-27 17:54:30 +01:00
|
|
|
*
|
|
|
|
* @file rpl.h
|
2014-06-18 12:11:12 +02:00
|
|
|
* @brief RPL header. Declaration of global variables and functions needed for
|
2014-07-08 16:54:54 +02:00
|
|
|
* core functionality of RPL.
|
2013-11-27 17:54:30 +01:00
|
|
|
*
|
2014-07-08 16:54:54 +02:00
|
|
|
* Header which includes all core RPL-functions. Normally it shouldn't be necessary to
|
|
|
|
* modify this file.
|
|
|
|
*
|
|
|
|
* @author Eric Engel <eric.engel@fu-berlin.de>
|
|
|
|
* @author Fabian Brandt <fabianbr@zedat.fu-berlin.de>
|
2013-06-22 05:11:53 +02:00
|
|
|
*/
|
|
|
|
|
2013-11-27 17:54:30 +01:00
|
|
|
#ifndef __RPL_H
|
|
|
|
#define __RPL_H
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
#include <string.h>
|
2012-01-19 17:35:50 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <vtimer.h>
|
|
|
|
#include <mutex.h>
|
2012-02-14 22:22:01 +01:00
|
|
|
#include <transceiver.h>
|
2013-08-05 16:10:54 +02:00
|
|
|
#include "ipv6.h"
|
2014-08-06 13:48:18 +02:00
|
|
|
#include "rpl/rpl_dodag.h"
|
2014-04-30 14:41:00 +02:00
|
|
|
#include "rpl/rpl_of_manager.h"
|
2012-01-19 17:35:50 +01:00
|
|
|
|
2014-10-10 11:51:11 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-09-17 19:46:50 +02:00
|
|
|
#undef CC1100_RADIO_MODE
|
2013-03-15 17:48:13 +01:00
|
|
|
#define CC1100_RADIO_MODE CC1100_MODE_WOR
|
|
|
|
|
2014-01-09 18:19:57 +01:00
|
|
|
#define RPL_PKT_RECV_BUF_SIZE 16
|
2014-07-08 16:54:54 +02:00
|
|
|
#define RPL_PROCESS_STACKSIZE KERNEL_CONF_STACKSIZE_MAIN
|
2012-01-26 20:26:55 +01:00
|
|
|
|
2014-06-18 12:11:12 +02:00
|
|
|
/* global variables */
|
2014-07-06 22:57:56 +02:00
|
|
|
extern kernel_pid_t rpl_process_pid;
|
2014-07-08 16:54:54 +02:00
|
|
|
extern uint8_t rpl_max_routing_entries;
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/* needed for receiving messages with ICMP-code 155. Received via IPC from ipv6.c */
|
|
|
|
extern mutex_t rpl_recv_mutex;
|
|
|
|
|
|
|
|
/* needed for sending RPL-messages */
|
|
|
|
extern mutex_t rpl_send_mutex;
|
|
|
|
|
|
|
|
extern msg_t rpl_msg_queue[RPL_PKT_RECV_BUF_SIZE];
|
|
|
|
extern char rpl_process_buf[RPL_PROCESS_STACKSIZE];
|
|
|
|
extern uint8_t rpl_buffer[BUFFER_SIZE - LL_HDR_LEN];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialization of RPL.
|
|
|
|
*
|
|
|
|
* This function initializes all basic RPL resources such as mutex for send/receive,
|
|
|
|
* corresponding objective functions and sixlowpan (including own address). Calls
|
|
|
|
* initialization for mode as specified by PL_DEFAULT_MOP in rpl_structs.h.
|
|
|
|
*
|
|
|
|
* @param[in] if_id ID of the interface, which correspond to the network under RPL-control
|
|
|
|
*
|
|
|
|
* @return 1 if initialization was successful
|
|
|
|
* @return 0 if initialization was not successful
|
|
|
|
*
|
|
|
|
*/
|
2014-02-13 13:57:59 +01:00
|
|
|
uint8_t rpl_init(int if_id);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialization of RPL-root.
|
|
|
|
*
|
|
|
|
* This function initializes all RPL resources to act as a root node.
|
|
|
|
* Because the root has different features in different modes, the core
|
|
|
|
* initialization just calls the root-initialization of the chosen mode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void rpl_init_root(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sends a DIO-message to a given destination
|
|
|
|
*
|
|
|
|
* This function sends a DIO message to a given destination. Because nodes can act
|
|
|
|
* differently in different modes, this function just sets the mutex and call the DIO
|
|
|
|
* sending function of the chosen mode.
|
|
|
|
*
|
|
|
|
* @param[in] destination IPv6-address of the destination of the DIO. Should be a direct neighbor.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_send_DIO(ipv6_addr_t *destination);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sends a DAO-message to a given destination
|
|
|
|
*
|
|
|
|
* This function sends a DAO message to a given destination. Because nodes can act
|
|
|
|
* differently in different modes, this function just sets the mutex and call the DAO
|
|
|
|
* sending function of the chosen mode.
|
|
|
|
*
|
|
|
|
* @param[in] destination IPv6-address of the destination of the DAO. Should be the preferred parent.
|
|
|
|
* @param[in] lifetime Lifetime of the node. Reflect the estimated time of presence in the network.
|
|
|
|
* @param[in] default_lifetime If true, param lifetime is ignored and lifetime is dodag default-lifetime
|
|
|
|
* @param[in] start_index Describes whether a DAO must be split because of too many routing entries.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_send_DAO(ipv6_addr_t *destination, uint8_t lifetime, bool default_lifetime, uint8_t start_index);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sends a DIS-message to a given destination
|
|
|
|
*
|
|
|
|
* This function sends a DIS message to a given destination or multicast-address. Because nodes can act
|
|
|
|
* differently in different modes, this function just sets the mutex and call the DIS
|
|
|
|
* sending function of the chosen mode.
|
|
|
|
*
|
|
|
|
* @param[in] destination IPv6-address of the destination of the DIS. Should be a direct neighbor or multicast-address.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_send_DIS(ipv6_addr_t *destination);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sends a DAO acknowledgment-message to a given destination
|
|
|
|
*
|
|
|
|
* This function sends a DAO_ACK message to a given destination. Because nodes can act
|
|
|
|
* differently in different modes, this function just sets the mutex and call the DAO_ACK
|
|
|
|
* sending function of the chosen mode.
|
|
|
|
*
|
|
|
|
* @param[in] destination IPv6-address of the destination of the DAO_ACK. Should be a direct neighbor.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_send_DAO_ACK(ipv6_addr_t *destination);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Receives a DIO message
|
|
|
|
*
|
|
|
|
* This function handles receiving a DIO message. Because nodes can act differently in different modes,
|
|
|
|
* this function just calls the receiving function of the chosen mode.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_recv_DIO(void);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Receives a DAO message
|
|
|
|
*
|
|
|
|
* This function handles receiving a DAO message. Because nodes can act differently in different modes,
|
|
|
|
* this function just calls the receiving function of the chosen mode.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_recv_DAO(void);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Receives a DIS message
|
|
|
|
*
|
|
|
|
* This function handles receiving a DIS message. Because nodes can act differently in different modes,
|
|
|
|
* this function just calls the receiving function of the chosen mode.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_recv_DIS(void);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Receives a DAO acknowledgment message
|
|
|
|
*
|
|
|
|
* This function handles receiving a DAO_ACK message. Because nodes can act differently in different modes,
|
|
|
|
* this function just calls the receiving function of the chosen mode.
|
|
|
|
*
|
|
|
|
*/
|
2014-07-08 16:54:54 +02:00
|
|
|
void rpl_recv_DAO_ACK(void);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initialization of RPl-root.
|
|
|
|
*
|
|
|
|
* This function initializes all RPL resources especially for root purposes.
|
|
|
|
* corresponding objective functions and sixlowpan (including own address). It also register mutexes for
|
|
|
|
* sending and receiving RPL-based messages. Both are necessary because of parallel access from different
|
|
|
|
* layers/modules of RIOT. May change with future structure changes.
|
|
|
|
*
|
2014-03-04 20:20:01 +01:00
|
|
|
* @param arg ignored
|
|
|
|
* @returns nothing
|
2014-06-18 12:11:12 +02:00
|
|
|
*/
|
2014-03-04 20:20:01 +01:00
|
|
|
void *rpl_process(void *arg);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns next hop from routing table.
|
|
|
|
*
|
|
|
|
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
|
|
|
|
* common routing information base.
|
|
|
|
*
|
|
|
|
* @param[in] addr Destination address
|
|
|
|
*
|
|
|
|
* @return Next hop address
|
|
|
|
*
|
|
|
|
* */
|
2013-06-22 05:11:53 +02:00
|
|
|
ipv6_addr_t *rpl_get_next_hop(ipv6_addr_t *addr);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Adds routing entry to routing table
|
|
|
|
*
|
|
|
|
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
|
|
|
|
* common routing information base.
|
|
|
|
*
|
|
|
|
* @param[in] addr Destination address
|
|
|
|
* @param[in] next_hop Next hop address
|
|
|
|
* @param[in] lifetime Lifetime of the entry
|
|
|
|
*
|
|
|
|
* */
|
2012-04-07 20:30:13 +02:00
|
|
|
void rpl_add_routing_entry(ipv6_addr_t *addr, ipv6_addr_t *next_hop, uint16_t lifetime);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Deletes routing entry to routing table
|
|
|
|
*
|
|
|
|
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
|
|
|
|
* common routing information base.
|
|
|
|
*
|
|
|
|
* @param[in] addr Destination address
|
|
|
|
*
|
|
|
|
* */
|
2012-02-14 22:22:01 +01:00
|
|
|
void rpl_del_routing_entry(ipv6_addr_t *addr);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Finds routing entry for a given destination.
|
|
|
|
*
|
|
|
|
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
|
|
|
|
* common routing information base.
|
|
|
|
*
|
|
|
|
* @param[in] addr Destination address
|
|
|
|
*
|
|
|
|
* @return Routing entry address
|
|
|
|
*
|
|
|
|
* */
|
2013-06-22 05:11:53 +02:00
|
|
|
rpl_routing_entry_t *rpl_find_routing_entry(ipv6_addr_t *addr);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clears routing table.
|
|
|
|
*
|
|
|
|
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
|
|
|
|
* common routing information base.
|
|
|
|
*
|
|
|
|
* */
|
2013-06-10 17:36:56 +02:00
|
|
|
void rpl_clear_routing_table(void);
|
2014-06-18 12:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns routing table
|
|
|
|
*
|
|
|
|
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
|
|
|
|
* common routing information base.
|
|
|
|
*
|
|
|
|
* @return Routing table
|
|
|
|
*
|
|
|
|
* */
|
2012-02-22 00:50:40 +01:00
|
|
|
rpl_routing_entry_t *rpl_get_routing_table(void);
|
2013-11-27 17:54:30 +01:00
|
|
|
|
2014-07-08 16:54:54 +02:00
|
|
|
/**
|
|
|
|
* @brief Returns the network status of the actual node
|
|
|
|
*
|
|
|
|
* @return 1 if root, 0 otherwise
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
uint8_t rpl_is_root(void);
|
|
|
|
|
|
|
|
#if RPL_DEFAULT_MOP == RPL_NON_STORING_MODE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Adds one pair of child and its parent to the source routing table
|
|
|
|
*
|
|
|
|
* @deprecated This function is obsolete and will be removed shortly. This will be replaced with a
|
|
|
|
* common routing information base.
|
|
|
|
*
|
|
|
|
* @param[in] child Child IPv6-address
|
|
|
|
* @param[in] parent Parent IPv6-address
|
|
|
|
* @param[in] lifetime Lifetime of the relation
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
void rpl_add_srh_entry(ipv6_addr_t *child, ipv6_addr_t *parent, uint16_t lifetime);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Constructs a source routing header based on an original IPv6-header
|
|
|
|
*
|
|
|
|
* @param[in] act_ipv6_hdr Pointer to original IPv6-packet header
|
|
|
|
* @return Source routing header or NULL
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
ipv6_srh_t *rpl_get_srh_header(ipv6_hdr_t *act_ipv6_hdr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Manages sending an SRH-header integrated in an original IPv6-package to the next hop.
|
|
|
|
*
|
|
|
|
* @param[in] buf Pointer to original payload
|
|
|
|
* @param[in] len Length of the original payload
|
|
|
|
* @param[in] src Original source address
|
|
|
|
* @param[in] dest Destination address
|
|
|
|
* @param[in] srh_header Pre-build source routing header
|
|
|
|
* @param[in] srh_length Length of the pre-built source routing header
|
|
|
|
* @return Status of sending progress
|
|
|
|
* */
|
|
|
|
int rpl_srh_sendto(const void *buf, uint16_t len, ipv6_addr_t *src, ipv6_addr_t *dest, ipv6_srh_t *srh_header, uint8_t srh_length);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sends IPC-message to the service, which is indicated by the next-header-field in the source routing header
|
|
|
|
*
|
|
|
|
* @param[in] ipv6_header Actual IPv6-header
|
|
|
|
* @return IPv6-address of the next-hop. Is NULL on error occurrence.
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
void rpl_remove_srh_header(ipv6_hdr_t *ipv6_header, const void *buf, uint8_t nextheader);
|
|
|
|
|
2014-10-10 11:51:11 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-07-08 16:54:54 +02:00
|
|
|
#endif
|
2013-11-27 17:54:30 +01:00
|
|
|
/** @} */
|
|
|
|
#endif /* __RPL_H */
|