diff options
author | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-09-07 16:05:37 +0000 |
---|---|---|
committer | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-09-07 16:05:37 +0000 |
commit | 72c9662da6a474c89d96d2d0160d5a24ed4129c1 (patch) | |
tree | 42b2d7c425c4fa565b484a7c0b63f8b0257782bc /epan | |
parent | ea0ab046e0116f46cefcda47dcc75e40066b784d (diff) |
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')
-rw-r--r-- | epan/addr_resolv.c | 60 | ||||
-rw-r--r-- | epan/addr_resolv.h | 1 | ||||
-rw-r--r-- | epan/column-utils.c | 7 |
3 files changed, 59 insertions, 9 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) { diff --git a/epan/addr_resolv.h b/epan/addr_resolv.h index 87300f6158..d07f19184c 100644 --- a/epan/addr_resolv.h +++ b/epan/addr_resolv.h @@ -107,6 +107,7 @@ extern gchar *get_sctp_port(guint port); /* address 10.10.10.10 */ const gchar *get_addr_name(address *addr); +const gchar *se_get_addr_name(address *addr); /* get_addr_name_buf solves an address in the same way as get_addr_name above */ /* The difference is that get_addr_name_buf takes as input a buffer, into which it puts */ diff --git a/epan/column-utils.c b/epan/column-utils.c index 8c4110f930..7910e65b00 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -1163,10 +1163,15 @@ col_set_addr(packet_info *pinfo, int col, address *addr, gboolean is_res _U_, struct e_in6_addr ipv6_addr; if (addr->type == AT_NONE) - return; /* no address, nothing to do */ + /* No address, nothing to do */ + return; +#ifdef NEW_PACKET_LIST + pinfo->cinfo->col_data[col] = se_get_addr_name(addr); +#else get_addr_name_buf(addr, pinfo->cinfo->col_buf[col], COL_MAX_LEN); pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; +#endif switch (addr->type) { |