Skip to content
Permalink
Browse files

net: ip: ipv6_nbr: Make LLAO length calculation more universal

This commit changes the Link-Layer Address Option length calculation
from hardcoded values to a numerical rounding up to full 8.
The length is calculated according to rfc4861 section 4.6.1.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
  • Loading branch information...
alexanderwachter authored and jukkar committed Aug 9, 2019
1 parent 0307f6c commit 210455a0ae791c945b43b70bf97b97a2efc9f25d
Showing with 3 additions and 12 deletions.
  1. +3 −12 subsys/net/ip/ipv6_nbr.c
@@ -972,19 +972,10 @@ struct net_nbr *net_ipv6_get_nbr(struct net_if *iface, u8_t idx)

static inline u8_t get_llao_len(struct net_if *iface)
{
if (net_if_get_link_addr(iface)->len == 6U) {
return 8;
} else if (net_if_get_link_addr(iface)->len == 8U) {
return 16;
} else if (net_if_get_link_addr(iface)->len == 2U) {
return 8;
}

/* What else could it be? */
NET_ASSERT_INFO(0, "Invalid link address length %d",
net_if_get_link_addr(iface)->len);
u8_t total_len = net_if_get_link_addr(iface)->len +
sizeof(struct net_icmpv6_nd_opt_hdr);

return 0;
return ROUND_UP(total_len, 8U);
}

static inline bool set_llao(struct net_pkt *pkt,

0 comments on commit 210455a

Please sign in to comment.
You can’t perform that action at this time.