gap_end = address_decrement(loc_network_get_first_address(network));
// There is a gap
- if (in6_addr_cmp(gap_start, &gap_end) < 0) {
+ if (loc_address_cmp(gap_start, &gap_end) < 0) {
r = loc_network_list_summarize(enumerator->ctx,
gap_start, &gap_end, &enumerator->stack);
if (r) {
if (r)
return r;
- if (in6_addr_cmp(&enumerator->gap6_start, &gap_end) < 0) {
+ if (loc_address_cmp(&enumerator->gap6_start, &gap_end) < 0) {
r = loc_network_list_summarize(enumerator->ctx,
&enumerator->gap6_start, &gap_end, &enumerator->stack);
if (r)
if (r)
return r;
- if (in6_addr_cmp(&enumerator->gap4_start, &gap_end) < 0) {
+ if (loc_address_cmp(&enumerator->gap4_start, &gap_end) < 0) {
r = loc_network_list_summarize(enumerator->ctx,
&enumerator->gap4_start, &gap_end, &enumerator->stack);
if (r)
return AF_INET6;
}
-static inline int in6_addr_cmp(const struct in6_addr* a1, const struct in6_addr* a2) {
+static inline int loc_address_cmp(const struct in6_addr* a1, const struct in6_addr* a2) {
for (unsigned int i = 0; i < 16; i++) {
if (a1->s6_addr[i] > a2->s6_addr[i])
return 1;
if (r)
return r;
- if (in6_addr_cmp(address, &all_zeroes) == 0)
+ if (loc_address_cmp(address, &all_zeroes) == 0)
return 1;
return 0;
}
// Check if the last address is larger than the first address
- if (in6_addr_cmp(first, last) >= 0) {
+ if (loc_address_cmp(first, last) >= 0) {
ERROR(ctx, "The first address must be smaller than the last address\n");
errno = EINVAL;
return 1;
const int family_bit_length = loc_address_family_bit_length(family1);
- while (in6_addr_cmp(&start, last) <= 0) {
+ while (loc_address_cmp(&start, last) <= 0) {
struct in6_addr num;
int bits1;
LOC_EXPORT int loc_network_matches_address(struct loc_network* network, const struct in6_addr* address) {
// Address must be larger than the start address
- if (in6_addr_cmp(&network->first_address, address) > 0)
+ if (loc_address_cmp(&network->first_address, address) > 0)
return 0;
// Address must be smaller than the last address
- if (in6_addr_cmp(&network->last_address, address) < 0)
+ if (loc_address_cmp(&network->last_address, address) < 0)
return 0;
// The address is inside this network
LOC_EXPORT int loc_network_cmp(struct loc_network* self, struct loc_network* other) {
// Compare address
- int r = in6_addr_cmp(&self->first_address, &other->first_address);
+ int r = loc_address_cmp(&self->first_address, &other->first_address);
if (r)
return r;
// If the start address of the other network is smaller than this network,
// it cannot be a subnet.
- if (in6_addr_cmp(&self->first_address, &other->first_address) > 0)
+ if (loc_address_cmp(&self->first_address, &other->first_address) > 0)
return 0;
// If the end address of the other network is greater than this network,
// it cannot be a subnet.
- if (in6_addr_cmp(&self->last_address, &other->last_address) < 0)
+ if (loc_address_cmp(&self->last_address, &other->last_address) < 0)
return 0;
return 1;