Add Mike Garratt to the list of authors for (at the very least) his contributions...
[metze/wireshark/wip.git] / epan / geoip_db.h
1 /* geoip_db.h
2  * GeoIP database support
3  *
4  * $Id$
5  *
6  * Copyright 2008, Gerald Combs <gerald@wireshark.org>
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
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.
16  *
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.
21  *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26
27 #ifndef __GEOIP_DB_H__
28 #define __GEOIP_DB_H__
29
30 #include <epan/ipv6-utils.h>
31 #include <epan/prefs.h>
32 #include "ws_symbol_export.h"
33
34 /* Fake databases to make lat/lon values available */
35 /* XXX - find a better way to interface */
36 #define WS_LAT_FAKE_EDITION (NUM_DB_TYPES+1)
37 #define WS_LON_FAKE_EDITION (NUM_DB_TYPES+2)
38
39
40 /**
41  * Init function called from epan.h
42  */
43 extern void geoip_db_pref_init(module_t *nameres);
44
45 /**
46  * Number of databases we have loaded
47  *
48  * @return The number GeoIP databases successfully loaded
49  */
50 WS_DLL_PUBLIC guint geoip_db_num_dbs(void);
51
52 /**
53  * Fetch the name of a database
54  *
55  * @param dbnum Database index
56  * @return The database name or "Invalid database"
57  */
58 WS_DLL_PUBLIC const gchar *geoip_db_name(guint dbnum);
59
60 /**
61  * Fetch the database type. Types are enumerated in GeoIPDBTypes in GeoIP.h.
62  *
63  * @param dbnum Database index
64  * @return The database type or -1
65  */
66 WS_DLL_PUBLIC int geoip_db_type(guint dbnum);
67
68 /**
69  * Look up an IPv4 address in a database
70  *
71  * @param dbnum Database index
72  * @param addr IPv4 address to look up
73  * @param not_found The string to return if the lookup fails. May be NULL.
74  * @return The database entry if found, else not_found
75  */
76 WS_DLL_PUBLIC const char *geoip_db_lookup_ipv4(guint dbnum, guint32 addr, const char *not_found);
77
78 /**
79  * Look up an IPv6 address in a database
80  *
81  * @param dbnum Database index
82  * @param addr IPv6 address to look up
83  * @param not_found The string to return if the lookup fails. May be NULL.
84  * @return The database entry if found, else not_found
85  */
86 WS_DLL_PUBLIC const char *geoip_db_lookup_ipv6(guint dbnum, struct e_in6_addr addr, const char *not_found);
87
88 /**
89  * Get all configured paths
90  *
91  * @return String with all paths separated by a path separator
92  */
93 WS_DLL_PUBLIC gchar *geoip_db_get_paths(void);
94
95 #endif /* __GEOIP_DB_H__ */