Compile Hping on OpenSuse (and maybe others…)

I could not find any package for Hping3 in the repositories of OpenSuse (both official and non official). However, the source of Hping3 is available here and (almost) ready to be compiled. Almost ? let’s see why…

For compilation, you will need libpcap and tcl headers. That was available for me in the repositories. But, I still had an error during the compilation :

$ make
gcc -c -O2 -Wall    -g  main.c
gcc -c -O2 -Wall    -g  getifname.c
getifname.c: In function ‘get_output_if’:
getifname.c:343: warning: pointer targets in passing argument 3 of ‘getsockname’ differ in signedness
gcc -c -O2 -Wall    -g  getlhs.c
gcc -c -O2 -Wall    -g  parseoptions.c
gcc -c -O2 -Wall    -g  datafiller.c
gcc -c -O2 -Wall    -g  datahandler.c
gcc -c -O2 -Wall    -g  gethostname.c
gcc -c -O2 -Wall    -g  binding.c
gcc -c -O2 -Wall    -g  getusec.c
gcc -c -O2 -Wall    -g  opensockraw.c
gcc -c -O2 -Wall    -g  logicmp.c
gcc -c -O2 -Wall    -g  waitpacket.c
gcc -c -O2 -Wall    -g  resolve.c
gcc -c -O2 -Wall    -g  sendip.c
gcc -c -O2 -Wall    -g  sendicmp.c
gcc -c -O2 -Wall    -g  sendudp.c
gcc -c -O2 -Wall    -g  sendtcp.c
gcc -c -O2 -Wall    -g  cksum.c
gcc -c -O2 -Wall    -g  statistics.c
gcc -c -O2 -Wall    -g  usage.c
gcc -c -O2 -Wall    -g  version.c
gcc -c -O2 -Wall    -g  antigetopt.c
gcc -c -O2 -Wall    -g  sockopt.c
gcc -c -O2 -Wall    -g  listen.c
gcc -c -O2 -Wall    -g  sendhcmp.c
gcc -c -O2 -Wall    -g  memstr.c
gcc -c -O2 -Wall    -g  rtt.c
gcc -c -O2 -Wall    -g  relid.c
gcc -c -O2 -Wall    -g  sendip_handler.c
gcc -c -O2 -Wall    -g  libpcap_stuff.c
libpcap_stuff.c:20:21: error: net/bpf.h: Aucun fichier ou répertoire de ce type
libpcap_stuff.c: In function ‘pcap_recv’:
libpcap_stuff.c:61: warning: pointer targets in assignment differ in signedness
make: *** [libpcap_stuff.o] Erreur 1

I went through it doing :

$ ln -s /usr/include/pcap-bpf.h /usr/include/net/bpf.h

It is not the best solution, but at least it works. These paths related issues depending on the distribution are so annoying…

UPDATE for openSUSE 11.1 :

First, I got this error :

error "Please, edit Makefile and add -DBYTE_ORDER_(BIG|LITTLE)_ENDIAN

In addition to the above trick, if you are runing 64 bits, you need to apply hping-suse.patch to the source :

$ patch -p0 < hping-suse.patch

Then, I still had an issue with the tcl-devel package which is a prerequisite to compile hping with tcl-support.
The error :

/usr/bin/ld: cannot find -ltcl

I ended up compiling tcl from the source, and finally it compiled properly…