Fix TCP follow stream feature:
authordeniel <deniel@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 31 Jul 1999 13:55:16 +0000 (13:55 +0000)
committerdeniel <deniel@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 31 Jul 1999 13:55:16 +0000 (13:55 +0000)
- call reset_tcp_reassembly before build_follow_filter
- modify reassemble_tcp so that packet validity is
  checked before processing it.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@410 f5534014-38df-0310-8fa8-9805f1628bb7

ethereal.c
follow.c
follow.h
packet-tcp.c

index 574e018351f9332015883060ed1fdd8aa3dfffb1..d83036b7a4c307230768146493227ae6ccd00f91 100644 (file)
@@ -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,
index fd48457db3f07e576c487258c8942a9135e0fcab..850737c01ae8615c8806db5acefc15f60f4e0b83 100644 (file)
--- 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;
index 7af23bef81ca429d9d234f24216867eef1a0acb9..bce8e0a675505879c512f85a14f99604b3e999f1 100644 (file)
--- 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
index a5bc9de72308c8593bea1b0810d78b844d3933ab..9c56e92d8e97de648eb0340807250879c2dd39b3 100644 (file)
@@ -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); 
   }
 }