summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorAnthony Coddington <anthony.coddington@endace.com>2017-06-09 20:03:38 +1200
committerMichael Mann <mmann78@netscape.net>2017-06-19 14:33:09 +0000
commit193cef0bcbcab25b95b4f124920d004ceaa7ae8a (patch)
tree6bcaa542e1a1bb57a6a9306775541718949a9f1a /epan
parent6ecd6b816406597783ec662f00233f3a018553f7 (diff)
downloadwireshark-193cef0bcbcab25b95b4f124920d004ceaa7ae8a.tar.gz
Attempt to clean up addr_resolv flags by removing DUMMY_ADDRESS_ENTRY
Replace with easier to understand and already present NAME_RESOLVED given dummy address is always filled. Change-Id: If8464f89e88722aac70689749fe0d4a31c119db2 Bug: 13798 Reviewed-on: https://code.wireshark.org/review/22110 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r--epan/addr_resolv.c30
-rw-r--r--epan/addr_resolv.h9
2 files changed, 14 insertions, 25 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 7cf134c6c2..97c5ef6412 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -131,6 +131,7 @@
typedef struct sub_net_hashipv4 {
guint addr;
+ /* XXX: No longer needed?*/
guint8 flags; /* B0 dummy_entry, B1 resolve, B2 If the address is used in the trace */
struct sub_net_hashipv4 *next;
gchar name[MAXNAMELEN];
@@ -688,10 +689,7 @@ fill_dummy_ip4(const guint addr, hashipv4_t* volatile tp)
{
subnet_entry_t subnet_entry;
- if (tp->flags & DUMMY_ADDRESS_ENTRY)
- return; /* already done */
-
- tp->flags |= DUMMY_ADDRESS_ENTRY; /* Overwrite if we get async DNS reply */
+ /* Overwrite if we get async DNS reply */
/* Do we have a subnet for this address? */
subnet_entry = subnet_lookup(addr);
@@ -723,6 +721,7 @@ fill_dummy_ip4(const guint addr, hashipv4_t* volatile tp)
*/
g_snprintf(tp->name, MAXNAMELEN, "%s%s", subnet_entry.name, paddr);
} else {
+ /* XXX: This means we end up printing "1.2.3.4 (1.2.3.4)" in many cases */
ip_to_str_buf((const guint8 *)&addr, tp->name, MAXNAMELEN);
}
}
@@ -733,10 +732,7 @@ fill_dummy_ip4(const guint addr, hashipv4_t* volatile tp)
static void
fill_dummy_ip6(hashipv6_t* volatile tp)
{
- if (tp->flags & DUMMY_ADDRESS_ENTRY)
- return; /* already done */
-
- tp->flags |= DUMMY_ADDRESS_ENTRY; /* Overwrite if we get async DNS reply */
+ /* Overwrite if we get async DNS reply */
g_strlcpy(tp->name, tp->ip6, MAXNAMELEN);
}
@@ -805,8 +801,9 @@ host_lookup(const guint addr)
* and then try to resolve it.
*/
tp = new_ipv4(addr);
+ fill_dummy_ip4(addr, tp);
wmem_map_insert(ipv4_hash_table, GUINT_TO_POINTER(addr), tp);
- } else if ((tp->flags & DUMMY_AND_RESOLVE_FLGS) != DUMMY_ADDRESS_ENTRY) {
+ } else if (tp->flags & TRIED_OR_RESOLVED_MASK) {
return tp;
}
@@ -815,7 +812,6 @@ host_lookup(const guint addr)
* resolve it already.
*/
- fill_dummy_ip4(addr, tp);
if (!gbl_resolv_flags.network_name)
return tp;
@@ -865,8 +861,9 @@ host_lookup6(const struct e_in6_addr *addr)
addr_key = wmem_new(wmem_epan_scope(), struct e_in6_addr);
tp = new_ipv6(addr);
memcpy(addr_key, addr, 16);
+ fill_dummy_ip6(tp);
wmem_map_insert(ipv6_hash_table, addr_key, tp);
- } else if ((tp->flags & DUMMY_AND_RESOLVE_FLGS) != DUMMY_ADDRESS_ENTRY) {
+ } else if (tp->flags & TRIED_OR_RESOLVED_MASK) {
return tp;
}
@@ -875,7 +872,6 @@ host_lookup6(const struct e_in6_addr *addr)
* resolve it already.
*/
- fill_dummy_ip6(tp);
if (!gbl_resolv_flags.network_name)
return tp;
@@ -2102,7 +2098,7 @@ ipv4_hash_table_resolved_to_list(gpointer key _U_, gpointer value, gpointer user
addrinfo_lists_t *lists = (addrinfo_lists_t*)user_data;
hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value;
- if ((ipv4_hash_table_entry->flags & USED_AND_RESOLVED_MASK) == RESOLVED_ADDRESS_USED) {
+ if ((ipv4_hash_table_entry->flags & USED_AND_RESOLVED_MASK) == USED_AND_RESOLVED_MASK) {
lists->ipv4_addr_list = g_list_prepend(lists->ipv4_addr_list, ipv4_hash_table_entry);
}
@@ -2118,7 +2114,7 @@ ipv6_hash_table_resolved_to_list(gpointer key _U_, gpointer value, gpointer user
addrinfo_lists_t *lists = (addrinfo_lists_t*)user_data;
hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value;
- if ((ipv6_hash_table_entry->flags & USED_AND_RESOLVED_MASK) == RESOLVED_ADDRESS_USED) {
+ if ((ipv6_hash_table_entry->flags & USED_AND_RESOLVED_MASK) == USED_AND_RESOLVED_MASK) {
lists->ipv6_addr_list = g_list_prepend (lists->ipv6_addr_list, ipv6_hash_table_entry);
}
@@ -2293,8 +2289,6 @@ subnet_entry_set(guint32 subnet_addr, const guint8 mask_length, const gchar* nam
tp->next = NULL;
tp->addr = subnet_addr;
- /* Clear DUMMY_ADDRESS_ENTRY */
- tp->flags &= ~DUMMY_ADDRESS_ENTRY; /*Never used again...*/
g_strlcpy(tp->name, name, MAXNAMELEN); /* This is longer than subnet names can actually be */
have_subnet_entry = TRUE;
}
@@ -2711,8 +2705,6 @@ add_ipv4_name(const guint addr, const gchar *name)
new_resolved_objects = TRUE;
}
tp->flags |= TRIED_RESOLVE_ADDRESS|NAME_RESOLVED;
- /* Clear DUMMY_ADDRESS_ENTRY */
- tp->flags &= ~DUMMY_ADDRESS_ENTRY;
} /* add_ipv4_name */
/* -------------------------- */
@@ -2743,8 +2735,6 @@ add_ipv6_name(const struct e_in6_addr *addrp, const gchar *name)
new_resolved_objects = TRUE;
}
tp->flags |= TRIED_RESOLVE_ADDRESS|NAME_RESOLVED;
- /* Clear DUMMY_ADDRESS_ENTRY */
- tp->flags &= ~DUMMY_ADDRESS_ENTRY;
} /* add_ipv6_name */
static void
diff --git a/epan/addr_resolv.h b/epan/addr_resolv.h
index 88955ebc72..20445379b4 100644
--- a/epan/addr_resolv.h
+++ b/epan/addr_resolv.h
@@ -88,13 +88,12 @@ typedef struct serv_port {
/*
* Flags for various IPv4/IPv6 hash table entries.
*/
-#define DUMMY_ADDRESS_ENTRY (1U<<0) /* XXX - what does this bit *really* mean? */
-#define TRIED_RESOLVE_ADDRESS (1U<<1) /* XXX - what does this bit *really* mean? */
+#define TRIED_RESOLVE_ADDRESS (1U<<0) /* XXX - what does this bit *really* mean? */
+#define NAME_RESOLVED (1U<<1) /* the name field contains a host name, not a printable address */
#define RESOLVED_ADDRESS_USED (1U<<2) /* a get_hostname* call returned the host name */
-#define NAME_RESOLVED (1U<<3) /* the name field contains a host name, not a printable address */
-#define DUMMY_AND_RESOLVE_FLGS (DUMMY_ADDRESS_ENTRY | TRIED_RESOLVE_ADDRESS)
-#define USED_AND_RESOLVED_MASK (DUMMY_ADDRESS_ENTRY | RESOLVED_ADDRESS_USED)
+#define TRIED_OR_RESOLVED_MASK (TRIED_RESOLVE_ADDRESS | NAME_RESOLVED)
+#define USED_AND_RESOLVED_MASK (NAME_RESOLVED | RESOLVED_ADDRESS_USED)
/*
* Flag controlling what names to resolve.