From d898109ed68abc3a02b766cf1c65f39b21430b48 Mon Sep 17 00:00:00 2001 From: salo Date: Thu, 30 Mar 2006 13:51:28 +0000 Subject: Update to hping2, release candidate 3 Changes: - don't install hping suid root by default, add "hping-suid" option. - add bunch on patches from Pavel Kankovsky namely: add --flood and --tcp-mss options (self-explanatory), some checksum and interface binding fixes and warning fixes 2.0.0rc3: ======= FIX: Fix for interface guessing with aliases on BSD Thanks and FIX: fixed cksum.c. Bad outgoing packet checksum with some packet. Thanks to Brett Eldridge . ADD: scan mode (--scan) ADD: A rc4-based PRNG to use with --rand-source and --rand-dest FIX: Fix -I option for BSD/Apple ADD: Add support for BSDI and MacOSX (thanks Dennis Opacki and Jan-Hinrich Fessel ) ADD: A few useful ICMP options ADD: Add support for : WLAN (Fabian Melzow ) ATM (Debian bug #193436, thanks to Domenico Andreoli) Token Ring (jim.r.halfpenny@britishairways.com) ADD: MacOSX patches (Hans-Joachim Knobloch ) FIX: --rand-source patches from Quentin Garnier . ensure randomness . do not stop on errors when using a E or D class address (BSD only?) --- net/hping/MESSAGE | 6 ---- net/hping/Makefile | 14 ++++---- net/hping/distinfo | 26 ++++++++++----- net/hping/options.mk | 11 ++++++ net/hping/patches/patch-aa | 50 +++++++++++++++++++++++++--- net/hping/patches/patch-ab | 57 +++++++++++++++++++++++++------ net/hping/patches/patch-ad | 11 +++--- net/hping/patches/patch-ae | 34 +++++++++---------- net/hping/patches/patch-af | 78 +++++++++++++++++++++++++++++++++++++++++++ net/hping/patches/patch-ag | 83 ++++++++++++++++++++++++++++++++++++++++++++++ net/hping/patches/patch-ah | 34 +++++++++++++++++++ net/hping/patches/patch-ai | 30 +++++++++++++++++ net/hping/patches/patch-aj | 24 ++++++++++++++ net/hping/patches/patch-ak | 47 ++++++++++++++++++++++++++ net/hping/patches/patch-al | 21 ++++++++++++ net/hping/patches/patch-am | 58 ++++++++++++++++++++++++++++++++ net/hping/patches/patch-an | 44 ++++++++++++++++++++++++ net/hping/patches/patch-ao | 13 ++++++++ 18 files changed, 581 insertions(+), 60 deletions(-) delete mode 100644 net/hping/MESSAGE create mode 100644 net/hping/options.mk create mode 100644 net/hping/patches/patch-af create mode 100644 net/hping/patches/patch-ag create mode 100644 net/hping/patches/patch-ah create mode 100644 net/hping/patches/patch-ai create mode 100644 net/hping/patches/patch-aj create mode 100644 net/hping/patches/patch-ak create mode 100644 net/hping/patches/patch-al create mode 100644 net/hping/patches/patch-am create mode 100644 net/hping/patches/patch-an create mode 100644 net/hping/patches/patch-ao (limited to 'net') diff --git a/net/hping/MESSAGE b/net/hping/MESSAGE deleted file mode 100644 index e04c0af397b..00000000000 --- a/net/hping/MESSAGE +++ /dev/null @@ -1,6 +0,0 @@ -=========================================================================== -$NetBSD: MESSAGE,v 1.1.1.1 2002/04/04 17:02:30 atatat Exp $ - - NOTE: ${PREFIX}/sbin/hping (and hping2) are setuid "root". - -=========================================================================== diff --git a/net/hping/Makefile b/net/hping/Makefile index 39069491be9..6b937ced189 100644 --- a/net/hping/Makefile +++ b/net/hping/Makefile @@ -1,27 +1,27 @@ -# $NetBSD: Makefile,v 1.7 2005/12/05 20:50:46 rillig Exp $ +# $NetBSD: Makefile,v 1.8 2006/03/30 13:51:28 salo Exp $ # -DISTNAME= hping2.0.0-rc2 -PKGNAME= hping-2.0.0.2 +DISTNAME= hping2.0.0-rc3 +PKGNAME= hping-2.0.0.3 CATEGORIES= net MASTER_SITES= http://www.hping.org/ MAINTAINER= atatat@NetBSD.org HOMEPAGE= http://www.hping.org/ -COMMENT= Traceroute and ping using TCP and UDP as well as ICMP +COMMENT= Command-line oriented TCP/IP packet assembler/analyzer -WRKSRC= ${WRKDIR}/hping2-rc2 +WRKSRC= ${WRKDIR}/hping2-rc3 HAS_CONFIGURE= YES MANPATH= ${PREFIX}/man CONFIGURE_ENV+= MANPATH=${MANPATH:Q} -NOT_FOR_PLATFORM= NetBSD-0.*-* NetBSD-1.[0-4]*-* -BINMODE= 4755 INSTALLATION_DIRS= man/man8 sbin CONFIGURE_ENV+= PCAPINCDIR=${BUILDLINK_PREFIX.libpcap}/include CONFIGURE_ENV+= PCAPLIBDIR=${BUILDLINK_PREFIX.libpcap}/lib +.include "options.mk" + do-install: ${INSTALL_PROGRAM} ${WRKSRC}/hping2 ${PREFIX}/sbin ${LN} -s ../sbin/hping2 ${PREFIX}/sbin/hping diff --git a/net/hping/distinfo b/net/hping/distinfo index b5b1e866760..fa49431125e 100644 --- a/net/hping/distinfo +++ b/net/hping/distinfo @@ -1,10 +1,20 @@ -$NetBSD: distinfo,v 1.6 2006/03/14 02:29:11 joerg Exp $ +$NetBSD: distinfo,v 1.7 2006/03/30 13:51:28 salo Exp $ -SHA1 (hping2.0.0-rc2.tar.gz) = ee10aa5cce7431ab0887ca0328b0fed86407cd3c -RMD160 (hping2.0.0-rc2.tar.gz) = e32479f8d1f7408eaeaa9e507c8050618c81825e -Size (hping2.0.0-rc2.tar.gz) = 100501 bytes -SHA1 (patch-aa) = f0b60b33df37c5b5f332c4dd5b668c87f2f00780 -SHA1 (patch-ab) = 7862d487c5fa9940a51c82154e5427f426c93270 +SHA1 (hping2.0.0-rc3.tar.gz) = ec48293ca25e08155bf4b51ad6140b1be576a16f +RMD160 (hping2.0.0-rc3.tar.gz) = 345c6b29e48c2f9aea6b8bafb68c258f9ff8b083 +Size (hping2.0.0-rc3.tar.gz) = 124573 bytes +SHA1 (patch-aa) = 651a2dad60439e19a5815909ef6e857c9d6cde86 +SHA1 (patch-ab) = 062bc2405c76d0c550a4750c3ffb8def236dc06d SHA1 (patch-ac) = b39369c28ca8932f13d9500509b84e28a1db6058 -SHA1 (patch-ad) = 0229fb92f51ec3884a8e16ff9487fd5cfa238f1c -SHA1 (patch-ae) = 42d25825134ce41a84122d5effc67973c10b37f4 +SHA1 (patch-ad) = 292d9807ca7af37a70d1901bd614c00662ae9a74 +SHA1 (patch-ae) = db7634c10680a8729ffdcace4fd7abb676140b5d +SHA1 (patch-af) = 1099dc70a7053e6c7bead73445b3748d3798cfef +SHA1 (patch-ag) = 60b3e784c18f0a1c5a84af401dbc59b9e81f9d3d +SHA1 (patch-ah) = fe763d1f21f744b950f62ca062fbf8bd4a7e00f3 +SHA1 (patch-ai) = af2d948240101f264c1fb97eedd4417fd3bf8d6a +SHA1 (patch-aj) = 8143a56a7fa28f7985b08d4dcf752153dc8d9edf +SHA1 (patch-ak) = 1021be12c2ceb7b9a1b428dd9f928c28f1f0f8b7 +SHA1 (patch-al) = d27e28938e731952e8bceb642c3441a4741f0b3d +SHA1 (patch-am) = 9f71209f239c34e9be54e34505cbbd0a5da92cb2 +SHA1 (patch-an) = 4b2a4b7b7b3b4a206d8cadf2ab62c703059b7d7d +SHA1 (patch-ao) = 139cc79d5473c46b838a1f70d06595f598398f17 diff --git a/net/hping/options.mk b/net/hping/options.mk new file mode 100644 index 00000000000..817f3c43564 --- /dev/null +++ b/net/hping/options.mk @@ -0,0 +1,11 @@ +# $NetBSD: options.mk,v 1.1 2006/03/30 13:51:28 salo Exp $ + +PKG_OPTIONS_VAR= PKG_OPTIONS.hping +PKG_SUPPORTED_OPTIONS= hping-suid + +.include "../../mk/bsd.options.mk" + +.if !empty(PKG_OPTIONS:Mhping-suid) +BINOWN= root +BINMODE= 4511 +.endif diff --git a/net/hping/patches/patch-aa b/net/hping/patches/patch-aa index 5f459e5c127..01cb1db40ee 100644 --- a/net/hping/patches/patch-aa +++ b/net/hping/patches/patch-aa @@ -1,8 +1,34 @@ -$NetBSD: patch-aa,v 1.2 2003/09/25 22:12:15 recht Exp $ +$NetBSD: patch-aa,v 1.3 2006/03/30 13:51:29 salo Exp $ ---- main.c.orig 2003-07-31 12:06:55.000000000 +0200 -+++ main.c -@@ -166,6 +166,17 @@ int main(int argc, char **argv) +--- main.c.orig 2003-08-08 01:55:55.000000000 +0200 ++++ main.c 2005-11-05 21:45:04.000000000 +0100 +@@ -47,7 +47,8 @@ + signlen, + lsr_length = 0, + ssr_length = 0, +- tcp_ack; ++ tcp_ack, ++ tcp_mss; + + + unsigned short int +@@ -65,6 +66,7 @@ + recv_pkt = 0, + out_of_sequence_pkt = 0, + sending_wait = DEFAULT_SENDINGWAIT, /* see DEFAULT_SENDINGWAIT */ ++ opt_flood = FALSE, + opt_rawipmode = FALSE, + opt_icmpmode = FALSE, + opt_udpmode = FALSE, +@@ -98,6 +100,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, +@@ -179,6 +182,17 @@ char setflags[1024] = {'\0'}; int c, hdr_size; @@ -20,7 +46,7 @@ $NetBSD: patch-aa,v 1.2 2003/09/25 22:12:15 recht Exp $ if (parse_options(argc, argv) == -1) { printf("hping2: missing host argument\n" "Try `hping2 --help' for more information.\n"); -@@ -206,13 +217,6 @@ int main(int argc, char **argv) +@@ -219,13 +233,6 @@ ifname, ifstraddr, h_if_mtu); } @@ -34,3 +60,17 @@ $NetBSD: patch-aa,v 1.2 2003/09/25 22:12:15 recht Exp $ /* set SO_BROADCAST option */ socket_broadcast(sockraw); /* set SO_IPHDRINCL option */ +@@ -355,6 +362,13 @@ + } + } + ++ /* flood mode */ ++ if (opt_flood) { ++ printf("Flooding...\n"); ++ for (;;) ++ send_packet(0 /* dummy */); ++ } ++ + /* start packet sending */ + kill(getpid(), SIGALRM); + diff --git a/net/hping/patches/patch-ab b/net/hping/patches/patch-ab index 2fae15ebd0b..5b9449fa0be 100644 --- a/net/hping/patches/patch-ab +++ b/net/hping/patches/patch-ab @@ -1,15 +1,50 @@ -$NetBSD: patch-ab,v 1.1 2002/04/04 20:56:39 agc Exp $ +$NetBSD: patch-ab,v 1.2 2006/03/30 13:51:29 salo Exp $ -hping needs to run as root, even for -v. For non-root builds, comment this part out. - ---- Makefile.in 2002/04/04 20:54:28 1.1 -+++ Makefile.in 2002/04/04 20:54:42 -@@ -35,7 +35,7 @@ +--- Makefile.in.orig 2004-05-03 11:29:39.000000000 +0200 ++++ Makefile.in 2005-11-05 21:07:50.000000000 +0100 +@@ -6,14 +6,14 @@ + # $date: Sun Jul 25 17:56:15 MET DST 1999$ + # $rev: 3$ + +-CC= gcc +-AR=/usr/bin/ar +-RANLIB=/usr/bin/ranlib +-CCOPT= -O2 -Wall @PCAP_INCLUDE@ +-DEBUG= -g ++#CC= gcc ++#AR=/usr/bin/ar ++#RANLIB=/usr/bin/ranlib ++#CCOPT= -O2 -Wall @PCAP_INCLUDE@ ++#DEBUG= -g + #uncomment the following if you need libpcap based build under linux + #(not raccomanded) +-COMPILE_TIME= @FORCE_LIBPCAP@ ++#COMPILE_TIME= @FORCE_LIBPCAP@ + INSTALL_MANPATH=@MANPATH@ + @PCAP@ + +@@ -39,21 +39,17 @@ + all: hping2 + + libars.a: $(ARSOBJ) +- $(AR) rc $@ $^ ++ $(AR) rc $@ $> + $(RANLIB) $@ + hping2: byteorder.h $(OBJ) - $(CC) -o hping2 $(CCOPT) $(DEBUG) $(OBJ) $(PCAP) @SOLARISLIB@ - @echo +- $(CC) -o hping2 $(CCOPT) $(DEBUG) $(OBJ) $(PCAP) @SOLARISLIB@ +- @echo - ./hping2 -v -+ #./hping2 -v - @echo "use \`make strip' to strip hping2 binary" - @echo "use \`make install' to install hping2" +- @echo "use \`make strip' to strip hping2 binary" +- @echo "use \`make install' to install hping2" ++ $(CC) -o hping2 $(LDFLAGS) $(OBJ) $(PCAP) @SOLARISLIB@ + + byteorder.h: + ./configure + + .c.o: +- $(CC) -c $(CCOPT) $(DEBUG) $(COMPILE_TIME) $< ++ $(CC) -c $(CFLAGS) $< + clean: + rm -rf hping2 *.o *.a diff --git a/net/hping/patches/patch-ad b/net/hping/patches/patch-ad index bc47f1ad875..4c31fcd378b 100644 --- a/net/hping/patches/patch-ad +++ b/net/hping/patches/patch-ad @@ -1,14 +1,13 @@ -$NetBSD: patch-ad,v 1.2 2006/03/14 02:29:11 joerg Exp $ +$NetBSD: patch-ad,v 1.3 2006/03/30 13:51:29 salo Exp $ ---- libpcap_stuff.c.orig 2001-08-23 18:49:39.000000000 +0000 -+++ libpcap_stuff.c -@@ -15,8 +15,11 @@ - #include +--- libpcap_stuff.c.orig 2002-12-13 15:07:07.000000000 +0100 ++++ libpcap_stuff.c 2006-03-22 19:54:51.000000000 +0100 +@@ -16,8 +16,10 @@ + #include #include #include -#include +#include -+#include #include +#define PCAP_DONT_INCLUDE_PCAP_BPF_H +#include diff --git a/net/hping/patches/patch-ae b/net/hping/patches/patch-ae index b522d113359..00e0f32b6cb 100644 --- a/net/hping/patches/patch-ae +++ b/net/hping/patches/patch-ae @@ -1,31 +1,31 @@ -$NetBSD: patch-ae,v 1.1 2006/03/14 02:29:11 joerg Exp $ +$NetBSD: patch-ae,v 1.2 2006/03/30 13:51:29 salo Exp $ ---- getifname.c.orig 2006-03-14 02:23:00.000000000 +0000 -+++ getifname.c -@@ -15,7 +15,7 @@ - #include +--- getifname.c.orig 2004-05-03 10:55:53.000000000 +0200 ++++ getifname.c 2006-03-22 19:56:40.000000000 +0100 +@@ -17,7 +17,7 @@ #include /* close */ --#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) -+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) + #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ +- defined(__bsdi__) || defined(__APPLE__) ++ defined(__bsdi__) || defined(__APPLE__) || defined(__DragonFly__) #include #include - #endif /* defined(__*BSD__) */ -@@ -23,7 +23,7 @@ - #include "hping2.h" - #include "globals.h" + #include +@@ -28,7 +28,7 @@ --#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__linux__) && !defined(__sun__) -+#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__linux__) && !defined(__sun__) && !defined(__DragonFly__) + #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && \ + !defined(__linux__) && !defined(__sun__) && !defined(__bsdi__) && \ +- !defined(__APPLE__) ++ !defined(__APPLE__) && !defined(__DragonFly__) #error Sorry, interface code not implemented. #endif -@@ -169,7 +169,7 @@ int get_if_name(void) - return 0; +@@ -175,7 +175,7 @@ } --#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) -+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ +- defined(__bsdi__) || defined(__APPLE__) ++ defined(__bsdi__) || defined(__APPLE__) || defined(__DragonFly__) /* return interface informations : - from the specified (-I) interface diff --git a/net/hping/patches/patch-af b/net/hping/patches/patch-af new file mode 100644 index 00000000000..f82c42fad50 --- /dev/null +++ b/net/hping/patches/patch-af @@ -0,0 +1,78 @@ +$NetBSD: patch-af,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- ars.c.orig 2003-07-28 11:00:54.000000000 +0200 ++++ ars.c 2005-11-05 21:35:00.000000000 +0100 +@@ -372,7 +372,7 @@ + } + if (nbytes == 1) { + oddbyte = 0; +- *((u_int16_t *) &oddbyte) = *(u_int8_t *) buf; ++ *((u_int8_t *) &oddbyte) = *((u_int8_t *) buf); + sum += oddbyte; + } + sum = (sum >> 16) + (sum & 0xffff); +@@ -381,6 +381,13 @@ + } + + /* Multiple buffers checksum facility */ ++/* ++ * Important facts about the checksum (sum = ~cksum, Ai are bytes): ++ * 1. sum(A0...A2i-1,A2i...A2n-1) = sum(A0...A2i-1) + sum(A2i...B2n-1), ++ * 2. sum(A0...A2i,A2i+1...A2n-1) = sum(A0...A2i,0) + sum(0,A2i+1...A2n-1) ++ * 3. sum(A0...A2n-1,A2n) = sum(A0...A2n-1,A2n,0) (ex definitiones) ++ * 4. sum(0,A0...Ak) = swap_bytes(sum(A0...Ak)) ++ */ + u_int16_t ars_multi_cksum(struct mc_context *c, int op, void *vbuf, + size_t nbytes) + { +@@ -394,38 +401,27 @@ + c->old = 0; + return -ARS_OK; + } else if (op == ARS_MC_UPDATE) { +- if (c->oddbyte_flag) { +- u_int8_t *x = (u_int8_t*)&oddbyte; +- oddbyte = 0; +- *((u_int16_t *) &oddbyte) = c->oddbyte << 8; +- *((u_int16_t *) &oddbyte) |= *(u_int8_t *) buf; +- oddbyte = (x[0] << 8) | x[1]; /* fix endianess */ +- c->old += oddbyte; +- nbytes--; +- c->oddbyte_flag = 0; +- /* We need to stay aligned -- bad slowdown, fix? */ +- tmp = alloca(nbytes); +- memcpy(tmp, vbuf+1, nbytes); +- buf = tmp; +- } +- sum = c->old; ++ sum = 0; + while (nbytes > 1) { + sum += *buf++; + nbytes -= 2; + } +- c->old = sum; + if (nbytes == 1) { +- c->oddbyte = *(u_int8_t*) buf; +- c->oddbyte_flag++; ++ oddbyte = 0; ++ *((u_int8_t *) &oddbyte) = *((u_int8_t *) buf); ++ sum += oddbyte; + } ++ if (c->oddbyte_flag) { ++ /* reverse checksum endianness */ ++ sum = (sum >> 16) + (sum & 0xffff); ++ sum += (sum >> 16); ++ sum = ((sum & 0xff00) >> 8) | ((sum & 0xff) << 8); ++ } ++ c->old += sum; ++ c->oddbyte_flag ^= (nbytes == 1 ? 1 : 0); + return -ARS_OK; + } else if (op == ARS_MC_FINAL) { + sum = c->old; +- if (c->oddbyte_flag == 1) { +- oddbyte = 0; +- *((u_int16_t *) &oddbyte) = c->oddbyte; +- sum += oddbyte; +- } + sum = (sum >> 16) + (sum & 0xffff); + sum += (sum >> 16); + return (u_int16_t) ~sum; diff --git a/net/hping/patches/patch-ag b/net/hping/patches/patch-ag new file mode 100644 index 00000000000..2068ddcea31 --- /dev/null +++ b/net/hping/patches/patch-ag @@ -0,0 +1,83 @@ +$NetBSD: patch-ag,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- getifname.c.orig 2004-05-03 10:55:53.000000000 +0200 ++++ getifname.c 2005-11-05 21:38:18.000000000 +0100 +@@ -45,10 +45,11 @@ + { + int fd; + struct ifconf ifc; +- struct ifreq ibuf[16], +- ifr, ++ struct ifreq ifr, + *ifrp, + *ifend; ++ char *ibuf; ++ int ibuflen; + struct sockaddr_in sa; + struct sockaddr_in output_if_addr; + int known_output_if = 0; +@@ -72,21 +73,40 @@ + return -1; + } + +- memset(ibuf, 0, sizeof(struct ifreq)*16); +- ifc.ifc_len = sizeof ibuf; ++ ibuf = NULL; ++ ibuflen = 16 * sizeof(struct ifreq); ++ for (;;) { ++ char *nibuf = (char *) realloc(ibuf, ibuflen); ++ if (!nibuf) { ++ perror("[get_if_name] realloc"); ++ goto go_out; ++ } ++ ++ ibuf = nibuf; ++ memset(ibuf, 0, ibuflen); ++ ifc.ifc_len = ibuflen; + ifc.ifc_buf = (caddr_t) ibuf; + + /* gets interfaces list */ + if ( ioctl(fd, SIOCGIFCONF, (char*)&ifc) == -1 || + ifc.ifc_len < sizeof(struct ifreq) ) { + perror("[get_if_name] ioctl(SIOCGIFCONF)"); +- close(fd); +- return -1; ++ goto go_out; ++ } ++ ++ if (ifc.ifc_len + sizeof(struct ifreq) <= ibuflen) ++ break; ++ if (ibuflen >= 1024 * sizeof(struct ifreq)) { ++ fprintf(stderr, "Warning: Too many network " ++ "interfaces.\n"); ++ break; ++ } ++ ibuflen *= 2; + } + + /* ifrp points to buffer and ifend points to buffer's end */ +- ifrp = ibuf; +- ifend = (struct ifreq*) ((char*)ibuf + ifc.ifc_len); ++ ifrp = (struct ifreq *) ibuf; ++ ifend = (struct ifreq *) (ibuf + ifc.ifc_len); + + for (; ifrp < ifend; ifrp++) { + strlcpy(ifr.ifr_name, ifrp->ifr_name, sizeof(ifr.ifr_name)); +@@ -162,14 +182,15 @@ + h_if_mtu = ifr.ifr_mtu; + #endif + } +- close(fd); +- return 0; ++ goto go_out; + } + /* interface not found, use 'lo' */ + strlcpy(ifname, "lo", 1024); + strlcpy(ifstraddr, "127.0.0.1", 1024); + h_if_mtu = 1500; + ++go_out: ++ free(ibuf); + close(fd); + return 0; + } diff --git a/net/hping/patches/patch-ah b/net/hping/patches/patch-ah new file mode 100644 index 00000000000..5028e799c3f --- /dev/null +++ b/net/hping/patches/patch-ah @@ -0,0 +1,34 @@ +$NetBSD: patch-ah,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- ip_opt_build.c.orig 2002-01-19 19:57:47.000000000 +0100 ++++ ip_opt_build.c 2005-11-05 21:39:25.000000000 +0100 +@@ -34,7 +34,8 @@ + } + else + { +- printf("Warning: loose source route is too long, discarding it"); ++ fprintf(stderr, "Warning: loose source route is too " ++ "long, discarding it.\n"); + opt_lsrr=0; + } + } +@@ -48,7 +49,8 @@ + } + else + { +- printf("Warning: strict source route is too long, discarding it"); ++ fprintf(stderr, "Warning: strict source route is too " ++ "long, discarding it.\n"); + opt_ssrr=0; + } + } +@@ -66,7 +68,8 @@ + } + else + { +- printf("Warning: no room for record route, discarding option\n"); ++ fprintf(stderr, "Warning: no room for record route, " ++ "discarding option.\n"); + opt_rroute=0; + } + } diff --git a/net/hping/patches/patch-ai b/net/hping/patches/patch-ai new file mode 100644 index 00000000000..20c53f8d235 --- /dev/null +++ b/net/hping/patches/patch-ai @@ -0,0 +1,30 @@ +$NetBSD: patch-ai,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- globals.h.orig 2003-08-08 01:55:55.000000000 +0200 ++++ globals.h 2005-11-05 21:44:31.000000000 +0100 +@@ -32,7 +32,8 @@ + tcp_seqnum, + set_ack, + ip_header_length, +- tcp_ack; ++ tcp_ack, ++ tcp_mss; + + extern unsigned short int + data_size; +@@ -44,6 +45,7 @@ + recv_pkt, + out_of_sequence_pkt, + sending_wait, ++ opt_flood, + opt_rawipmode, + opt_icmpmode, + opt_udpmode, +@@ -77,6 +79,7 @@ + opt_tcpexitcode, + opt_badcksum, + opt_tr_keep_ttl, ++ opt_tcp_mss, + opt_tcp_timestamp, + opt_tr_stop, + opt_tr_no_rtt, diff --git a/net/hping/patches/patch-aj b/net/hping/patches/patch-aj new file mode 100644 index 00000000000..758d46f86c3 --- /dev/null +++ b/net/hping/patches/patch-aj @@ -0,0 +1,24 @@ +$NetBSD: patch-aj,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- send.c.orig 2003-08-01 16:53:08.000000000 +0200 ++++ send.c 2005-11-05 21:46:21.000000000 +0100 +@@ -79,9 +79,17 @@ + else send_tcp(); + + sent_pkt++; +- Signal(SIGALRM, send_packet); + +- if (count != -1 && count == sent_pkt) { /* count reached? */ ++ if (opt_flood) { ++ if (count != -1 && count <= sent_pkt) { /* count reached? */ ++ print_statistics(0); ++ } ++ errno = errno_save; ++ return; ++ } ++ ++ Signal(SIGALRM, send_packet); ++ if (count != -1 && count <= sent_pkt) { /* count reached? */ + Signal(SIGALRM, print_statistics); + alarm(COUNTREACHED_TIMEOUT); + } else if (!opt_listenmode) { diff --git a/net/hping/patches/patch-ak b/net/hping/patches/patch-ak new file mode 100644 index 00000000000..f02ea15398e --- /dev/null +++ b/net/hping/patches/patch-ak @@ -0,0 +1,47 @@ +$NetBSD: patch-ak,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- parseoptions.c.orig 2003-08-08 16:39:00.000000000 +0200 ++++ parseoptions.c 2005-11-05 21:48:10.000000000 +0100 +@@ -31,10 +31,11 @@ + 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 }; ++ OPT_ICMP_GW, OPT_FORCE_ICMP, OPT_APD_SEND, OPT_SCAN, OPT_FASTER, ++ OPT_FLOOD }; + + static struct ago_optlist hping_optlist[] = { + { 'c', "count", OPT_COUNT, AGO_NEEDARG }, +@@ -105,8 +106,10 @@ + { '\0', "tcpexitcode", OPT_TCPEXITCODE, AGO_NOARG }, + { '\0', "fast", OPT_FAST, AGO_NOARG|AGO_EXCEPT0 }, + { '\0', "faster", OPT_FASTER, AGO_NOARG|AGO_EXCEPT0 }, ++ { '\0', "flood", OPT_FLOOD, AGO_NOARG|AGO_EXCEPT0 }, + { '\0', "tr-keep-ttl", OPT_TR_KEEP_TTL, AGO_NOARG }, + { '\0', "tcp-timestamp",OPT_TCP_TIMESTAMP, AGO_NOARG }, ++ { '\0', "tcp-mss", OPT_TCP_MSS, AGO_NEEDARG|AGO_EXCEPT0 }, + { '\0', "tr-stop", OPT_TR_STOP, AGO_NOARG }, + { '\0', "tr-no-rtt", OPT_TR_NO_RTT, AGO_NOARG }, + { '\0', "rand-dest", OPT_RAND_DEST, AGO_NOARG }, +@@ -503,9 +506,17 @@ + usec_delay.it_interval.tv_sec = 0; + usec_delay.it_value.tv_usec = + usec_delay.it_interval.tv_usec = 1; ++ break; ++ case OPT_FLOOD: ++ opt_flood = TRUE; ++ break; + case OPT_TR_KEEP_TTL: + opt_tr_keep_ttl = TRUE; + break; ++ case OPT_TCP_MSS: ++ opt_tcp_mss = TRUE; ++ tcp_mss = strtoul(ago_optarg, NULL, 0); ++ break; + case OPT_TCP_TIMESTAMP: + opt_tcp_timestamp = TRUE; + break; diff --git a/net/hping/patches/patch-al b/net/hping/patches/patch-al new file mode 100644 index 00000000000..7743a873626 --- /dev/null +++ b/net/hping/patches/patch-al @@ -0,0 +1,21 @@ +$NetBSD: patch-al,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- usage.c.orig 2003-08-08 01:55:55.000000000 +0200 ++++ usage.c 2005-11-05 21:48:56.000000000 +0100 +@@ -22,6 +22,8 @@ + " -c --count packet count\n" + " -i --interval wait (uX for X microseconds, for example -i u1000)\n" + " --fast alias for -i u10000 (10 packets for second)\n" ++" --faster alias for -i u1 (OS dependent results)\n" ++" --flood send as fast as you can\n" + " -n --numeric numeric output\n" + " -q --quiet quiet\n" + " -I --interface interface name (otherwise default routing interface)\n" +@@ -84,6 +86,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" diff --git a/net/hping/patches/patch-am b/net/hping/patches/patch-am new file mode 100644 index 00000000000..10e80ed53d4 --- /dev/null +++ b/net/hping/patches/patch-am @@ -0,0 +1,58 @@ +$NetBSD: patch-am,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- sendtcp.c.orig 2002-06-17 17:56:42.000000000 +0200 ++++ sendtcp.c 2005-11-05 21:51:35.000000000 +0100 +@@ -26,10 +26,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); +@@ -39,7 +41,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); +@@ -62,14 +64,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 */ diff --git a/net/hping/patches/patch-an b/net/hping/patches/patch-an new file mode 100644 index 00000000000..97c086fa17d --- /dev/null +++ b/net/hping/patches/patch-an @@ -0,0 +1,44 @@ +$NetBSD: patch-an,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- docs/hping2.8.orig 2003-08-09 03:50:52.000000000 +0200 ++++ docs/hping2.8 2005-11-05 22:06:29.000000000 +0100 +@@ -14,6 +14,10 @@ + ] [ + .B \-\-fast + ] [ ++.B \-\-faster ++] [ ++.B \-\-flood ++] [ + .B \-I + .I interface + ] [ +@@ -98,6 +102,8 @@ + ] [ + .B \-\-tcpexitcode + ] [ ++.B \-\-tcp-mss ++] [ + .B \-\-tcp-timestamp + ] [ + .B \-\-tr-stop +@@ -180,6 +186,9 @@ + .TP + .I --faster + Alias for -i u1. Faster then --fast ;) (but not as fast as your computer can send packets due to the signal-driven design). ++.TP ++.I --flood ++Send packets as fast as possible. + .TP + .I -n --numeric + Numeric output only, No attempt will be made to lookup symbolic names for host addresses. +@@ -501,6 +510,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. diff --git a/net/hping/patches/patch-ao b/net/hping/patches/patch-ao new file mode 100644 index 00000000000..259430740d1 --- /dev/null +++ b/net/hping/patches/patch-ao @@ -0,0 +1,13 @@ +$NetBSD: patch-ao,v 1.1 2006/03/30 13:51:29 salo Exp $ + +--- cksum.c.orig 2003-12-06 14:39:35.000000000 +0100 ++++ cksum.c 2005-11-05 21:35:00.000000000 +0100 +@@ -27,7 +27,7 @@ + + if (nbytes == 1) { + oddbyte = 0; +- *((__u16 *) &oddbyte) = *(__u16 *) buf; ++ *((__u8 *) &oddbyte) = *(__u8 *) buf; + sum += oddbyte; + } + -- cgit v1.2.3