[riot-notifications] [RIOT-OS/RIOT] gnrc_ipv6_nib: use generated EUI-64 for ARO build and check (#10817)

Marian Buschsieweke notifications at github.com
Fri Jan 18 17:11:39 CET 2019

maribu commented on this pull request.

> +#endif /* defined(MODULE_CC110X) || defined(MODULE_NRFMIN) */
+int gnrc_netif_eui64_from_addr(const gnrc_netif_t *netif,
+                               const uint8_t *addr, size_t addr_len,
+                               eui64_t *eui64)
+    if (netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR) {
+        switch (netif->device_type) {
+#if defined(MODULE_NETDEV_ETH) || defined(MODULE_ESP_NOW) || \
+            case NETDEV_TYPE_ETHERNET:
+            case NETDEV_TYPE_ESP_NOW:
+            case NETDEV_TYPE_BLE:
+                if (addr_len == sizeof(eui48_t)) {
+                    eui48_to_eui64(eui64, (const eui48_t *)addr);

Basic data types have the alignment requirements of their size. Arrays have the same alignment as their elements. A union and structs will have the same alignment requirement as their member with the highest requirement.

``` C
typedef union {
     uint8_t uint8[6];            // <-- Alignment requirement of 1 bytes
     network_uint16_t uint16[3];  // <-- Alignment requirement of 2 bytes
 } eui48_t;

So `eui48_t` will have `MAX(2, 1) == 2` as alignment requirement. Dropping the `uint16` member would reduce the alignment requirement. But I though more about changing `eui48_to_eui64` to accept `uint8_t *` as second argument.

Good to know I'm not the only one still learning while working at RIOT :-)

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190118/09c30059/attachment.html>

More information about the notifications mailing list