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
This commit is contained in:
Kovarththanan Rajaratnam 2009-09-07 16:05:37 +00:00
parent ea0ab046e0
commit 72c9662da6
4 changed files with 78 additions and 27 deletions

View File

@ -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 se_address_to_str -unless addr->type is wrongly defined- */
/* or it should be solvable in address_to_str -unless addr->type is wrongly defined */
if (addr->type == AT_NONE){
return "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 */
if (addr->type == AT_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)
{

View File

@ -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 */

View File

@ -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) {

View File

@ -672,23 +672,24 @@ packet_list_change_record(PacketList *packet_list, guint row, gint col, column_i
switch (cfile.cinfo.col_fmt[col]) {
case COL_DEF_SRC:
case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
case COL_UNRES_SRC:
case COL_DEF_DL_SRC:
case COL_RES_DL_SRC:
case COL_UNRES_DL_SRC:
case COL_DEF_NET_SRC:
case COL_RES_NET_SRC:
case COL_UNRES_NET_SRC:
case COL_DEF_DST:
case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
case COL_UNRES_DST:
case COL_DEF_DL_DST:
case COL_RES_DL_DST:
case COL_UNRES_DL_DST:
case COL_DEF_NET_DST:
case COL_RES_NET_DST:
case COL_UNRES_NET_DST:
case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
case COL_UNRES_SRC:
case COL_DEF_DL_SRC:
case COL_RES_DL_SRC:
case COL_UNRES_DL_SRC:
case COL_DEF_NET_SRC:
case COL_RES_NET_SRC:
case COL_UNRES_NET_SRC:
case COL_DEF_DST:
case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
case COL_UNRES_DST:
case COL_DEF_DL_DST:
case COL_RES_DL_DST:
case COL_UNRES_DL_DST:
case COL_DEF_NET_DST:
case COL_RES_NET_DST:
case COL_UNRES_NET_DST:
g_assert(cinfo->col_data[col] != cinfo->col_buf[col]);
/* This is a constant string, so we don't have to copy it */
record->fdata->col_text[col] = (gchar *) cinfo->col_data[col];
record->fdata->col_text_len[col] = (guint) strlen(record->fdata->col_text[col]);