Snort: speed up parsing of options by avoiding g_snprintf()
[metze/wireshark/wip.git] / epan / geoip_db.h
1 /* geoip_db.h
2  * GeoIP database support
3  *
4  * Copyright 2008, Gerald Combs <gerald@wireshark.org>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #ifndef __GEOIP_DB_H__
26 #define __GEOIP_DB_H__
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 #include <epan/ipv6.h>
33 #include <epan/prefs.h>
34 #include "ws_symbol_export.h"
35
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)
40
41
42 /**
43  * Init function called from epan.h
44  */
45 extern void geoip_db_pref_init(module_t *nameres);
46
47 /**
48  * Number of databases we have loaded
49  *
50  * @return The number GeoIP databases successfully loaded
51  */
52 WS_DLL_PUBLIC guint geoip_db_num_dbs(void);
53
54 /**
55  * Fetch the name of a database
56  *
57  * @param dbnum Database index
58  * @return The database name or "Invalid database"
59  */
60 WS_DLL_PUBLIC const gchar *geoip_db_name(guint dbnum);
61
62 /**
63  * Fetch the database type. Types are enumerated in GeoIPDBTypes in GeoIP.h.
64  *
65  * @param dbnum Database index
66  * @return The database type or -1
67  */
68 WS_DLL_PUBLIC int geoip_db_type(guint dbnum);
69
70 /**
71  * Look up an IPv4 address in a database
72  *
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.
76  *
77  * @return The database entry if found, else not_found. Return value must be freed with wmem_free.
78  */
79 WS_DLL_PUBLIC char *geoip_db_lookup_ipv4(guint dbnum, guint32 addr, const char *not_found);
80
81 /**
82  * Look up an IPv6 address in a database
83  *
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.
87  *
88  * @return The database entry if found, else not_found. Return value must be freed with wmem_free.
89  */
90 WS_DLL_PUBLIC char *geoip_db_lookup_ipv6(guint dbnum, ws_in6_addr addr, const char *not_found);
91
92 /**
93  * Get all configured paths
94  *
95  * @return String with all paths separated by a path separator
96  */
97 WS_DLL_PUBLIC gchar *geoip_db_get_paths(void);
98
99 #ifdef __cplusplus
100 }
101 #endif /* __cplusplus */
102
103 #endif /* __GEOIP_DB_H__ */
104
105 /*
106  * Editor modelines
107  *
108  * Local Variables:
109  * c-basic-offset: 4
110  * tab-width: 8
111  * indent-tabs-mode: nil
112  * End:
113  *
114  * ex: set shiftwidth=4 tabstop=8 expandtab:
115  * :indentSize=4:tabSize=8:noTabs=true:
116  */