Skip to content
Snippets Groups Projects
Unverified Commit 0c790c66 authored by Koen Zandberg's avatar Koen Zandberg
Browse files

gnrc_rpl: fix zeroing of RPL DIS fields

The code originally assumed that the location of DIS struct is directly
after the ICMPv6 struct. This is not necessarily true when both structs
are individually allocated by pktbuf. This commit fixes this issue by
directly accessing the location of the DIS struct.
parent 11f1955a
No related branches found
No related tags found
No related merge requests found
...@@ -314,7 +314,6 @@ void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination, ...@@ -314,7 +314,6 @@ void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination,
gnrc_rpl_internal_opt_t **options, size_t num_opts) gnrc_rpl_internal_opt_t **options, size_t num_opts)
{ {
gnrc_pktsnip_t *pkt = NULL, *tmp; gnrc_pktsnip_t *pkt = NULL, *tmp;
icmpv6_hdr_t *icmp;
gnrc_rpl_dis_t *dis; gnrc_rpl_dis_t *dis;
/* No options provided to be attached to the DIS, so we PadN 2 bytes */ /* No options provided to be attached to the DIS, so we PadN 2 bytes */
...@@ -358,6 +357,9 @@ void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination, ...@@ -358,6 +357,9 @@ void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination,
return; return;
} }
pkt = tmp; pkt = tmp;
dis = (gnrc_rpl_dis_t *)pkt->data;
dis->flags = 0;
dis->reserved = 0;
if ((tmp = gnrc_icmpv6_build(pkt, ICMPV6_RPL_CTRL, GNRC_RPL_ICMPV6_CODE_DIS, if ((tmp = gnrc_icmpv6_build(pkt, ICMPV6_RPL_CTRL, GNRC_RPL_ICMPV6_CODE_DIS,
sizeof(icmpv6_hdr_t))) == NULL) { sizeof(icmpv6_hdr_t))) == NULL) {
...@@ -366,12 +368,6 @@ void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination, ...@@ -366,12 +368,6 @@ void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination,
return; return;
} }
pkt = tmp; pkt = tmp;
icmp = (icmpv6_hdr_t *)pkt->data;
dis = (gnrc_rpl_dis_t *)(icmp + 1);
dis->flags = 0;
dis->reserved = 0;
#ifdef MODULE_NETSTATS_RPL #ifdef MODULE_NETSTATS_RPL
gnrc_rpl_netstats_tx_DIS(&gnrc_rpl_netstats, gnrc_pkt_len(pkt), gnrc_rpl_netstats_tx_DIS(&gnrc_rpl_netstats, gnrc_pkt_len(pkt),
(destination && !ipv6_addr_is_multicast(destination))); (destination && !ipv6_addr_is_multicast(destination)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment