aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/tools/networking/hping/default.nix
blob: daa0ba38e9ee7ac18a8b3b940848ebdd9c3da88d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ stdenv, fetchFromGitHub, libpcap, withTcl ? true, tcl }:

stdenv.mkDerivation rec {
  pname = "hping";
  version = "2014-12-26";

  src = fetchFromGitHub {
    owner = "antirez";
    repo = pname;
    rev = "3547c7691742c6eaa31f8402e0ccbb81387c1b99"; # there are no tags/releases
    sha256 = "0y0n1ybij3yg9lfgzcwfmjz1sjg913zcqrv391xx83dm0j80sdpb";
  };

  buildInputs = [ libpcap ] ++ stdenv.lib.optional withTcl tcl;

  postPatch = ''
    substituteInPlace Makefile.in --replace "gcc" "$CC"
    substituteInPlace version.c --replace "RELEASE_DATE" "\"$version\""
  '' + stdenv.lib.optionalString stdenv.isLinux ''
    sed -i -e 's|#include <net/bpf.h>|#include <pcap/bpf.h>|' \
      libpcap_stuff.c script.c
  '';

  configureFlags = [ (if withTcl then "TCLSH=${tcl}/bin/tclsh" else "--no-tcl") ];

  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
  '';

  meta = with stdenv.lib; {
    description = "A command-line oriented TCP/IP packet assembler/analyzer";
    homepage = "http://www.hping.org/";
    license = licenses.gpl2Only;
    platforms = platforms.unix;
  };
}