2022-06-16 17:23:12 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, libpcap, withTcl ? true, tcl }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "hping";
|
2020-09-25 04:45:31 +00:00
|
|
|
version = "2014-12-26";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "antirez";
|
|
|
|
repo = pname;
|
|
|
|
rev = "3547c7691742c6eaa31f8402e0ccbb81387c1b99"; # there are no tags/releases
|
|
|
|
sha256 = "0y0n1ybij3yg9lfgzcwfmjz1sjg913zcqrv391xx83dm0j80sdpb";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-06-16 17:23:12 +00:00
|
|
|
patches = [
|
|
|
|
# Pull patch pending upstream inclusion for -fno-common toolchain
|
|
|
|
# support: https://github.com/antirez/hping/pull/64
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fno-common.patch";
|
|
|
|
url = "https://github.com/antirez/hping/pull/64/commits/d057b9309aec3a5a53aaee1ac3451a8a5b71b4e8.patch";
|
|
|
|
sha256 = "0bqr7kdlziijja588ipj8g5hv2109wq01c6x2qadbhjfnsps1b6l";
|
|
|
|
})
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
buildInputs = [ libpcap ] ++ lib.optional withTcl tcl;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile.in --replace "gcc" "$CC"
|
|
|
|
substituteInPlace version.c --replace "RELEASE_DATE" "\"$version\""
|
2024-09-26 11:04:55 +00:00
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
|
2020-09-25 04:45:31 +00:00
|
|
|
sed -i -e 's|#include <net/bpf.h>|#include <pcap/bpf.h>|' \
|
2020-04-24 23:36:52 +00:00
|
|
|
libpcap_stuff.c script.c
|
2024-01-02 11:29:13 +00:00
|
|
|
'' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
|
|
|
|
substituteInPlace configure --replace 'BYTEORDER=`./byteorder -m`' BYTEORDER=${
|
|
|
|
{
|
|
|
|
littleEndian = "__LITTLE_ENDIAN_BITFIELD";
|
|
|
|
bigEndian = "__BIG_ENDIAN_BITFIELD";
|
|
|
|
}.${stdenv.hostPlatform.parsed.cpu.significantByte.name}}
|
|
|
|
substituteInPlace Makefile.in --replace './hping3 -v' ""
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
configureFlags = [ (if withTcl then "TCLSH=${tcl}/bin/tclsh" else "--no-tcl") ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 hping3 -t $out/sbin
|
|
|
|
ln -s $out/sbin/hping3 $out/sbin/hping
|
|
|
|
ln -s $out/sbin/hping3 $out/sbin/hping2
|
|
|
|
install -Dm644 docs/hping3.8 -t $out/share/man/man8
|
|
|
|
ln -s hping3.8.gz $out/share/man/man8/hping.8.gz
|
|
|
|
ln -s hping3.8.gz $out/share/man/man8/hping2.8.gz
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Command-line oriented TCP/IP packet assembler/analyzer";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://www.hping.org/";
|
2020-09-25 04:45:31 +00:00
|
|
|
license = licenses.gpl2Only;
|
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|