diff options
author | Michael Mann <mmann78@netscape.net> | 2014-12-08 21:40:24 -0500 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-12-10 09:04:00 +0000 |
commit | a97176853010e5e39492d8a1fea79799ef43758b (patch) | |
tree | 2d4d2da0fb11863ce802cdd2f388e0959c3fe86b /epan/dissectors/packet-udp.c | |
parent | e050ad27a4a7b330bf7c4cb223958b0e9f656deb (diff) |
Refactor "color" conversation filters
Have dissectors register their desire to be part of "color" conversation filters and have the GUI use that registered list. GUI actually using API will come in a separate commit.
Change-Id: I5ffe922d97894fe7bf3182056b76ab5839a9461a
Reviewed-on: https://code.wireshark.org/review/5658
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-udp.c')
-rw-r--r-- | epan/dissectors/packet-udp.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 86f874b919..6750e777bc 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -44,6 +44,7 @@ #include "packet-ip.h" #include <epan/conversation.h> #include <epan/conversation_table.h> +#include <epan/color_dissector_filters.h> #include <epan/tap.h> #include <epan/decode_as.h> @@ -382,6 +383,35 @@ udpip_hostlist_prefix(void) return "endpoints"; } +static gboolean +udp_color_filter_valid(packet_info *pinfo) +{ + return proto_is_frame_protocol(pinfo->layers, "udp"); +} + +static gchar* +udp_build_color_filter(packet_info *pinfo) +{ + if( pinfo->net_src.type == AT_IPv4 && pinfo->net_dst.type == AT_IPv4 ) { + /* UDP over IPv4 */ + return g_strdup_printf("(ip.addr eq %s and ip.addr eq %s) and (udp.port eq %d and udp.port eq %d)", + ip_to_str( (const guint8 *)pinfo->net_src.data), + ip_to_str( (const guint8 *)pinfo->net_dst.data), + pinfo->srcport, pinfo->destport ); + } + + if( pinfo->net_src.type == AT_IPv6 && pinfo->net_dst.type == AT_IPv6 ) { + /* UDP over IPv6 */ + return g_strdup_printf("(ipv6.addr eq %s and ipv6.addr eq %s) and (udp.port eq %d and udp.port eq %d)", + ip6_to_str((const struct e_in6_addr *)pinfo->net_src.data), + ip6_to_str((const struct e_in6_addr *)pinfo->net_dst.data), + pinfo->srcport, pinfo->destport ); + } + + return NULL; +} + + /* Attach process info to a flow */ /* XXX - We depend on the UDP dissector finding the conversation first */ void @@ -990,6 +1020,7 @@ proto_register_udp(void) register_decode_as(&udp_da); register_conversation_table(proto_udp, FALSE, udpip_conversation_packet, udpip_hostlist_packet, udpip_hostlist_prefix); + register_color_conversation_filter("UDP", udp_color_filter_valid, udp_build_color_filter); register_init_routine(udp_init); |