Skip to content

Commit

Permalink
Merge pull request #4581 from Yonezawa-T2/neighbor_discovery_option_f…
Browse files Browse the repository at this point in the history
…or_6lowpan

gnrc_ndp: fixed ND Option handling for 6LoWPAN
  • Loading branch information
miri64 committed Jan 6, 2016
2 parents e368234 + 639f7dc commit a0b27b0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,24 @@ int gnrc_ndp_internal_sl2a_opt_handle(gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, uin
pkt = pkt->next;
}

#ifdef MODULE_GNRC_SIXLOWPAN_ND
if ((sl2a_len == 2) || (sl2a_len == 8)) {
/* The link-layer seems to be IEEE 802.15.4.
* Determining address length from the option length:
* https://tools.ietf.org/html/rfc4944#section-8 */
if (sl2a_opt->len == 1) {
sl2a_len = 2;
}
else if (sl2a_opt->len == 2) {
sl2a_len = 8;
}
else {
DEBUG("ndp: invalid source link-layer address option received\n");
return -EINVAL;
}
}
#endif

DEBUG("ndp: received SL2A (link-layer address: %s)\n",
gnrc_netif_addr_to_str(addr_str, sizeof(addr_str), sl2a, sl2a_len));

Expand Down Expand Up @@ -647,6 +665,23 @@ int gnrc_ndp_internal_tl2a_opt_handle(gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6,
}
pkt = pkt->next;
}
#ifdef MODULE_GNRC_SIXLOWPAN_ND
if ((tl2a_len == 2) || (tl2a_len == 8)) {
/* The link-layer seems to be IEEE 802.15.4.
* Determining address length from the option length:
* https://tools.ietf.org/html/rfc4944#section-8 */
if (tl2a_opt->len == 1) {
tl2a_len = 2;
}
else if (tl2a_opt->len == 2) {
tl2a_len = 8;
}
else {
DEBUG("ndp: invalid target link-layer address option received\n");
return -EINVAL;
}
}
#endif

if (tl2a_len == 0) { /* in case there was no source address in l2 */
tl2a_len = (tl2a_opt->len / 8) - sizeof(ndp_opt_t);
Expand Down

0 comments on commit a0b27b0

Please sign in to comment.