From 563dc3286b60ddeb6fa1934cc830440a47d5be10 Mon Sep 17 00:00:00 2001 From: Simon Vincent Date: Thu, 28 Aug 2014 17:11:42 +0100 Subject: [PATCH] Fix malformed DIO messages when sending prefix information. Issue #4 --- include/rpl.h | 4 +++- lib/libndmgmt/dio.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/rpl.h b/include/rpl.h index 34924364..5e0aa04a 100644 --- a/include/rpl.h +++ b/include/rpl.h @@ -108,7 +108,9 @@ struct rpl_dio_destprefix { u_int8_t rpl_dio_len; u_int8_t rpl_dio_prefixlen; /* in bits */ u_int8_t rpl_dio_prf; /* flags, including Route Preference */ - u_int32_t rpl_dio_prefixlifetime; /* in seconds */ + u_int32_t rpl_dio_valid_lifetime; /* in seconds */ + u_int32_t rpl_dio_preferred_lifetime; /* in seconds */ + u_int32_t reserved2; /* in seconds */ u_int8_t rpl_dio_prefix[0]; /* variables number of bytes */ } PACKED; diff --git a/lib/libndmgmt/dio.cpp b/lib/libndmgmt/dio.cpp index 982d41b4..13aca996 100644 --- a/lib/libndmgmt/dio.cpp +++ b/lib/libndmgmt/dio.cpp @@ -129,13 +129,14 @@ int dag_network::build_prefix_dioopt(ip_subnet prefix) struct rpl_dio_destprefix *diodp = (struct rpl_dio_destprefix *)optbuff; diodp->rpl_dio_prf = 0x00; - diodp->rpl_dio_prefixlifetime = htonl(this->mDio_lifetime); + diodp->rpl_dio_valid_lifetime = htonl(this->mDio_lifetime); + diodp->rpl_dio_preferred_lifetime = htonl(this->mDio_lifetime); diodp->rpl_dio_prefixlen = prefix.maskbits; for(int i=0; i < (prefix.maskbits+7)/8; i++) { diodp->rpl_dio_prefix[i]=prefix.addr.u.v6.sin6_addr.s6_addr[i]; } - this->optlen = ((prefix.maskbits+7)/8 + 1 + 4 + 4); + this->optlen = 30; return this->optlen; }