From 5823e6e50bad432ff7b6ea6c3c0dc2dc9232b469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Mon, 5 Oct 2015 13:51:58 +0100 Subject: Remove duplicate transport ports from proto tree summary Don't display duplicate ports if transport name resolution is not enabled (for UDP/TCP/DCCP). Also introduce col_append_port() to handle info column port display with name resolution in a uniform format. Change-Id: Icb8ac45f726b7c539b4534c62061473e9b582753 Reviewed-on: https://code.wireshark.org/review/10804 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- epan/column-utils.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'epan/column-utils.c') diff --git a/epan/column-utils.c b/epan/column-utils.c index 8db8521e67..b52e08ff8f 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -410,7 +410,7 @@ col_append_lstr(column_info *cinfo, const gint el, const gchar *str1, ...) } void -col_append_str_uint(column_info *cinfo, const gint col, const gchar *sep, const gchar *abbrev, guint32 val) +col_append_str_uint(column_info *cinfo, const gint col, const gchar *abbrev, guint32 val, const gchar *sep) { char buf[16]; @@ -418,6 +418,21 @@ col_append_str_uint(column_info *cinfo, const gint col, const gchar *sep, const col_append_lstr(cinfo, col, sep ? sep : "", abbrev, "=", buf, COL_ADD_LSTR_TERMINATOR); } +void +col_append_port(column_info *cinfo, const gint col, port_type typ, guint16 val, const gchar *sep) +{ + const char *str; + char buf[32]; + + if (gbl_resolv_flags.transport_name && + (str = try_serv_name_lookup(typ, val)) != NULL) { + g_snprintf(buf, sizeof(buf), "%s(%u)", str, val); + } else { + g_snprintf(buf, sizeof(buf), "%u", val); + } + col_append_lstr(cinfo, col, sep ? sep : "", buf, COL_ADD_LSTR_TERMINATOR); +} + static void col_do_append_fstr(column_info *cinfo, const int el, const char *separator, const char *format, va_list ap) { -- cgit v1.2.1