-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Introduction of an of-manager for RPL. #1080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 */ | ||
| /** @} */ | ||
| 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]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please move
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I second @mehlis. And |
||
|
|
||
| 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; | ||
| } | ||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure :/