Skip to content

Commit

Permalink
rpl: wrong length of DIO options
Browse files Browse the repository at this point in the history
Currently, the DIO options `dodag conf` and `prefix info` are off by two
bytes in their `length` field. The RFC states, that the length field
should not include the option `type` field and the `length` field (two bytes).

For Prefix Info Option: Option Length: 30 (RFC 6550, P.61)
For Dodag Conf  Option: Option Length: 14 (RFC 6550, P.52)

Wireshark complains about DIOs as malformed packets, otherwise.
Can be reproduced by running the rpl_udp example and logging the DIOs
via wireshark.
  • Loading branch information
cgundogan committed Feb 3, 2015
1 parent 9b65000 commit 432688a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sys/net/routing/rpl/rpl_nonstoring/rpl_nonstoring.c
Expand Up @@ -263,7 +263,7 @@ void rpl_send_DIO_mode(ipv6_addr_t *destination)
/* DODAG configuration option */
rpl_send_opt_dodag_conf_buf = get_rpl_send_opt_dodag_conf_buf(DIO_BASE_LEN);
rpl_send_opt_dodag_conf_buf->type = RPL_OPT_DODAG_CONF;
rpl_send_opt_dodag_conf_buf->length = RPL_OPT_DODAG_CONF_LEN;
rpl_send_opt_dodag_conf_buf->length = (RPL_OPT_DODAG_CONF_LEN - RPL_OPT_LEN);
rpl_send_opt_dodag_conf_buf->flags_a_pcs = 0;
rpl_send_opt_dodag_conf_buf->DIOIntDoubl = mydodag->dio_interval_doubling;
rpl_send_opt_dodag_conf_buf->DIOIntMin = mydodag->dio_min;
Expand Down Expand Up @@ -468,7 +468,7 @@ void rpl_recv_DIO_mode(void)
case (RPL_OPT_DODAG_CONF): {
has_dodag_conf_opt = 1;

if (rpl_opt_buf->length != RPL_OPT_DODAG_CONF_LEN) {
if (rpl_opt_buf->length != (RPL_OPT_DODAG_CONF_LEN - RPL_OPT_LEN)) {
DEBUGF("DODAG configuration is malformed.\n");
/* error malformed */
return;
Expand All @@ -488,7 +488,7 @@ void rpl_recv_DIO_mode(void)
}

case (RPL_OPT_PREFIX_INFO): {
if (rpl_opt_buf->length != RPL_OPT_PREFIX_INFO_LEN) {
if (rpl_opt_buf->length != (RPL_OPT_PREFIX_INFO_LEN - RPL_OPT_LEN)) {
/* error malformed */
return;
}
Expand Down
6 changes: 3 additions & 3 deletions sys/net/routing/rpl/rpl_storing/rpl_storing.c
Expand Up @@ -262,7 +262,7 @@ void rpl_send_DIO_mode(ipv6_addr_t *destination)
/* DODAG configuration option */
rpl_send_opt_dodag_conf_buf = get_rpl_send_opt_dodag_conf_buf(DIO_BASE_LEN);
rpl_send_opt_dodag_conf_buf->type = RPL_OPT_DODAG_CONF;
rpl_send_opt_dodag_conf_buf->length = RPL_OPT_DODAG_CONF_LEN;
rpl_send_opt_dodag_conf_buf->length = (RPL_OPT_DODAG_CONF_LEN - RPL_OPT_LEN);
rpl_send_opt_dodag_conf_buf->flags_a_pcs = 0;
rpl_send_opt_dodag_conf_buf->DIOIntDoubl = mydodag->dio_interval_doubling;
rpl_send_opt_dodag_conf_buf->DIOIntMin = mydodag->dio_min;
Expand Down Expand Up @@ -499,7 +499,7 @@ void rpl_recv_DIO_mode(void)
case (RPL_OPT_DODAG_CONF): {
has_dodag_conf_opt = 1;

if (rpl_opt_buf->length != RPL_OPT_DODAG_CONF_LEN) {
if (rpl_opt_buf->length != (RPL_OPT_DODAG_CONF_LEN - RPL_OPT_LEN)) {
DEBUGF("DODAG configuration is malformed.\n");
/* error malformed */
return;
Expand All @@ -519,7 +519,7 @@ void rpl_recv_DIO_mode(void)
}

case (RPL_OPT_PREFIX_INFO): {
if (rpl_opt_buf->length != RPL_OPT_PREFIX_INFO_LEN) {
if (rpl_opt_buf->length != (RPL_OPT_PREFIX_INFO_LEN - RPL_OPT_LEN)) {
/* error malformed */
return;
}
Expand Down

0 comments on commit 432688a

Please sign in to comment.