Merge pull request #429 from carlosgp143/contrib/rpl-leaf-only
Change RPL_LEAF_ONLY flag to a run-time flag
This commit is contained in:
commit
38f52b7023
|
@ -185,10 +185,10 @@
|
||||||
* This value decides if this node must stay as a leaf or not
|
* This value decides if this node must stay as a leaf or not
|
||||||
* as allowed by draft-ietf-roll-rpl-19#section-8.5
|
* as allowed by draft-ietf-roll-rpl-19#section-8.5
|
||||||
*/
|
*/
|
||||||
#ifdef RPL_CONF_LEAF_ONLY
|
#ifdef RPL_CONF_DEFAULT_LEAF_ONLY
|
||||||
#define RPL_LEAF_ONLY RPL_CONF_LEAF_ONLY
|
#define RPL_DEFAULT_LEAF_ONLY RPL_CONF_DEFAULT_LEAF_ONLY
|
||||||
#else
|
#else
|
||||||
#define RPL_LEAF_ONLY 0
|
#define RPL_DEFAULT_LEAF_ONLY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -342,14 +342,14 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||||
/* Make sure we're up-to-date before sending data out */
|
/* Make sure we're up-to-date before sending data out */
|
||||||
rpl_dag_update_state();
|
rpl_dag_update_state();
|
||||||
|
|
||||||
#if RPL_LEAF_ONLY
|
if(rpl_get_leaf_only()) {
|
||||||
/* In leaf mode, we only send DIO messages as unicasts in response to
|
/* In leaf mode, we only send DIO messages as unicasts in response to
|
||||||
unicast DIS messages. */
|
unicast DIS messages. */
|
||||||
if(uc_addr == NULL) {
|
if(uc_addr == NULL) {
|
||||||
/* Do not send multicast DIO in leaf mode */
|
/* Do not send multicast DIO in leaf mode */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* RPL_LEAF_ONLY */
|
}
|
||||||
|
|
||||||
/* DAG Information Object */
|
/* DAG Information Object */
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -358,11 +358,11 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||||
buffer[pos++] = curr_instance.instance_id;
|
buffer[pos++] = curr_instance.instance_id;
|
||||||
buffer[pos++] = curr_instance.dag.version;
|
buffer[pos++] = curr_instance.dag.version;
|
||||||
|
|
||||||
#if RPL_LEAF_ONLY
|
if(rpl_get_leaf_only()) {
|
||||||
set16(buffer, pos, RPL_INFINITE_RANK);
|
set16(buffer, pos, RPL_INFINITE_RANK);
|
||||||
#else /* RPL_LEAF_ONLY */
|
} else {
|
||||||
set16(buffer, pos, curr_instance.dag.rank);
|
set16(buffer, pos, curr_instance.dag.rank);
|
||||||
#endif /* RPL_LEAF_ONLY */
|
}
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
buffer[pos] = 0;
|
buffer[pos] = 0;
|
||||||
|
@ -383,7 +383,7 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||||
memcpy(buffer + pos, &curr_instance.dag.dag_id, sizeof(curr_instance.dag.dag_id));
|
memcpy(buffer + pos, &curr_instance.dag.dag_id, sizeof(curr_instance.dag.dag_id));
|
||||||
pos += 16;
|
pos += 16;
|
||||||
|
|
||||||
#if !RPL_LEAF_ONLY
|
if(!rpl_get_leaf_only()) {
|
||||||
if(curr_instance.mc.type != RPL_DAG_MC_NONE) {
|
if(curr_instance.mc.type != RPL_DAG_MC_NONE) {
|
||||||
buffer[pos++] = RPL_OPTION_DAG_METRIC_CONTAINER;
|
buffer[pos++] = RPL_OPTION_DAG_METRIC_CONTAINER;
|
||||||
buffer[pos++] = 6;
|
buffer[pos++] = 6;
|
||||||
|
@ -405,7 +405,7 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !RPL_LEAF_ONLY */
|
}
|
||||||
|
|
||||||
/* Always add a DAG configuration option. */
|
/* Always add a DAG configuration option. */
|
||||||
buffer[pos++] = RPL_OPTION_DAG_CONF;
|
buffer[pos++] = RPL_OPTION_DAG_CONF;
|
||||||
|
@ -442,9 +442,9 @@ rpl_icmp6_dio_output(uip_ipaddr_t *uc_addr)
|
||||||
pos += 16;
|
pos += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !RPL_LEAF_ONLY
|
if(!rpl_get_leaf_only()) {
|
||||||
addr = addr != NULL ? addr : &rpl_multicast_addr;
|
addr = addr != NULL ? addr : &rpl_multicast_addr;
|
||||||
#endif /* RPL_LEAF_ONLY */
|
}
|
||||||
|
|
||||||
LOG_INFO("sending a %s-DIO with rank %u to ",
|
LOG_INFO("sending a %s-DIO with rank %u to ",
|
||||||
uc_addr != NULL ? "unicast" : "multicast",
|
uc_addr != NULL ? "unicast" : "multicast",
|
||||||
|
|
|
@ -150,11 +150,11 @@ rpl_timers_dio_reset(const char *str)
|
||||||
{
|
{
|
||||||
if(rpl_dag_ready_to_advertise()) {
|
if(rpl_dag_ready_to_advertise()) {
|
||||||
LOG_INFO("reset DIO timer (%s)\n", str);
|
LOG_INFO("reset DIO timer (%s)\n", str);
|
||||||
#if !RPL_LEAF_ONLY
|
if(!rpl_get_leaf_only()) {
|
||||||
curr_instance.dag.dio_counter = 0;
|
curr_instance.dag.dio_counter = 0;
|
||||||
curr_instance.dag.dio_intcurrent = curr_instance.dio_intmin;
|
curr_instance.dag.dio_intcurrent = curr_instance.dio_intmin;
|
||||||
new_dio_interval();
|
new_dio_interval();
|
||||||
#endif /* RPL_LEAF_ONLY */
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#define LOG_LEVEL LOG_LEVEL_RPL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
uip_ipaddr_t rpl_multicast_addr;
|
uip_ipaddr_t rpl_multicast_addr;
|
||||||
|
static uint8_t rpl_leaf_only = RPL_DEFAULT_LEAF_ONLY;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
|
@ -223,6 +224,18 @@ drop_route(uip_ds6_route_t *route)
|
||||||
/* Do nothing. RPL-lite only supports non-storing mode, i.e. no routes */
|
/* Do nothing. RPL-lite only supports non-storing mode, i.e. no routes */
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
rpl_set_leaf_only(uint8_t value)
|
||||||
|
{
|
||||||
|
rpl_leaf_only = value;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uint8_t
|
||||||
|
rpl_get_leaf_only(void)
|
||||||
|
{
|
||||||
|
return rpl_leaf_only;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
const struct routing_driver rpl_lite_driver = {
|
const struct routing_driver rpl_lite_driver = {
|
||||||
"RPL Lite",
|
"RPL Lite",
|
||||||
init,
|
init,
|
||||||
|
|
|
@ -133,6 +133,20 @@ int rpl_lollipop_greater_than(int a, int b);
|
||||||
*/
|
*/
|
||||||
void rpl_refresh_routes(const char *str);
|
void rpl_refresh_routes(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the value of the rpl_leaf_only flag, which determines if a node acts
|
||||||
|
* only as a leaf in the network
|
||||||
|
*
|
||||||
|
* \param value the value to set: 0-disable, 1-enable
|
||||||
|
*/
|
||||||
|
void rpl_set_leaf_only(uint8_t value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of the rpl_leaf_only flag
|
||||||
|
*
|
||||||
|
* \return The value of the rpl_leaf_only flag
|
||||||
|
*/
|
||||||
|
uint8_t rpl_get_leaf_only(void);
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#endif /* RPL_H */
|
#endif /* RPL_H */
|
||||||
|
|
Loading…
Reference in New Issue