diff options
Diffstat (limited to 'network/hping3/patches/tcp_mss.diff')
-rw-r--r-- | network/hping3/patches/tcp_mss.diff | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/network/hping3/patches/tcp_mss.diff b/network/hping3/patches/tcp_mss.diff new file mode 100644 index 0000000000..37113dc8da --- /dev/null +++ b/network/hping3/patches/tcp_mss.diff @@ -0,0 +1,180 @@ +Add tcp-mss support. + +--- a/main.c ++++ b/main.c +@@ -44,7 +44,8 @@ + signlen, + lsr_length = 0, + ssr_length = 0, +- tcp_ack; ++ tcp_ack, ++ tcp_mss; + + + unsigned short int +@@ -95,6 +96,7 @@ + opt_tcpexitcode = FALSE, + opt_badcksum = FALSE, + opt_tr_keep_ttl = FALSE, ++ opt_tcp_mss = FALSE, + opt_tcp_timestamp = FALSE, + opt_tr_stop = FALSE, + opt_tr_no_rtt = FALSE, +--- a/globals.h ++++ b/globals.h +@@ -32,7 +32,8 @@ + tcp_seqnum, + set_ack, + ip_header_length, +- tcp_ack; ++ tcp_ack, ++ tcp_mss; + + extern unsigned short int + data_size; +@@ -77,6 +78,7 @@ + opt_tcpexitcode, + opt_badcksum, + opt_tr_keep_ttl, ++ opt_tcp_mss, + opt_tcp_timestamp, + opt_tr_stop, + opt_tr_no_rtt, +--- a/parseoptions.c ++++ b/parseoptions.c +@@ -31,7 +31,7 @@ + OPT_RROUTE, OPT_IPPROTO, OPT_ICMP_IPVER, OPT_ICMP_IPHLEN, + OPT_ICMP_IPLEN, OPT_ICMP_IPID, OPT_ICMP_IPPROTO, OPT_ICMP_CKSUM, + OPT_ICMP_TS, OPT_ICMP_ADDR, OPT_TCPEXITCODE, OPT_FAST, OPT_TR_KEEP_TTL, +- OPT_TCP_TIMESTAMP, OPT_TR_STOP, OPT_TR_NO_RTT, OPT_ICMP_HELP, ++ OPT_TCP_TIMESTAMP, OPT_TCP_MSS, OPT_TR_STOP, OPT_TR_NO_RTT, OPT_ICMP_HELP, + OPT_RAND_DEST, OPT_RAND_SOURCE, OPT_LSRR, OPT_SSRR, OPT_ROUTE_HELP, + OPT_ICMP_IPSRC, OPT_ICMP_IPDST, OPT_ICMP_SRCPORT, OPT_ICMP_DSTPORT, + OPT_ICMP_GW, OPT_FORCE_ICMP, OPT_APD_SEND, OPT_SCAN, OPT_FASTER, +@@ -124,6 +124,7 @@ + { '\0', "force-icmp", OPT_FORCE_ICMP, AGO_NOARG }, + { '\0', "beep", OPT_BEEP, AGO_NOARG }, + { '\0', "flood", OPT_FLOOD, AGO_NOARG }, ++ { '\0', "tcp-mss", OPT_TCP_MSS, AGO_NEEDARG|AGO_EXCEPT0 }, + AGO_LIST_TERM + }; + +@@ -556,6 +557,10 @@ + case OPT_FLOOD: + opt_flood = TRUE; + break; ++ case OPT_TCP_MSS: ++ opt_tcp_mss = TRUE; ++ tcp_mss = strtoul(ago_optarg, NULL, 0); ++ break; + } + } + +--- a/usage.c ++++ b/usage.c +@@ -87,6 +87,7 @@ + " -X --xmas set X unused flag (0x40)\n" + " -Y --ymas set Y unused flag (0x80)\n" + " --tcpexitcode use last tcp->th_flags as exit code\n" ++" --tcp-mss enable the TCP MSS option with the given value\n" + " --tcp-timestamp enable the TCP timestamp option to guess the HZ/uptime\n" + "Common\n" + " -d --data data size (default is 0)\n" +--- a/sendtcp.c ++++ b/sendtcp.c +@@ -28,10 +28,12 @@ + char *packet, *data; + struct mytcphdr *tcp; + struct pseudohdr *pseudoheader; +- unsigned char *tstamp; ++ unsigned char *opts; + ++ if (opt_tcp_mss) ++ tcp_opt_size += 4; + if (opt_tcp_timestamp) +- tcp_opt_size = 12; ++ tcp_opt_size += 12; + + packet_size = TCPHDR_SIZE + tcp_opt_size + data_size; + packet = malloc(PSEUDOHDR_SIZE + packet_size); +@@ -41,7 +43,7 @@ + } + pseudoheader = (struct pseudohdr*) packet; + tcp = (struct mytcphdr*) (packet+PSEUDOHDR_SIZE); +- tstamp = (unsigned char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE); ++ opts = (unsigned char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE); + data = (char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE+tcp_opt_size); + + memset(packet, 0, PSEUDOHDR_SIZE+packet_size); +@@ -64,14 +66,24 @@ + tcp->th_win = htons(src_winsize); + tcp->th_flags = tcp_th_flags; + ++ /* tcp MSS option */ ++ if (opt_tcp_mss) { ++ opts[0] = 2; ++ opts[1] = 4; /* 4 bytes, kind+len+MSS */ ++ opts[2] = tcp_mss >> 8; ++ opts[3] = tcp_mss & 0xff; ++ opts += 4; ++ } ++ + /* tcp timestamp option */ + if (opt_tcp_timestamp) { + __u32 randts = rand() ^ (rand() << 16); +- tstamp[0] = tstamp[1] = 1; /* NOOP */ +- tstamp[2] = 8; +- tstamp[3] = 10; /* 10 bytes, kind+len+T1+T2 */ +- memcpy(tstamp+4, &randts, 4); /* random */ +- memset(tstamp+8, 0, 4); /* zero */ ++ opts[0] = opts[1] = 1; /* NOOP */ ++ opts[2] = 8; ++ opts[3] = 10; /* 10 bytes, kind+len+T1+T2 */ ++ memcpy(opts+4, &randts, 4); /* random */ ++ memset(opts+8, 0, 4); /* zero */ ++ opts += 12; + } + + /* data */ +--- a/docs/hping3.8 ++++ b/docs/hping3.8 +@@ -98,6 +98,8 @@ + ] [ + .B \-\-tcpexitcode + ] [ ++.B \-\-tcp-mss ++] [ + .B \-\-tcp-timestamp + ] [ + .B \-\-tr-stop +@@ -510,6 +512,9 @@ + .I -b --badcksum + Send packets with a bad UDP/TCP checksum. + .TP ++.I --tcp-mss ++Enable the TCP MSS option and set it to the given value. ++.TP + .I --tcp-timestamp + Enable the TCP timestamp option, and try to guess the timestamp update + frequency and the remote system uptime. +--- a/docs/french/hping2-fr.8 ++++ b/docs/french/hping2-fr.8 +@@ -99,6 +99,8 @@ + ] [ + .B \-\-tcpexitcode + ] [ ++.B \-\-tcp-mss ++] [ + .B \-\-tcp-timestamp + ] [ + .B \-\-tr-stop +@@ -549,6 +551,9 @@ + .I -b --badcksum + Envoie des paquets avec une mauvaise somme de contrôle UDP/TCP + .TP ++.I --tcp-mss ++Active l'option TCP MSS et la fixe avec la valeur donnée. ++.TP + .I --tcp-timestamp + Active l'option TCP timestamp, et essaye de deviner la fréquence de mise à + jour du timestamp et l'uptime du système distant. |