netsniff-ng.git
14 months agomausezahn: use getopt_long instead of getoptmaster
Zahari Doychev [Thu, 8 Dec 2022 16:40:17 +0000 (8 17:40 +0100)]
mausezahn: use getopt_long instead of getopt

The musl getopt stops processing the options at the first non-option
argument comapared to the glibc variant. Using getopt_long fixes this
problem.

Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
23 months agotrafgen: Check pointer in ipv6 device address lookup function
MatPerin [Fri, 15 Apr 2022 02:15:07 +0000 (14 22:15 -0400)]
trafgen: Check pointer in ipv6 device address lookup function

The getifaddrs function returns a linked list node for L2
even in the case of L3 interfaces (e.g. a TUN device), but
with the pointer to the address structure set to NULL.
This causes a segfault when trying to access the address
family from it when such network interfaces are present
in the system.

The issue is solved by checking the validity of the pointer
beforehand: if the address structure is present the address
family can be fetched and the current iteration can go on
safely, otherwise the node is skipped (as it is not linked
to any address).

Signed-off-by: Matteo Perin <matteoperin1302@gmail.com>
2 years agonetsniff-ng: dump stats on stderr when fdo is stdout
Clément Péron [Thu, 17 Feb 2022 17:38:59 +0000 (17 18:38 +0100)]
netsniff-ng: dump stats on stderr when fdo is stdout

When the output of netsniff-ng is configured as stdout, there is
no more stats outputed.

Let's output them on stderr.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2 years agoCmds: automatically create folder
Clément Péron [Thu, 17 Feb 2022 17:39:06 +0000 (17 18:39 +0100)]
Cmds: automatically create folder

When installing netsniff-ng, the make install complain when
the folder are not present.

Let's create them for the user.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2 years agotrafgen: Fix documentation for seqinc and seqdec
Sean Anderson [Tue, 7 Dec 2021 19:55:10 +0000 (7 14:55 -0500)]
trafgen: Fix documentation for seqinc and seqdec

These functions take the "times" argument as the second parameter, not
the third.

Fixes: 00e83a5 ("man: trafgen: finish syntax section")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2 years agoci: install libsodium in build tests
Tobias Klauser [Thu, 2 Sep 2021 13:11:49 +0000 (2 15:11 +0200)]
ci: install libsodium in build tests

This allows to test the curvetun build.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2 years agotrafgen.8: fix typo in example packet
Baruch Siach [Thu, 2 Sep 2021 11:01:10 +0000 (2 14:01 +0300)]
trafgen.8: fix typo in example packet

First MAC address is destination, but the second is source.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2 years agoDetect libpcap dependencies using pkg-config
Baruch Siach [Thu, 2 Sep 2021 09:56:00 +0000 (2 12:56 +0300)]
Detect libpcap dependencies using pkg-config

When building statically the link command line must include all
dependencies of all libraries. libpcap can optionally depend on libnl.
mausezahn can't build statically in this case.

Use pkg-config in configure and in the link command to construct the
library flags we need to link with libpcap.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agotrafgen: allow to use a range of CPUs starting from any CPU
Ivan Koveshnikov [Mon, 29 Mar 2021 12:38:01 +0000 (29 17:38 +0500)]
trafgen: allow to use a range of CPUs starting from any CPU

Signed-off-by: Ivan Koveshnikov <ivan.koveshnikov@gcorelabs.com>
3 years agotrafgen: allow to set packet rate in kpps and Mpps
Ivan Koveshnikov [Mon, 29 Mar 2021 11:12:15 +0000 (29 16:12 +0500)]
trafgen: allow to set packet rate in kpps and Mpps

Signed-off-by: Ivan Koveshnikov <ivan.koveshnikov@gcorelabs.com>
3 years agoRemove mentions of Travis CI in docs and config
Tobias Klauser [Mon, 29 Mar 2021 16:36:24 +0000 (29 18:36 +0200)]
Remove mentions of Travis CI in docs and config

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoRemove Travis CI integration
Tobias Klauser [Mon, 29 Mar 2021 16:15:57 +0000 (29 18:15 +0200)]
Remove Travis CI integration

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoAdd GitHub action for build testing
Tobias Klauser [Mon, 29 Mar 2021 16:15:38 +0000 (29 18:15 +0200)]
Add GitHub action for build testing

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agonetsniff-ng v0.6.8v0.6.8
Tobias Klauser [Mon, 11 Jan 2021 11:47:19 +0000 (11 12:47 +0100)]
netsniff-ng v0.6.8

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoastraceroute: make some panic() messages more verbose
uno20001 [Tue, 8 Oct 2019 10:43:18 +0000 (8 12:43 +0200)]
astraceroute: make some panic() messages more verbose

