Skip to content

Commit

Permalink
Fix malformed DIO messages when sending prefix information. Issue Ani…
Browse files Browse the repository at this point in the history
  • Loading branch information
s0129 committed Aug 28, 2014
1 parent 407af20 commit 563dc32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion include/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions lib/libndmgmt/dio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 563dc32

Please sign in to comment.