]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
Drop loc_network_eq in favour of loc_network_cmp
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Nov 2020 15:48:55 +0000 (15:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Nov 2020 15:48:55 +0000 (15:48 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libloc.sym
src/loc/network.h
src/network.c
src/test-network.c

index 4b0ce45a4b56ec3c8169e10028ddaa077f04173e..d8e8f14925d435bf64f7b5b63c525a28ef556eb7 100644 (file)
@@ -107,7 +107,6 @@ global:
        # Network
        loc_network_address_family;
        loc_network_cmp;
-       loc_network_eq;
        loc_network_exclude;
        loc_network_exclude_list;
        loc_network_format_first_address;
index 8ab156251e344116009ad0384c4aabc7377f7d65..d5d0ccde27f569f91180c259b888b6e255ad2594 100644 (file)
@@ -59,7 +59,6 @@ int loc_network_set_flag(struct loc_network* network, uint32_t flag);
 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_eq(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);
index 7ab22f86a6b430624cfcd37e4d5f5c267a683c48..503bf3d02e0eb47c8af8b91b744ae3a428d01ff2 100644 (file)
@@ -463,22 +463,6 @@ LOC_EXPORT int loc_network_cmp(struct loc_network* self, struct loc_network* oth
        return 0;
 }
 
-LOC_EXPORT int loc_network_eq(struct loc_network* self, struct loc_network* other) {
-       // Family must be the same
-       if (self->family != other->family)
-               return 0;
-
-       // The start address must be the same
-       if (in6_addr_cmp(&self->first_address, &other->first_address) != 0)
-               return 0;
-
-       // The prefix length must be the same
-       if (self->prefix != other->prefix)
-               return 0;
-
-       return 1;
-}
-
 LOC_EXPORT int loc_network_gt(struct loc_network* self, struct loc_network* other) {
        // Families must match
        if (self->family != other->family)
@@ -596,12 +580,12 @@ static int __loc_network_exclude(struct loc_network* network,
        if (r)
                goto ERROR;
 
-       if (loc_network_eq(other, subnet1)) {
+       if (loc_network_cmp(other, subnet1) == 0) {
                r = loc_network_list_push(list, subnet2);
                if (r)
                        goto ERROR;
 
-       } else if (loc_network_eq(other, subnet2)) {
+       } else if (loc_network_cmp(other, subnet2) == 0) {
                r = loc_network_list_push(list, subnet1);
                if (r)
                        goto ERROR;
@@ -657,7 +641,7 @@ static int __loc_network_exclude_to_list(struct loc_network* self,
        }
 
        // We cannot perform this operation if both networks equal
-       if (loc_network_eq(self, other)) {
+       if (loc_network_cmp(self, other) == 0) {
                DEBUG(self->ctx, "Networks %p and %p are equal\n", self, other);
 
                return 1;
@@ -745,7 +729,7 @@ LOC_EXPORT struct loc_network_list* loc_network_exclude_list(
                        subnet = loc_network_list_get(list, i);
 
                        // Drop this subnet if is is already in list
-                       if (loc_network_eq(subnet_to_check, subnet)) {
+                       if (loc_network_cmp(subnet_to_check, subnet) == 0) {
                                passed = 0;
                                loc_network_unref(subnet);
                                break;
index 8a6763c953d1e8247dd0d0451129246f3617ab42..f4cf97b5bb6786b5e58ce48ace9fb4ccbf82f33c 100644 (file)
@@ -125,14 +125,14 @@ int main(int argc, char** argv) {
 #endif
 
        // Check equals function
-       err = loc_network_eq(network1, network1);
-       if (!err) {
+       err = loc_network_cmp(network1, network1);
+       if (err) {
                fprintf(stderr, "Network is not equal with itself\n");
                exit(EXIT_FAILURE);
        }
 
-       err = loc_network_eq(network1, network2);
-       if (err) {
+       err = loc_network_cmp(network1, network2);
+       if (!err) {
                fprintf(stderr, "Networks equal unexpectedly\n");
                exit(EXIT_FAILURE);
        }