mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-26 23:11:19 +01:00
Merge pull request #3396 from authmillenon/ng_ndp/fix/get-l2src
ng_ndp: fix _get_l2src
This commit is contained in:
commit
666c04e7fe
@ -636,23 +636,27 @@ static uint16_t _get_l2src(uint8_t *l2src, size_t l2src_size, kernel_pid_t iface
|
||||
bool try_long = false;
|
||||
int res;
|
||||
uint16_t l2src_len;
|
||||
/* maximum address length that fits into a minimum length (8) S/TL2A option */
|
||||
const uint16_t max_short_len = 6;
|
||||
|
||||
/* try getting source address */
|
||||
if ((ng_netapi_get(iface, NETCONF_OPT_SRC_LEN, 0, &l2src_len,
|
||||
sizeof(l2src_len)) >= 0) &&
|
||||
(l2src_len == 8)) {
|
||||
(l2src_len > max_short_len)) {
|
||||
try_long = true;
|
||||
}
|
||||
|
||||
if ((try_long && ((res = ng_netapi_get(iface, NETCONF_OPT_ADDRESS_LONG, 0,
|
||||
l2src, l2src_size)) < 0)) ||
|
||||
((res = ng_netapi_get(iface, NETCONF_OPT_ADDRESS, 0, l2src,
|
||||
l2src_size)) < 0)) {
|
||||
DEBUG("ndp: no link-layer address found.\n");
|
||||
l2src_len = 0;
|
||||
if (try_long && ((res = ng_netapi_get(iface, NETCONF_OPT_ADDRESS_LONG, 0,
|
||||
l2src, l2src_size)) > max_short_len)) {
|
||||
l2src_len = (uint16_t)res;
|
||||
}
|
||||
else if ((res = ng_netapi_get(iface, NETCONF_OPT_ADDRESS, 0, l2src,
|
||||
l2src_size)) >= 0) {
|
||||
l2src_len = (uint16_t)res;
|
||||
}
|
||||
else {
|
||||
l2src_len = (uint16_t)res;
|
||||
DEBUG("ndp: no link-layer address found.\n");
|
||||
l2src_len = 0;
|
||||
}
|
||||
|
||||
return l2src_len;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user