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 /epan | |
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 'epan')
-rw-r--r-- | epan/follow.c | 30 | ||||
-rw-r--r-- | epan/follow.h | 18 |
2 files changed, 25 insertions, 23 deletions
diff --git a/epan/follow.c b/epan/follow.c index 8e64044ce1..f8e23596dd 100644 --- a/epan/follow.c +++ b/epan/follow.c @@ -40,8 +40,6 @@ #include <epan/conversation.h> #include <epan/tap.h> -#define MAX_IPADDR_LEN 16 - typedef struct _tcp_frag { guint32 seq; guint32 len; @@ -60,7 +58,7 @@ static guint32 stream_to_follow[MAX_STREAM] = {0}; static gboolean find_addr[MAX_STREAM] = {FALSE}; static gboolean find_index[MAX_STREAM] = {FALSE}; static address tcp_addr[2]; -static guint8 ip_address[2][MAX_IPADDR_LEN]; +static stream_addr ip_address[2]; static guint port[2]; static guint bytes_written[2]; static gboolean is_ipv6 = FALSE; @@ -71,11 +69,11 @@ follow_stats(follow_stats_t* stats) int i; for (i = 0; i < 2 ; i++) { - memcpy(stats->ip_address[i], ip_address[i], MAX_IPADDR_LEN); + stats->ip_address[i] = ip_address[i]; stats->port[i] = port[i]; stats->bytes_written[i] = bytes_written[i]; - stats->is_ipv6 = is_ipv6; } + stats->is_ipv6 = is_ipv6; } /* This will build a display filter text that will only @@ -163,8 +161,8 @@ build_follow_conv_filter( packet_info *pi, const char* append_filter ) { else { return NULL; } - memcpy(ip_address[0], pi->net_src.data, len); - memcpy(ip_address[1], pi->net_dst.data, len); + memcpy(&ip_address[0], pi->net_src.data, len); + memcpy(&ip_address[1], pi->net_dst.data, len); port[0] = pi->srcport; port[1] = pi->destport; return buf; @@ -180,8 +178,8 @@ udp_follow_packet(void *tapdata _U_, packet_info *pinfo, } else { is_ipv6 = FALSE; } - memcpy(ip_address[0], pinfo->net_src.data, pinfo->net_src.len); - memcpy(ip_address[1], pinfo->net_dst.data, pinfo->net_dst.len); + memcpy(&ip_address[0], pinfo->net_src.data, pinfo->net_src.len); + memcpy(&ip_address[1], pinfo->net_dst.data, pinfo->net_dst.len); port[0] = pinfo->srcport; port[1] = pinfo->destport; find_addr[UDP_STREAM] = FALSE; @@ -197,7 +195,7 @@ udp_follow_packet(void *tapdata _U_, packet_info *pinfo, static tcp_frag *frags[2] = { 0, 0 }; static guint32 seq[2]; -static guint8 src_addr[2][MAX_IPADDR_LEN]; +static stream_addr src_addr[2]; static guint src_port[2] = { 0, 0 }; void @@ -214,9 +212,9 @@ reset_stream_follow(stream_type stream) { for( i=0; i<2; i++ ) { seq[i] = 0; - memset(src_addr[i], '\0', MAX_IPADDR_LEN); + memset(&src_addr[i], 0, sizeof(src_addr[i])); src_port[i] = 0; - memset(ip_address[i], '\0', MAX_IPADDR_LEN); + memset(&ip_address[i], 0, sizeof(src_addr[i])); port[i] = 0; bytes_written[i] = 0; current = frags[i]; @@ -273,16 +271,16 @@ follow_addr(stream_type stream, const address *addr0, guint port0, } - memcpy(ip_address[0], addr0->data, addr0->len); + memcpy(&ip_address[0], addr0->data, addr0->len); port[0] = port0; - memcpy(ip_address[1], addr1->data, addr1->len); + memcpy(&ip_address[1], addr1->data, addr1->len); port[1] = port1; if (stream == TCP_STREAM) { find_index[TCP_STREAM] = TRUE; - set_address(&tcp_addr[0], addr0->type, addr0->len, ip_address[0]); - set_address(&tcp_addr[1], addr1->type, addr1->len, ip_address[1]); + set_address(&tcp_addr[0], addr0->type, addr0->len, &ip_address[0]); + set_address(&tcp_addr[1], addr1->type, addr1->len, &ip_address[1]); } return TRUE; diff --git a/epan/follow.h b/epan/follow.h index 06f0e135e9..e12be69253 100644 --- a/epan/follow.h +++ b/epan/follow.h @@ -30,22 +30,26 @@ extern "C" { #endif /* __cplusplus */ #include <epan/packet.h> +#include <epan/ipv6.h> #include "ws_symbol_export.h" -#define MAX_IPADDR_LEN 16 - typedef enum { TCP_STREAM = 0, UDP_STREAM, MAX_STREAM } stream_type; +typedef union _stream_addr { + guint32 ipv4; + struct e_in6_addr ipv6; +} stream_addr; + /* With MSVC and a libwireshark.dll, we need a special declaration. */ WS_DLL_PUBLIC gboolean empty_tcp_stream; WS_DLL_PUBLIC gboolean incomplete_tcp_stream; typedef struct _tcp_stream_chunk { - guint8 src_addr[MAX_IPADDR_LEN]; + stream_addr src_addr; guint16 src_port; guint32 dlen; guint32 packet_num; @@ -94,10 +98,10 @@ WS_DLL_PUBLIC void reset_stream_follow(stream_type stream); typedef struct { - guint8 ip_address[2][MAX_IPADDR_LEN]; - guint32 port[2]; - unsigned int bytes_written[2]; - gboolean is_ipv6; + stream_addr ip_address[2]; + guint32 port[2]; + guint bytes_written[2]; + gboolean is_ipv6; } follow_stats_t; WS_DLL_PUBLIC |