Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
loc_network_get_country_code;
loc_network_get_first_address;
loc_network_get_last_address;
- loc_network_gt;
loc_network_has_flag;
loc_network_is_subnet;
loc_network_match_asn;
int loc_network_match_flag(struct loc_network* network, uint32_t flag);
int loc_network_cmp(struct loc_network* self, struct loc_network* other);
-int loc_network_gt(struct loc_network* self, struct loc_network* other);
int loc_network_overlaps(struct loc_network* self, struct loc_network* other);
int loc_network_is_subnet(struct loc_network* self, struct loc_network* other);
int loc_network_subnets(struct loc_network* network, struct loc_network** subnet1, struct loc_network** subnet2);
return 0;
}
-LOC_EXPORT int loc_network_gt(struct loc_network* self, struct loc_network* other) {
- // Families must match
- if (self->family != other->family)
- return -1;
-
- int r = in6_addr_cmp(&self->first_address, &other->first_address);
-
- switch (r) {
- // Smaller
- case -1:
- return 0;
-
- // Larger
- case 1:
- return 1;
-
- default:
- break;
- }
-
- if (self->prefix > other->prefix)
- return 1;
-
- // Dunno
- return 0;
-}
-
LOC_EXPORT int loc_network_overlaps(struct loc_network* self, struct loc_network* other) {
if (loc_network_match_address(self, &other->first_address) == 0)
return 1;