aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorUli Heilmeier <uh@heilmeier.eu>2019-05-26 12:59:07 +0200
committerAnders Broman <a.broman58@gmail.com>2019-05-27 08:34:33 +0000
commit26a4fb332b0febd39cf6f227ab54df36ee31ac7e (patch)
tree3241188b61a15aa991898047d309216f3e91b41f /epan/addr_resolv.c
parentbc5b71c00bbba559615877730a8da6ebb93606d3 (diff)
VLAN resolving: check profile first
If the profile directory contains a vlans file we will use it. Otherwise fall back to normal user preferences. Bug: 15795 Change-Id: Ie6a63a6f7a29bd83a15799875aa5883be7010039 Reviewed-on: https://code.wireshark.org/review/33378 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index bbb8bdf03b..7068db574d 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -247,6 +247,16 @@ static hashether_t *add_eth_name(const guint8 *addr, const gchar *name);
static void add_serv_port_cb(const guint32 port, gpointer ptr);
+static gboolean check_file_exists(const char * filename){
+ /* try to open file to read */
+ FILE *file;
+ if ((file = ws_fopen(filename, "r"))){
+ fclose(file);
+ return TRUE;
+ }
+ return FALSE;
+}
+
/* http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx#existing
* One-at-a-Time hash
*/
@@ -2109,9 +2119,14 @@ initialize_vlans(void)
/* Set g_pvlan_path here, but don't actually do anything
* with it. It's used in get_vlannamebyid()
*/
- if (g_pvlan_path == NULL)
- g_pvlan_path = get_persconffile_path(ENAME_VLANS, FALSE);
-
+ if (g_pvlan_path == NULL) {
+ /* Check profile directory before personal configuration */
+ g_pvlan_path = get_persconffile_path(ENAME_VLANS, TRUE);
+ if (!check_file_exists(g_pvlan_path)) {
+ g_free(g_pvlan_path);
+ g_pvlan_path = get_persconffile_path(ENAME_VLANS, FALSE);
+ }
+ }
} /* initialize_vlans */
static void
@@ -3047,6 +3062,8 @@ void host_name_lookup_reset(void)
{
host_name_lookup_cleanup();
host_name_lookup_init();
+ vlan_name_lookup_cleanup();
+ initialize_vlans();
}
void