diff options
author | obache <obache@pkgsrc.org> | 2009-02-11 08:06:17 +0000 |
---|---|---|
committer | obache <obache@pkgsrc.org> | 2009-02-11 08:06:17 +0000 |
commit | dca4ca3df879040e298c39b2392c7e0eb9c9327b (patch) | |
tree | 8639908c803b1060df5092198ed112e89cb28a28 /net/hping | |
parent | 240462e2c61540dadfce82bb389084c2d33b19b5 (diff) | |
download | pkgsrc-dca4ca3df879040e298c39b2392c7e0eb9c9327b.tar.gz |
* detection of endian in bytesex.h is not enough, use result of byteorder.h.
* replace hard coded user and mode for hping-suid option with SPECIAL_PERMS.
* replace remaining of hard coded "man" with ${PKGMANDIR}.
* add DESTDIR support.
* merge patch-a{e,g}, both for same file.
* patch to replace __sun__ with __sun for portability, pkglint(1) said.
* also regen other patches with mkpatches(1).
Diffstat (limited to 'net/hping')
-rw-r--r-- | net/hping/Makefile | 14 | ||||
-rw-r--r-- | net/hping/PLIST | 8 | ||||
-rw-r--r-- | net/hping/distinfo | 33 | ||||
-rw-r--r-- | net/hping/options.mk | 5 | ||||
-rw-r--r-- | net/hping/patches/patch-aa | 18 | ||||
-rw-r--r-- | net/hping/patches/patch-ab | 8 | ||||
-rw-r--r-- | net/hping/patches/patch-ac | 6 | ||||
-rw-r--r-- | net/hping/patches/patch-ad | 15 | ||||
-rw-r--r-- | net/hping/patches/patch-ae | 110 | ||||
-rw-r--r-- | net/hping/patches/patch-af | 16 | ||||
-rw-r--r-- | net/hping/patches/patch-ag | 83 | ||||
-rw-r--r-- | net/hping/patches/patch-ah | 12 | ||||
-rw-r--r-- | net/hping/patches/patch-ai | 12 | ||||
-rw-r--r-- | net/hping/patches/patch-aj | 8 | ||||
-rw-r--r-- | net/hping/patches/patch-ak | 12 | ||||
-rw-r--r-- | net/hping/patches/patch-al | 10 | ||||
-rw-r--r-- | net/hping/patches/patch-am | 12 | ||||
-rw-r--r-- | net/hping/patches/patch-an | 27 | ||||
-rw-r--r-- | net/hping/patches/patch-ao | 8 | ||||
-rw-r--r-- | net/hping/patches/patch-ap | 13 | ||||
-rw-r--r-- | net/hping/patches/patch-aq | 25 |
21 files changed, 263 insertions, 192 deletions
diff --git a/net/hping/Makefile b/net/hping/Makefile index db8d3ea24af..3ee1b409df4 100644 --- a/net/hping/Makefile +++ b/net/hping/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.9 2007/01/07 09:14:02 rillig Exp $ +# $NetBSD: Makefile,v 1.10 2009/02/11 08:06:17 obache Exp $ # DISTNAME= hping2.0.0-rc3 @@ -10,9 +10,11 @@ MAINTAINER= atatat@NetBSD.org HOMEPAGE= http://www.hping.org/ COMMENT= Command-line oriented TCP/IP packet assembler/analyzer +PKG_DESTDIR_SUPPORT= user-destdir + WRKSRC= ${WRKDIR}/hping2-rc3 HAS_CONFIGURE= YES -MANPATH= ${PREFIX}/man +MANPATH= ${PREFIX}/${PKGMANDIR} CONFIGURE_ENV+= MANPATH=${MANPATH:Q} INSTALLATION_DIRS= ${PKGMANDIR}/man8 sbin @@ -23,10 +25,10 @@ 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 - ${INSTALL_MAN} ${WRKSRC}/docs/hping2.8 ${PREFIX}/${PKGMANDIR}/man8 - ${LN} -s ../../man/man8/hping2.8 ${PREFIX}/${PKGMANDIR}/man8/hping.8 + ${INSTALL_PROGRAM} ${WRKSRC}/hping2 ${DESTDIR}${PREFIX}/sbin + ${LN} -s hping2 ${DESTDIR}${PREFIX}/sbin/hping + ${INSTALL_MAN} ${WRKSRC}/docs/hping2.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8 + ${LN} -s hping2.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8/hping.8 .include "../../net/libpcap/buildlink3.mk" .include "../../mk/bsd.pkg.mk" diff --git a/net/hping/PLIST b/net/hping/PLIST index f9a2788458f..6c702efc1d5 100644 --- a/net/hping/PLIST +++ b/net/hping/PLIST @@ -1,5 +1,5 @@ -@comment $NetBSD: PLIST,v 1.1.1.1 2002/04/04 17:02:30 atatat Exp $ -sbin/hping2 -sbin/hping -man/man8/hping2.8 +@comment $NetBSD: PLIST,v 1.2 2009/02/11 08:06:17 obache Exp $ man/man8/hping.8 +man/man8/hping2.8 +sbin/hping +sbin/hping2 diff --git a/net/hping/distinfo b/net/hping/distinfo index fa49431125e..d08b08cf30b 100644 --- a/net/hping/distinfo +++ b/net/hping/distinfo @@ -1,20 +1,21 @@ -$NetBSD: distinfo,v 1.7 2006/03/30 13:51:28 salo Exp $ +$NetBSD: distinfo,v 1.8 2009/02/11 08:06:17 obache Exp $ 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) = 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 +SHA1 (patch-aa) = 6d0e1dc19c1573fb15e482620b04a1dcd9366f55 +SHA1 (patch-ab) = 9862f8d4c350f5f242c5315521ca46053a055d58 +SHA1 (patch-ac) = 9608992ff762b779faf4417c4f19df7bf7f54361 +SHA1 (patch-ad) = d90ed1c6bebe74903f5f0f78ca292c8494f28f8b +SHA1 (patch-ae) = ad261bd6c3a86c6dafde85d4cd23ec46c3e49345 +SHA1 (patch-af) = 2809447092057013a4971843df7d7b7c7d860b62 +SHA1 (patch-ah) = f3599715ef150adbf435d4dee216dbd8cb90b52f +SHA1 (patch-ai) = e52b3544e0fdee5531362acebe16de6f56a938e0 +SHA1 (patch-aj) = 83c49aa82ad0bd90b877a7c14f9c46fb02e48622 +SHA1 (patch-ak) = 75772bcb61ae10957084a542858bffcae680d841 +SHA1 (patch-al) = 0e924bc1ac062f2b3d2a73d3aee7c23790ce75c5 +SHA1 (patch-am) = 658ac214b36c3f60b33b5eb4d7f7cd8153bd27b5 +SHA1 (patch-an) = f660b165d5564149a5b57fa7b84e305af1fefc51 +SHA1 (patch-ao) = 52d30d71d91c33174de17dd1d0096c05e533504b +SHA1 (patch-ap) = 369b03242eb513ba73d75e7102e7aa5491a13e2e +SHA1 (patch-aq) = 548dd11def5085580ec118bb8ecff43df60a4140 diff --git a/net/hping/options.mk b/net/hping/options.mk index 817f3c43564..e512b76087f 100644 --- a/net/hping/options.mk +++ b/net/hping/options.mk @@ -1,4 +1,4 @@ -# $NetBSD: options.mk,v 1.1 2006/03/30 13:51:28 salo Exp $ +# $NetBSD: options.mk,v 1.2 2009/02/11 08:06:17 obache Exp $ PKG_OPTIONS_VAR= PKG_OPTIONS.hping PKG_SUPPORTED_OPTIONS= hping-suid @@ -6,6 +6,5 @@ PKG_SUPPORTED_OPTIONS= hping-suid .include "../../mk/bsd.options.mk" .if !empty(PKG_OPTIONS:Mhping-suid) -BINOWN= root -BINMODE= 4511 +SPECIAL_PERMS+= sbin/hping2 ${SETUID_ROOT_PERMS} .endif diff --git a/net/hping/patches/patch-aa b/net/hping/patches/patch-aa index 01cb1db40ee..52197d7ec9c 100644 --- a/net/hping/patches/patch-aa +++ b/net/hping/patches/patch-aa @@ -1,8 +1,8 @@ -$NetBSD: patch-aa,v 1.3 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-aa,v 1.4 2009/02/11 08:06:17 obache Exp $ ---- 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 @@ +--- main.c.orig 2003-08-07 23:55:55.000000000 +0000 ++++ main.c +@@ -47,7 +47,8 @@ unsigned int signlen, lsr_length = 0, ssr_length = 0, @@ -12,7 +12,7 @@ $NetBSD: patch-aa,v 1.3 2006/03/30 13:51:29 salo Exp $ unsigned short int -@@ -65,6 +66,7 @@ +@@ -65,6 +66,7 @@ int recv_pkt = 0, out_of_sequence_pkt = 0, sending_wait = DEFAULT_SENDINGWAIT, /* see DEFAULT_SENDINGWAIT */ @@ -20,7 +20,7 @@ $NetBSD: patch-aa,v 1.3 2006/03/30 13:51:29 salo Exp $ opt_rawipmode = FALSE, opt_icmpmode = FALSE, opt_udpmode = FALSE, -@@ -98,6 +100,7 @@ +@@ -98,6 +100,7 @@ int opt_tcpexitcode = FALSE, opt_badcksum = FALSE, opt_tr_keep_ttl = FALSE, @@ -28,7 +28,7 @@ $NetBSD: patch-aa,v 1.3 2006/03/30 13:51:29 salo Exp $ opt_tcp_timestamp = FALSE, opt_tr_stop = FALSE, opt_tr_no_rtt = FALSE, -@@ -179,6 +182,17 @@ +@@ -179,6 +182,17 @@ int main(int argc, char **argv) char setflags[1024] = {'\0'}; int c, hdr_size; @@ -46,7 +46,7 @@ $NetBSD: patch-aa,v 1.3 2006/03/30 13:51:29 salo Exp $ if (parse_options(argc, argv) == -1) { printf("hping2: missing host argument\n" "Try `hping2 --help' for more information.\n"); -@@ -219,13 +233,6 @@ +@@ -219,13 +233,6 @@ int main(int argc, char **argv) ifname, ifstraddr, h_if_mtu); } @@ -60,7 +60,7 @@ $NetBSD: patch-aa,v 1.3 2006/03/30 13:51:29 salo Exp $ /* set SO_BROADCAST option */ socket_broadcast(sockraw); /* set SO_IPHDRINCL option */ -@@ -355,6 +362,13 @@ +@@ -355,6 +362,13 @@ int main(int argc, char **argv) } } diff --git a/net/hping/patches/patch-ab b/net/hping/patches/patch-ab index 5b9449fa0be..1e82dd68021 100644 --- a/net/hping/patches/patch-ab +++ b/net/hping/patches/patch-ab @@ -1,7 +1,7 @@ -$NetBSD: patch-ab,v 1.2 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-ab,v 1.3 2009/02/11 08:06:17 obache Exp $ ---- Makefile.in.orig 2004-05-03 11:29:39.000000000 +0200 -+++ Makefile.in 2005-11-05 21:07:50.000000000 +0100 +--- Makefile.in.orig 2004-05-03 09:29:39.000000000 +0000 ++++ Makefile.in @@ -6,14 +6,14 @@ # $date: Sun Jul 25 17:56:15 MET DST 1999$ # $rev: 3$ @@ -23,7 +23,7 @@ $NetBSD: patch-ab,v 1.2 2006/03/30 13:51:29 salo Exp $ INSTALL_MANPATH=@MANPATH@ @PCAP@ -@@ -39,21 +39,17 @@ +@@ -39,21 +39,17 @@ ARSOBJ = ars.o apd.o split.o all: hping2 libars.a: $(ARSOBJ) diff --git a/net/hping/patches/patch-ac b/net/hping/patches/patch-ac index ce113fee1bc..a9dc7af565e 100644 --- a/net/hping/patches/patch-ac +++ b/net/hping/patches/patch-ac @@ -1,8 +1,8 @@ -$NetBSD: patch-ac,v 1.1 2005/07/13 14:18:22 drochner Exp $ +$NetBSD: patch-ac,v 1.2 2009/02/11 08:06:17 obache Exp $ ---- configure.orig 2005-07-13 15:30:53.000000000 +0200 +--- configure.orig 2002-12-13 16:19:30.000000000 +0000 +++ configure -@@ -61,8 +61,8 @@ if [ "$CONFIGOSTYPE" = "LINUX" ]; then +@@ -66,8 +66,8 @@ if [ "$CONFIGOSTYPE" = "LINUX" ]; then PCAP="" PCAP_INCLUDE="" else diff --git a/net/hping/patches/patch-ad b/net/hping/patches/patch-ad index 4c31fcd378b..919c88f484e 100644 --- a/net/hping/patches/patch-ad +++ b/net/hping/patches/patch-ad @@ -1,7 +1,7 @@ -$NetBSD: patch-ad,v 1.3 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-ad,v 1.4 2009/02/11 08:06:17 obache Exp $ ---- libpcap_stuff.c.orig 2002-12-13 15:07:07.000000000 +0100 -+++ libpcap_stuff.c 2006-03-22 19:54:51.000000000 +0100 +--- libpcap_stuff.c.orig 2002-12-13 14:07:07.000000000 +0000 ++++ libpcap_stuff.c @@ -16,8 +16,10 @@ #include <string.h> #include <stdlib.h> @@ -14,3 +14,12 @@ $NetBSD: patch-ad,v 1.3 2006/03/30 13:51:29 salo Exp $ #include "globals.h" +@@ -35,7 +37,7 @@ int open_pcap() + printf("[open_pcap] pcap_open_live: %s\n", errbuf); + return -1; + } +-#if (!defined OSTYPE_LINUX) && (!defined __sun__) ++#if (!defined OSTYPE_LINUX) && (!defined __sun) + /* Return the packets to userspace as fast as possible */ + if (ioctl(pcap_fileno(pcapfp), BIOCIMMEDIATE, &on) == -1) + perror("[open_pcap] ioctl(... BIOCIMMEDIATE ...)"); diff --git a/net/hping/patches/patch-ae b/net/hping/patches/patch-ae index 00e0f32b6cb..718bef3148f 100644 --- a/net/hping/patches/patch-ae +++ b/net/hping/patches/patch-ae @@ -1,7 +1,7 @@ -$NetBSD: patch-ae,v 1.2 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-ae,v 1.3 2009/02/11 08:06:17 obache Exp $ ---- getifname.c.orig 2004-05-03 10:55:53.000000000 +0200 -+++ getifname.c 2006-03-22 19:56:40.000000000 +0100 +--- getifname.c.orig 2004-05-03 08:55:53.000000000 +0000 ++++ getifname.c @@ -17,7 +17,7 @@ #include <unistd.h> /* close */ @@ -11,16 +11,114 @@ $NetBSD: patch-ae,v 1.2 2006/03/30 13:51:29 salo Exp $ #include <stdlib.h> #include <ifaddrs.h> #include <net/route.h> -@@ -28,7 +28,7 @@ +@@ -27,12 +27,12 @@ + #include "globals.h" #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && \ - !defined(__linux__) && !defined(__sun__) && !defined(__bsdi__) && \ +- !defined(__linux__) && !defined(__sun__) && !defined(__bsdi__) && \ - !defined(__APPLE__) ++ !defined(__linux__) && !defined(__sun) && !defined(__bsdi__) && \ + !defined(__APPLE__) && !defined(__DragonFly__) #error Sorry, interface code not implemented. #endif -@@ -175,7 +175,7 @@ +-#ifdef __sun__ ++#ifdef __sun + #include <sys/sockio.h> + #include <net/route.h> + #include <net/if_dl.h> +@@ -40,15 +40,16 @@ + + static int get_output_if(struct sockaddr_in *dest, struct sockaddr_in *ifip); + +-#if (defined OSTYPE_LINUX) || (defined __sun__) ++#if (defined OSTYPE_LINUX) || (defined __sun) + int get_if_name(void) + { + 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 @@ int get_if_name(void) + 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)); +@@ -155,27 +175,28 @@ int get_if_name(void) + } + else + { +-#ifdef __sun__ ++#ifdef __sun + /* somehow solaris is braidamaged in wrt ifr_mtu */ + h_if_mtu = ifr.ifr_metric; + #else + 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; } #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ diff --git a/net/hping/patches/patch-af b/net/hping/patches/patch-af index f82c42fad50..3436725087a 100644 --- a/net/hping/patches/patch-af +++ b/net/hping/patches/patch-af @@ -1,8 +1,8 @@ -$NetBSD: patch-af,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-af,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- ars.c.orig 2003-07-28 09:00:54.000000000 +0000 ++++ ars.c +@@ -372,7 +372,7 @@ u_int16_t ars_cksum(void *vbuf, size_t n } if (nbytes == 1) { oddbyte = 0; @@ -11,7 +11,7 @@ $NetBSD: patch-af,v 1.1 2006/03/30 13:51:29 salo Exp $ sum += oddbyte; } sum = (sum >> 16) + (sum & 0xffff); -@@ -381,6 +381,13 @@ +@@ -381,6 +381,13 @@ u_int16_t ars_cksum(void *vbuf, size_t n } /* Multiple buffers checksum facility */ @@ -25,7 +25,7 @@ $NetBSD: patch-af,v 1.1 2006/03/30 13:51:29 salo Exp $ u_int16_t ars_multi_cksum(struct mc_context *c, int op, void *vbuf, size_t nbytes) { -@@ -394,38 +401,27 @@ +@@ -394,38 +401,27 @@ u_int16_t ars_multi_cksum(struct mc_cont c->old = 0; return -ARS_OK; } else if (op == ARS_MC_UPDATE) { @@ -56,13 +56,13 @@ $NetBSD: patch-af,v 1.1 2006/03/30 13:51:29 salo Exp $ + 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; diff --git a/net/hping/patches/patch-ag b/net/hping/patches/patch-ag deleted file mode 100644 index 2068ddcea31..00000000000 --- a/net/hping/patches/patch-ag +++ /dev/null @@ -1,83 +0,0 @@ -$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 index 5028e799c3f..05c5a3d4de8 100644 --- a/net/hping/patches/patch-ah +++ b/net/hping/patches/patch-ah @@ -1,8 +1,8 @@ -$NetBSD: patch-ah,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-ah,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- ip_opt_build.c.orig 2002-01-19 18:57:47.000000000 +0000 ++++ ip_opt_build.c +@@ -34,7 +34,8 @@ unsigned char ip_opt_build(char* ip_opt) } else { @@ -12,7 +12,7 @@ $NetBSD: patch-ah,v 1.1 2006/03/30 13:51:29 salo Exp $ opt_lsrr=0; } } -@@ -48,7 +49,8 @@ +@@ -48,7 +49,8 @@ unsigned char ip_opt_build(char* ip_opt) } else { @@ -22,7 +22,7 @@ $NetBSD: patch-ah,v 1.1 2006/03/30 13:51:29 salo Exp $ opt_ssrr=0; } } -@@ -66,7 +68,8 @@ +@@ -66,7 +68,8 @@ unsigned char ip_opt_build(char* ip_opt) } else { diff --git a/net/hping/patches/patch-ai b/net/hping/patches/patch-ai index 20c53f8d235..862cfcb1451 100644 --- a/net/hping/patches/patch-ai +++ b/net/hping/patches/patch-ai @@ -1,8 +1,8 @@ -$NetBSD: patch-ai,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-ai,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- globals.h.orig 2003-08-07 23:55:55.000000000 +0000 ++++ globals.h +@@ -32,7 +32,8 @@ extern unsigned int tcp_seqnum, set_ack, ip_header_length, @@ -12,7 +12,7 @@ $NetBSD: patch-ai,v 1.1 2006/03/30 13:51:29 salo Exp $ extern unsigned short int data_size; -@@ -44,6 +45,7 @@ +@@ -44,6 +45,7 @@ extern int opt_debug, recv_pkt, out_of_sequence_pkt, sending_wait, @@ -20,7 +20,7 @@ $NetBSD: patch-ai,v 1.1 2006/03/30 13:51:29 salo Exp $ opt_rawipmode, opt_icmpmode, opt_udpmode, -@@ -77,6 +79,7 @@ +@@ -77,6 +79,7 @@ extern int opt_debug, opt_tcpexitcode, opt_badcksum, opt_tr_keep_ttl, diff --git a/net/hping/patches/patch-aj b/net/hping/patches/patch-aj index 758d46f86c3..3f0dfb7b90b 100644 --- a/net/hping/patches/patch-aj +++ b/net/hping/patches/patch-aj @@ -1,8 +1,8 @@ -$NetBSD: patch-aj,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-aj,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- send.c.orig 2003-08-01 14:53:08.000000000 +0000 ++++ send.c +@@ -79,9 +79,17 @@ void send_packet (int signal_id) else send_tcp(); sent_pkt++; diff --git a/net/hping/patches/patch-ak b/net/hping/patches/patch-ak index f02ea15398e..1a5d721c03d 100644 --- a/net/hping/patches/patch-ak +++ b/net/hping/patches/patch-ak @@ -1,8 +1,8 @@ -$NetBSD: patch-ak,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-ak,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- parseoptions.c.orig 2003-08-08 14:39:00.000000000 +0000 ++++ parseoptions.c +@@ -31,10 +31,11 @@ enum { OPT_COUNT, OPT_INTERVAL, OPT_NUME 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, @@ -16,7 +16,7 @@ $NetBSD: patch-ak,v 1.1 2006/03/30 13:51:29 salo Exp $ static struct ago_optlist hping_optlist[] = { { 'c', "count", OPT_COUNT, AGO_NEEDARG }, -@@ -105,8 +106,10 @@ +@@ -105,8 +106,10 @@ static struct ago_optlist hping_optlist[ { '\0', "tcpexitcode", OPT_TCPEXITCODE, AGO_NOARG }, { '\0', "fast", OPT_FAST, AGO_NOARG|AGO_EXCEPT0 }, { '\0', "faster", OPT_FASTER, AGO_NOARG|AGO_EXCEPT0 }, @@ -27,7 +27,7 @@ $NetBSD: patch-ak,v 1.1 2006/03/30 13:51:29 salo Exp $ { '\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 @@ +@@ -503,9 +506,17 @@ int parse_options(int argc, char **argv) usec_delay.it_interval.tv_sec = 0; usec_delay.it_value.tv_usec = usec_delay.it_interval.tv_usec = 1; diff --git a/net/hping/patches/patch-al b/net/hping/patches/patch-al index 7743a873626..399de70548c 100644 --- a/net/hping/patches/patch-al +++ b/net/hping/patches/patch-al @@ -1,8 +1,8 @@ -$NetBSD: patch-al,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-al,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- usage.c.orig 2003-08-07 23:55:55.000000000 +0000 ++++ usage.c +@@ -22,6 +22,8 @@ void show_usage(void) " -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" @@ -11,7 +11,7 @@ $NetBSD: patch-al,v 1.1 2006/03/30 13:51:29 salo Exp $ " -n --numeric numeric output\n" " -q --quiet quiet\n" " -I --interface interface name (otherwise default routing interface)\n" -@@ -84,6 +86,7 @@ +@@ -84,6 +86,7 @@ void show_usage(void) " -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" diff --git a/net/hping/patches/patch-am b/net/hping/patches/patch-am index 10e80ed53d4..db4a6852b5e 100644 --- a/net/hping/patches/patch-am +++ b/net/hping/patches/patch-am @@ -1,8 +1,8 @@ -$NetBSD: patch-am,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-am,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- sendtcp.c.orig 2002-06-17 15:56:42.000000000 +0000 ++++ sendtcp.c +@@ -26,10 +26,12 @@ void send_tcp(void) char *packet, *data; struct mytcphdr *tcp; struct pseudohdr *pseudoheader; @@ -17,7 +17,7 @@ $NetBSD: patch-am,v 1.1 2006/03/30 13:51:29 salo Exp $ packet_size = TCPHDR_SIZE + tcp_opt_size + data_size; packet = malloc(PSEUDOHDR_SIZE + packet_size); -@@ -39,7 +41,7 @@ +@@ -39,7 +41,7 @@ void send_tcp(void) } pseudoheader = (struct pseudohdr*) packet; tcp = (struct mytcphdr*) (packet+PSEUDOHDR_SIZE); @@ -26,7 +26,7 @@ $NetBSD: patch-am,v 1.1 2006/03/30 13:51:29 salo Exp $ data = (char*) (packet+PSEUDOHDR_SIZE+TCPHDR_SIZE+tcp_opt_size); memset(packet, 0, PSEUDOHDR_SIZE+packet_size); -@@ -62,14 +64,24 @@ +@@ -62,14 +64,24 @@ void send_tcp(void) tcp->th_win = htons(src_winsize); tcp->th_flags = tcp_th_flags; diff --git a/net/hping/patches/patch-an b/net/hping/patches/patch-an index 97c086fa17d..084a5f1b0c7 100644 --- a/net/hping/patches/patch-an +++ b/net/hping/patches/patch-an @@ -1,8 +1,8 @@ -$NetBSD: patch-an,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-an,v 1.2 2009/02/11 08:06:17 obache 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 @@ +--- docs/hping2.8.orig 2003-08-09 01:50:52.000000000 +0000 ++++ docs/hping2.8 +@@ -14,6 +14,10 @@ hping2 \- send (almost) arbitrary TCP/IP ] [ .B \-\-fast ] [ @@ -13,7 +13,7 @@ $NetBSD: patch-an,v 1.1 2006/03/30 13:51:29 salo Exp $ .B \-I .I interface ] [ -@@ -98,6 +102,8 @@ +@@ -98,6 +102,8 @@ hping2 \- send (almost) arbitrary TCP/IP ] [ .B \-\-tcpexitcode ] [ @@ -22,17 +22,17 @@ $NetBSD: patch-an,v 1.1 2006/03/30 13:51:29 salo Exp $ .B \-\-tcp-timestamp ] [ .B \-\-tr-stop -@@ -180,6 +186,9 @@ - .TP +@@ -181,6 +187,9 @@ Alias for -i u10000. Hping will send 10 .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 + .TP +.I --flood +Send packets as fast as possible. - .TP ++.TP .I -n --numeric Numeric output only, No attempt will be made to lookup symbolic names for host addresses. -@@ -501,6 +510,9 @@ + .TP +@@ -501,6 +510,9 @@ numbers are predictable. .I -b --badcksum Send packets with a bad UDP/TCP checksum. .TP @@ -42,3 +42,10 @@ $NetBSD: patch-an,v 1.1 2006/03/30 13:51:29 salo Exp $ .I --tcp-timestamp Enable the TCP timestamp option, and try to guess the timestamp update frequency and the remote system uptime. +@@ -714,4 +726,4 @@ On solaris hping does not work on the lo + a solaris problem, as stated in the tcpdump-workers mailing list, + so the libpcap can't do nothing to handle it properly. + .SH SEE ALSO +-ping(8), traceroute(8), ifconfig(8), nmap(1) +\ No newline at end of file ++ping(8), traceroute(8), ifconfig(8), nmap(1) diff --git a/net/hping/patches/patch-ao b/net/hping/patches/patch-ao index 259430740d1..45635657715 100644 --- a/net/hping/patches/patch-ao +++ b/net/hping/patches/patch-ao @@ -1,8 +1,8 @@ -$NetBSD: patch-ao,v 1.1 2006/03/30 13:51:29 salo Exp $ +$NetBSD: patch-ao,v 1.2 2009/02/11 08:06:18 obache 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 @@ +--- cksum.c.orig 2003-12-06 13:39:35.000000000 +0000 ++++ cksum.c +@@ -27,7 +27,7 @@ __u16 cksum(__u16 *buf, int nbytes) if (nbytes == 1) { oddbyte = 0; diff --git a/net/hping/patches/patch-ap b/net/hping/patches/patch-ap new file mode 100644 index 00000000000..fab94ccb183 --- /dev/null +++ b/net/hping/patches/patch-ap @@ -0,0 +1,13 @@ +$NetBSD: patch-ap,v 1.1 2009/02/11 08:06:18 obache Exp $ + +--- hping2.h.orig 2003-08-07 23:55:55.000000000 +0000 ++++ hping2.h +@@ -19,7 +19,7 @@ + #include "byteorder.h" + #include "systype.h" + +-#ifdef __sun__ ++#ifdef __sun + typedef char int_8_t; + typedef unsigned char u_int8_t; + typedef short int_16_t; diff --git a/net/hping/patches/patch-aq b/net/hping/patches/patch-aq new file mode 100644 index 00000000000..ce4211ea3fb --- /dev/null +++ b/net/hping/patches/patch-aq @@ -0,0 +1,25 @@ +$NetBSD: patch-aq,v 1.1 2009/02/11 08:06:18 obache Exp $ + +--- bytesex.h.orig 2003-07-28 09:00:55.000000000 +0000 ++++ bytesex.h +@@ -7,16 +7,11 @@ + #ifndef ARS_BYTESEX_H + #define ARS_BYTESEX_H + +-#if defined(__i386__) \ +- || defined(__alpha__) \ +- || (defined(__mips__) && (defined(MIPSEL) || defined (__MIPSEL__))) ++#include "byteorder.h" ++ ++#if defined(__LITTLE_ENDIAN_BITFIELD) + #define BYTE_ORDER_LITTLE_ENDIAN +-#elif defined(__mc68000__) \ +- || defined (__sparc__) \ +- || defined (__sparc) \ +- || defined (__PPC__) \ +- || defined (__BIG_ENDIAN__) \ +- || (defined(__mips__) && (defined(MIPSEB) || defined (__MIPSEB__))) ++#elif defined(__BIG_ENDIAN_BITFIELD) + #define BYTE_ORDER_BIG_ENDIAN + #else + # error can not find the byte order for this architecture, fix bytesex.h |