Merge pull request #917 from cetic/pr-hbh-user-conf

Allow user configuration of RPL hop-by-hop option
This commit is contained in:
Nicolas Tsiftes 2015-04-03 22:19:51 +02:00
commit 7d06494331
2 changed files with 16 additions and 0 deletions

View file

@ -195,4 +195,16 @@
#define RPL_PREFERENCE 0 #define RPL_PREFERENCE 0
#endif #endif
/*
* Hop-by-hop option
* This option control the insertion of the RPL Hop-by-Hop extension header
* into packets originating from this node. Incoming Hop-by-hop extension
* header are still processed and forwarded.
*/
#ifdef RPL_CONF_INSERT_HBH_OPTION
#define RPL_INSERT_HBH_OPTION RPL_CONF_INSERT_HBH_OPTION
#else
#define RPL_INSERT_HBH_OPTION 1
#endif
#endif /* RPL_CONF_H */ #endif /* RPL_CONF_H */

View file

@ -215,6 +215,7 @@ rpl_update_header_empty(void)
} }
break; break;
default: default:
#if RPL_INSERT_HBH_OPTION
PRINTF("RPL: No hop-by-hop option found, creating it\n"); PRINTF("RPL: No hop-by-hop option found, creating it\n");
if(uip_len + RPL_HOP_BY_HOP_LEN > UIP_BUFSIZE) { if(uip_len + RPL_HOP_BY_HOP_LEN > UIP_BUFSIZE) {
PRINTF("RPL: Packet too long: impossible to add hop-by-hop option\n"); PRINTF("RPL: Packet too long: impossible to add hop-by-hop option\n");
@ -223,6 +224,7 @@ rpl_update_header_empty(void)
} }
set_rpl_opt(uip_ext_opt_offset); set_rpl_opt(uip_ext_opt_offset);
uip_ext_len = last_uip_ext_len + RPL_HOP_BY_HOP_LEN; uip_ext_len = last_uip_ext_len + RPL_HOP_BY_HOP_LEN;
#endif
return 0; return 0;
} }
@ -374,9 +376,11 @@ rpl_invert_header(void)
void void
rpl_insert_header(void) rpl_insert_header(void)
{ {
#if RPL_INSERT_HBH_OPTION
if(default_instance != NULL && !uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { if(default_instance != NULL && !uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
rpl_update_header_empty(); rpl_update_header_empty();
} }
#endif
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/