man/loc_database_new.3 \
man/loc_get_log_priority.3 \
man/loc_new.3 \
+ man/loc_set_log_callback.3 \
man/loc_set_log_fn.3 \
man/loc_set_log_priority.3
== Name
-libloc - A tool to query the IPFire Location database
+libloc - A library to query the IPFire Location database
== Synopsis
[verse]
* link:loc_new[3]
* link:loc_get_log_priority[3]
* link:loc_set_log_priority[3]
- * link:loc_get_log_fn[3]
+ * link:loc_set_log_fn[3]
+ * link:loc_set_log_callback[3]
* link:loc_database_count_as[3]
* link:loc_database_get_as[3]
* link:loc_database_get_country[3]
== Copying
-Copyright (C) 2022 {author}. +
+Copyright (C) 2022 IPFire Development Team. +
This library is free software; you can redistribute it and/or modify it under the terms
of the GNU Lesser General Public License as published by the Free Software Foundation;
either version 2.1 of the License, or (at your option) any later version.
loc_database_get_country - Fetch country information from the database
== Synopsis
+[verse]
#include <libloc/database.h>
loc_database_lookup - Lookup a network from the database
== Synopsis
+[verse]
#include <libloc/database.h>
_loc_database_lookup_ takes the IP address as _struct in6_addr_ format which can either
be a regular IPv6 address or a mapped IPv4 address.
-_loc_database_lookup_string_ takes the IP address as string and will parse it automatically.
+_loc_database_lookup_from_string_ takes the IP address as string and will parse it automatically.
== Return Value
== Name
-loc_database_new - Create a new libloc context
+loc_database_new - Open a location database
== Synopsis
[verse]
== Description
-loc_database_new() opens a new database from the given file descriptor.
-The file descriptor can be closed after this operation because the function is creating
-its own copy.
+loc_database_new() opens a new database from the given file handle.
+The file handle can be closed after this operation because the function duplicates
+the underlying file descriptor.
If the database could be opened successfully, zero is returned. Otherwise a non-zero
return code will indicate an error and errno will be set appropriately.
== Description
-Every operation in libloc requires to set up a context first.
+Every operation in libloc requires a context to be set up first.
This is done by calling loc_new(3).
Every time another part of your code is holding a reference to the context,
--- /dev/null
+= loc_set_log_callback(3)
+
+== Name
+
+loc_set_log_callback - Set a callback for log messages
+
+== Synopsis
+[verse]
+
+#include <libloc/libloc.h>
+
+typedef void ({empty}*loc_log_callback)(struct loc_ctx{empty}* ctx, void{empty}* data,
+ int priority, const char{empty}* file, int line, const char{empty}* fn,
+ const char{empty}* format, va_list args);
+
+void loc_set_log_callback(struct loc_ctx{empty}* ctx, loc_log_callback callback,
+ void{empty}* data);
+
+== Description
+
+libloc can use the calling application's logging system by setting this callback.
+
+It will be called once for each log message according to the configured log
+priority (see link:loc_set_log_priority[3]).
+
+_data_ is an opaque pointer which is passed through to the callback on every
+invocation.
+
+This function replaces the deprecated link:loc_set_log_fn[3].
+
+== See Also
+
+link:libloc[3]
+
+== Authors
+
+Michael Tremer
void loc_set_log_fn(struct loc_ctx{empty}* ctx,
void ({empty}*log_fn)(struct loc_ctx{empty}* ctx, int priority,
const char{empty}* file, int line, const char{empty}* fn, const char{empty}* format,
- va_list args)
+ va_list args));
== Description
-libloc can use the calling application's logging system by setting this callback.
+This function is deprecated and has no effect.
-It will be called once for each log message according to the configured log level.
+Use link:loc_set_log_callback[3] to send log messages to the calling
+application's logging system instead.
== See Also
link:libloc[3]
+link:loc_set_log_callback[3]
== Authors
#include <libloc/libloc.h>
-void loc_set_log_priority(struct loc_ctx{empty}* ctx, int priority)
+void loc_set_log_priority(struct loc_ctx{empty}* ctx, int priority);
== Description
== See Also
link:libloc[3]
-link:loc_set_log_fn(3)
+link:loc_set_log_fn[3]
== Authors
== SYNOPSIS
[verse]
-`location export --directory=DIR [--format=FORMAT] [--family=ipv6|ipv4] [ASN|CC ...]`
+`location dump [OUTPUT]`
+`location export [--directory=DIR] [--format=FORMAT] [--family=ipv6|ipv4] [ASN|CC ...]`
+`location export-zone --output=FILE --origin=ORIGIN [--ttl=TTL] [--master=MASTER] [--zonemaster=EMAIL] [--nameserver=NS ...] TYPE`
`location get-as ASN [ASN...]`
+`location list-bogons [--family=ipv6|ipv4] [--format=FORMAT]`
`location list-countries [--show-name] [--show-continent]`
-`location list-networks-by-as ASN`
-`location list-networks-by-cc COUNTRY_CODE`
-`location list-networks-by-flags [--anonymous-proxy|--satellite-provider|--anycast|--drop]`
+`location list-networks-by-as [--family=ipv6|ipv4] [--format=FORMAT] ASN`
+`location list-networks-by-cc [--family=ipv6|ipv4] [--format=FORMAT] COUNTRY_CODE`
+`location list-networks-by-flags [--family=ipv6|ipv4] [--format=FORMAT] [--anonymous-proxy|--satellite-provider|--anycast|--drop]`
`location lookup ADDRESS [ADDRESS...]`
`location search-as STRING`
`location update [--cron=daily|weekly|monthly]`
+
If this option is omitted, the system's database will be opened.
+--public-key FILE::
+-k FILE::
+ The path of the public key which is used to verify the database
+ (see 'verify' command).
+ +
+ If this option is omitted, the vendor's public key that is shipped
+ with libloc will be used.
+
--quiet::
Enable quiet mode
== COMMANDS
+'dump [OUTPUT]'::
+ This command dumps the entire database as text, preceded by a header
+ with its metadata (creation time, vendor, license, and description).
+ +
+ The output is written to the given file, or to stdout if OUTPUT is
+ omitted.
+
'export [--directory=DIR] [--format=FORMAT] [--family=ipv6|ipv4] [ASN|CC ...]'::
This command exports the whole database into the given directory.
+
If the '--directory' option is omitted, the output will be written to stdout which
is useful when you want to load any custom exports straight into nftables or ipset.
+'export-zone --output=FILE --origin=ORIGIN [--ttl=TTL] [--master=MASTER] [--zonemaster=EMAIL] [--nameserver=NS ...] TYPE'::
+ This command exports the database as a DNS zone file.
+ +
+ TYPE selects which data is being exported: 'asn' (AS names), 'cc'
+ (country codes of all networks), 'bogons', 'origin' (the AS of each
+ network), 'prefix', or 'everything'.
+ +
+ The zone is written to the file given with '--output' and rooted at
+ the origin given with '--origin'. Both options are required.
+ +
+ The '--ttl', '--master', and '--zonemaster' parameters set the TTL,
+ the zone master, and the email address of the zone's administrator,
+ respectively. Nameservers can be added to the zone by passing
+ '--nameserver' one or more times.
+
'get-as ASN [ASN...]'::
This command returns the name of the owning organisation of the Autonomous
System.
'list-networks-by-cc [--family=[ipv6|ipv4]] [--format=FORMAT] COUNTRY_CODE'::
Lists all networks that belong to a country.
+
- The country has to be encoded in ISO3166 Alpha-2 notation.
+ The country has to be encoded in ISO 3166 Alpha-2 notation.
+
See above for usage of the '--family' and '--format' parameters.
Shows a short help text on using this program.
'--version'::
- Shows the program's version and exists.
+ Shows the program's version and exits.
== EXIT CODES
The 'location' command will normally exit with code zero.