Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions sys/net/include/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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;

Expand Down Expand Up @@ -75,18 +75,6 @@ extern uint8_t rpl_buffer[BUFFER_SIZE - LL_HDR_LEN];
*/
uint8_t rpl_init(int if_id);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd like to keep these two lines or did I overlook something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure :/

/**
* @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.
*
Expand Down
46 changes: 46 additions & 0 deletions sys/net/include/rpl/rpl_of_manager.h
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken indentation.

* directory for more details.
*
* @ingroup rpl
* @{
* @file rpl_of_manager.h
* @brief RPL Objective functions manager header
* @author Fabian Brandt <[email protected]>
* @}
*/

#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 */
/** @} */
26 changes: 2 additions & 24 deletions sys/net/routing/rpl/rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
60 changes: 60 additions & 0 deletions sys/net/routing/rpl/rpl_of_manager.c
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
* @}
*/



#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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move NUMBER_IMPLEMENTED_OFS in this file, this define is not used in any other place and hard to find now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I second @mehlis. And rpl_objective_functions can be removed, too, right?


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;
}