diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 58d505b04d..5a27de43fb 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -807,21 +807,6 @@ int gnrc_netif_ipv6_group_idx(gnrc_netif_t *netif, const ipv6_addr_t *addr) return idx; } -#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_CC110X) || \ - defined(MODULE_NRFMIN) || defined(MODULE_XBEE) -static void _create_iid_from_short(const gnrc_netif_t *netif, eui64_t *eui64) -{ - const unsigned offset = sizeof(eui64_t) - netif->l2addr_len; - - assert(netif->l2addr_len <= 3); - memset(eui64->uint8, 0, sizeof(eui64->uint8)); - eui64->uint8[3] = 0xff; - eui64->uint8[4] = 0xfe; - memcpy(&eui64->uint8[offset], netif->l2addr, netif->l2addr_len); -} -#endif /* defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_CC110X) || - * defined(MODULE_NRFMIN) || defined(MODULE_XBEE) */ - int gnrc_netif_ipv6_get_iid(gnrc_netif_t *netif, eui64_t *eui64) { #if GNRC_NETIF_L2ADDR_MAXLEN > 0 @@ -833,59 +818,14 @@ int gnrc_netif_ipv6_get_iid(gnrc_netif_t *netif, eui64_t *eui64) if (res == sizeof(eui64_t)) { return 0; } - - switch (netif->device_type) { -#if defined(MODULE_NETDEV_ETH) || defined(MODULE_ESP_NOW) - case NETDEV_TYPE_ETHERNET: - case NETDEV_TYPE_ESP_NOW: - assert(netif->l2addr_len == ETHERNET_ADDR_LEN); - eui64->uint8[0] = netif->l2addr[0] ^ 0x02; - eui64->uint8[1] = netif->l2addr[1]; - eui64->uint8[2] = netif->l2addr[2]; - eui64->uint8[3] = 0xff; - eui64->uint8[4] = 0xfe; - eui64->uint8[5] = netif->l2addr[3]; - eui64->uint8[6] = netif->l2addr[4]; - eui64->uint8[7] = netif->l2addr[5]; - return 0; -#endif -#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE) - case NETDEV_TYPE_IEEE802154: - switch (netif->l2addr_len) { - case IEEE802154_SHORT_ADDRESS_LEN: - _create_iid_from_short(netif, eui64); - return 0; - case IEEE802154_LONG_ADDRESS_LEN: - memcpy(eui64, netif->l2addr, sizeof(eui64_t)); - eui64->uint8[0] ^= 0x02; - return 0; - default: - /* this should not happen */ - assert(false); - break; - } - break; -#endif -#ifdef MODULE_NORDIC_SOFTDEVICE_BLE - case NETDEV_TYPE_BLE: - assert(netif->l2addr_len == sizeof(eui64_t)); - memcpy(eui64, netif->l2addr, sizeof(eui64_t)); - eui64->uint8[0] ^= 0x02; - return 0; -#endif -#if defined(MODULE_CC110X) || defined(MODULE_NRFMIN) - case NETDEV_TYPE_CC110X: - case NETDEV_TYPE_NRFMIN: - _create_iid_from_short(netif, eui64); - return 0; -#endif - default: - (void)eui64; - break; + res = gnrc_netif_ipv6_iid_from_addr(netif, + netif->l2addr, netif->l2addr_len, + eui64); + if (res > 0) { + return 0; } } #endif /* GNRC_NETIF_L2ADDR_MAXLEN > 0 */ - return -ENOTSUP; }