2018-05-19 12:36:22 +00:00
|
|
|
{ stdenv, lib, fetchurl, pkgconfig
|
|
|
|
, dpdk, libpcap, numactl, utillinux
|
2016-09-11 21:24:51 +00:00
|
|
|
, gtk2, withGtk ? false
|
2016-06-29 08:34:17 +00:00
|
|
|
}:
|
2016-06-01 23:41:25 +00:00
|
|
|
|
2018-05-19 12:36:22 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
# pktgen needs a specific version of lua to apply its patch (see lib/lua/Makefile).
|
|
|
|
lua = rec {
|
|
|
|
name = "lua-5.3.4";
|
|
|
|
basename = name + ".tar.gz";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.lua.org/ftp/${basename}";
|
|
|
|
sha256 = "0320a8dg3aci4hxla380dx1ifkw8gj4gbw5c4dz41g1kh98sm0gn";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "pktgen";
|
2018-05-19 12:36:22 +00:00
|
|
|
version = "3.5.0";
|
2016-06-01 23:41:25 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2018-05-19 12:36:22 +00:00
|
|
|
url = "http://dpdk.org/browse/apps/pktgen-dpdk/snapshot/pktgen-${version}.tar.xz";
|
|
|
|
sha256 = "1gy99jr9dbwzi9pd3w5k673h3pfnbkz6rbzmrkwcyis72pnphy5z";
|
2016-06-01 23:41:25 +00:00
|
|
|
};
|
|
|
|
|
2016-06-29 08:34:17 +00:00
|
|
|
nativeBuildInputs = stdenv.lib.optionals withGtk [ pkgconfig ];
|
|
|
|
|
|
|
|
buildInputs =
|
2018-05-19 12:36:22 +00:00
|
|
|
[ dpdk libpcap numactl ]
|
2016-09-11 21:24:51 +00:00
|
|
|
++ stdenv.lib.optionals withGtk [gtk2];
|
2016-06-01 23:41:25 +00:00
|
|
|
|
2018-05-21 01:04:31 +00:00
|
|
|
RTE_SDK = "${dpdk}/share/dpdk";
|
2016-06-01 23:41:25 +00:00
|
|
|
RTE_TARGET = "x86_64-native-linuxapp-gcc";
|
2016-06-29 08:34:17 +00:00
|
|
|
GUI = stdenv.lib.optionalString withGtk "true";
|
2016-06-01 23:41:25 +00:00
|
|
|
|
2018-05-19 12:36:22 +00:00
|
|
|
NIX_CFLAGS_COMPILE = [ "-msse3" ];
|
2016-06-03 17:57:40 +00:00
|
|
|
|
2018-05-19 12:36:22 +00:00
|
|
|
postPatch = let dpdkMajor = lib.versions.major dpdk.version; in ''
|
|
|
|
substituteInPlace app/Makefile --replace 'yy :=' 'yy := ${dpdkMajor} #'
|
2017-01-01 23:37:59 +00:00
|
|
|
substituteInPlace lib/common/lscpu.h --replace /usr/bin/lscpu ${utillinux}/bin/lscpu
|
2018-05-19 12:36:22 +00:00
|
|
|
|
|
|
|
ln -s ${lua.src} lib/lua/${lua.basename}
|
|
|
|
make -C lib/lua get_tarball # unpack and patch
|
|
|
|
substituteInPlace lib/lua/${lua.name}/src/luaconf.h --replace /usr/local $out
|
2017-01-01 23:37:59 +00:00
|
|
|
'';
|
|
|
|
|
2016-06-01 23:41:25 +00:00
|
|
|
installPhase = ''
|
|
|
|
install -d $out/bin
|
2017-09-09 01:29:26 +00:00
|
|
|
install -m 0755 app/${RTE_TARGET}/pktgen $out/bin
|
2016-06-01 23:41:25 +00:00
|
|
|
install -d $out/lib/lua/5.3
|
|
|
|
install -m 0644 Pktgen.lua $out/lib/lua/5.3
|
|
|
|
'';
|
|
|
|
|
2018-05-19 12:36:22 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2016-06-01 23:41:25 +00:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Traffic generator powered by DPDK";
|
|
|
|
homepage = http://dpdk.org/;
|
|
|
|
license = licenses.bsdOriginal;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
maintainers = [ maintainers.abuibrahim ];
|
|
|
|
};
|
|
|
|
}
|