]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
networks: Copy all attributes when splitting networks
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 12 Nov 2020 20:09:37 +0000 (20:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 12 Nov 2020 20:12:55 +0000 (20:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/network.c

index 751e8e5ba1b4235d28afa7e8d5113533143ffb10..d67f1162e5398a6ee2560f5f2ed0227e7498aa4e 100644 (file)
@@ -550,6 +550,20 @@ LOC_EXPORT struct loc_network_list* loc_network_subnets(struct loc_network* netw
        if (r)
                goto ERROR;
 
+       // Copy country code
+       const char* country_code = loc_network_get_country_code(network);
+       if (country_code) {
+               loc_network_set_country_code(subnet1, country_code);
+               loc_network_set_country_code(subnet2, country_code);
+       }
+
+       // Copy ASN
+       uint32_t asn = loc_network_get_asn(network);
+       if (asn) {
+               loc_network_set_asn(subnet1, asn);
+               loc_network_set_asn(subnet2, asn);
+       }
+
        loc_network_unref(subnet1);
        loc_network_unref(subnet2);