Skip to content
Snippets Groups Projects
Commit 639f7dc0 authored by Yonezawa-T2's avatar Yonezawa-T2
Browse files

gnrc_ndp: fixed ND Option handling for 6LoWPAN

The forms of the Source/Target Link-layer Address option for 6LoWPAN are defined
in RFC 4944 Section 8:
https://tools.ietf.org/html/rfc4944#section-8
The address is 16 bit if length is 1, 64 bit if length is 2.
parent 693d4380
No related branches found
No related tags found
No related merge requests found
...@@ -598,6 +598,24 @@ int gnrc_ndp_internal_sl2a_opt_handle(gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, uin ...@@ -598,6 +598,24 @@ int gnrc_ndp_internal_sl2a_opt_handle(gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, uin
pkt = pkt->next; 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", DEBUG("ndp: received SL2A (link-layer address: %s)\n",
gnrc_netif_addr_to_str(addr_str, sizeof(addr_str), sl2a, sl2a_len)); gnrc_netif_addr_to_str(addr_str, sizeof(addr_str), sl2a, sl2a_len));
...@@ -644,6 +662,23 @@ int gnrc_ndp_internal_tl2a_opt_handle(gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6, ...@@ -644,6 +662,23 @@ int gnrc_ndp_internal_tl2a_opt_handle(gnrc_pktsnip_t *pkt, ipv6_hdr_t *ipv6,
} }
pkt = pkt->next; 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 */ if (tl2a_len == 0) { /* in case there was no source address in l2 */
tl2a_len = (tl2a_opt->len / 8) - sizeof(ndp_opt_t); tl2a_len = (tl2a_opt->len / 8) - sizeof(ndp_opt_t);
......
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