Added support for Mode of Operation flags in DIOs. Removed obsolete destination advertisement flags.
This commit is contained in:
parent
b66da85392
commit
c9cc87ef25
3 changed files with 39 additions and 32 deletions
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-dag.c,v 1.39 2010/12/10 22:48:31 joxe Exp $
|
||||
* $Id: rpl-dag.c,v 1.40 2010/12/13 10:54:25 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
|
@ -117,9 +117,8 @@ remove_parents(rpl_dag_t *dag, rpl_rank_t minimum_rank)
|
|||
static int
|
||||
should_send_dao(rpl_dag_t *dag, rpl_dio_t *dio, rpl_parent_t *p)
|
||||
{
|
||||
return dio->dst_adv_supported;
|
||||
/* return dio->dst_adv_supported && dio->dst_adv_trigger &&
|
||||
dio->dtsn > p->dtsn && p == dag->preferred_parent;*/
|
||||
return 1;
|
||||
/* return dio->dtsn > p->dtsn && p == dag->preferred_parent;*/
|
||||
}
|
||||
/************************************************************************/
|
||||
static int
|
||||
|
@ -153,6 +152,7 @@ rpl_set_root(uip_ipaddr_t *dag_id)
|
|||
dag->joined = 1;
|
||||
dag->version = version + 1;
|
||||
dag->grounded = RPL_GROUNDED;
|
||||
dag->mop = RPL_MOP_DEFAULT;
|
||||
dag->rank = ROOT_RANK;
|
||||
dag->of = rpl_find_of(RPL_DEFAULT_OCP);
|
||||
dag->preferred_parent = NULL;
|
||||
|
@ -444,8 +444,9 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
|||
dag->joined = 1;
|
||||
dag->used = 1;
|
||||
dag->of = of;
|
||||
dag->preference = dio->preference;
|
||||
dag->grounded = dio->grounded;
|
||||
dag->mop = dio->mop;
|
||||
dag->preference = dio->preference;
|
||||
dag->instance_id = dio->instance_id;
|
||||
|
||||
dag->max_rankinc = dio->dag_max_rankinc;
|
||||
|
@ -477,7 +478,7 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
|||
if(should_send_dao(dag, dio, p)) {
|
||||
rpl_schedule_dao(dag);
|
||||
} else {
|
||||
PRINTF("RPL: dst_adv_trigger not set in incoming DIO!\n");
|
||||
PRINTF("RPL: The DIO does not meet the prerequisites for sending a DAO\n");
|
||||
}
|
||||
}
|
||||
/************************************************************************/
|
||||
|
@ -605,6 +606,11 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
|||
rpl_dag_t *dag;
|
||||
rpl_parent_t *p;
|
||||
|
||||
if(dio->mop != RPL_MOP_DEFAULT) {
|
||||
PRINTF("RPL: Ignoring a DIO with an unsupported MOP: %d\n", dio->mop);
|
||||
return;
|
||||
}
|
||||
|
||||
dag = rpl_get_dag(dio->instance_id);
|
||||
if(dag == NULL) {
|
||||
/* Join the first possible DAG of this RPL instance. */
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-icmp6.c,v 1.30 2010/12/13 09:59:46 joxe Exp $
|
||||
* $Id: rpl-icmp6.c,v 1.31 2010/12/13 10:54:25 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
|
@ -59,14 +59,10 @@
|
|||
#include "net/uip-debug.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define RPL_DIO_GROUNDED 0x80
|
||||
#define RPL_DIO_DEST_ADV_SUPPORTED 0x40
|
||||
#define RPL_DIO_DEST_ADV_TRIGGER 0x20
|
||||
#define RPL_DIO_MOP_MASK 0x18
|
||||
#define RPL_DIO_MOP_NON_STORING 0x00
|
||||
#define RPL_DIO_MOP_STORING 0x10
|
||||
#define RPL_DIO_DAG_PREFERENCE_MASK 0x07
|
||||
|
||||
#define RPL_DIO_GROUNDED 0x80
|
||||
#define RPL_DIO_MOP_SHIFT 3
|
||||
#define RPL_DIO_MOP_MASK 0x3c
|
||||
#define RPL_DIO_PREFERENCE_MASK 0x07
|
||||
|
||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
|
@ -142,11 +138,11 @@ dis_output(uip_ipaddr_t *addr)
|
|||
unsigned char *buffer;
|
||||
uip_ipaddr_t tmpaddr;
|
||||
|
||||
/* DAG Information Solicitation - 2 bytes flags and reserved */
|
||||
/* DAG Information Solicitation - 2 bytes reserved */
|
||||
/* 0 1 2 */
|
||||
/* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 */
|
||||
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
|
||||
/* | flags | reserved | Option(s)... */
|
||||
/* | Flags | Reserved | Option(s)... */
|
||||
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
|
||||
|
||||
buffer = UIP_ICMP_PAYLOAD;
|
||||
|
@ -160,7 +156,6 @@ dis_output(uip_ipaddr_t *addr)
|
|||
PRINTF("RPL: Sending a unicast DIS\n");
|
||||
}
|
||||
uip_icmp6_send(addr, ICMP6_RPL, RPL_CODE_DIS, 2);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
|
@ -216,9 +211,8 @@ dio_input(void)
|
|||
PRINTF("RPL: Incoming DIO rank %u\n", (unsigned)dio.rank);
|
||||
|
||||
dio.grounded = buffer[i] & RPL_DIO_GROUNDED;
|
||||
dio.dst_adv_trigger = buffer[i] & RPL_DIO_DEST_ADV_TRIGGER;
|
||||
dio.dst_adv_supported = buffer[i] & RPL_DIO_DEST_ADV_SUPPORTED;
|
||||
dio.preference = buffer[i++] & RPL_DIO_DAG_PREFERENCE_MASK;
|
||||
dio.mop = (buffer[i]& RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT;
|
||||
dio.preference = buffer[i++] & RPL_DIO_PREFERENCE_MASK;
|
||||
|
||||
dio.dtsn = buffer[i++];
|
||||
/* two reserved bytes */
|
||||
|
@ -314,7 +308,7 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
|
|||
int pos;
|
||||
uip_ipaddr_t addr;
|
||||
|
||||
/* DIO - DODAG Information Object */
|
||||
/* DAG Information Solicitation */
|
||||
pos = 0;
|
||||
|
||||
buffer = UIP_ICMP_PAYLOAD;
|
||||
|
@ -327,8 +321,8 @@ dio_output(rpl_dag_t *dag, uip_ipaddr_t *uc_addr)
|
|||
if(dag->grounded) {
|
||||
buffer[pos] |= RPL_DIO_GROUNDED;
|
||||
}
|
||||
/* Set dst_adv_trigger and dst_adv_supported. */
|
||||
buffer[pos] |= RPL_DIO_DEST_ADV_SUPPORTED | RPL_DIO_DEST_ADV_TRIGGER;
|
||||
|
||||
buffer[pos] = dag->mop << RPL_DIO_MOP_SHIFT;
|
||||
pos++;
|
||||
|
||||
buffer[pos++] = ++dag->dtsn_out;
|
||||
|
@ -441,7 +435,7 @@ dao_input(void)
|
|||
pos++;
|
||||
sequence = buffer[pos++];
|
||||
|
||||
/* is the DAGID present ? */
|
||||
/* Is the DAGID present? */
|
||||
if(flags & RPL_DAO_D_FLAG) {
|
||||
/* currently the DAG ID is ignored since we only use global
|
||||
RPL Instance IDs... */
|
||||
|
@ -500,10 +494,10 @@ dao_input(void)
|
|||
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)
|
||||
/* && uip_ds6_route_lookup(&prefix) == NULL*/) {
|
||||
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));
|
||||
DAG_RANK(p->rank, dag), DAG_RANK(dag->rank, dag));
|
||||
rpl_local_repair(dag);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Joakim Eriksson, Nicolas Tsiftes
|
||||
*
|
||||
* $Id: rpl.h,v 1.23 2010/10/28 20:39:06 joxe Exp $
|
||||
* $Id: rpl.h,v 1.24 2010/12/13 10:54:25 nvt-se Exp $
|
||||
*/
|
||||
|
||||
#ifndef RPL_H
|
||||
|
@ -137,6 +137,13 @@
|
|||
#define RPL_ROUTE_FROM_MULTICAST_DAO 2
|
||||
#define RPL_ROUTE_FROM_DIO 3
|
||||
|
||||
/* DAG Mode of Operation */
|
||||
#define RPL_MOP_NO_DOWNWARD_ROUTES 0
|
||||
#define RPL_MOP_NON_STORING 1
|
||||
#define RPL_MOP_STORING_NO_MULTICAST 2
|
||||
#define RPL_MOP_STORING_MULTICAST 3
|
||||
#define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
|
||||
|
||||
/* DAG Metric Container Object Types, to be confirmed by IANA. */
|
||||
#define RPL_DAG_MC_NSA 1
|
||||
#define RPL_DAG_MC_NE 2
|
||||
|
@ -224,8 +231,7 @@ struct rpl_dio {
|
|||
rpl_ocp_t ocp;
|
||||
rpl_rank_t rank;
|
||||
uint8_t grounded;
|
||||
uint8_t dst_adv_trigger;
|
||||
uint8_t dst_adv_supported;
|
||||
uint8_t mop;
|
||||
uint8_t preference;
|
||||
uint8_t version;
|
||||
uint8_t instance_id;
|
||||
|
@ -271,8 +277,9 @@ struct rpl_dag {
|
|||
uint8_t dtsn_out;
|
||||
uint8_t instance_id;
|
||||
uint8_t version;
|
||||
uint8_t preference;
|
||||
uint8_t grounded;
|
||||
uint8_t mop;
|
||||
uint8_t preference;
|
||||
uint8_t dio_intdoubl;
|
||||
uint8_t dio_intmin;
|
||||
uint8_t dio_redundancy;
|
||||
|
|
Loading…
Reference in a new issue