aboutsummaryrefslogtreecommitdiffstats
path: root/epan/addr_resolv.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2015-10-05 11:53:07 +0100
committerMichael Mann <mmann78@netscape.net>2015-10-05 18:10:48 +0000
commita459ac72a2c01ec12d186907837aff891e3e223b (patch)
tree01328590650245061ae8d78c02f14c8fbdde0381 /epan/addr_resolv.c
parentd52322efb3ab782871312950876803334ec018b9 (diff)
Add BASE_PT_ field display types
Avoid displaying duplicate port numbers with transport name resolution disabled and make some dissector code simpler. Introduces port_with_resolution_to_str_buf() function and amends UDP/TCP/DCCP/SCTP to use the new field display type. Change-Id: Ifb97810b9c669ccbb1a310a2c0ffd6e2b63af210 Reviewed-on: https://code.wireshark.org/review/10625 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/addr_resolv.c')
-rw-r--r--epan/addr_resolv.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 648d6274dc..8aab2bdc9c 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -621,8 +621,8 @@ wmem_utoa(wmem_allocator_t *allocator, guint port)
}
-static gchar
-*serv_name_lookup(const guint port, const port_type proto)
+static const gchar *
+serv_name_lookup(const guint port, const port_type proto)
{
serv_port_t *serv_port_table;
gchar *name;
@@ -659,10 +659,7 @@ static gchar
} /* proto */
}
- /* getservbyport() was used here but it was to expensive, if the functionality is desired
- * it would be better to pre parse etc/services or C:\Windows\System32\drivers\etc at
- * startup
- */
+ /* Use numerical port string */
name = (gchar*)g_malloc(16);
guint32_to_str_buf(port, name, 16);
@@ -3001,6 +2998,20 @@ sctp_port_to_display(wmem_allocator_t *allocator, guint port)
} /* sctp_port_to_display */
+int
+port_with_resolution_to_str_buf(gchar *buf, gulong buf_size, port_type port_typ, guint16 port_num)
+{
+ const gchar *port_res_str;
+
+ if (!gbl_resolv_flags.transport_name ||
+ (port_typ == PT_NONE) ||
+ ((port_res_str = serv_name_lookup(port_num, port_typ)) == NULL)) {
+ /* No name resolution support, just return port string */
+ return g_snprintf(buf, buf_size, "%u", port_num);
+ }
+ return g_snprintf(buf, buf_size, "%s (%u)", port_res_str, port_num);
+}
+
gchar *
get_ether_name(const guint8 *addr)
{