mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #1080 from fabianbrandt/of_manager
Introduction of an of-manager for RPL.
This commit is contained in:
commit
b358d8517f
@ -34,6 +34,7 @@
|
||||
#include <transceiver.h>
|
||||
#include "ipv6.h"
|
||||
#include "rpl/rpl_dodag.h"
|
||||
#include "rpl/rpl_of_manager.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -46,7 +47,6 @@ extern "C" {
|
||||
#define RPL_PROCESS_STACKSIZE KERNEL_CONF_STACKSIZE_DEFAULT
|
||||
|
||||
/* global variables */
|
||||
extern rpl_of_t *rpl_objective_functions[NUMBER_IMPLEMENTED_OFS];
|
||||
extern rpl_routing_entry_t rpl_routing_table[RPL_MAX_ROUTING_ENTRIES];
|
||||
extern kernel_pid_t rpl_process_pid;
|
||||
|
||||
@ -75,18 +75,6 @@ extern uint8_t rpl_buffer[BUFFER_SIZE - LL_HDR_LEN];
|
||||
*/
|
||||
uint8_t rpl_init(int if_id);
|
||||
|
||||
/**
|
||||
* @brief Get entry point for default objective function.
|
||||
*
|
||||
* This function is obsolete in rpl.h and will be moved shortly.
|
||||
*
|
||||
* @param[in] ocp Objective code point for desired objective function
|
||||
*
|
||||
* @return Implementation of objective function
|
||||
*
|
||||
* */
|
||||
rpl_of_t *rpl_get_of_for_ocp(uint16_t ocp);
|
||||
|
||||
/**
|
||||
* @brief Initialization of RPL-root.
|
||||
*
|
||||
|
46
sys/net/include/rpl/rpl_of_manager.h
Normal file
46
sys/net/include/rpl/rpl_of_manager.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 rpl_of_manager.h
|
||||
* @brief RPL Objective functions manager header
|
||||
* @author Fabian Brandt <fabianbr@zedat.fu-berlin.de>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef __RPL_OFM_H
|
||||
#define __RPL_OFM_H
|
||||
|
||||
#include "rpl_structs.h"
|
||||
#include "rpl_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialization of Manager and of-functions.
|
||||
* @param[in] my_address Own address for initialization of beaconing
|
||||
*/
|
||||
void rpl_of_manager_init(ipv6_addr_t *my_address);
|
||||
|
||||
/**
|
||||
* @brief Returns objective function with a given cope point
|
||||
* @param[in] ocp Objective code point of objective function
|
||||
* @return Pointer of corresponding objective function implementation
|
||||
*/
|
||||
rpl_of_t *rpl_get_of_for_ocp(uint16_t ocp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RPL_OFM_H */
|
||||
/** @} */
|
@ -47,7 +47,6 @@ char addr_str[IPV6_MAX_ADDR_STR_LEN];
|
||||
#include "debug.h"
|
||||
|
||||
/* global variables */
|
||||
rpl_of_t *rpl_objective_functions[NUMBER_IMPLEMENTED_OFS];
|
||||
rpl_routing_entry_t rpl_routing_table[RPL_MAX_ROUTING_ENTRIES];
|
||||
kernel_pid_t rpl_process_pid = KERNEL_PID_UNDEF;
|
||||
mutex_t rpl_recv_mutex = MUTEX_INIT;
|
||||
@ -59,18 +58,6 @@ uint8_t rpl_buffer[BUFFER_SIZE - LL_HDR_LEN];
|
||||
/* IPv6 message buffer */
|
||||
ipv6_hdr_t *ipv6_buf;
|
||||
|
||||
/* find implemented OF via objective code point */
|
||||
rpl_of_t *rpl_get_of_for_ocp(uint16_t ocp)
|
||||
{
|
||||
for (uint16_t i = 0; i < NUMBER_IMPLEMENTED_OFS; i++) {
|
||||
if (ocp == rpl_objective_functions[i]->ocp) {
|
||||
return rpl_objective_functions[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint8_t rpl_init(int if_id)
|
||||
{
|
||||
rpl_instances_init();
|
||||
@ -82,10 +69,6 @@ uint8_t rpl_init(int if_id)
|
||||
PRIORITY_MAIN - 1, CREATE_STACKTEST,
|
||||
rpl_process, NULL, "rpl_process");
|
||||
|
||||
/* INSERT NEW OBJECTIVE FUNCTIONS HERE */
|
||||
rpl_objective_functions[0] = rpl_get_of0();
|
||||
rpl_objective_functions[1] = rpl_get_of_mrhof();
|
||||
|
||||
sixlowpan_lowpan_init_interface(if_id);
|
||||
/* need link local prefix to query _our_ corresponding address */
|
||||
ipv6_addr_t my_address;
|
||||
@ -94,13 +77,8 @@ uint8_t rpl_init(int if_id)
|
||||
ipv6_net_if_get_best_src_addr(&my_address, &ll_address);
|
||||
ipv6_register_rpl_handler(rpl_process_pid);
|
||||
|
||||
/* initialize ETX-calculation if needed */
|
||||
if (RPL_DEFAULT_OCP == 1) {
|
||||
DEBUGF("INIT ETX BEACONING\n");
|
||||
etx_init_beaconing(&my_address);
|
||||
}
|
||||
|
||||
rpl_init_mode(&my_address);
|
||||
/* initialize objective function manager */
|
||||
rpl_of_manager_init(&my_address);
|
||||
|
||||
return SIXLOWERROR_SUCCESS;
|
||||
}
|
||||
|
60
sys/net/routing/rpl/rpl_of_manager.c
Normal file
60
sys/net/routing/rpl/rpl_of_manager.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 rpl_of_manager.c
|
||||
* @brief RPL Objective functions manager
|
||||
* @author Fabian Brandt <fabianbr@zedat.fu-berlin.de>
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "rpl/rpl_of_manager.h"
|
||||
#include "of0.h"
|
||||
#include "of_mrhof.h"
|
||||
#include "etx_beaconing.h"
|
||||
#include "rpl/rpl_config.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
rpl_of_t *objective_functions[NUMBER_IMPLEMENTED_OFS];
|
||||
|
||||
void rpl_of_manager_init(ipv6_addr_t *my_address)
|
||||
{
|
||||
/* insert new objective functions here */
|
||||
objective_functions[0] = rpl_get_of0();
|
||||
objective_functions[1] = rpl_get_of_mrhof();
|
||||
|
||||
if (RPL_DEFAULT_OCP == 1) {
|
||||
DEBUG("%s, %d: INIT ETX BEACONING\n", __FILE__, __LINE__);
|
||||
etx_init_beaconing(my_address);
|
||||
}
|
||||
}
|
||||
|
||||
/* find implemented OF via objective code point */
|
||||
rpl_of_t *rpl_get_of_for_ocp(uint16_t ocp)
|
||||
{
|
||||
for (uint16_t i = 0; i < NUMBER_IMPLEMENTED_OFS; i++) {
|
||||
if (objective_functions[i] == NULL) {
|
||||
/* fallback if something goes wrong */
|
||||
return rpl_get_of0();
|
||||
}
|
||||
else if (ocp == objective_functions[i]->ocp) {
|
||||
return objective_functions[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
Loading…
Reference in New Issue
Block a user