Browse Source

ng_ndp: fix _get_l2src

dev/timer
Martine Lenders 8 years ago
parent
commit
6f85433fa8
  1. 20
      sys/net/network_layer/ng_ndp/ng_ndp.c

20
sys/net/network_layer/ng_ndp/ng_ndp.c

@ -636,24 +636,28 @@ 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 {
else if ((res = ng_netapi_get(iface, NETCONF_OPT_ADDRESS, 0, l2src,
l2src_size)) >= 0) {
l2src_len = (uint16_t)res;
}
else {
DEBUG("ndp: no link-layer address found.\n");
l2src_len = 0;
}
return l2src_len;
}

Loading…
Cancel
Save