build: Use NACL_{INC,LIB}_DIR set by configure

The environment variables $NACL_INC_DIR/$NACL_LIB_DIR might not always
be set, but the configure script will attempt to detect an existing NaCl
installation if they aren't. Thus use the
$CONFIG_NACL_INC_DIR/$CONFIG_NACL_LIB_DIR variables as emitted by the
configure script for the build.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
flowtop: Fix compiler warnings

Fix the following compiler warnings that occur when building with "-W
-Wall -Wextra":

flowtop.c: In function ‘walk_process’:
flowtop.c:417:45: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
flowtop.c: In function ‘presenter_screen_update’:
flowtop.c:937:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
flowtop.c:938:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
man: Align synopsis with other sections

In all the tools' man pages the synopsis line is indented by one space
with respect to the text in the sections above and below. Remove the
space to have consistent alignment.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
build: use VERSION_SHORT instead of VERSION_STRING

We have recently changed VERSION_STRING to append CONFIG_RC at the
end of the string. Thus, for the build system, change it to
VERSION_SHORT where needed, e.g. in release targets where the "+"
appendix is not wished.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: tag: add 'v' prefix for tag name

We need to add a 'v' prefix to the actual version for the tag name.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: fix up GIT_PEOPLE and GIT_LOG macros

Fix them up so that a proper changelog can be generated automatically.
Also while at it, add two "hidden" targets that can be used to test
their output.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: fix up announce message in announce target

Bring the announce message in line with the latest released announce
message from rc1. So that in future this can be generated automatically.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: Don't uninstall configuration files

Several of the tools install/uninstall files from $NCONF_FILES,
however if we call the uninstall target for a specific tool (e.g.  `make
astraceroute_uninstall') but other tools depending on one or more of the
config files are still installed, the file is still removed
unconditionally. As it would require quite some logic in the Makefile
in order to detect installed tools and their dependencies, we just don't
uninstall the configuration files anymore.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
build: reduce Extra contents to bare minimum

Improve the build system, so that configuration files are installed
per tool basis. Also, introduce post_install targets, so that config
files can be altered in some way, e.g. done by trafgen. Moreover,
move custom targets from Extra to tool-specific Makefiles.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
build: Use -n option to head command

Make the call to `head' equivalent to the one to `tail'.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
dev: Constify `ifname' parameter to device_up_and_running()

The parameter `ifname' to device_up_and_running() is never modified
inside the function, thus mark it as const.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ioops: Constify `name' parameter to tun_open_or_die()

The parameter `name' to tun_open_or_die() is never modified
inside the function, thus mark it as const.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
netsniff-ng 0.5.8-rc2

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
build: split CFLAGS_DEF and always add CFLAGS_MIN

Currently, when doing a custom "make CFLAGS=...", we run into a compile
error as several necessary defines are not set. Therefore, use override
to always set those.

Reported-by: Marco Belmonte <mbelmonte@globalmedia.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
trafgen: Remove unused local variable in apply_*() functions.

The variable `i' in apply_counter(), apply_randomizer() and
apply_csum16() is only set once, so use the original parameter
`counter_id' instead. Rename `counter_id' to `id' in order to keep it
short.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
built_in: Add min_t() and max_t() macros and use them

Introduce non-typechecking versions of min_t() and max_t() and use them
where a cast would be needed.

The macros were taken from the Linux Kernel, release under GPL v2.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
build: prevent redefinition of _FORTIFY_SOURCE in gentoo

Add a -U_FORTIFY_SOURCE in HARDENING=1 [1] to prevent [2], e.g. as in:

x86_64-pc-linux-gnu-gcc -march=native -O2 -pipe -std=gnu99 -pipe -fPIE
  -pie -Wl,-z,relro,-z,now -fstack-protector-all -Wstack-protector
  --param=ssp-buffer-size=4 -ftrapv -D_FORTIFY_SOURCE=2 -fexceptions
  -fomit-frame-pointer -fno-strict-aliasing -fasynchronous-unwind-tables
  -fno-delete-null-pointer-checks -D_REENTRANT -D_LARGEFILE_SOURCE
  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DVERSION_STRING=\""0.5.8-rc2"""\"
  -DVERSION_LONG=\""0.5.8-rc2"" (Ziggomatic)"\" -DPREFIX_STRING=\"\"
  -Wall -I. -I/usr/include/libnl3 -I/usr/include/libnl3
  -DHAVE_DISSECTOR_PROTOS -DNEED_TCPDUMP_LIKE_FILTER -I/usr/include/libnl3
  -I/usr/include/libnl3 -DHAVE_DISSECTOR_PROTOS -DNEED_TCPDUMP_LIKE_FILTER
  -o netsniff-ng/proto_igmp.o -c proto_igmp.c
:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]
proto_igmp.c:1:0: note: this is the location of the previous definition

[1] http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-analyzer/netsniff-ng/files/netsniff-ng-0.5.8-fortify_source.patch?revision=1.1&view=markup
[2] http://b-4.xmw.de/var/log/portage/build/net-analyzer/netsniff-ng-0.5.8_rc2:20130805-070734.log

Reported-by: Michael Weber <michael@xmw.de>
Suggested-by: Michael Weber <michael@xmw.de>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
mausezahn: libcli: add sys/time.h for older libcli versions

Older versions of libcli lack an include in libcli.h. [1] fixed the
configure script to not fail in in the test [2], and an include into
cli.h was added as well for the main mausezahn build.

[1] http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-analyzer/netsniff-ng/files/netsniff-ng-0.5.8-libcli-test.patch?revision=1.1&view=markup
[2] http://b-4.xmw.de/var/log/portage/build/net-analyzer/netsniff-ng-0.5.8_rc2:20130805-055918.log

Reported-by: Michael Weber <michael@xmw.de>
Suggested-by: Michael Weber <michael@xmw.de>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
astraceroute: Use size_t for struct members storing packet lengths

Packet lengths are strictly positive and the functions dealing with them
(sendto(), recvfrom() etc.) take size_t, thus use size_t.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
dev: Make device_mtu() return size_t

We don't return negative values and the MTU is supposed to be the
(maximum) length of a packet, thus make it of type size_t. Most of the
users in the code store it in size_t already anyway.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>