diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2016-07-29 18:29:00 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2016-07-30 12:23:50 +0000 |
commit | 9e747b9c388df04b49d2794a59285d88a583ffc0 (patch) | |
tree | 4fd0a7ca4e53bf2658ac812f4653f890e3092d92 | |
parent | fd84add714e8d64c623007adec139f98126d33f5 (diff) | |
download | wireshark-9e747b9c388df04b49d2794a59285d88a583ffc0.tar.gz |
Add GeoIP database UN*X system path
Most distros provide GeoIP database packages that install to /usr/share/GeoIP.
Use this as a system default.
Change-Id: I2b4ddf7e2467263491b18a97e908a247db0ac9a3
Reviewed-on: https://code.wireshark.org/review/16767
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
-rw-r--r-- | epan/geoip_db.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/epan/geoip_db.c b/epan/geoip_db.c index 01b743bc26..d22c439794 100644 --- a/epan/geoip_db.c +++ b/epan/geoip_db.c @@ -90,6 +90,12 @@ typedef struct _geoip_db_path_t { static geoip_db_path_t *geoip_db_paths = NULL; static guint num_geoip_db_paths = 0; +static const geoip_db_path_t geoip_db_system_paths[] = { +#ifdef G_OS_UNIX + { "/usr/share/GeoIP" }, +#endif + { NULL } +}; static uat_t *geoip_db_paths_uat = NULL; UAT_DIRECTORYNAME_CB_DEF(geoip_mod, path, geoip_db_path_t) @@ -171,6 +177,11 @@ static void geoip_db_post_update_cb(void) { /* allocate the array */ geoip_dat_arr = g_array_new(FALSE, FALSE, sizeof(GeoIP *)); + /* First try the system paths */ + for (i = 0; geoip_db_system_paths[i].path != NULL; i++) { + geoip_dat_scan_dir(geoip_db_system_paths[i].path); + } + /* Walk all the directories */ for (i = 0; i < num_geoip_db_paths; i++) { if (geoip_db_paths[i].path) { @@ -540,19 +551,19 @@ geoip_db_lookup_ipv6(guint dbnum _U_, struct e_in6_addr addr _U_, const char *no gchar * geoip_db_get_paths(void) { GString* path_str = NULL; - char path_separator; guint i; path_str = g_string_new(""); -#ifdef _WIN32 - path_separator = ';'; -#else - path_separator = ':'; -#endif + + for (i = 0; geoip_db_system_paths[i].path != NULL; i++) { + g_string_append_printf(path_str, + "%s" G_SEARCHPATH_SEPARATOR_S, geoip_db_system_paths[i].path); + } for (i = 0; i < num_geoip_db_paths; i++) { if (geoip_db_paths[i].path) { - g_string_append_printf(path_str, "%s%c", geoip_db_paths[i].path, path_separator); + g_string_append_printf(path_str, + "%s" G_SEARCHPATH_SEPARATOR_S, geoip_db_paths[i].path); } } |