updated rpl dio message format to be compliant with latest version

This commit is contained in:
joxe 2010-12-13 10:59:37 +00:00
parent c9cc87ef25
commit 3e293e6cfc
3 changed files with 32 additions and 9 deletions

View File

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-dag.c,v 1.40 2010/12/13 10:54:25 nvt-se Exp $
* $Id: rpl-dag.c,v 1.41 2010/12/13 10:59:37 joxe Exp $
*/
/**
* \file
@ -166,6 +166,9 @@ rpl_set_root(uip_ipaddr_t *dag_id)
dag->max_rankinc = DEFAULT_MAX_RANKINC;
dag->min_hoprankinc = DEFAULT_MIN_HOPRANKINC;
dag->default_lifetime = DEFAULT_RPL_DEF_LIFETIME;
dag->lifetime_unit = DEFAULT_RPL_LIFETIME_UNIT;
PRINTF("RPL: Node set to be a DAG root with DAG ID ");
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
@ -472,6 +475,9 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
dag->rank = dag->of->calculate_rank(NULL, dio->rank);
dag->min_rank = dag->rank; /* So far this is the lowest rank we know */
dag->default_lifetime = dio->default_lifetime;
dag->lifetime_unit = dio->lifetime_unit;
rpl_reset_dio_timer(dag, 1);
rpl_set_default_route(dag, from);

View File

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rpl-icmp6.c,v 1.31 2010/12/13 10:54:25 nvt-se Exp $
* $Id: rpl-icmp6.c,v 1.32 2010/12/13 10:59:37 joxe Exp $
*/
/**
* \file
@ -276,9 +276,13 @@ dio_input(void)
dio.dag_max_rankinc = (buffer[i + 6] << 8) | buffer[i + 7];
dio.dag_min_hoprankinc = (buffer[i + 8] << 8) | buffer[i + 9];
dio.ocp = (buffer[i + 10] << 8) | buffer[i + 11];
PRINTF("RPL: DIO Conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d\n",
/* buffer + 12 is reserved */
dio.default_lifetime = buffer[i + 13];
dio.lifetime_unit = (buffer[i + 14] << 8) | buffer[i + 15];
PRINTF("RPL: DIO Conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n",
dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund,
dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp);
dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp,
dio.default_lifetime, dio.lifetime_unit);
break;
case RPL_DIO_SUBOPT_PREFIX_INFO:
if(len != 32) {
@ -326,16 +330,18 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
pos++;
buffer[pos++] = ++dag->dtsn_out;
/* reserved 2 bytes */
pos += 2;
buffer[pos++] = 0; /* flags */
buffer[pos++] = 0; /* reserved */
memcpy(buffer + pos, &dag->dag_id, sizeof(dag->dag_id));
pos += 16;
/* always add a sub-option for DAG configuration */
buffer[pos++] = RPL_DIO_SUBOPT_DAG_CONF;
buffer[pos++] = 10;
buffer[pos++] = 0; /* PCS */
buffer[pos++] = 14;
buffer[pos++] = 0; /* No Auth, PCS = 0 */
buffer[pos++] = dag->dio_intdoubl;
buffer[pos++] = dag->dio_intmin;
buffer[pos++] = dag->dio_redundancy;
@ -343,9 +349,13 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
buffer[pos++] = dag->max_rankinc & 0xff;
buffer[pos++] = dag->min_hoprankinc >> 8;
buffer[pos++] = dag->min_hoprankinc & 0xff;
/* OCP is now last in the DAG_CONF option */
/* OCP is in the DAG_CONF option */
buffer[pos++] = dag->of->ocp >> 8;
buffer[pos++] = dag->of->ocp & 0xff;
buffer[pos++] = 0; /* reserved */
buffer[pos++] = dag->default_lifetime;
buffer[pos++] = dag->lifetime_unit >> 8;
buffer[pos++] = dag->lifetime_unit & 0xff;
/* if prefix info length > 0 then we have a prefix to send! */
if(dag->prefix_info.length > 0) {

View File

@ -30,7 +30,7 @@
*
* Author: Joakim Eriksson, Nicolas Tsiftes
*
* $Id: rpl.h,v 1.24 2010/12/13 10:54:25 nvt-se Exp $
* $Id: rpl.h,v 1.25 2010/12/13 10:59:37 joxe Exp $
*/
#ifndef RPL_H
@ -96,6 +96,9 @@
/* Default route lifetime in seconds. */
#define DEFAULT_ROUTE_LIFETIME INFINITE_LIFETIME
#define DEFAULT_RPL_LIFETIME_UNIT 0xffff
#define DEFAULT_RPL_DEF_LIFETIME 0xff
#define DEFAULT_MIN_HOPRANKINC 256
#define DEFAULT_MAX_RANKINC 3*DEFAULT_MIN_HOPRANKINC
@ -239,6 +242,8 @@ struct rpl_dio {
uint8_t dag_intdoubl;
uint8_t dag_intmin;
uint8_t dag_redund;
uint8_t default_lifetime;
uint16_t lifetime_unit;
rpl_rank_t dag_max_rankinc;
rpl_rank_t dag_min_hoprankinc;
rpl_prefix_t destination_prefix;
@ -286,6 +291,8 @@ struct rpl_dag {
rpl_rank_t max_rankinc;
rpl_rank_t min_hoprankinc;
uint8_t used;
uint8_t default_lifetime;
uint16_t lifetime_unit; /* lifetime in seconds = l_u * d_l */
/* live data for the DAG */
uint8_t joined;
uint8_t dio_intcurrent;