+ uint64_t mask[2];
+ uint64_t *a1 = (uint64_t *) &((struct sockaddr_in6 *)&ban->address)->sin6_addr.s6_addr;
+ uint64_t *a2 = (uint64_t *) &((struct sockaddr_in6 *)address)->sin6_addr.s6_addr;
+
+ if (ban->mask == 128)
+ mask[0] = mask[1] = 0xffffffffffffffffULL;
+ else if (ban->mask > 64) {
+ mask[0] = 0xffffffffffffffffULL;
+ mask[1] = SWAPPED(~((1ULL << (128 - ban->mask)) - 1));
+ } else {
+ mask[0] = SWAPPED(~((1ULL << (64 - ban->mask)) - 1));
+ mask[1] = 0ULL;
+ }
+ if ((a1[0] & mask[0]) == (a2[0] & mask[0]) &&
+ (a1[1] & mask[1]) == (a2[1] & mask[1]))
+ return true;