Fixed issues with propagation of the route lifetime configuration. Removed deprecated configuration parameters.

This commit is contained in:
Nicolas Tsiftes 2011-06-28 17:08:44 +02:00
parent baa6578341
commit b1fea35e47
6 changed files with 47 additions and 48 deletions

View file

@ -467,7 +467,7 @@ dao_input(void)
unsigned char *buffer;
uint16_t sequence;
uint8_t instance_id;
uint32_t lifetime;
rpl_lifetime_t lifetime;
uint8_t prefixlen;
uint8_t flags;
uint8_t subopt_type;
@ -482,7 +482,6 @@ dao_input(void)
int learned_from;
rpl_parent_t *p;
lifetime = 0;
prefixlen = 0;
uip_ipaddr_copy(&dao_sender_addr, &UIP_IP_BUF->srcipaddr);
@ -495,7 +494,7 @@ dao_input(void)
buffer = UIP_ICMP_PAYLOAD;
buffer_length = uip_len - uip_l2_l3_icmp_hdr_len;
#if RPL_CONF_ADJUST_LLH_LEN
buffer_length+=UIP_LLH_LEN; //Add jackdaw, minimal-net ethernet header
buffer_length += UIP_LLH_LEN; /* Add jackdaw, minimal-net ethernet header */
#endif
pos = 0;
@ -508,6 +507,8 @@ dao_input(void)
return;
}
lifetime = dag->default_lifetime;
flags = buffer[pos++];
/* reserved */
pos++;
@ -515,19 +516,19 @@ dao_input(void)
/* Is the DAGID present? */
if(flags & RPL_DAO_D_FLAG) {
/* currently the DAG ID is ignored since we only use global
RPL Instance IDs... */
/* Currently the DAG ID is ignored since we only use global
RPL Instance IDs. */
pos += 16;
}
/* Check if there are any DIO suboptions. */
/* Check if there are any DIO sub-options. */
i = pos;
for(; i < buffer_length; i += len) {
subopt_type = buffer[i];
if(subopt_type == RPL_DIO_SUBOPT_PAD1) {
len = 1;
} else {
/* Suboption with a two-byte header + payload */
/* Sub-option with a two-byte header and payload */
len = 2 + buffer[i + 1];
}
@ -539,23 +540,24 @@ dao_input(void)
memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT);
break;
case RPL_DIO_SUBOPT_TRANSIT:
/* path sequence and control ignored */
/* The path sequence and control are ignored. */
pathcontrol = buffer[i + 3];
pathsequence = buffer[i + 4];
lifetime = buffer[i + 5];
/* parent address also ignored */
/* The parent address is also ignored. */
break;
}
}
PRINTF("RPL: DAO lifetime: %lu, prefix length: %u prefix: ",
(unsigned long)lifetime, (unsigned)prefixlen);
PRINTF("RPL: DAO lifetime: %u, prefix length: %u prefix: ",
(unsigned)lifetime, (unsigned)prefixlen);
PRINT6ADDR(&prefix);
PRINTF("\n");
rep = uip_ds6_route_lookup(&prefix);
if(lifetime == ZERO_LIFETIME) {
/* No-Path DAO received; invoke the route purging routine. */
rep = uip_ds6_route_lookup(&prefix);
if(rep != NULL && rep->state.saved_lifetime == 0) {
PRINTF("RPL: Setting expiration timer for prefix ");
PRINT6ADDR(&prefix);
@ -570,12 +572,9 @@ dao_input(void)
RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO;
if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) {
/* Check if this is a DAO forwarding loop. */
/* Check whether this is a DAO forwarding loop. */
p = rpl_find_parent(dag, &dao_sender_addr);
/* check if this is a new DAO registration with an "illegal" rank */
/* if we already route to this node it is likely */
if(p != NULL && DAG_RANK(p->rank, dag) < DAG_RANK(dag->rank, dag)
/* && uip_ds6_route_lookup(&prefix) == NULL*/) {
if(p != NULL && DAG_RANK(p->rank, dag) < DAG_RANK(dag->rank, dag)) {
PRINTF("RPL: Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n",
DAG_RANK(p->rank, dag), DAG_RANK(dag->rank, dag));
p->rank = INFINITE_RANK;
@ -584,16 +583,18 @@ dao_input(void)
}
}
rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr);
if(rep == NULL) {
RPL_STAT(rpl_stats.mem_overflows++);
PRINTF("RPL: Could not add a route after receiving a DAO\n");
return;
} else {
rep->state.lifetime = lifetime * dag->lifetime_unit;
rep->state.learned_from = learned_from;
rep = rpl_add_route(dag, &prefix, prefixlen, &dao_sender_addr);
if(rep == NULL) {
RPL_STAT(rpl_stats.mem_overflows++);
PRINTF("RPL: Could not add a route after receiving a DAO\n");
return;
}
}
rep->state.lifetime = RPL_LIFETIME(dag, lifetime);
rep->state.learned_from = learned_from;
if(learned_from == RPL_ROUTE_FROM_UNICAST_DAO) {
if(dag->preferred_parent) {
PRINTF("RPL: Forwarding DAO to parent ");
@ -608,7 +609,7 @@ dao_input(void)
}
/*---------------------------------------------------------------------------*/
void
dao_output(rpl_parent_t *n, uint32_t lifetime)
dao_output(rpl_parent_t *n, rpl_lifetime_t lifetime)
{
rpl_dag_t *dag;
unsigned char *buffer;
@ -656,13 +657,13 @@ dao_output(rpl_parent_t *n, uint32_t lifetime)
memcpy(buffer + pos, &prefix, (prefixlen + 7) / CHAR_BIT);
pos += ((prefixlen + 7) / CHAR_BIT);
/* create a transit information subopt (RPL-18)*/
/* Create a transit information sub-option. */
buffer[pos++] = RPL_DIO_SUBOPT_TRANSIT;
buffer[pos++] = 4;
buffer[pos++] = 0; /* flags - ignored */
buffer[pos++] = 0; /* path control - ignored */
buffer[pos++] = 0; /* path seq - ignored */
buffer[pos++] = (lifetime / dag->lifetime_unit) & 0xff;
buffer[pos++] = lifetime;
if(n == NULL) {
uip_create_linklocal_rplnodes_mcast(&addr);