diff --git a/include/net/net_linkaddr.h b/include/net/net_linkaddr.h index 1e96b5219f2..e5b2e1b084f 100644 --- a/include/net/net_linkaddr.h +++ b/include/net/net_linkaddr.h @@ -19,6 +19,12 @@ extern "C" { #endif +#ifdef CONFIG_NET_L2_IEEE802154 +#define NET_LINK_ADDR_MAX_LENGTH 8 +#else +#define NET_LINK_ADDR_MAX_LENGTH 6 +#endif + /** * @brief Hardware link address structure * @@ -37,27 +43,17 @@ struct net_linkaddr { * * Used to hold the link address information. This variant is needed * when we have to store the link layer address. - * Note that you cannot cast this to net_linkaddr as they store - * different things. + * + * Note that you cannot cast this to net_linkaddr as uint8_t * is + * handled differently than uint8_t addr[] and the fields are purposely + * in a different order. */ struct net_linkaddr_storage { /** The real length of the ll address. */ uint8_t len; - union { - /** The array of bytes representing the address */ - uint8_t addr[0]; - - struct { - /* The integer array allocate total of 8 bytes - * that can hold currently all the supported - * link layer addresses. These int's can be - * used when comparing lladdr instead of using - * memcmp() - */ - uint32_t storage[2]; - }; - }; + /** The array of bytes representing the address */ + uint8_t addr[NET_LINK_ADDR_MAX_LENGTH]; }; /** diff --git a/subsys/net/ip/nbr.c b/subsys/net/ip/nbr.c index 2f021bcdddf..627a2de308d 100644 --- a/subsys/net/ip/nbr.c +++ b/subsys/net/ip/nbr.c @@ -148,7 +148,7 @@ int net_nbr_unlink(struct net_nbr *nbr, struct net_linkaddr *lladdr) if (!net_neighbor_lladdr[nbr->idx].ref) { memset(net_neighbor_lladdr[nbr->idx].lladdr.addr, 0, - sizeof(net_neighbor_lladdr[nbr->idx].lladdr.storage)); + sizeof(net_neighbor_lladdr[nbr->idx].lladdr.addr)); } nbr->idx = NET_NBR_LLADDR_UNKNOWN; diff --git a/tests/net/rpl/src/main.c b/tests/net/rpl/src/main.c index eb2dbc495ef..03be28b14b7 100644 --- a/tests/net/rpl/src/main.c +++ b/tests/net/rpl/src/main.c @@ -48,12 +48,12 @@ static struct in6_addr in6addr_mcast = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; static struct net_linkaddr_storage lladdr_src_storage = { - .storage = { 0x00000102, 0x03040506 }, - .len = 6 + .addr = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }, + .len = NET_LINK_ADDR_MAX_LENGTH }; static struct net_linkaddr lladdr_src = { - .addr = &lladdr_src_storage.addr[0], - .len = 6 + .addr = lladdr_src_storage.addr, + .len = NET_LINK_ADDR_MAX_LENGTH }; static bool test_failed;