Improve RPL hop-by-hop option detection

This commit is contained in:
Laurent Deru 2014-05-09 11:28:36 +02:00
parent d45782fbcd
commit 02972e6514

View file

@ -72,6 +72,16 @@ rpl_verify_header(int uip_ext_opt_offset)
uint8_t sender_closer; uint8_t sender_closer;
uip_ds6_route_t *route; uip_ds6_route_t *route;
if(UIP_HBHO_BUF->len != RPL_HOP_BY_HOP_LEN - 8) {
PRINTF("RPL: Hop-by-hop extension header has wrong size\n");
return 1;
}
if(UIP_EXT_HDR_OPT_RPL_BUF->opt_type != UIP_EXT_HDR_OPT_RPL) {
PRINTF("RPL: Non RPL Hop-by-hop option\n");
return 1;
}
if(UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) { if(UIP_EXT_HDR_OPT_RPL_BUF->opt_len != RPL_HDR_OPT_LEN) {
PRINTF("RPL: Bad header option! (wrong length)\n"); PRINTF("RPL: Bad header option! (wrong length)\n");
return 1; return 1;
@ -187,7 +197,17 @@ rpl_update_header_empty(void)
switch(UIP_IP_BUF->proto) { switch(UIP_IP_BUF->proto) {
case UIP_PROTO_HBHO: case UIP_PROTO_HBHO:
if(UIP_HBHO_BUF->len != RPL_HOP_BY_HOP_LEN - 8) { if(UIP_HBHO_BUF->len != RPL_HOP_BY_HOP_LEN - 8) {
PRINTF("RPL: Non RPL Hop-by-hop options support not implemented\n"); PRINTF("RPL: Hop-by-hop extension header has wrong size\n");
uip_ext_len = last_uip_ext_len;
return;
}
if(UIP_EXT_HDR_OPT_RPL_BUF->opt_type != UIP_EXT_HDR_OPT_RPL) {
PRINTF("RPL: Non RPL Hop-by-hop option support not implemented\n");
uip_ext_len = last_uip_ext_len;
return;
}
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; uip_ext_len = last_uip_ext_len;
return; return;
} }