mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-24 18:03:06 +02:00
libloc: Import latest fixes from upstream
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -487,7 +487,7 @@ index 2ba93e6..7aac0db 100644
|
||||
if (!c)
|
||||
return -ENOMEM;
|
||||
diff --git a/src/database.c b/src/database.c
|
||||
index fa1dad0..7100298 100644
|
||||
index fa1dad0..4b8bf1d 100644
|
||||
--- a/src/database.c
|
||||
+++ b/src/database.c
|
||||
@@ -38,8 +38,10 @@
|
||||
@@ -876,7 +876,7 @@ index fa1dad0..7100298 100644
|
||||
be32toh(n->one), 1, node->depth + 1);
|
||||
|
||||
if (r)
|
||||
@@ -1175,56 +1261,145 @@ LOC_EXPORT int loc_database_enumerator_next_network(
|
||||
@@ -1175,54 +1261,142 @@ LOC_EXPORT int loc_database_enumerator_next_network(
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
@@ -970,7 +970,7 @@ index fa1dad0..7100298 100644
|
||||
- return 0;
|
||||
+ loc_network_unref(subnet);
|
||||
+ continue;
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ // If this is not a subnet, we push it back onto the stack and break
|
||||
+ r = loc_network_list_push(enumerator->stack, subnet);
|
||||
@@ -979,7 +979,7 @@ index fa1dad0..7100298 100644
|
||||
+ loc_network_list_unref(subnets);
|
||||
+
|
||||
+ return r;
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ loc_network_unref(subnet);
|
||||
+ break;
|
||||
@@ -987,17 +987,18 @@ index fa1dad0..7100298 100644
|
||||
|
||||
- // Reached the end of the search
|
||||
+ DEBUG(enumerator->ctx, "Found %zu subnet(s)\n", loc_network_list_size(subnets));
|
||||
+
|
||||
+ // We can abort here if the network has no subnets
|
||||
+ if (loc_network_list_empty(subnets)) {
|
||||
+ loc_network_list_unref(subnets);
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
|
||||
- // Mark all nodes as non-visited
|
||||
- for (unsigned int i = 0; i < enumerator->db->network_nodes_count; i++)
|
||||
- enumerator->networks_visited[i] = 0;
|
||||
+ // We can abort here if the network has no subnets
|
||||
+ if (loc_network_list_empty(subnets)) {
|
||||
+ loc_network_list_unref(subnets);
|
||||
|
||||
- return 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // If the network has any subnets, we will break it into smaller parts
|
||||
+ // without the subnets.
|
||||
+ struct loc_network_list* excluded = loc_network_exclude_list(*network, subnets);
|
||||
@@ -1027,13 +1028,12 @@ index fa1dad0..7100298 100644
|
||||
+ loc_network_list_unref(subnets);
|
||||
+ loc_network_list_unref(excluded);
|
||||
+
|
||||
+ // Replace network with the first one from the stack
|
||||
+ // Drop the network and restart the whole process again to pick the next network
|
||||
+ loc_network_unref(*network);
|
||||
+ *network = loc_network_list_pop_first(enumerator->stack);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+
|
||||
+ return __loc_database_enumerator_next_network_flattened(enumerator, network);
|
||||
+}
|
||||
+
|
||||
+LOC_EXPORT int loc_database_enumerator_next_network(
|
||||
+ struct loc_database_enumerator* enumerator, struct loc_network** network) {
|
||||
+ // Do not do anything if not in network mode
|
||||
@@ -1045,11 +1045,9 @@ index fa1dad0..7100298 100644
|
||||
+ return __loc_database_enumerator_next_network_flattened(enumerator, network);
|
||||
+
|
||||
+ return __loc_database_enumerator_next_network(enumerator, network, 1);
|
||||
+}
|
||||
+
|
||||
}
|
||||
|
||||
LOC_EXPORT int loc_database_enumerator_next_country(
|
||||
struct loc_database_enumerator* enumerator, struct loc_country** country) {
|
||||
*country = NULL;
|
||||
diff --git a/src/libloc.sym b/src/libloc.sym
|
||||
index b8296eb..ee333f1 100644
|
||||
--- a/src/libloc.sym
|
||||
|
||||
Reference in New Issue
Block a user