fixed format of transit subopt

This commit is contained in:
Joakim Eriksson 2011-03-01 12:33:34 +01:00
parent 7f3c198a78
commit fa0fbf5dab
2 changed files with 13 additions and 8 deletions

View File

@ -459,6 +459,8 @@ dao_input(void)
uint8_t prefixlen; uint8_t prefixlen;
uint8_t flags; uint8_t flags;
uint8_t subopt_type; uint8_t subopt_type;
uint8_t pathcontrol;
uint8_t pathsequence;
uip_ipaddr_t prefix; uip_ipaddr_t prefix;
uip_ds6_route_t *rep; uip_ds6_route_t *rep;
uint8_t buffer_length; uint8_t buffer_length;
@ -523,7 +525,9 @@ dao_input(void)
break; break;
case RPL_DIO_SUBOPT_TRANSIT: case RPL_DIO_SUBOPT_TRANSIT:
/* path sequence and control ignored */ /* path sequence and control ignored */
lifetime = get32(buffer, i + 4); pathcontrol = buffer[i + 3];
pathsequence = buffer[i + 4];
lifetime = buffer[i + 5];
/* parent address also ignored */ /* parent address also ignored */
break; break;
} }
@ -571,7 +575,7 @@ dao_input(void)
PRINTF("RPL: Could not add a route after receiving a DAO\n"); PRINTF("RPL: Could not add a route after receiving a DAO\n");
return; return;
} else { } else {
rep->state.lifetime = lifetime; rep->state.lifetime = lifetime * dag->lifetime_unit;
rep->state.learned_from = learned_from; rep->state.learned_from = learned_from;
} }
@ -637,13 +641,13 @@ dao_output(rpl_parent_t *n, uint32_t lifetime)
memcpy(buffer + pos, &prefix, (prefixlen + 7) / CHAR_BIT); memcpy(buffer + pos, &prefix, (prefixlen + 7) / CHAR_BIT);
pos += ((prefixlen + 7) / CHAR_BIT); pos += ((prefixlen + 7) / CHAR_BIT);
/* create a transit information subopt */ /* create a transit information subopt (RPL-18)*/
buffer[pos++] = RPL_DIO_SUBOPT_TRANSIT; buffer[pos++] = RPL_DIO_SUBOPT_TRANSIT;
buffer[pos++] = 6; buffer[pos++] = 4;
buffer[pos++] = 0; /* path seq - ignored */ buffer[pos++] = 0; /* flags - ignored */
buffer[pos++] = 0; /* path control - ignored */ buffer[pos++] = 0; /* path control - ignored */
set32(buffer, pos, lifetime); buffer[pos++] = 0; /* path seq - ignored */
pos += 4; buffer[pos++] = (lifetime / dag->lifetime_unit) & 0xff;
if(n == NULL) { if(n == NULL) {
uip_create_linklocal_rplnodes_mcast(&addr); uip_create_linklocal_rplnodes_mcast(&addr);

View File

@ -205,7 +205,8 @@ handle_dao_timer(void *ptr)
fan-out as being under investigation. */ fan-out as being under investigation. */
if(dag->preferred_parent != NULL) { if(dag->preferred_parent != NULL) {
PRINTF("RPL: handle_dao_timer - sending DAO\n"); PRINTF("RPL: handle_dao_timer - sending DAO\n");
dao_output(dag->preferred_parent, DEFAULT_ROUTE_LIFETIME); /* set time to maxtime */
dao_output(dag->preferred_parent, dag->lifetime_unit * 0xffUL);
} else { } else {
PRINTF("RPL: Could not find a parent to send a DAO to \n"); PRINTF("RPL: Could not find a parent to send a DAO to \n");
} }