Signed-off-by: uno20001 <regisztralo111@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoastraceroute: change type of variables from int to bool in struct ctx
uno20001 [Tue, 8 Oct 2019 10:41:37 +0000 (8 12:41 +0200)]
astraceroute: change type of variables from int to bool in struct ctx

Signed-off-by: uno20001 <regisztralo111@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoall: change bug report instructions in copyright message
Tobias Klauser [Fri, 2 Oct 2020 15:27:26 +0000 (2 17:27 +0200)]
all: change bug report instructions in copyright message

The bugs@netsniff-ng.org e-mail bounces. Also it's more convenient to
report bugs using GitHub rather than via e-mail, so consistently mention
https://github.com/netsniff-ng/netsniff-ng/issues for where to report
bugs.

Fixes #226

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agomausezahn: move variable definitions from mz.h to mausezahn.c
Tobias Klauser [Wed, 19 Aug 2020 11:13:54 +0000 (19 13:13 +0200)]
mausezahn: move variable definitions from mz.h to mausezahn.c

Move variable definitions to avoid "multiple definition of symbol"
linker errors with gcc-10.

Fixes #216

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agomausezahn: move variable definitions from llist.h to llist.c
Tobias Klauser [Wed, 19 Aug 2020 11:13:34 +0000 (19 13:13 +0200)]
mausezahn: move variable definitions from llist.h to llist.c

Move variable definitions to avoid "multiple definition of symbol"
linker errors with gcc-10.

Updates #216

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agomausezahn: move variable definitions from mops.h to mops.c
Tobias Klauser [Wed, 19 Aug 2020 10:58:51 +0000 (19 12:58 +0200)]
mausezahn: move variable definitions from mops.h to mops.c

Move variable definitions to avoid "multiple definition of symbol"
linker errors with gcc-10.

Updates #216

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agomausezahn: move variable definitions cli.h to cli.c
Tobias Klauser [Wed, 19 Aug 2020 10:04:47 +0000 (19 12:04 +0200)]
mausezahn: move variable definitions cli.h to cli.c

Move variable definitions to avoid "multiple definition of symbol"
linker errors with gcc-10.

Updates #216

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agomausezahn: make needlessly global variables static
Tobias Klauser [Thu, 13 Aug 2020 10:09:28 +0000 (13 12:09 +0200)]
mausezahn: make needlessly global variables static

Move variables only used withing a single compilation unit from mz.h and
make them static. This avoids "multiple definition of symbol" linker
errors with gcc-10.

Updates #216

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoAUTHORS: update
Tobias Klauser [Fri, 14 Aug 2020 11:53:55 +0000 (14 13:53 +0200)]
AUTHORS: update

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agocookie: add sys/types header
Rosen Penev [Fri, 14 Aug 2020 04:31:37 +0000 (13 21:31 -0700)]
cookie: add sys/types header

Needed for ssize_t under uClibc-ng.

3 years agotrafgen: remove write-only variable pkt
Tobias Klauser [Fri, 19 Jun 2020 13:00:30 +0000 (19 15:00 +0200)]
trafgen: remove write-only variable pkt

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoastraceroute.8: use more sensitive terminology
Tobias Klauser [Fri, 19 Jun 2020 12:46:31 +0000 (19 14:46 +0200)]
astraceroute.8: use more sensitive terminology

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agomausezahn: remove unused MZ_SIZE_LONG_INT
Tobias Klauser [Mon, 15 Jun 2020 16:05:09 +0000 (15 18:05 +0200)]
mausezahn: remove unused MZ_SIZE_LONG_INT

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agonetsniff-ng v0.6.7v0.6.7
Tobias Klauser [Mon, 4 May 2020 12:22:34 +0000 (4 14:22 +0200)]
netsniff-ng v0.6.7

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoAUTHORS: update
Tobias Klauser [Mon, 4 May 2020 12:15:07 +0000 (4 14:15 +0200)]
AUTHORS: update

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoproto_lldp: prevent accidental out of bounds memory access
Nathaniel Ferguson [Sun, 3 May 2020 07:18:47 +0000 (3 03:18 -0400)]
proto_lldp: prevent accidental out of bounds memory access

Added an integer arithmetic check prior to performing arithmetic to
prevent accidental out of bounds memory access.

Signed-off-by: Nathaniel Ferguson <nathaniel@leapfrog.foundation>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoproto_lldp: fix pointer increment in LLDP_TLV_SYSTEM_CAP case
Nathaniel Ferguson [Sun, 3 May 2020 07:17:46 +0000 (3 03:17 -0400)]
proto_lldp: fix pointer increment in LLDP_TLV_SYSTEM_CAP case

