{
if (ipaddr->af == AF_INET) {
/*
- * 224.0.0.0 (3758096384) - 239.255.255.255 (4026531839)
+ * 224.0.0.0 - 239.255.255.255.
*/
- if ((ipaddr->addr.v4.s_addr >= 3758096384) && (ipaddr->addr.v4.s_addr <= 4026531839)) return 1;
+ if ((ipaddr->addr.v4.s_addr >= htonl((uint32_t) 0xe0000000)) &&
+ (ipaddr->addr.v4.s_addr < htonl((uint32_t) 0xf0000000))) return 1;
#ifdef HAVE_STRUCT_SOCKADDR_IN6
} else if (ipaddr->af == AF_INET6) {
/* Unconst for emscripten/musl */
* This function returns only one IP address, of the specified address family,
* or the first address (of whatever family), if AF_UNSPEC is used.
*
- * If fallback is specified and af is AF_INET, but not AF_INET records were
- * found and a record for AF_INET6 exists that record will be returned.
+ * If fallback is specified and af is AF_INET, but no AF_INET records were
+ * found and a record for AF_INET6 exists, then the IPv6 record will be returned.
*
* If fallback is specified and af is AF_INET6, and a record with AF_INET4 exists
* that record will be returned inserted.
return -1;
}
out->af = af;
- out->prefix = 32;
+ out->prefix = (af == AF_INET) ? 32 : 128;
out->scope_id = 0;
return 0;
if (!p || !*p) return 0;
/*
- * Parse scope.
+ * Parse scope ID.
*/
prefix = strtoul(p, &eptr, 10);
if (prefix > UINT32_MAX) {
return -1;
}
+ out->scope_id = prefix;
+
return 0;
}
if (salen < sizeof(s4)) {
fr_strerror_const("IPv4 address is too small");
- return 0;
+ return -1;
}
memcpy(&s4, sa, sizeof(s4));
if (salen < sizeof(s6)) {
fr_strerror_const("IPv6 address is too small");
- return 0;
+ return -1;
}
memcpy(&s6, sa, sizeof(s6));
int ret;
ret = CMP(a->ss_family, b->ss_family);
- if (ret != 0) return 0;
+ if (ret != 0) return ret;
switch (a->ss_family) {
case AF_INET: