From 39a61a1680b5a7405d7e81f9c15903fc958cc0cd Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Thu, 29 Aug 2013 18:59:49 +0000 Subject: [PATCH] Don't store address in the hastable when name resolution is off. svn path=/trunk/; revision=51577 --- epan/addr_resolv.c | 30 +++++++++++------------------- epan/addr_resolv.h | 2 -- ui/gtk/addr_resolution_dlg.c | 6 ++---- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index 8107cab2be..7bad2dcad1 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -899,7 +899,6 @@ new_ipv4(const guint addr) tp->addr = addr; tp->resolve = FALSE; tp->is_dummy_entry = FALSE; - ip_to_str_buf((const guint8 *)&addr, tp->ip, sizeof(tp->ip)); return tp; } @@ -985,7 +984,6 @@ new_ipv6(const struct e_in6_addr *addr) tp->addr = *addr; tp->resolve = FALSE; tp->is_dummy_entry = FALSE; - ip6_to_str_buf(addr, tp->ip6); return tp; } @@ -1040,7 +1038,6 @@ try_resolv: * going to risk changing the semantics. */ if (!tp->is_dummy_entry) { - g_strlcpy(tp->name, tp->ip6, MAXNAMELEN); ip6_to_str_buf(addr, tp->name); tp->is_dummy_entry = TRUE; } @@ -1062,7 +1059,6 @@ try_resolv: /* unknown host or DNS timeout */ if (!tp->is_dummy_entry) { tp->is_dummy_entry = TRUE; - g_strlcpy(tp->name, tp->ip6, MAXNAMELEN); } *found = FALSE; return tp; @@ -2656,14 +2652,12 @@ const gchar * get_hostname(const guint addr) { gboolean found; - - /* XXX why do we call this if we're not resolving? To create hash entries? - * Why? - */ - hashipv4_t *tp = host_lookup(addr, &found); + hashipv4_t *tp; if (!gbl_resolv_flags.network_name) - return tp->ip; + return ip_to_str((guint8*)&addr); + + tp = host_lookup(addr, &found); return tp->name; } @@ -2674,16 +2668,14 @@ const gchar * get_hostname6(const struct e_in6_addr *addr) { gboolean found; - - /* XXX why do we call this if we're not resolving? To create hash entries? - * Why? - */ - hashipv6_t *tp = host_lookup6(addr, &found); + hashipv6_t *tp; if (!gbl_resolv_flags.network_name) - return tp->ip6; + return ip6_to_str(addr); - return tp->name; + tp = host_lookup6(addr, &found); + + return tp->name; } /* -------------------------- */ @@ -2698,7 +2690,7 @@ add_ipv4_name(const guint addr, const gchar *name) * Don't add zero-length names; apparently, some resolvers will return * them if they get them from DNS. */ - if (name[0] == '\0') + if ((name[0] == '\0')||(!gbl_resolv_flags.network_name)) return; @@ -2753,7 +2745,7 @@ add_ipv6_name(const struct e_in6_addr *addrp, const gchar *name) * Don't add zero-length names; apparently, some resolvers will return * them if they get them from DNS. */ - if (name[0] == '\0') + if ((name[0] == '\0')||(!gbl_resolv_flags.network_name)) return; tp = (hashipv6_t *)g_hash_table_lookup(ipv6_hash_table, addrp); diff --git a/epan/addr_resolv.h b/epan/addr_resolv.h index c6743a3a2f..72f03def93 100644 --- a/epan/addr_resolv.h +++ b/epan/addr_resolv.h @@ -80,7 +80,6 @@ typedef struct hashipv4 { guint addr; gboolean is_dummy_entry; /* name is IPv4 address in dot format */ gboolean resolve; /* already tried to resolve it */ - gchar ip[16]; gchar name[MAXNAMELEN]; } hashipv4_t; @@ -89,7 +88,6 @@ typedef struct hashipv6 { struct e_in6_addr addr; gboolean is_dummy_entry; /* name is IPv6 address in colon format */ gboolean resolve; /* */ - gchar ip6[MAX_IP6_STR_LEN]; /* XX */ gchar name[MAXNAMELEN]; } hashipv6_t; /* diff --git a/ui/gtk/addr_resolution_dlg.c b/ui/gtk/addr_resolution_dlg.c index 919e872120..4cd82d7d1d 100644 --- a/ui/gtk/addr_resolution_dlg.c +++ b/ui/gtk/addr_resolution_dlg.c @@ -172,9 +172,8 @@ ipv4_hash_table_to_texbuff(gpointer key, gpointer value, gpointer user_data) hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value; int addr = *(int*)key; - g_snprintf(string_buff, ADDRESS_STR_MAX, "Key:0x%x IP: %s, Name: %s\n", + g_snprintf(string_buff, ADDRESS_STR_MAX, "Key:0x%x Name: %s\n", addr, - ipv4_hash_table_entry->ip, ipv4_hash_table_entry->name); gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1); @@ -188,8 +187,7 @@ ipv6_hash_table_to_texbuff(gpointer key _U_, gpointer value, gpointer user_data) GtkTextBuffer *buffer = (GtkTextBuffer*)user_data; hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value; - g_snprintf(string_buff, ADDRESS_STR_MAX, "IP: %s, Name: %s\n", - ipv6_hash_table_entry->ip6, + g_snprintf(string_buff, ADDRESS_STR_MAX, "Name: %s\n", ipv6_hash_table_entry->name); gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);