diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2016-01-05 11:30:16 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-01-07 01:09:35 +0000 |
commit | f410121cf2a94ef06fa42863352a77ba42a5fdf7 (patch) | |
tree | d0c6acefca85ec9dbb758950cc6d48c79252970c /ui/gtk | |
parent | 7888c43a5711710222343ee8fca8c5e500b5ed3a (diff) |
Remove some unnecessary dependencies and cleanup some code
No need for the GTK dependency on dissectors/packet-ipv6.h.
Add the stream_addr typedef in follow.h to make some code simpler.
Change-Id: I1cf906f58734a90263141362f2da33a140f93533
Reviewed-on: https://code.wireshark.org/review/13063
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/gtk')
-rw-r--r-- | ui/gtk/firewall_dlg.c | 1 | ||||
-rw-r--r-- | ui/gtk/follow_http.c | 18 | ||||
-rw-r--r-- | ui/gtk/follow_ssl.c | 23 | ||||
-rw-r--r-- | ui/gtk/follow_tcp.c | 22 | ||||
-rw-r--r-- | ui/gtk/follow_udp.c | 18 |
5 files changed, 28 insertions, 54 deletions
diff --git a/ui/gtk/firewall_dlg.c b/ui/gtk/firewall_dlg.c index 8ec00efa6c..155ba05669 100644 --- a/ui/gtk/firewall_dlg.c +++ b/ui/gtk/firewall_dlg.c @@ -42,7 +42,6 @@ #include <epan/addr_resolv.h> #include <epan/epan_dissect.h> #include <wsutil/filesystem.h> -#include <epan/dissectors/packet-ipv6.h> #include <ui/alert_box.h> #include <ui/last_open_dir.h> diff --git a/ui/gtk/follow_http.c b/ui/gtk/follow_http.c index 8e8bb96b3e..cf651f2018 100644 --- a/ui/gtk/follow_http.c +++ b/ui/gtk/follow_http.c @@ -176,17 +176,11 @@ follow_http_stream_cb(GtkWidget *w _U_, gpointer data _U_) follow_stats(&stats); if (stats.is_ipv6) { - struct e_in6_addr ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname0 = get_hostname6(&ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 16); - hostname1 = get_hostname6(&ipaddr); + hostname0 = get_hostname6(&stats.ip_address[0].ipv6); + hostname1 = get_hostname6(&stats.ip_address[1].ipv6); } else { - guint32 ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 4); - hostname0 = get_hostname(ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 4); - hostname1 = get_hostname(ipaddr); + hostname0 = get_hostname(stats.ip_address[0].ipv4); + hostname1 = get_hostname(stats.ip_address[1].ipv4); } port0 = tcp_port_to_display(NULL, stats.port[0]); @@ -198,8 +192,8 @@ follow_http_stream_cb(GtkWidget *w _U_, gpointer data _U_) both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", follow_info->bytes_written[0] + follow_info->bytes_written[1]); if ((follow_info->client_port == stats.port[0]) && - ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 16) == 0)) || - (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 4) == 0)))) { + ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 16) == 0)) || + (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 4) == 0)))) { server_to_client_string = g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", hostname0, port0, diff --git a/ui/gtk/follow_ssl.c b/ui/gtk/follow_ssl.c index 1ee6b49574..053283e2b2 100644 --- a/ui/gtk/follow_ssl.c +++ b/ui/gtk/follow_ssl.c @@ -31,7 +31,6 @@ #include <gtk/gtk.h> #include <epan/follow.h> -#include <epan/dissectors/packet-ipv6.h> #include <epan/prefs.h> #include <epan/addr_resolv.h> #include <epan/epan_dissect.h> @@ -226,21 +225,15 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) follow_stats(&stats); if (stats.is_ipv6) { - struct e_in6_addr ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname0 = get_hostname6(&ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 16); - hostname1 = get_hostname6(&ipaddr); + hostname0 = get_hostname6(&stats.ip_address[0].ipv6); + hostname1 = get_hostname6(&stats.ip_address[1].ipv6); } else { - guint32 ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 4); - hostname0 = get_hostname(ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 4); - hostname1 = get_hostname(ipaddr); + hostname0 = get_hostname(stats.ip_address[0].ipv4); + hostname1 = get_hostname(stats.ip_address[1].ipv4); } - port0 = (char*)tcp_port_to_display(NULL, stats.port[0]); - port1 = (char*)tcp_port_to_display(NULL, stats.port[1]); + port0 = tcp_port_to_display(NULL, stats.port[0]); + port1 = tcp_port_to_display(NULL, stats.port[1]); follow_info->is_ipv6 = stats.is_ipv6; @@ -250,8 +243,8 @@ follow_ssl_stream_cb(GtkWidget * w _U_, gpointer data _U_) /* ...and then the server-to-client and client-to-server directions. */ if ((follow_info->client_port == stats.port[0]) && - ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 16) == 0)) || - (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 4) == 0)))) { + ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 16) == 0)) || + (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 4) == 0)))) { server_hostname = hostname0; server_port = port0; client_hostname = hostname1; diff --git a/ui/gtk/follow_tcp.c b/ui/gtk/follow_tcp.c index d94792d67d..edfbfac381 100644 --- a/ui/gtk/follow_tcp.c +++ b/ui/gtk/follow_tcp.c @@ -187,30 +187,24 @@ follow_tcp_stream_cb(GtkWidget * w _U_, gpointer data _U_) follow_stats(&stats); if (stats.is_ipv6) { - struct e_in6_addr ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname0 = get_hostname6(&ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 16); - hostname1 = get_hostname6(&ipaddr); + hostname0 = get_hostname6(&stats.ip_address[0].ipv6); + hostname1 = get_hostname6(&stats.ip_address[1].ipv6); } else { - guint32 ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 4); - hostname0 = get_hostname(ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 4); - hostname1 = get_hostname(ipaddr); + hostname0 = get_hostname(stats.ip_address[0].ipv4); + hostname1 = get_hostname(stats.ip_address[1].ipv4); } follow_info->is_ipv6 = stats.is_ipv6; - port0 = (char*)tcp_port_to_display(NULL, stats.port[0]); - port1 = (char*)tcp_port_to_display(NULL, stats.port[1]); + port0 = tcp_port_to_display(NULL, stats.port[0]); + port1 = tcp_port_to_display(NULL, stats.port[1]); /* Both Stream Directions */ both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", follow_info->bytes_written[0] + follow_info->bytes_written[1]); if ((follow_info->client_port == stats.port[0]) && - ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 16) == 0)) || - (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 4) == 0)))) { + ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 16) == 0)) || + (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 4) == 0)))) { server_to_client_string = g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", hostname0, port0, diff --git a/ui/gtk/follow_udp.c b/ui/gtk/follow_udp.c index fa5f14ff40..c519d82685 100644 --- a/ui/gtk/follow_udp.c +++ b/ui/gtk/follow_udp.c @@ -176,17 +176,11 @@ follow_udp_stream_cb(GtkWidget *w _U_, gpointer data _U_) follow_stats(&stats); if (stats.is_ipv6) { - struct e_in6_addr ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 16); - hostname0 = get_hostname6(&ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 16); - hostname1 = get_hostname6(&ipaddr); + hostname0 = get_hostname6(&stats.ip_address[0].ipv6); + hostname1 = get_hostname6(&stats.ip_address[1].ipv6); } else { - guint32 ipaddr; - memcpy(&ipaddr, stats.ip_address[0], 4); - hostname0 = get_hostname(ipaddr); - memcpy(&ipaddr, stats.ip_address[1], 4); - hostname1 = get_hostname(ipaddr); + hostname0 = get_hostname(stats.ip_address[0].ipv4); + hostname1 = get_hostname(stats.ip_address[1].ipv4); } port0 = udp_port_to_display(NULL, stats.port[0]); @@ -198,8 +192,8 @@ follow_udp_stream_cb(GtkWidget *w _U_, gpointer data _U_) both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", follow_info->bytes_written[0] + follow_info->bytes_written[1]); if ((follow_info->client_port == stats.port[0]) && - ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 16) == 0)) || - (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, stats.ip_address[0], 4) == 0)))) { + ((stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 16) == 0)) || + (!stats.is_ipv6 && (memcmp(follow_info->client_ip.data, &stats.ip_address[0], 4) == 0)))) { server_to_client_string = g_strdup_printf("%s:%s " UTF8_RIGHTWARDS_ARROW " %s:%s (%u bytes)", hostname0, port0, |