summaryrefslogtreecommitdiff
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-07 16:05:37 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-07 16:05:37 +0000
commit72c9662da6a474c89d96d2d0160d5a24ed4129c1 (patch)
tree42b2d7c425c4fa565b484a7c0b63f8b0257782bc /epan/addr_resolv.c
parentea0ab046e0116f46cefcda47dcc75e40066b784d (diff)
downloadwireshark-72c9662da6a474c89d96d2d0160d5a24ed4129c1.tar.gz
ntroduce some seasonal address name lookup functions which we use when NEW_PACKET_LIST is defined. This change partially reverts some parts of r29768, which didn't seem to work because it assumed that get_addr_name() would always return a seasonal string. This wasn't the case if the adddress type was AT_STRINGZ.
svn path=/trunk/; revision=29771
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c60
1 files changed, 52 insertions, 8 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 3dbc58684c..871e17b6d3 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -1004,6 +1004,33 @@ static const gchar *solve_address_to_name(address *addr)
}
}
+static const gchar *se_solve_address_to_name(address *addr)
+{
+ switch (addr->type) {
+
+ case AT_ETHER:
+ return get_ether_name(addr->data);
+
+ case AT_IPv4: {
+ guint32 ipv4_addr;
+ memcpy(&ipv4_addr, addr->data, sizeof ipv4_addr);
+ return get_hostname(ipv4_addr);
+ }
+
+ case AT_IPv6: {
+ struct e_in6_addr ipv6_addr;
+ memcpy(&ipv6_addr.bytes, addr->data, sizeof ipv6_addr.bytes);
+ return get_hostname6(&ipv6_addr);
+ }
+
+ case AT_STRINGZ:
+ return se_strdup(addr->data);
+
+ default:
+ return NULL;
+ }
+}
+
/*
* Ethernet / manufacturer resolution
*
@@ -2683,28 +2710,45 @@ extern gchar *get_sctp_port(guint port)
} /* get_sctp_port */
-
const gchar *get_addr_name(address *addr)
{
const gchar *result;
result = solve_address_to_name(addr);
- if (result!=NULL){
- return result;
+ if (result != NULL)
+ return result;
+
+ /* if it gets here, either it is of type AT_NONE, */
+ /* or it should be solvable in address_to_str -unless addr->type is wrongly defined */
+
+ if (addr->type == AT_NONE){
+ return "NONE";
}
+ /* We need an ephemeral allocated string */
+ return ep_address_to_str(addr);
+}
+
+const gchar *se_get_addr_name(address *addr)
+{
+ const gchar *result;
+
+ result = se_solve_address_to_name(addr);
+
+ if (result != NULL)
+ return result;
+
/* if it gets here, either it is of type AT_NONE, */
- /* or it should be solvable in se_address_to_str -unless addr->type is wrongly defined- */
+ /* or it should be solvable in se_address_to_str -unless addr->type is wrongly defined */
if (addr->type == AT_NONE){
- return "NONE";
+ return "NONE";
}
/* We need a "permanently" allocated string */
- return(se_address_to_str(addr));
-} /* get_addr_name */
-
+ return se_address_to_str(addr);
+}
void get_addr_name_buf(address *addr, gchar *buf, gsize size)
{