Drop forwarding error packet and send back DAO to originating parent

This commit is contained in:
Laurent Deru 2014-01-31 09:38:42 +01:00
parent a964380155
commit 29f894c07e
4 changed files with 32 additions and 9 deletions

View file

@ -48,6 +48,7 @@
#include "net/ip/tcpip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/rpl/rpl-private.h"
#include "net/packetbuf.h"
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
@ -175,12 +176,13 @@ set_rpl_opt(unsigned uip_ext_opt_offset)
}
}
/*---------------------------------------------------------------------------*/
void
int
rpl_update_header_empty(void)
{
rpl_instance_t *instance;
int uip_ext_opt_offset;
int last_uip_ext_len;
rpl_parent_t *parent;
last_uip_ext_len = uip_ext_len;
uip_ext_len = 0;
@ -203,12 +205,12 @@ rpl_update_header_empty(void)
if(UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
PRINTF("RPL: RPL Hop-by-hop option has wrong length\n");
uip_ext_len = last_uip_ext_len;
return;
return 0;
}
instance = rpl_get_instance(UIP_EXT_HDR_OPT_RPL_BUF->instance);
if(instance == NULL || !instance->used || !instance->current_dag->joined) {
PRINTF("RPL: Unable to add hop-by-hop extension header: incorrect instance\n");
return;
return 0;
}
break;
default:
@ -216,11 +218,11 @@ rpl_update_header_empty(void)
if(uip_len + RPL_HOP_BY_HOP_LEN > UIP_BUFSIZE) {
PRINTF("RPL: Packet too long: impossible to add hop-by-hop option\n");
uip_ext_len = last_uip_ext_len;
return;
return 0;
}
set_rpl_opt(uip_ext_opt_offset);
uip_ext_len = last_uip_ext_len + RPL_HOP_BY_HOP_LEN;
return;
return 0;
}
switch(UIP_EXT_HDR_OPT_BUF->type) {
@ -236,6 +238,15 @@ rpl_update_header_empty(void)
if(uip_ds6_route_lookup(&UIP_IP_BUF->destipaddr) == NULL) {
UIP_EXT_HDR_OPT_RPL_BUF->flags |= RPL_HDR_OPT_FWD_ERR;
PRINTF("RPL forwarding error\n");
/* We should send back the packet to the originating parent,
but it is not feasible yet, so we send a No-Path DAO instead */
PRINTF("RPL generate No-Path DAO\n");
parent = rpl_get_parent((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
if(parent != NULL) {
dao_output_target(parent, &UIP_IP_BUF->destipaddr, RPL_ZERO_LIFETIME);
}
/* Drop packet */
return 1;
}
} else {
/* Set the down extension flag correctly as described in Section
@ -254,11 +265,11 @@ rpl_update_header_empty(void)
}
uip_ext_len = last_uip_ext_len;
return;
return 0;
default:
PRINTF("RPL: Multi Hop-by-hop options not implemented\n");
uip_ext_len = last_uip_ext_len;
return;
return 0;
}
}
/*---------------------------------------------------------------------------*/