[netfilter-cvslog] r3432 - in trunk/nfsim: core/ipv4 tools

rusty at netfilter.org rusty at netfilter.org
Fri Dec 17 09:00:44 CET 2004


Author: rusty at netfilter.org
Date: 2004-12-17 09:00:44 +0100 (Fri, 17 Dec 2004)
New Revision: 3432

Modified:
   trunk/nfsim/core/ipv4/ipv4.c
   trunk/nfsim/tools/gen_ip.c
Log:
Fix parsing of OPT= on TCP packets, and logging TCP packets with options.


Modified: trunk/nfsim/core/ipv4/ipv4.c
===================================================================
--- trunk/nfsim/core/ipv4/ipv4.c	2004-12-17 07:59:58 UTC (rev 3431)
+++ trunk/nfsim/core/ipv4/ipv4.c	2004-12-17 08:00:44 UTC (rev 3432)
@@ -793,13 +793,11 @@
 		break;
 
 	case IPPROTO_TCP:
-		/* FIXME: handle options. --RR */
 		tcph = (struct tcphdr *)(iph + 1);
 		ptr += sprintf(ptr, "%u %u ",
-		       iplen - sizeof(struct tcphdr), iph->protocol);
+		       iplen - tcph->doff*4, iph->protocol);
 
-		if (len - sizeof(struct iphdr) <
-		               sizeof(struct tcphdr)) {
+		if (len - sizeof(struct iphdr) < sizeof(struct tcphdr)) {
 			ptr += sprintf(ptr, "-TRUNCATED-");
 			goto out;
 		}

Modified: trunk/nfsim/tools/gen_ip.c
===================================================================
--- trunk/nfsim/tools/gen_ip.c	2004-12-17 07:59:58 UTC (rev 3431)
+++ trunk/nfsim/tools/gen_ip.c	2004-12-17 08:00:44 UTC (rev 3432)
@@ -400,12 +400,12 @@
 parse_tcp(struct packet *packet, int datalen, char *args[], int *dump_flags)
 {
 	int spt, dpt, window = 0;
-	u_int16_t tcplen = sizeof(packet->u.tcph) + datalen;
+	u_int16_t tcplen;
 	struct {
 		u_int32_t srcip, dstip;
 		u_int8_t mbz, protocol;
 		u_int16_t proto_len;
-	} pseudo_header = { packet->iph.saddr, packet->iph.daddr, 0, IPPROTO_TCP, htons(tcplen) };
+	} pseudo_header = { packet->iph.saddr, packet->iph.daddr, 0, IPPROTO_TCP };
 
 	packet->u.tcph.seq = packet->u.tcph.ack_seq = window = 0;
 
@@ -482,6 +482,8 @@
 	packet->u.tcph.window = htons(window);
 	packet->u.tcph.check = packet->u.tcph.urg_ptr = 0;
 
+	tcplen = packet->u.tcph.doff * 4 + datalen;
+	pseudo_header.proto_len = htons(tcplen);
 	packet->u.tcph.check
 		= csum_fold(csum_partial(&packet->u.tcph, tcplen,
 					 csum_partial(&pseudo_header,




More information about the netfilter-cvslog mailing list