Fixed a typo wherein a pointer was incremented by sizeof(uint32_t) after
reading sizeof(uint16_t) and before reading another sizeof(uint16_t). In
essence a potential out of bounds memory access (read) due to improper
increment of pointer

Signed-off-by: Nathaniel Ferguson <nathaniel@leapfrog.foundation>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoproto_lldp: Check inet_ntop() return values
Nathaniel Ferguson [Sun, 3 May 2020 07:13:25 +0000 (3 03:13 -0400)]
proto_lldp: Check inet_ntop() return values

Make netsniff error out of a recv routine if calls to inet_ntop() fail
by adding return value checks. There are other inet_ntop() usages of
similar however these are in a receive code path with user data for most
of the variables

Signed-off-by: Nathaniel Ferguson <nathaniel@leapfrog.foundation>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
3 years agoproto_ipv4: Make netsniff detect and properly handle some malformed packets
Nathaniel Ferguson [Sun, 3 May 2020 07:12:37 +0000 (3 03:12 -0400)]
proto_ipv4: Make netsniff detect and properly handle some malformed packets

Entails the potential integer underflow of a signed integer.

Signed-off-by: Nathaniel Ferguson <nathaniel@leapfrog.foundation>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agomz: Zero memory allocated for new automops element
Michael R Torres [Fri, 21 Feb 2020 04:29:00 +0000 (20 20:29 -0800)]
mz: Zero memory allocated for new automops element

Prevent crashes when using mausezahn in interactive mode by using calloc
to zero the memory upon allocation.

Fixes #195

Signed-off-by: Michael R Torres <mic.ric.tor@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agoAUTHORS: update
Tobias Klauser [Fri, 21 Feb 2020 10:47:59 +0000 (21 11:47 +0100)]
AUTHORS: update

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agomz: Fix accidental assignment in conditional statement
Michael R. Torres [Thu, 20 Feb 2020 04:59:36 +0000 (19 20:59 -0800)]
mz: Fix accidental assignment in conditional statement
Corrects the accidental assignment of _c_ to 'c' or 'p' due to a missing equals sign. This enables the proper display of the missing argument error message for all relevant options.

Signed-off-by: Michael R Torres <mic.ric.tor@gmail.com>
4 years agoAUTHORS: update
Tobias Klauser [Sat, 1 Feb 2020 14:12:25 +0000 (1 15:12 +0100)]
AUTHORS: update

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agoifpps: fix iface stat parsing if uppercase
Benoît Ganne [Sat, 1 Feb 2020 13:19:20 +0000 (1 14:19 +0100)]
ifpps: fix iface stat parsing if uppercase

Linux netdev can contain uppercase characters.

Signed-off-by: Benoît Ganne <benoit.ganne@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agomausezahn: Support -R to set packet priority
Petr Machata [Tue, 1 Oct 2019 16:40:11 +0000 (1 16:40 +0000)]
mausezahn: Support -R to set packet priority

Add a command line option -R to specify SO_PRIORITY socket option. This
then sets priority of the generated SKBs, which is handy for testing Qdiscs
and other priority-dependent functionality.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agomausezahn.8: Document -r
Petr Machata [Tue, 1 Oct 2019 16:40:10 +0000 (1 16:40 +0000)]
mausezahn.8: Document -r

This option is mentioned further in the man page, but is omitted in the
main section. Add it.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agoastraceroute: reorder function declarations
uno20001 [Wed, 26 Jun 2019 09:51:22 +0000 (26 11:51 +0200)]
astraceroute: reorder function declarations

Group functions for the same protocol together.

Signed-off-by: uno20001 <regisztralo111@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agoAUTHORS: update
Tobias Klauser [Mon, 23 Sep 2019 08:06:55 +0000 (23 10:06 +0200)]
AUTHORS: update

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agotrafgen: reset errno before calling sscanf in str2mac
Joachim Nilsson [Mon, 23 Sep 2019 07:45:49 +0000 (23 09:45 +0200)]
trafgen: reset errno before calling sscanf in str2mac

When testing trafgen with the following example from the man page the
error message "Failed to parse MAC address 11:22:33:44:55:66" is
printed.

  trafgen -o lo --cpus 1 -n 3 '{ eth(da=11:22:33:44:55:66, da[0]=dinc()), tcp() }'

