[BACK]Return to patch-src_trace-tcp.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / net / tcptraceroute6 / patches

File: [cvs.NetBSD.org] / pkgsrc / net / tcptraceroute6 / patches / Attic / patch-src_trace-tcp.c (download)

Revision 1.1, Fri Nov 6 20:36:01 2015 UTC (4 years, 8 months ago) by joerg
Branch: MAIN
CVS Tags: pkgsrc-2019Q4-base, pkgsrc-2019Q4, pkgsrc-2019Q3-base, pkgsrc-2019Q3, pkgsrc-2019Q2-base, pkgsrc-2019Q2, pkgsrc-2019Q1-base, pkgsrc-2019Q1, pkgsrc-2018Q4-base, pkgsrc-2018Q4, pkgsrc-2018Q3-base, pkgsrc-2018Q3, pkgsrc-2018Q2-base, pkgsrc-2018Q2, pkgsrc-2018Q1-base, pkgsrc-2018Q1, pkgsrc-2017Q4-base, pkgsrc-2017Q4, pkgsrc-2017Q3-base, pkgsrc-2017Q3, pkgsrc-2017Q2-base, pkgsrc-2017Q2, pkgsrc-2017Q1-base, pkgsrc-2017Q1, pkgsrc-2016Q4-base, pkgsrc-2016Q4, pkgsrc-2016Q3-base, pkgsrc-2016Q3, pkgsrc-2016Q2-base, pkgsrc-2016Q2, pkgsrc-2016Q1-base, pkgsrc-2016Q1, pkgsrc-2015Q4-base, pkgsrc-2015Q4

Avoid the horrible dynamic sized types extension from GCC.

$NetBSD: patch-src_trace-tcp.c,v 1.1 2015/11/06 20:36:01 joerg Exp $

--- src/trace-tcp.c.orig	2015-11-06 15:53:03.000000000 +0000
+++ src/trace-tcp.c
@@ -51,21 +51,21 @@ send_syn_probe (int fd, unsigned ttl, un
 	if (plen < sizeof (struct tcphdr))
 		plen = sizeof (struct tcphdr);
 
-	struct
-	{
-		struct tcphdr th;
-		uint8_t payload[plen - sizeof (struct tcphdr)];
-	} packet;
-
-	memset (&packet, 0, sizeof (packet));
-	packet.th.th_sport = sport;
-	packet.th.th_dport = port;
-	packet.th.th_seq = htonl ((ttl << 24) | (n << 16) | getpid ());
-	packet.th.th_off = sizeof (packet.th) / 4;
-	packet.th.th_flags = TH_SYN | (ecn ? (TH_ECE | TH_CWR) : 0);
-	packet.th.th_win = htons (TCP_WINDOW);
+	uint8_t buffer[plen];
 
-	return send_payload (fd, &packet, plen, ttl);
+	struct tcphdr th;
+
+	memset(&th, 0, sizeof (th));
+	memset(buffer, 0, plen);
+	th.th_sport = sport;
+	th.th_dport = port;
+	th.th_seq = htonl ((ttl << 24) | (n << 16) | getpid ());
+	th.th_off = sizeof (th) / 4;
+	th.th_flags = TH_SYN | (ecn ? (TH_ECE | TH_CWR) : 0);
+	th.th_win = htons (TCP_WINDOW);
+	memcpy(buffer, &th, sizeof(th));
+
+	return send_payload (fd, buffer, plen, ttl);
 }
 
 
@@ -128,21 +128,21 @@ send_ack_probe (int fd, unsigned ttl, un
 	if (plen < sizeof (struct tcphdr))
 		plen = sizeof (struct tcphdr);
 
-	struct
-	{
-		struct tcphdr th;
-		uint8_t payload[plen - sizeof (struct tcphdr)];
-	} packet;
-
-	memset (&packet, 0, sizeof (packet));
-	packet.th.th_sport = sport;
-	packet.th.th_dport = port;
-	packet.th.th_ack = htonl ((ttl << 24) | (n << 16) | getpid ());
-	packet.th.th_off = sizeof (packet.th) / 4;
-	packet.th.th_flags = TH_ACK;
-	packet.th.th_win = htons (TCP_WINDOW);
+	uint8_t buffer[plen];
+
+	struct tcphdr th;
+
+	memset(&th, 0, sizeof (th));
+	memset(buffer, 0, plen);
+	th.th_sport = sport;
+	th.th_dport = port;
+	th.th_ack = htonl ((ttl << 24) | (n << 16) | getpid ());
+	th.th_off = sizeof (th) / 4;
+	th.th_flags = TH_ACK;
+	th.th_win = htons (TCP_WINDOW);
+	memcpy(buffer, &th, sizeof(th));
 
-	return send_payload (fd, &packet, plen, ttl);
+	return send_payload (fd, buffer, plen, ttl);
 }