gnrc_rpl_of_manager.c
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* RPL dodag implementation
*
* Copyright (C) 2014 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.
*/
/**
*
* @ingroup rpl
* @{
* @file
* @brief RPL Objective functions manager
* @author Fabian Brandt <fabianbr@zedat.fu-berlin.de>
* @}
*/
#include "net/gnrc/rpl.h"
#include "net/gnrc/rpl/of_manager.h"
#include "of0.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
/* !!! TODO: port etx/mrhof to the new network stack */
static gnrc_rpl_of_t *objective_functions[GNRC_RPL_IMPLEMENTED_OFS_NUMOF];
void gnrc_rpl_of_manager_init(void)
{
/* insert new objective functions here */
objective_functions[0] = gnrc_rpl_get_of0();
/*objective_functions[1] = gnrc_rpl_get_of_mrhof(); */
}
/* find implemented OF via objective code point */
gnrc_rpl_of_t *gnrc_rpl_get_of_for_ocp(uint16_t ocp)
{
for (uint16_t i = 0; i < GNRC_RPL_IMPLEMENTED_OFS_NUMOF; i++) {
if (objective_functions[i] == NULL) {
/* fallback if something goes wrong */
return gnrc_rpl_get_of0();
}
else if (ocp == objective_functions[i]->ocp) {
return objective_functions[i];
}
}
return NULL;
}