Turns out errno was not cleared before str2mac() called sscanf().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agonetsniff-ng v0.6.6v0.6.6
Tobias Klauser [Thu, 9 May 2019 07:22:22 +0000 (9 09:22 +0200)]
netsniff-ng v0.6.6

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
4 years agoAUTHORS: regenerate and correct Jon's name
Tobias Klauser [Fri, 3 May 2019 08:34:04 +0000 (3 10:34 +0200)]
AUTHORS: regenerate and correct Jon's name

Jon's name was spelled wrong in .mailmap in commit 79608cdc169b
("AUTHORS: auto-generate from commit log") and thus ended up being wrong
in the AUTHORS file since we started auto-generating it. Sorry about
that!

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agotrafgen: fix -t 0 option to use sendto
Quentin Chateau [Tue, 9 Apr 2019 21:19:42 +0000 (9 23:19 +0200)]
trafgen: fix -t 0 option to use sendto

Currently, using -t 0 option calls shaper_set_delay with 0 sec and 0 ns,
which results in sh->type to be SHAPER_NONE. This in turn causes trafgen
to use TX_RING.

Expected behavior, from "man trafgen":

    If this option is given, then instead of packet(7)'s TX_RING
    interface, trafgen will use sendto(2) I/O for network packets, even
    if the argument is 0.

This patch forces sh->type to be set to SHAPER_DELAY even if
the delay is 0. shaper_delay already handles the case where
sh->type is SHAPER_DELAY and the delay is 0.

Fixes #208

Signed-off-by: Quentin Chateau <quentin.chateau@gmail.com>
[tklauser: adjusted commit message to include change description]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: update
Tobias Klauser [Wed, 6 Mar 2019 09:04:43 +0000 (6 10:04 +0100)]
AUTHORS: update

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoBuild system: Use GZIP_ENV instead of GZIP
Daniel Roggow [Tue, 5 Mar 2019 20:54:42 +0000 (5 14:54 -0600)]
Build system: Use GZIP_ENV instead of GZIP

Older versions of gzip assume the GZIP environment variable contains
flags[1].  Building netsniff-ng on a system with such a version of gzip
will yield the following error:

  INST  netsniff-ng/netsniff-ng
  gzip -9 -c netsniff-ng.8 > netsniff-ng/netsniff-ng.8.gz
  gzip: gzip: No such file or directory

A practical alternative to redefining GZIP in the Makefile seems to be
to use the GZIP_ENV make variable[2] instead.

[1] The GZIP environment variable was deprecated in gzip version 1.7.
See https://www.gnu.org/software/gzip/manual/html_node/Environment.html
and https://git.savannah.gnu.org/cgit/gzip.git/tree/NEWS for more
information.

[2] https://www.gnu.org/software/automake/manual/automake.html#index-GZIP_005fENV

Signed-off-by: Daniel Roggow <daniel.roggow@rockwellcollins.com>
5 years agoAUTHORS: update authors
Tobias Klauser [Tue, 11 Dec 2018 08:50:03 +0000 (11 09:50 +0100)]
AUTHORS: update authors

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoastraceroute: checksum calculation for ICMP and TCP
uno20001 [Wed, 5 Dec 2018 09:12:20 +0000 (5 10:12 +0100)]
astraceroute: checksum calculation for ICMP and TCP

Calculate ICMP and TCP checksums for both IPv4 and IPv6,

Fixes #198
Fixes #200

Signed-off-by: uno20001 <regisztralo111@gmail.com>
[tk: code formatting, C89 compatibility]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agooui.conf: update from upstream
Tobias Klauser [Mon, 10 Dec 2018 14:10:23 +0000 (10 15:10 +0100)]
oui.conf: update from upstream

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: auto-generate from commit log
Tobias Klauser [Mon, 10 Dec 2018 13:30:14 +0000 (10 14:30 +0100)]
AUTHORS: auto-generate from commit log

I tend to forget to update the AUTHORS file with new contributors. Let's
automate it and extract the contributors from the commit log.

Manually mention people how have contributed in other ways (bug reports,
documentation etc.) or how had commits in the previousl, no longer
existing repository.

Script based on
https://github.com/cilium/cilium/blob/master/contrib/scripts/extract_authors.sh

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: single list of contributors
Tobias Klauser [Mon, 10 Dec 2018 13:16:10 +0000 (10 14:16 +0100)]
AUTHORS: single list of contributors

As a preparation for auto-generating the AUTHORS file, move everybody to
a single list of contributors.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agocontrib: move auxiliary scripts to own directory
Tobias Klauser [Mon, 10 Dec 2018 13:13:34 +0000 (10 14:13 +0100)]
contrib: move auxiliary scripts to own directory

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoFix manpage warnings
Kartik Mistry [Mon, 10 Dec 2018 04:26:15 +0000 (10 09:56 +0530)]
Fix manpage warnings

