2 * GeoIP database support
4 * Copyright 2008, Gerald Combs <gerald@wireshark.org>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __GEOIP_DB_H__
26 #define __GEOIP_DB_H__
30 #endif /* __cplusplus */
32 #include <epan/ipv6.h>
33 #include <epan/prefs.h>
34 #include "ws_symbol_export.h"
36 /* Fake databases to make lat/lon values available */
37 /* XXX - find a better way to interface */
38 #define WS_LAT_FAKE_EDITION (NUM_DB_TYPES+1)
39 #define WS_LON_FAKE_EDITION (NUM_DB_TYPES+2)
43 * Init function called from epan.h
45 extern void geoip_db_pref_init(module_t *nameres);
48 * Number of databases we have loaded
50 * @return The number GeoIP databases successfully loaded
52 WS_DLL_PUBLIC guint geoip_db_num_dbs(void);
55 * Fetch the name of a database
57 * @param dbnum Database index
58 * @return The database name or "Invalid database"
60 WS_DLL_PUBLIC const gchar *geoip_db_name(guint dbnum);
63 * Fetch the database type. Types are enumerated in GeoIPDBTypes in GeoIP.h.
65 * @param dbnum Database index
66 * @return The database type or -1
68 WS_DLL_PUBLIC int geoip_db_type(guint dbnum);
71 * Look up an IPv4 address in a database
73 * @param dbnum Database index
74 * @param addr IPv4 address to look up
75 * @param not_found The string to return if the lookup fails. May be NULL.
77 * @return The database entry if found, else not_found. Return value must be freed with wmem_free.
79 WS_DLL_PUBLIC char *geoip_db_lookup_ipv4(guint dbnum, guint32 addr, const char *not_found);
82 * Look up an IPv6 address in a database
84 * @param dbnum Database index
85 * @param addr IPv6 address to look up
86 * @param not_found The string to return if the lookup fails. May be NULL.
88 * @return The database entry if found, else not_found. Return value must be freed with wmem_free.
90 WS_DLL_PUBLIC char *geoip_db_lookup_ipv6(guint dbnum, struct e_in6_addr addr, const char *not_found);
93 * Get all configured paths
95 * @return String with all paths separated by a path separator
97 WS_DLL_PUBLIC gchar *geoip_db_get_paths(void);
101 #endif /* __cplusplus */
103 #endif /* __GEOIP_DB_H__ */
111 * indent-tabs-mode: nil
114 * ex: set shiftwidth=4 tabstop=8 expandtab:
115 * :indentSize=4:tabSize=8:noTabs=true: