Commit 9268db5a authored by Michael Tremer's avatar Michael Tremer

Implement searching for networks with a certain flag

Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent a293f829
......@@ -80,6 +80,7 @@ struct loc_database_enumerator {
char* string;
char country_code[3];
uint32_t asn;
enum loc_network_flags flags;
// Index of the AS we are looking at
unsigned int as_index;
......@@ -662,6 +663,13 @@ LOC_EXPORT int loc_database_enumerator_set_asn(
return 0;
}
LOC_EXPORT int loc_database_enumerator_set_flag(
struct loc_database_enumerator* enumerator, enum loc_network_flags flag) {
enumerator->flags |= flag;
return 0;
}
LOC_EXPORT int loc_database_enumerator_next_as(
struct loc_database_enumerator* enumerator, struct loc_as** as) {
*as = NULL;
......@@ -807,6 +815,13 @@ LOC_EXPORT int loc_database_enumerator_next_network(
continue;
}
// Skip if flags do not match
if (enumerator->flags &&
!loc_network_match_flag(*network, enumerator->flags)) {
loc_network_unref(*network);
*network = NULL;
}
return 0;
}
}
......
......@@ -57,6 +57,7 @@ struct loc_database_enumerator* loc_database_enumerator_unref(struct loc_databas
int loc_database_enumerator_set_string(struct loc_database_enumerator* enumerator, const char* string);
int loc_database_enumerator_set_country_code(struct loc_database_enumerator* enumerator, const char* country_code);
int loc_database_enumerator_set_asn(struct loc_database_enumerator* enumerator, unsigned int asn);
int loc_database_enumerator_set_flag(struct loc_database_enumerator* enumerator, enum loc_network_flags flag);
int loc_database_enumerator_next_as(
struct loc_database_enumerator* enumerator, struct loc_as** as);
int loc_database_enumerator_next_network(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment