Skip to content

Commit

Permalink
Merge pull request #3674 from authmillenon/gnrc_sixlowpan/fix/max-dat…
Browse files Browse the repository at this point in the history
…agram-size

gnrc_sixlowpan: don't send packets that exceed maximum datagram size
  • Loading branch information
cgundogan committed Aug 21, 2015
2 parents 79ac710 + 52c57be commit 04a8c15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions sys/include/net/sixlowpan.h
Expand Up @@ -39,6 +39,8 @@ extern "C" {
#define SIXLOWPAN_FRAG_1_DISP (0xc0) /**< dispatch for 1st fragment */
#define SIXLOWPAN_FRAG_N_DISP (0xe0) /**< dispatch for subsequent
* fragments */
#define SIXLOWPAN_FRAG_MAX_LEN (2047) /**< Maximum datagram size @f$ (2^{11} - 1) @f$ */

/**
* @brief Dispatch mask for LOWPAN_IPHC.
* @see <a href="https://tools.ietf.org/html/rfc6282#section-3.1">
Expand Down
11 changes: 8 additions & 3 deletions sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c
Expand Up @@ -265,15 +265,20 @@ static void _send(gnrc_pktsnip_t *pkt)
return;
}
#ifdef MODULE_GNRC_SIXLOWPAN_FRAG
else {
else if (datagram_size <= SIXLOWPAN_FRAG_MAX_LEN) {
DEBUG("6lo: Send fragmented (%u > %" PRIu16 ")\n",
(unsigned int)datagram_size, iface->max_frag_size);
gnrc_sixlowpan_frag_send(hdr->if_pid, pkt2, datagram_size);
}
else {
DEBUG("6lo: packet too big (%u > %" PRIu16 ")\n",
(unsigned int)datagram_size, SIXLOWPAN_FRAG_MAX_LEN);
gnrc_pktbuf_release(pkt2);
}
#else
(void)datagram_size;
DEBUG("6lo: packet too big (%u> %" PRIu16 ")\n",
DEBUG("6lo: packet too big (%u > %" PRIu16 ")\n",
(unsigned int)datagram_size, iface->max_frag_size);
gnrc_pktbuf_release(pkt2);
#endif
}

Expand Down

0 comments on commit 04a8c15

Please sign in to comment.