2 * GeoIP database support
6 * Copyright 2008, Gerald Combs <gerald@wireshark.org>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #ifndef __GEOIP_DB_H__
28 #define __GEOIP_DB_H__
30 #include <epan/ipv6-utils.h>
32 /* Fake databases to make lat/lon values available */
33 /* XXX - find a better way to interface */
34 #define WS_LAT_FAKE_EDITION (NUM_DB_TYPES+1)
35 #define WS_LON_FAKE_EDITION (NUM_DB_TYPES+2)
39 * Init function called from epan.h
41 extern void geoip_db_init(void);
44 * Number of databases we have loaded
46 * @return The number GeoIP databases successfully loaded
48 extern guint geoip_db_num_dbs(void);
51 * Fetch the name of a database
53 * @param dbnum Database index
54 * @return The database name or "Invalid database"
56 extern const gchar *geoip_db_name(guint dbnum);
59 * Fetch the database type. Types are enumerated in GeoIPDBTypes in GeoIP.h.
61 * @param dbnum Database index
62 * @return The database type or -1
64 extern int geoip_db_type(guint dbnum);
67 * Look up an IPv4 address in a database
69 * @param dbnum Database index
70 * @param addr IPv4 address to look up
71 * @param not_found The string to return if the lookup fails. May be NULL.
72 * @return The database entry if found, else not_found
74 extern const char *geoip_db_lookup_ipv4(guint dbnum, guint32 addr, char *not_found);
77 * Look up an IPv6 address in a database
79 * @param dbnum Database index
80 * @param addr IPv6 address to look up
81 * @param not_found The string to return if the lookup fails. May be NULL.
82 * @return The database entry if found, else not_found
84 extern const char *geoip_db_lookup_ipv6(guint dbnum, struct e_in6_addr addr, char *not_found);
87 * Get all configured paths
89 * @return String with all paths separated by a path separator
91 extern gchar *geoip_db_get_paths(void);
93 #endif /* __GEOIP_DB_H__ */