aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Deniel <laurent.deniel@free.fr>1999-07-31 13:55:16 +0000
committerLaurent Deniel <laurent.deniel@free.fr>1999-07-31 13:55:16 +0000
commitfb8aa8fb7a85b3557bc17e3b63b1ed1fd2655453 (patch)
treed511fedee6d1f6f9d42037adf020e36bdeff4593
parent68e50f34862eca036a8c9069de891a89ddf1af8a (diff)
downloadwireshark-fb8aa8fb7a85b3557bc17e3b63b1ed1fd2655453.tar.gz
wireshark-fb8aa8fb7a85b3557bc17e3b63b1ed1fd2655453.tar.bz2
wireshark-fb8aa8fb7a85b3557bc17e3b63b1ed1fd2655453.zip
Fix TCP follow stream feature:
- call reset_tcp_reassembly before build_follow_filter - modify reassemble_tcp so that packet validity is checked before processing it. svn path=/trunk/; revision=410
-rw-r--r--ethereal.c4
-rw-r--r--follow.c21
-rw-r--r--follow.h5
-rw-r--r--packet-tcp.c7
4 files changed, 29 insertions, 8 deletions
diff --git a/ethereal.c b/ethereal.c
index 574e018351..d83036b7a4 100644
--- a/ethereal.c
+++ b/ethereal.c
@@ -1,6 +1,6 @@
/* ethereal.c
*
- * $Id: ethereal.c,v 1.69 1999/07/31 13:10:18 deniel Exp $
+ * $Id: ethereal.c,v 1.70 1999/07/31 13:55:15 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -223,6 +223,7 @@ follow_stream_cb( GtkWidget *w, gpointer data ) {
g_free( cf.dfilter );
cf.dfilter = NULL;
}
+ reset_tcp_reassembly();
/* create a new one and set the display filter entry accordingly */
cf.dfilter = build_follow_filter( &pi );
if (filter_te)
@@ -234,7 +235,6 @@ follow_stream_cb( GtkWidget *w, gpointer data ) {
if( data_out_file == NULL ) {
fprintf( stderr, "Could not open tmp file %s\n", filename1 );
}
- reset_tcp_reassembly();
/* Compile the filter */
if (dfilter_compile(cf.dfilter, &cf.dfcode) != 0) {
simple_dialog(ESD_TYPE_WARN, NULL,
diff --git a/follow.c b/follow.c
index fd48457db3..850737c01a 100644
--- a/follow.c
+++ b/follow.c
@@ -1,6 +1,6 @@
/* follow.c
*
- * $Id: follow.c,v 1.13 1999/07/31 11:21:05 deniel Exp $
+ * $Id: follow.c,v 1.14 1999/07/31 13:55:16 deniel Exp $
*
* Copyright 1998 Mike Hall <mlh@io.com>
*
@@ -50,6 +50,9 @@ extern FILE* data_out_file;
gboolean incomplete_tcp_stream = FALSE;
+static u_long ip_address[2];
+static u_int tcp_port[2];
+
static int check_fragments( int );
static void write_packet_data( const u_char *, int );
@@ -72,6 +75,10 @@ build_follow_filter( packet_info *pi ) {
free( buf );
return NULL;
}
+ ip_address[0] = pi->ip_src;
+ ip_address[1] = pi->ip_dst;
+ tcp_port[0] = pi->srcport;
+ tcp_port[1] = pi->destport;
return buf;
}
@@ -84,11 +91,19 @@ static u_long seq[2];
static u_long src[2] = { 0, 0 };
void
-reassemble_tcp( u_long sequence, u_long length, const char* data, u_long data_length, int synflag, u_long srcx ) {
+reassemble_tcp( u_long sequence, u_long length, const char* data, u_long data_length, int synflag, u_long srcx, u_long dstx, u_int srcport, u_int dstport ) {
int src_index, j, first = 0;
u_long newseq;
tcp_frag *tmp_frag;
src_index = -1;
+
+ /* first check if this packet should be processed */
+ if ((srcx != ip_address[0] && srcx != ip_address[1]) ||
+ (dstx != ip_address[0] && dstx != ip_address[1]) ||
+ (srcport != tcp_port[0] && srcport != tcp_port[1]) ||
+ (dstport != tcp_port[0] && dstport != tcp_port[1]))
+ return;
+
/* first we check to see if we have seen this src ip before. */
for( j=0; j<2; j++ ) {
if( src[j] == srcx ) {
@@ -225,6 +240,8 @@ reset_tcp_reassembly() {
for( i=0; i<2; i++ ) {
seq[i] = 0;
src[i] = 0;
+ ip_address[i] = 0;
+ tcp_port[i] = 0;
current = frags[i];
while( current ) {
next = current->next;
diff --git a/follow.h b/follow.h
index 7af23bef81..bce8e0a675 100644
--- a/follow.h
+++ b/follow.h
@@ -1,6 +1,6 @@
/* follow.h
*
- * $Id: follow.h,v 1.4 1999/07/07 01:41:15 guy Exp $
+ * $Id: follow.h,v 1.5 1999/07/31 13:55:16 deniel Exp $
*
* Copyright 1998 Mike Hall <mlh@io.com>
*
@@ -41,7 +41,8 @@ typedef struct _tcp_frag {
} tcp_frag;
char* build_follow_filter( packet_info * );
-void reassemble_tcp( u_long, u_long, const char*, u_long, int, u_long );
+void reassemble_tcp( u_long, u_long, const char*, u_long, int,
+ u_long, u_long, u_int, u_int );
void reset_tcp_reassembly( void );
#endif
diff --git a/packet-tcp.c b/packet-tcp.c
index a5bc9de723..9c56e92d8e 100644
--- a/packet-tcp.c
+++ b/packet-tcp.c
@@ -1,7 +1,7 @@
/* packet-tcp.c
* Routines for TCP packet disassembly
*
- * $Id: packet-tcp.c,v 1.28 1999/07/31 02:18:35 guy Exp $
+ * $Id: packet-tcp.c,v 1.29 1999/07/31 13:55:16 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -506,7 +506,10 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
( pd+offset ), /* data */
( fd->cap_len - offset ), /* captured data length */
( th.th_flags & 0x02 ), /* is syn set? */
- pi.ip_src ); /* src ip */
+ pi.ip_src,
+ pi.ip_dst,
+ pi.srcport,
+ pi.destport);
}
}