gnrc_ipv6_nib: use gnrc_netif_get_eui64() for ARO build and check

This commit is contained in:
Martine Lenders 2019-01-18 15:53:51 +01:00 committed by Martine Lenders
parent 0fa8419c4a
commit d680aeae07
2 changed files with 10 additions and 10 deletions

View File

@ -29,11 +29,12 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN];
extern void _handle_search_rtr(gnrc_netif_t *netif); extern void _handle_search_rtr(gnrc_netif_t *netif);
static inline bool _is_iface_eui64(gnrc_netif_t *netif, const eui64_t *eui64) static bool _is_iface_eui64(gnrc_netif_t *netif, const eui64_t *eui64)
{ {
/* TODO: adapt for short addresses */ eui64_t iface_eui64;
return (netif->l2addr_len == sizeof(eui64_t)) && int res = gnrc_netif_get_eui64(netif, &iface_eui64);
(memcmp(&netif->l2addr, eui64, netif->l2addr_len) == 0); return (res == sizeof(eui64_t)) &&
(iface_eui64.uint64.u64 == eui64->uint64.u64);
} }
bool _resolve_addr_from_ipv6(const ipv6_addr_t *dst, gnrc_netif_t *netif, bool _resolve_addr_from_ipv6(const ipv6_addr_t *dst, gnrc_netif_t *netif,

View File

@ -43,16 +43,15 @@ void _snd_ns(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
if ((src != NULL) && gnrc_netif_is_6ln(netif) && if ((src != NULL) && gnrc_netif_is_6ln(netif) &&
(_nib_onl_get_if(dr->next_hop) == (unsigned)netif->pid) && (_nib_onl_get_if(dr->next_hop) == (unsigned)netif->pid) &&
ipv6_addr_equal(&dr->next_hop->ipv6, dst)) { ipv6_addr_equal(&dr->next_hop->ipv6, dst)) {
netdev_t *dev = netif->dev; eui64_t eui64;
uint8_t l2src[GNRC_NETIF_L2ADDR_MAXLEN]; int res = gnrc_netif_get_eui64(netif, &eui64);
size_t l2src_len = (uint16_t)dev->driver->get(dev, NETOPT_ADDRESS_LONG,
l2src, sizeof(l2src)); if (res != sizeof(eui64_t)) {
if (l2src_len != sizeof(eui64_t)) {
DEBUG("nib: can't get EUI-64 of the interface for ARO\n"); DEBUG("nib: can't get EUI-64 of the interface for ARO\n");
return; return;
} }
ext_opt = gnrc_sixlowpan_nd_opt_ar_build(0, GNRC_SIXLOWPAN_ND_AR_LTIME, ext_opt = gnrc_sixlowpan_nd_opt_ar_build(0, GNRC_SIXLOWPAN_ND_AR_LTIME,
(eui64_t *)l2src, NULL); &eui64, NULL);
if (ext_opt == NULL) { if (ext_opt == NULL) {
DEBUG("nib: error allocating ARO.\n"); DEBUG("nib: error allocating ARO.\n");
return; return;