Commit 8d4f5f67 authored by Stefan Schantl's avatar Stefan Schantl Committed by Michael Tremer

perl: Add function to perform AS number lookups.

Signed-off-by: default avatarStefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 946f4330
......@@ -113,6 +113,29 @@ lookup_country_code(db, address)
OUTPUT:
RETVAL
SV*
lookup_asn(db, address)
struct loc_database* db;
char* address;
CODE:
RETVAL = &PL_sv_undef;
// Lookup network
struct loc_network *network;
int err = loc_database_lookup_from_string(db, address, &network);
if (!err) {
// Extract the ASN
unsigned int as_number = loc_network_get_asn(network);
if (as_number > 0) {
RETVAL = newSViv(as_number);
}
loc_network_unref(network);
}
OUTPUT:
RETVAL
void
DESTROY(db)
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