static int prefixcmp(const void *va, const void *vb)
{
const struct odhcpd_ipaddr *a = va, *b = vb;
- uint32_t a_pref = ((a->addr.s6_addr[0] & 0xfe) != 0xfc) ? a->preferred : 1;
- uint32_t b_pref = ((b->addr.s6_addr[0] & 0xfe) != 0xfc) ? b->preferred : 1;
+ uint32_t a_pref = IN6_IS_ADDR_ULA(&a->addr) ? 1 : a->preferred;
+ uint32_t b_pref = IN6_IS_ADDR_ULA(&b->addr) ? 1 : b->preferred;
return (a_pref < b_pref) ? 1 : (a_pref > b_pref) ? -1 : 0;
}
#define ALL_IPV6_ROUTERS {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}
+#define IN6_IS_ADDR_ULA(a) (((a)->s6_addr32[0] & htonl(0xfe000000)) == htonl(0xfc000000))
struct interface;
struct nl_sock;
uint32_t this_lifetime = TIME_LEFT(addr->valid, now);
if (this_lifetime > UINT16_MAX)
this_lifetime = UINT16_MAX;
- if (((addr->addr.s6_addr[0] & 0xfe) != 0xfc || iface->default_router)
+ if ((!IN6_IS_ADDR_ULA(&addr->addr) || iface->default_router)
&& adv.h.nd_ra_router_lifetime
&& ntohs(adv.h.nd_ra_router_lifetime) < this_lifetime) {
adv.h.nd_ra_router_lifetime = htons(this_lifetime);