1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

rpl: reuse timer for periodic daos

This commit is contained in:
test 2015-11-17 19:53:26 +01:00
parent 421e69030a
commit 1f2c674026
3 changed files with 20 additions and 29 deletions

View File

@ -222,9 +222,7 @@ struct gnrc_rpl_dodag {
bool dao_ack_received; /**< flag to check for DAO-ACK */
bool dodag_conf_requested; /**< flag to send DODAG_CONF options */
bool prefix_info_requested; /**< flag to send PREFIX_INFO options */
msg_t dao_msg; /**< msg_t for firing a dao */
uint32_t dao_time; /**< time to schedule the next DAO */
xtimer_t dao_timer; /**< timer to schedule the next DAO */
uint8_t dao_time; /**< time to schedule a DAO in seconds */
trickle_t trickle; /**< trickle representation */
};

View File

@ -165,8 +165,6 @@ static void *_event_loop(void *args)
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
trickle_t *trickle;
gnrc_rpl_instance_t *inst;
gnrc_rpl_dodag_t *dodag;
/* start event loop */
while (1) {
DEBUG("RPL: waiting for incoming message.\n");
@ -191,14 +189,6 @@ static void *_event_loop(void *args)
trickle_callback(trickle);
}
break;
case GNRC_RPL_MSG_TYPE_DAO_HANDLE:
DEBUG("RPL: GNRC_RPL_MSG_TYPE_DAO_HANDLE received\n");
inst = (gnrc_rpl_instance_t *) msg.content.ptr;
dodag = &inst->dodag;
if (inst && (inst->state != 0)) {
_dao_handle_send(dodag);
}
break;
case GNRC_NETAPI_MSG_TYPE_RCV:
DEBUG("RPL: GNRC_NETAPI_MSG_TYPE_RCV received\n");
_receive((gnrc_pktsnip_t *)msg.content.ptr);
@ -243,12 +233,22 @@ void _update_lifetime(void)
for (int i = 0; i < GNRC_RPL_INSTANCES_NUMOF; ++i) {
inst = &gnrc_rpl_instances[i];
if ((inst->state != 0) && (inst->cleanup > 0) && (inst->dodag.parents == NULL) &&
(inst->dodag.my_rank == GNRC_RPL_INFINITE_RANK)) {
inst->cleanup -= GNRC_RPL_LIFETIME_UPDATE_STEP;
if (inst->cleanup <= 0) {
/* no parents - delete this instance and DODAG */
gnrc_rpl_instance_remove(inst);
if (inst->state != 0) {
if ((inst->cleanup > 0) && (inst->dodag.parents == NULL) &&
(inst->dodag.my_rank == GNRC_RPL_INFINITE_RANK)) {
inst->cleanup -= GNRC_RPL_LIFETIME_UPDATE_STEP;
if (inst->cleanup <= 0) {
/* no parents - delete this instance and DODAG */
gnrc_rpl_instance_remove(inst);
continue;
}
}
if (inst->dodag.dao_time > GNRC_RPL_LIFETIME_UPDATE_STEP) {
inst->dodag.dao_time -= GNRC_RPL_LIFETIME_UPDATE_STEP;
}
else {
_dao_handle_send(&inst->dodag);
}
}
}
@ -258,18 +258,16 @@ void _update_lifetime(void)
void gnrc_rpl_delay_dao(gnrc_rpl_dodag_t *dodag)
{
dodag->dao_time = GNRC_RPL_DEFAULT_DAO_DELAY * SEC_IN_USEC;
dodag->dao_time = GNRC_RPL_DEFAULT_DAO_DELAY;
dodag->dao_counter = 0;
dodag->dao_ack_received = false;
xtimer_set_msg(&dodag->dao_timer, dodag->dao_time, &dodag->dao_msg, gnrc_rpl_pid);
}
void gnrc_rpl_long_delay_dao(gnrc_rpl_dodag_t *dodag)
{
dodag->dao_time = GNRC_RPL_REGULAR_DAO_INTERVAL * SEC_IN_USEC;
dodag->dao_time = GNRC_RPL_REGULAR_DAO_INTERVAL;
dodag->dao_counter = 0;
dodag->dao_ack_received = false;
xtimer_set_msg(&dodag->dao_timer, dodag->dao_time, &dodag->dao_msg, gnrc_rpl_pid);
}
void _dao_handle_send(gnrc_rpl_dodag_t *dodag)
@ -277,8 +275,7 @@ void _dao_handle_send(gnrc_rpl_dodag_t *dodag)
if ((dodag->dao_ack_received == false) && (dodag->dao_counter < GNRC_RPL_DAO_SEND_RETRIES)) {
dodag->dao_counter++;
gnrc_rpl_send_DAO(dodag->instance, NULL, dodag->default_lifetime);
dodag->dao_time = GNRC_RPL_DEFAULT_WAIT_FOR_DAO_ACK * SEC_IN_USEC;
xtimer_set_msg(&dodag->dao_timer, dodag->dao_time, &dodag->dao_msg, gnrc_rpl_pid);
dodag->dao_time = GNRC_RPL_DEFAULT_WAIT_FOR_DAO_ACK;
}
else if (dodag->dao_ack_received == false) {
gnrc_rpl_long_delay_dao(dodag);

View File

@ -100,7 +100,6 @@ bool gnrc_rpl_instance_remove(gnrc_rpl_instance_t *inst)
gnrc_rpl_dodag_t *dodag = &inst->dodag;
gnrc_rpl_dodag_remove_all_parents(dodag);
trickle_stop(&dodag->trickle);
xtimer_remove(&dodag->dao_timer);
memset(inst, 0, sizeof(gnrc_rpl_instance_t));
return true;
}
@ -143,8 +142,6 @@ bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id)
dodag->dtsn = 0;
dodag->dao_ack_received = false;
dodag->dao_counter = 0;
dodag->dao_msg.type = GNRC_RPL_MSG_TYPE_DAO_HANDLE;
dodag->dao_msg.content.ptr = (char *) instance;
dodag->instance = instance;
return true;
@ -156,7 +153,6 @@ void gnrc_rpl_dodag_remove_all_parents(gnrc_rpl_dodag_t *dodag)
LL_FOREACH_SAFE(dodag->parents, elt, tmp) {
gnrc_rpl_parent_remove(elt);
}
dodag->instance->cleanup = GNRC_RPL_CLEANUP_TIME;
}
bool gnrc_rpl_parent_add_by_addr(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *addr,