1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/net/routing/rpl/of0.c
Fabian Brandt 12cd62c689 Introduction of RPL non-storing mode.
This implementation is based on RFC 6550 with addition of RFC 6554 (Source Routing Header for RPL). Both can be found under the following links:
- http://tools.ietf.org/html/rfc6550
- http://tools.ietf.org/html/rfc6554

The PR provides basic functionality for handling and forwarding packages in non-storing mode. In addition the structure of the previous implemented RPL storing mode is now revised, so that readability and modularity is increased. The following features are implemented:
- building function for a SRH and integration in common packets
- source-route build algorithm based on the structure of the DODAG
- an RPL-based interpretation of the SRH and removal at destination
- new structure for RPl-module with extracted beaconing-functionality
- leaf nodes are now supported

There are some missed goals and should be included in future updates:
- building a common routing table structure for different types of routing protocols
- routing tables are statically assigned via source code, future update should have an optional variable at build-time, which sets the size of the routing table depending on the desired functionality of a node in the network (root, node, leaf)
2014-11-27 21:42:40 +01:00

94 lines
1.8 KiB
C

/*
* Copyright (C) 2014 Oliver Hahm <oliver.hahm@inria.fr>
*
* 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.
*/
/**
* @ingroup rpl
* @{
* @file of0.c
* @brief Objective Function Zero.
*
* Implementation of Objective Function Zero.
*
* @author Eric Engel <eric.engel@fu-berlin.de>
* @}
*/
#include <string.h>
#include "of0.h"
//Function Prototypes
static uint16_t calc_rank(rpl_parent_t *, uint16_t);
static rpl_parent_t *which_parent(rpl_parent_t *, rpl_parent_t *);
static rpl_dodag_t *which_dodag(rpl_dodag_t *, rpl_dodag_t *);
static void reset(rpl_dodag_t *);
rpl_of_t rpl_of0 = {
0x0,
calc_rank,
which_parent,
which_dodag,
reset,
NULL,
NULL,
NULL
};
rpl_of_t *rpl_get_of0(void)
{
return &rpl_of0;
}
void reset(rpl_dodag_t *dodag)
{
/* Nothing to do in OF0 */
(void) dodag;
}
uint16_t calc_rank(rpl_parent_t *parent, uint16_t base_rank)
{
if (base_rank == 0) {
if (parent == NULL) {
return INFINITE_RANK;
}
base_rank = parent->rank;
}
uint16_t add;
if (parent != NULL) {
add = parent->dodag->minhoprankincrease;
}
else {
add = DEFAULT_MIN_HOP_RANK_INCREASE;
}
if (base_rank + add < base_rank) {
return INFINITE_RANK;
}
return base_rank + add;
}
/* We simply return the Parent with lower rank */
rpl_parent_t *which_parent(rpl_parent_t *p1, rpl_parent_t *p2)
{
if (p1->rank < p2->rank) {
return p1;
}
return p2;
}
/* Not used yet, as the implementation only makes use of one dodag for now. */
rpl_dodag_t *which_dodag(rpl_dodag_t *d1, rpl_dodag_t *d2)
{
(void) d2;
return d1;
}