Signed-off-by: Kartik Mistry <kartik.mistry@gmail.com>
5 years agodocs: remove again, moved to the netsniff-ng.github.io
Tobias Klauser [Tue, 4 Dec 2018 14:25:08 +0000 (4 15:25 +0100)]
docs: remove again, moved to the netsniff-ng.github.io

If we want to use https://netsniff-ng.github.io instead of
https://netsniff-ng.github.io/netsniff-ng the source apparently have to
live in a separate repository.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agodocs: add netsniff-ng website source for GitHub pages rendering
Tobias Klauser [Tue, 4 Dec 2018 14:16:40 +0000 (4 15:16 +0100)]
docs: add netsniff-ng website source for GitHub pages rendering

Let's move to GitHub pages so I don't always forget to update the
website upon a new release.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agonetsniff-ng: store default prefix in ctx
Tobias Klauser [Sun, 2 Dec 2018 18:21:34 +0000 (2 19:21 +0100)]
netsniff-ng: store default prefix in ctx

Store the default "dump-" prefix in ctx->prefix instead of checking it
every time in generate_multi_pcap_filename.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agozsh: netsniff-ng: add completion for --overwrite
Tobias Klauser [Sun, 2 Dec 2018 18:20:59 +0000 (2 19:20 +0100)]
zsh: netsniff-ng: add completion for --overwrite

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: add Whang Choi
Tobias Klauser [Sun, 2 Dec 2018 18:13:27 +0000 (2 19:13 +0100)]
AUTHORS: add Whang Choi

Add Whang Choi for PR #202

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agonetsniff-ng: implement rotating capture files
Whang Choi [Sat, 1 Dec 2018 00:31:54 +0000 (30 19:31 -0500)]
netsniff-ng: implement rotating capture files

Add a new option -O, --overwrite which allows to rotate capture files.
The timestamp in the file name is replaced with a number that wraps
around after reaching the specified number of files.

Example usage:

netsniff-ng -s -F 1KiB -O 10 -i eth0 -o /output/folder

Fixes #147

Signed-off-by: Whang Choi <wch0x01@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agobuild: use system libsodium by default
Tobias Klauser [Sun, 2 Dec 2018 16:17:35 +0000 (2 17:17 +0100)]
build: use system libsodium by default

If libsodium is installed (i.e. pkg-config --variable=includedir
libsodium returns a non-empty path), assume libsodium is installed and
use it instead of libnacl.

To use libnacl, set NACL_INC_DIR, NACL_LIBDIR and NACL_LIB accordingly.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoastraceroute: Fix for reading mirrors from file
Mandar Gokhale [Fri, 5 Oct 2018 06:27:33 +0000 (5 06:27 +0000)]
astraceroute: Fix for reading mirrors from file

If the file that GeoIP mirror addresses are being read from lacks a
terminating newline, then the code that reads them in exhibits an
off-by-one error.

Example of such a file:

   $ xxd /etc/netsniff-ng/geoip.conf
   00000000: 6765 6f6c 6974 652e 6d61 786d 696e 642e  geolite.maxmind.
   00000010: 636f 6d                                  com

Fix this by explicitly getting the part of the string before the
newline using `strcspn`.

Signed-off-by: Mandar Gokhale <mandarg@mandarg.com>
5 years agotrafgen: fixed '--in -' to work again with STDIN
Jaroslav Škarvada [Sat, 20 Oct 2018 20:35:28 +0000 (20 22:35 +0200)]
trafgen: fixed '--in -' to work again with STDIN

This has been broken by commit 4e47fd021a6945aa626eaef4446c5b547d8c2a85.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agomz: Add error handling for mismatched address families
Mandar Gokhale [Mon, 24 Sep 2018 21:57:08 +0000 (24 17:57 -0400)]
mz: Add error handling for mismatched address families

Check for errors in IP addresses specified, and throw an appropriate
error if they are not specified properly, e.g. if user uses `-6`
option with an IPv4 source address.

Closes #166

Signed-off-by: Mandar Gokhale <mandarg@mandarg.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agonetsniff-ng v0.6.5v0.6.5
Tobias Klauser [Thu, 20 Sep 2018 11:30:18 +0000 (20 13:30 +0200)]
netsniff-ng v0.6.5

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: add Matteo Croce
Tobias Klauser [Wed, 22 Aug 2018 08:23:23 +0000 (22 10:23 +0200)]
AUTHORS: add Matteo Croce

