diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-02-08 17:20:26 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2018-03-06 18:02:21 +0000 |
commit | a1da75c554881667dd92e11f098630f2d604872b (patch) | |
tree | b1d6a60a663bf93f1eede809a0c383544508d6e2 /epan/maxmind_db.h | |
parent | b2d3680558d19998c55b48e9807a26e145756eba (diff) |
Transition from GeoIP Legacy to MaxMindDB.
MaxMind is discontinuing its legacy databases in April in favor of
GeoIP2, which use a newer database format (MaxMind DB). The reference C
library (libmaxminddb) is available under the Apache 2.0 license which
isn't quite compatible with ours.
Add mmdbresolve, a utility that reads IPv4 and IPv6 addresses on stdin
and prints resolved information on stdout. Place it under a liberal
license (MIT) so that we can keep libmaxminddb at arm's length. Add
epan/maxmind_db.[ch], which spawns mmdbresolve and communicates with it
via stdio.
Migrate the preferences and documentation to MaxMindDB.
Change the IPv4 and IPv6 asnum fields to FT_UINT32s. Change the
geographic coordinate fields to FT_DOUBLEs.
Bug: 10658
Change-Id: I24aeed637bea1b41d173270bda413af230f4425f
Reviewed-on: https://code.wireshark.org/review/26214
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/maxmind_db.h')
-rw-r--r-- | epan/maxmind_db.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/epan/maxmind_db.h b/epan/maxmind_db.h new file mode 100644 index 0000000000..1b8e5fed0a --- /dev/null +++ b/epan/maxmind_db.h @@ -0,0 +1,93 @@ +/* maxmind_db.h + * Maxmind database support + * + * Copyright 2018, Gerald Combs <gerald@wireshark.org> + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef __MAXMIND_DB_H__ +#define __MAXMIND_DB_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <epan/ipv6.h> +#include <epan/prefs.h> +#include "ws_symbol_export.h" + +typedef struct _mmdb_lookup_t { + gboolean found; + const char *country; + const char *city; + unsigned int as_number; + const char *as_org; + double latitude; + double longitude; +} mmdb_lookup_t; + +/** + * Init function called from epan.h + */ +WS_DLL_LOCAL void maxmind_db_pref_init(module_t *nameres); + +/** + * Cleanup function called from epan.h + */ +WS_DLL_LOCAL void maxmind_db_pref_cleanup(void); + +/** + * Look up an IPv4 address in a database + * + * @param addr IPv4 address to look up + * + * @return The database entry if found, else NULL. + */ +WS_DLL_PUBLIC WS_RETNONNULL const mmdb_lookup_t *maxmind_db_lookup_ipv4(guint32 addr); + +/** + * Look up an IPv6 address in a database + * + * @param addr IPv6 address to look up + * + * @return The database entry if found, else NULL. + */ +WS_DLL_PUBLIC WS_RETNONNULL const mmdb_lookup_t *maxmind_db_lookup_ipv6(const ws_in6_addr *addr); + +/** + * Get all configured paths + * + * @return String with all paths separated by a path separator + */ +WS_DLL_PUBLIC gchar *maxmind_db_get_paths(void); + +/** + * Process outstanding requests. + * + * @return True if any new addresses were resolved. + */ +WS_DLL_LOCAL gboolean maxmind_db_lookup_process(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __MAXMIND_DB_H__ */ + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ |