Furthermore CPACK_PACKAGE_NAME and CPACK_PACKAGE_VERSION are set explicitly since this is needed for older CMake versions.
(Tested on Debian Stretch with CMake 3.7.2)
Use signal SIGUSR1 instead of SIGHUP to detect when to rotate the pcap dump file.
Use signal SIGHUP instead of SIGCONT to detect when the controlling terminal closed.
This signal usage provides that sngrep closes cleanly when its controlling (SSH) terminal closes.
'device' and 'outfile' are initialized from 'settings' in the later code,
but 'text_outfile' is not initialized, which may lead to writing to an unknown file.
* add siplify command for saving pcap to txt file
* remove unnecessary printf and commented code
* Refactor siplify into text; minor changes according to pull request review
strings.h required for strncasecmp, fixes an implicit function
declaration
config.h needed for the actual configuration, it sets -D_GNU_SOURCE that
is needed for strsep.
libpcap doesn't directly support this, so this is implemented using the
Linux call fopencookie which rereoutes the read,write,seek,close functions.
*BSD seems to have something similar (funopen) which is not implemented in
this patch because I'm not familiar enough with BSD.
gzip detection for read is done by first directly opening the given file
like before. If this fails, we retry with gzip.
gzip detection for write is done by looking at the filename to write to.
If it ends in ".gz" we activate gzip compression.
This currently just works for the commandline option --output because only
there you get to set the filename suffix freely. To make this usable in
the curses gui, the save dialog would have to be extended to allow setting
a .pcap.gz filename extension.
gzip compression must be compiled in to be active. This is done with the
--with-zlib configure option.
Before this patch the process was just terminated by the default signal
handler. This could lead for example to incompletely written pcap files.
So proper shutdown like in this patch is always a good idea. But it becomes
mandadory when implementing more complex file I/O with buffering, for
example with gzip streaming.
To not conflict with the threading used in sngrep, the signal handler
just sets a atomic flag. This flag is then checked in one of the two
main loops (with/without curses UI).
When using --no-interface without --quiet, a dialog counter
is shown and continously updated. Without this patch this
counter just shows the number of calls that are stored in RAM.
When rotation is used, it never shows more calls than the
rotation limit.
Since the --no-interface option is usually just used for
capturing, using it with a small number for rotation (down to 1)
is recommended to not waste RAM. This means the shown value
is useless.
This patch introduces the function sip_calls_count_unrotated() that
can be used to get the full number of calls since program start.
This is then used in the shown dialog count.
The #elifdef preprocessor directive will only become available with the
upcoming C2x standard.
I do not think that using it already is a good idea, since support for
it is very sparse and no long-term-stable distro has support for it.
Also replacing it with "#elif defined()" doesn't really complicate the code.
configure scripts need to be runnable with a POSIX-compliant /bin/sh.
On many (but not all!) systems, /bin/sh is provided by Bash, so errors
like this aren't spotted. Notably Debian defaults to /bin/sh provided
by dash which doesn't tolerate such bashisms as '=='.
This retains compatibility with bash.
Fixes configure warnings/errors like:
```
checking for pcap.h... yes
./configure: 6520: test: xyes: unexpected operator
checking for ncurses.h... yes
checking for initscr in -lncurses... yes
```
- the addrlen parameter must be filled with the size available for src_addr before
calling recvfrom()
- the size of the src_addr isn't really known before calling recvfrom, it can be
of different types. So use struct sockaddr_storage for it which is large enough
to allow different actual address types