lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit c8e6ee4e authored by Stefan Schantl's avatar Stefan Schantl Committed by Michael Tremer

perl: Add lookup_network_has_flag() function.

This function can be used to check if a given address or network has one
of the following network flags.

* LOC_NETWORK_FLAG_ANONYMOUS_PROXY
* LOC_NETWORK_FLAG_SATELLITE_PROVIDER
* LOC_NETWORK_FLAG_ANYCAST

It will return true if the given flag is set.
Signed-off-by: default avatarStefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 30c8e528
......@@ -181,6 +181,42 @@ lookup_country_code(db, address)
OUTPUT:
RETVAL
bool
lookup_network_has_flag(db, address, flag)
struct loc_database* db;
char* address;
char* flag;
CODE:
RETVAL = false;
enum loc_network_flags iv = 0;
if (strcmp("LOC_NETWORK_FLAG_ANONYMOUS_PROXY", flag) == 0)
iv |= LOC_NETWORK_FLAG_ANONYMOUS_PROXY;
else if (strcmp("LOC_NETWORK_FLAG_SATELLITE_PROVIDER", flag) == 0)
iv |= LOC_NETWORK_FLAG_SATELLITE_PROVIDER;
else if (strcmp("LOC_NETWORK_FLAG_ANYCAST", flag) == 0)
iv |= LOC_NETWORK_FLAG_ANYCAST;
else
croak("Invalid flag");
// Lookup network
struct loc_network *network;
int err = loc_database_lookup_from_string(db, address, &network);
if (!err) {
// Check if the network has the given flag.
if (loc_network_has_flag(network, iv)) {
RETVAL = true;
}
loc_network_unref(network);
}
OUTPUT:
RETVAL
SV*
lookup_asn(db, address)
struct loc_database* db;
......
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