1 { lib, stdenv, fetchFromGitHub, fetchpatch, libpcap, withTcl ? true, tcl }:
3 stdenv.mkDerivation rec {
5 version = "2014-12-26";
7 src = fetchFromGitHub {
10 rev = "3547c7691742c6eaa31f8402e0ccbb81387c1b99"; # there are no tags/releases
11 sha256 = "0y0n1ybij3yg9lfgzcwfmjz1sjg913zcqrv391xx83dm0j80sdpb";
14 # Pull patch pending upstream inclusion for -fno-common toolchain
15 # support: https://github.com/antirez/hping/pull/64
17 name = "fno-common.patch";
18 url = "https://github.com/antirez/hping/pull/64/commits/d057b9309aec3a5a53aaee1ac3451a8a5b71b4e8.patch";
19 sha256 = "0bqr7kdlziijja588ipj8g5hv2109wq01c6x2qadbhjfnsps1b6l";
23 buildInputs = [ libpcap ] ++ lib.optional withTcl tcl;
26 substituteInPlace Makefile.in --replace "gcc" "$CC"
27 substituteInPlace version.c --replace "RELEASE_DATE" "\"$version\""
28 '' + lib.optionalString stdenv.hostPlatform.isLinux ''
29 sed -i -e 's|#include <net/bpf.h>|#include <pcap/bpf.h>|' \
30 libpcap_stuff.c script.c
31 '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
32 substituteInPlace configure --replace 'BYTEORDER=`./byteorder -m`' BYTEORDER=${
34 littleEndian = "__LITTLE_ENDIAN_BITFIELD";
35 bigEndian = "__BIG_ENDIAN_BITFIELD";
36 }.${stdenv.hostPlatform.parsed.cpu.significantByte.name}}
37 substituteInPlace Makefile.in --replace './hping3 -v' ""
40 configureFlags = [ (if withTcl then "TCLSH=${tcl}/bin/tclsh" else "--no-tcl") ];
43 install -Dm755 hping3 -t $out/sbin
44 ln -s $out/sbin/hping3 $out/sbin/hping
45 ln -s $out/sbin/hping3 $out/sbin/hping2
46 install -Dm644 docs/hping3.8 -t $out/share/man/man8
47 ln -s hping3.8.gz $out/share/man/man8/hping.8.gz
48 ln -s hping3.8.gz $out/share/man/man8/hping2.8.gz
52 description = "Command-line oriented TCP/IP packet assembler/analyzer";
53 homepage = "http://www.hping.org/";
54 license = licenses.gpl2Only;
55 platforms = platforms.unix;