mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
Better validation of incoming DIOs. Added a reset function to the OF API.
This commit is contained in:
parent
d28865abac
commit
c13bb8666b
@ -32,7 +32,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: rpl-dag.c,v 1.10 2010/05/29 22:23:21 nvt-se Exp $
|
* $Id: rpl-dag.c,v 1.11 2010/05/31 14:22:00 nvt-se Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
@ -459,6 +459,7 @@ global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio)
|
|||||||
dag->rank = INFINITE_RANK;
|
dag->rank = INFINITE_RANK;
|
||||||
} else {
|
} else {
|
||||||
rpl_set_default_route(dag, from);
|
rpl_set_default_route(dag, from);
|
||||||
|
dag->of->reset(dag);
|
||||||
dag->rank = dag->of->increment_rank(dio->dag_rank, p);
|
dag->rank = dag->of->increment_rank(dio->dag_rank, p);
|
||||||
rpl_reset_dio_timer(dag, 1);
|
rpl_reset_dio_timer(dag, 1);
|
||||||
}
|
}
|
||||||
@ -505,8 +506,20 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(memcmp(&dag->dag_id, &dio->dag_id, sizeof(dag->dag_id))) {
|
||||||
|
PRINTF("RPL: Ignoring DIO for another DAG within our instance\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(dio->sequence_number > dag->sequence_number) {
|
if(dio->sequence_number > dag->sequence_number) {
|
||||||
global_repair(from, dag, dio);
|
if(dag->rank == ROOT_RANK) {
|
||||||
|
PRINTF("RPL: Root received inconsistent DIO sequence number\n");
|
||||||
|
dag->sequence_number = dio->sequence_number + 1;
|
||||||
|
rpl_reset_dio_timer(dag, 1);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
global_repair(from, dag, dio);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: rpl-of-etx.c,v 1.1 2010/05/29 22:23:21 nvt-se Exp $
|
* $Id: rpl-of-etx.c,v 1.2 2010/05/31 14:22:00 nvt-se Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
@ -46,11 +46,13 @@
|
|||||||
#define DEBUG DEBUG_ANNOTATE
|
#define DEBUG DEBUG_ANNOTATE
|
||||||
#include "net/uip-debug.h"
|
#include "net/uip-debug.h"
|
||||||
|
|
||||||
|
static void reset(void *);
|
||||||
static void parent_state_callback(rpl_parent_t *, int, int);
|
static void parent_state_callback(rpl_parent_t *, int, int);
|
||||||
static rpl_parent_t *best_parent(rpl_parent_t *, rpl_parent_t *);
|
static rpl_parent_t *best_parent(rpl_parent_t *, rpl_parent_t *);
|
||||||
static rpl_rank_t increment_rank(rpl_rank_t, rpl_parent_t *);
|
static rpl_rank_t increment_rank(rpl_rank_t, rpl_parent_t *);
|
||||||
|
|
||||||
rpl_of_t rpl_of_etx = {
|
rpl_of_t rpl_of_etx = {
|
||||||
|
reset,
|
||||||
parent_state_callback,
|
parent_state_callback,
|
||||||
best_parent,
|
best_parent,
|
||||||
increment_rank,
|
increment_rank,
|
||||||
@ -68,6 +70,12 @@ typedef unsigned char etx_t;
|
|||||||
|
|
||||||
static etx_t min_path_etx = INFINITY;
|
static etx_t min_path_etx = INFINITY;
|
||||||
|
|
||||||
|
static void
|
||||||
|
reset(void *dag)
|
||||||
|
{
|
||||||
|
min_path_etx = INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parent_state_callback(rpl_parent_t *parent, int known, int etx)
|
parent_state_callback(rpl_parent_t *parent, int known, int etx)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: rpl-of0.c,v 1.3 2010/05/29 22:23:21 nvt-se Exp $
|
* $Id: rpl-of0.c,v 1.4 2010/05/31 14:22:00 nvt-se Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
@ -46,10 +46,12 @@
|
|||||||
#define DEBUG DEBUG_ANNOTATE
|
#define DEBUG DEBUG_ANNOTATE
|
||||||
#include "net/uip-debug.h"
|
#include "net/uip-debug.h"
|
||||||
|
|
||||||
|
static void reset(void *);
|
||||||
static rpl_parent_t *best_parent(rpl_parent_t *, rpl_parent_t *);
|
static rpl_parent_t *best_parent(rpl_parent_t *, rpl_parent_t *);
|
||||||
static rpl_rank_t increment_rank(rpl_rank_t, rpl_parent_t *);
|
static rpl_rank_t increment_rank(rpl_rank_t, rpl_parent_t *);
|
||||||
|
|
||||||
rpl_of_t rpl_of0 = {
|
rpl_of_t rpl_of0 = {
|
||||||
|
reset,
|
||||||
NULL,
|
NULL,
|
||||||
best_parent,
|
best_parent,
|
||||||
increment_rank,
|
increment_rank,
|
||||||
@ -61,6 +63,12 @@ rpl_of_t rpl_of0 = {
|
|||||||
#define MAXIMUM_RANK_INCREMENT 16
|
#define MAXIMUM_RANK_INCREMENT 16
|
||||||
#define MAXIMUM_RANK_STRETCH 4
|
#define MAXIMUM_RANK_STRETCH 4
|
||||||
|
|
||||||
|
static void
|
||||||
|
reset(void *dag)
|
||||||
|
{
|
||||||
|
PRINTF("RPL: Resetting OF0\n");
|
||||||
|
}
|
||||||
|
|
||||||
static rpl_rank_t
|
static rpl_rank_t
|
||||||
increment_rank(rpl_rank_t rank, rpl_parent_t *parent)
|
increment_rank(rpl_rank_t rank, rpl_parent_t *parent)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
*
|
*
|
||||||
* Author: Joakim Eriksson, Nicolas Tsiftes
|
* Author: Joakim Eriksson, Nicolas Tsiftes
|
||||||
*
|
*
|
||||||
* $Id: rpl.h,v 1.5 2010/05/29 22:23:21 nvt-se Exp $
|
* $Id: rpl.h,v 1.6 2010/05/31 14:22:00 nvt-se Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RPL_H
|
#ifndef RPL_H
|
||||||
@ -138,6 +138,7 @@ struct rpl_parent {
|
|||||||
typedef struct rpl_parent rpl_parent_t;
|
typedef struct rpl_parent rpl_parent_t;
|
||||||
|
|
||||||
struct rpl_of {
|
struct rpl_of {
|
||||||
|
void (*reset)(void *);
|
||||||
void (*parent_state_callback)(rpl_parent_t *, int, int);
|
void (*parent_state_callback)(rpl_parent_t *, int, int);
|
||||||
rpl_parent_t *(*best_parent)(rpl_parent_t *, rpl_parent_t *);
|
rpl_parent_t *(*best_parent)(rpl_parent_t *, rpl_parent_t *);
|
||||||
rpl_rank_t (*increment_rank)(rpl_rank_t, rpl_parent_t *);
|
rpl_rank_t (*increment_rank)(rpl_rank_t, rpl_parent_t *);
|
||||||
|
Loading…
Reference in New Issue
Block a user