Add Matteo Croce for PR #194

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agomausezahn: improve random mac address generation
Matteo Croce [Tue, 21 Aug 2018 14:38:09 +0000 (21 16:38 +0200)]
mausezahn: improve random mac address generation

Modify -b option to generate all random MAC addresses.

Improve the random generation algorithm, use nrand48() which fills the
ethernet address in two calls instead of six calls to rand() and six
floating point calculations.

Set the locally administered bit of generated MAC addresses.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: add Radoslav Bodo
Tobias Klauser [Wed, 20 Jun 2018 11:24:15 +0000 (20 13:24 +0200)]
AUTHORS: add Radoslav Bodo

Add Radoslav Bodo for commit 76bd307a8ce8 ("trafgen: support ICMPv6
checksums") submitted via PR #193.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agotrafgen: support ICMPv6 checksums
Radoslav Bodo [Tue, 19 Jun 2018 19:57:37 +0000 (19 21:57 +0200)]
trafgen: support ICMPv6 checksums

Usage: csumicmp6(14, 54)

Signed-off-by: Radoslav Bodo <bodik@cesnet.cz>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: add Nick Grauel
Tobias Klauser [Thu, 31 May 2018 14:40:11 +0000 (31 16:40 +0200)]
AUTHORS: add Nick Grauel

Add Nick Grauel for commit 3f26829394ea ("mausezahn: Restore handling of
raw hex string passed in on command line") via PR #191.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agomausezahn: Restore handling of raw hex string passed in on command line
Nick Grauel [Thu, 31 May 2018 03:42:15 +0000 (30 23:42 -0400)]
mausezahn: Restore handling of raw hex string passed in on command line

Originally all hex strings (whether they were given on the command line
or in a file) were handled by a call to str2hex():

bytestring_s = str2hex (tx.arg_string, bytestring, MAX_PAYLOAD_SIZE);

Commit f634c74 added code to parse out "payload=" or "p=" flags that may
have been added at the start of the hex string. This code also changed the
logic around this str2hex() call to only call the function and populate
bytestring_s if one of these flags was found. This broke the ability to
pass in a raw hex string on the command line since it fails the check and
bytestring_s is never populated with the hex bytes. I've added an else
condition to make the str2hex() call using the old method in cases where
no "payload=" or "p=" flags are found.

Signed-off-by: Nick Grauel <nicolas.grauel@plexxi.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoman: reformat all man pages
Tobias Klauser [Thu, 17 May 2018 15:02:31 +0000 (17 17:02 +0200)]
man: reformat all man pages

- use .TP for option and example labels
- use .BR for references to other manpages, also in description texts
- highlight options using .B in description texts
- misc. cleanups

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: add Petr Machata
Tobias Klauser [Tue, 15 May 2018 07:07:00 +0000 (15 09:07 +0200)]
AUTHORS: add Petr Machata

Add Petr Machata for commit f6d450a5e405 ("mausezahn: Fix IPv6 address
comparison").

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agomausezahn: Fix IPv6 address comparison
Petr Machata [Mon, 14 May 2018 21:59:59 +0000 (15 00:59 +0300)]
mausezahn: Fix IPv6 address comparison

CMP_INT evaluates its arguments more than once, and thus passing a
post-incremented pointer as an argument causes double increments and
hence buffer overruns. This can be observed by erratic behavior of IPv6
address ranges. Fix by moving the increment to loop header.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoman: netsniff-ng: document time formats for -o/--out
Tobias Klauser [Mon, 14 May 2018 12:07:24 +0000 (14 14:07 +0200)]
man: netsniff-ng: document time formats for -o/--out

Commit e3e8eea41966 ("netsniff-ng: add date format strings to --out.")
introduced the possibility to specify time formats in the -o/--out
parameter. Document this in netsniff-ng(8)

Updates #158

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agonetsniff-ng: add date format strings to --out
Daniel Roberson [Thu, 19 Apr 2018 18:12:00 +0000 (19 11:12 -0700)]
netsniff-ng: add date format strings to --out

This adds the ability to use date(1)/strftime(3) style format strings
when specifying an output file.

Example:

  netsniff-ng --out %Y-%m-%d.pcap ### outputs to 2018-04-20.pcap

Fixes #158

Signed-off-by: Daniel Roberson <daniel@planethacker.net>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agoAUTHORS: add Daniel Roberson
Tobias Klauser [Thu, 19 Apr 2018 14:15:54 +0000 (19 16:15 +0200)]
AUTHORS: add Daniel Roberson

Add Daniel Roberson for 15f78c073276 ("mausezahn: fix strtok() segfault
if s or m are missing") via PR #189

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
5 years agomausezahn: fix strtok() segfault if s or m are missing
Daniel Roberson [Thu, 19 Apr 2018 04:52:01 +0000 (18 21:52 -0700)]
mausezahn: fix strtok() segfault if s or m are missing

The -d flag will result in a segmentation fault if 'm' or 's' are
specified without a numeric value.

Example: mausezahn -d m ### Results in a crash

Signed-off-by: Daniel Roberson <daniel@planethacker.net>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agotrafgen: support dumping IPv6 protocol header command
Tobias Klauser [Thu, 8 Mar 2018 17:10:37 +0000 (8 18:10 +0100)]
trafgen: support dumping IPv6 protocol header command

Support dissecting IPv6 headers into the îp6' trafgen protocol header
command.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agomake: consider $DESTDIR when creating $DATDIR
Tobias Klauser [Wed, 7 Mar 2018 08:31:54 +0000 (7 09:31 +0100)]
make: consider $DESTDIR when creating $DATDIR

Reported-by: @asavah
Fixes: 44ceece354c5 ("geoip: store GeoIP files in $(PREFIX)/share by default")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agoall: drop fmem{cpy,set}
Tobias Klauser [Tue, 6 Mar 2018 17:44:11 +0000 (6 18:44 +0100)]
all: drop fmem{cpy,set}

There is no need to explicity use the builtins. According to [1], GCC
will recognize mem{cpy,set} as built-in functions, unless the
corresponding -fno-builtin-* option is specified (which is not the case
for netsniff-ng).

[1] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agotrafgen: fix signedness warning in cleanup_packets
Tobias Klauser [Tue, 6 Mar 2018 17:42:10 +0000 (6 18:42 +0100)]
trafgen: fix signedness warning in cleanup_packets

This fixes the following GCC warning:

trafgen_parser.y: In function ‘cleanup_packets’:
trafgen_parser.y:1479:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (k = 0; k < hdr->sub_headers_count; k++)

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agotrafgen: don't close dev_out and dev_in in parent process
Tobias Klauser [Tue, 6 Mar 2018 17:28:27 +0000 (6 18:28 +0100)]
trafgen: don't close dev_out and dev_in in parent process

They are opened in main_loop which is only executed in the child(ren),
so close them there again. This avoids closing the devices twice, which
may lead to segfaults.

Fixes #188

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agogeoip: store GeoIP files in $(PREFIX)/share by default
Tobias Klauser [Tue, 6 Mar 2018 13:11:53 +0000 (6 14:11 +0100)]
geoip: store GeoIP files in $(PREFIX)/share by default

The /etc directory shouldn't contain non-human-readable files.
netsniff-ng (when called with the '-U' option) currently installs the
GeoIP database files to /etc/netsniff-ng by default.

Change this to install them to $(PREFIX)/share/netsniff-ng instead,
which is conformant to the FHS [1].

[1] https://wiki.debian.org/FilesystemHierarchyStandard

Also create the respective directory in the 'make install' target.

Fixes #187

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agoring: use xzmalloc_aligned
Tobias Klauser [Mon, 22 Jan 2018 17:15:10 +0000 (22 18:15 +0100)]
ring: use xzmalloc_aligned

Use xzmalloc_aligned instead of open-coding it.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agobpf: don't use builtin memset/memcpy in bpf_parse_rules
Tobias Klauser [Mon, 22 Jan 2018 17:10:41 +0000 (22 18:10 +0100)]
bpf: don't use builtin memset/memcpy in bpf_parse_rules

bpf_parse_rules is not called in a fast path, so just use the plain
memset/memcpy and let the compiler decide whether they should be
replaced.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agonetsniff-ng: add DCCP support
Markus Amend [Fri, 12 Jan 2018 07:27:12 +0000 (12 08:27 +0100)]
netsniff-ng: add DCCP support

Adds a first rudimentary support for the DCCP protocol.

Signed-off-by: Markus Amend <markus.amend@telekom.de>
[tk: minor formatting tweaks]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agonetsniff-ng v0.6.4v0.6.4
Tobias Klauser [Fri, 5 Jan 2018 11:02:22 +0000 (5 12:02 +0100)]
netsniff-ng v0.6.4

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agoflowtop: Fix use-after-free on filter reload
Vadim Kochan [Mon, 18 Dec 2017 22:38:18 +0000 (19 00:38 +0200)]
flowtop: Fix use-after-free on filter reload

There is missing logic which removes flow entry from
related proc's entry while destroying global flows list on
filter reloading, hence add common __flow_list_del_entry which
handles this logic for both cases - when ct destroyed or filter
changed.

This is a 2nd fix for issue #183.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agoflowtop: change tab title for process tab
Tobias Klauser [Mon, 18 Dec 2017 16:34:10 +0000 (18 17:34 +0100)]
flowtop: change tab title for process tab

Use plural to match the "Flows" tab and because it usually shows
multiple processes.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agoflowtop: Use RCU flow deletion from process entry
Vadim Kochan [Sun, 17 Dec 2017 21:25:40 +0000 (17 23:25 +0200)]
flowtop: Use RCU flow deletion from process entry

Use cds_list_del_rcu for safer deletion flow from the process flow
list to prevent possible use-after-free by UI thread when it is
refreshing the processes.

It may fix the #183 issue.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agotrafgen: fix dinc()/ddec() modifiers
Paolo Abeni [Thu, 14 Dec 2017 12:04:12 +0000 (14 13:04 +0100)]
trafgen: fix dinc()/ddec() modifiers

currently, after dinc(), the valued stored inside the packet is
not in the (min, max) range but in the (0, max - min + 1) range,
'counter->val' should be used instead of 'val'.

Additionally the values computed for ddec() are corrupted, in:

val = (val - counter->inc) % (counter->min - counter->max + 1);

the divider is negative, we should use (counter->max - counter->min + 1)
as in the INC case.

Finally we can avoid the switch statement at update time, inverting
the value of 'counter->inc' for decrement and using a data type wide
enough for the 'inc' field.

v1 -> v2:
 - changed 'counter->inc' type to int

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agoastraceroute: use switch instead of lookup table for short proto idcoverity_scan
Tobias Klauser [Fri, 20 Oct 2017 13:19:53 +0000 (20 15:19 +0200)]
astraceroute: use switch instead of lookup table for short proto id

Avoid having a 58 entry array on stack of which only 3 are ever used.
Just look up the short protocol identifier via a good'ol switch.

Fixes Coverity CID 1381806
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agotrafgen: fix NULL pointer dereference in -i option parsing
Tobias Klauser [Fri, 20 Oct 2017 13:10:41 +0000 (20 15:10 +0200)]
trafgen: fix NULL pointer dereference in -i option parsing

If trafgen is called with the -i option, it currently crashes due to an
NULL pointer dereference. Fix it.

Fixes Coverity CID 1381809
Fixes: 82a3c204c6f1 ("trafgen: Allow send packets from pcap file")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agotrafgen: fix resource leaks
Tobias Klauser [Fri, 20 Oct 2017 12:52:57 +0000 (20 14:52 +0200)]
trafgen: fix resource leaks

Fix two resource leaks in trafgen.

Fixes Coverity CID 1381807 and CID 1381811.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agobuild: check for fopencookie() in configure
Tobias Klauser [Fri, 20 Oct 2017 12:24:33 +0000 (20 14:24 +0200)]
build: check for fopencookie() in configure

fopencookie(3) is a non-standard GNU extension and some libc
implementations might not provide it (e.g. musl).

Check for fopencookie in the configure script and disable building
curvetun in case the function is not available, as curvetun is the only
tool using fopencookie.

Fixes #174
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agotrafgen: fix packet socket initialization with multiple CPUs
Paolo Abeni [Wed, 13 Sep 2017 15:54:52 +0000 (13 17:54 +0200)]
trafgen: fix packet socket initialization with multiple CPUs

The commit 78c13b71e196 ("trafgen: Allow to generate packets
to output pcap file") introduced a regression when output is
a network device and multiple CPU are in use: the packet
socket is created before fork() and thus the socket is shared
among all the processes: all of them except the first will
fail while setting the tx_ring.

Fix it splitting the io open() helper in a create() op,
called before forking, and the open() op called by each process.

Fixes: 78c13b71e196 ("trafgen: Allow to generate packets to output pcap file")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agoifpps: fix unintendet assignment
Tobias Klauser [Wed, 13 Sep 2017 12:00:47 +0000 (13 14:00 +0200)]
ifpps: fix unintendet assignment

Variable rate is assigned instead of compared in the check of the
interval in relation to the line rate. Fix it and at the same time fix
the compared against interval value to match the message we show if the
condition is fulfilled.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
6 years agolink: use uint32_t instead of u32
Tobias Klauser [Wed, 13 Sep 2017 10:21:45 +0000 (13 12:21 +0200)]
link: use uint32_t instead of u32

Use type uint32_t instead of u32 (which is typedef'ed to uint32_t in
built_in.h) in order to avoid confusion wrt. kernel-/user-space types.

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