ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: [Ethereal-dev] [patch] packet-tcp.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

Date Prev · Date Next · Thread Prev · Thread Next
From: Matthijs Melchior <mmelchior@xxxxxxxxx>
Date: Wed, 01 Oct 2003 00:37:57 +0200
Hi,
   recently I have noticed a problem with re-assembly of some of my
testing data streams.  Investigating I have found they were all created
with the text2pcap command.  And the problem was only there when I had
selected "tcp/use relative sequence numbers".  The root-cause of the
problem appeared to be the fact that a valid sequence number (0) is
used to indicate the base sequence number is not initialized. And
text2pcap actually uses that same sequence number.

The attached patch uses a different criterion to initialize the
base sequence number, it uses the fact that the "unacked list" starts
out empty. My pseudo-caputes are handled correctly now, but they
only contain data flow in one direction, and no packets in the other
direction.....

Please apply if you agree this is a better criterion to initialize
the base sequence number.

Thanks.

--
Regards,
----------------------------------------------------------------  -o)
Matthijs Melchior                                       Maarssen  /\\
mmelchior@xxxxxxxxx                                  Netherlands _\_v
---------------------------------------------------------------- ----

--- packet-tcp.c-ORG	2003-09-09 03:22:23.000000000 +0200
+++ packet-tcp.c	2003-10-01 00:15:21.000000000 +0200
@@ -492,23 +492,14 @@
 		ual1=tcpd->ual1;
 		ual2=tcpd->ual2;
 		tnp=&tcpd->pdu_seq2;
-		base_seq=tcpd->base_seq1;
-		base_ack=tcpd->base_seq2;
+		base_seq = (tcp_relative_seq && (ual1 == 0)) ? seq : tcpd->base_seq1;
+		base_ack = (tcp_relative_seq && (ual2 == 0)) ? ack : tcpd->base_seq2;
 	} else {
 		ual1=tcpd->ual2;
 		ual2=tcpd->ual1;
 		tnp=&tcpd->pdu_seq1;
-		base_seq=tcpd->base_seq2;
-		base_ack=tcpd->base_seq1;
-	}
-
-	if(tcp_relative_seq){
-		if(base_seq==0){
-			base_seq=seq;
-		}
-		if(base_ack==0){
-			base_ack=ack;
-		}
+		base_seq = (tcp_relative_seq && (ual1 == 0)) ? seq : tcpd->base_seq2;
+		base_ack = (tcp_relative_seq && (ual2 == 0)) ? ack : tcpd->base_seq1;
 	}
 
 	/* To handle FIN, just add 1 to the length.