Normally, it succeeds whether the device actually exists or not, but, in
some versions (but not the latest version), it may fail on Linux trying
to fetch the list of time stamp types. Check for that failure and, if
that's the reason for pcap_create() failing, return from
open_interface() so the caller can see if the interface name is actually
an interface index.
If N is a number, and is the name of an interface on the system, "-i N"
will now attempt to open that interface, not the Nth interface in the
list of interfaces. See GitHub issue #522.
Some UN*Xes apparently can have purely numeric interface names, so we
can't unconditionally treat purely numeric interface names as interface
indices. Do so only for "names" that don't correspond to interfaces.
Fixes GitHub issue #522.
As the string in question is passed as a constant from a printer, it
*shouldn't* contain any non-ASCII characters, but squelching the warning
is harmless and, on modern processors, a non-sign-extending byte load
shouldn't be any worse than a sign-extending byte load.
Have the call to smiLoadModule() be in a nd_load_smi_module() routine.
Have it set a *global* flag indicating whether a module has been loaded;
that's not per-netdissect_options. Use that global flag in print-snmp.c
- and don't test it once per loop iteration, it's not going to change
while the loop is running.
Have a routine to return the version of the library if we're built with
it or NULL if we're not.
That removes the last of the code that tests USE_LIBSMI or uses libsmi
from tcpdump.c.
Move stuff to initialize and clean up libraries that are used by
netdissect code into nd_init() and nd_cleanup() routines in
libnetdissect; this includes Winsock (which is used on Windows by, for
example, the code to get names for IP addresses) and libsmi.
Call nd_init() when tcpdump starts up, and call nd_cleanup() when it
exits.
Move util.c routines to tcpdump.c, and make them static.
Use ndo->ndo_error to report a failure to open a file in print-esp.c.
Multiplying a uint8_t by an int results in an int, not an unsigned int;
make NSH_HDR_WORD_SIZE an unsigned constant so the multiplication is
uint8_t times unsigned int.
Add support for an argument to --with-crypto, so that if you have one
version of libcrypto installed under /usr and another version installed
under /usr/local, you can force tcpdump to be built with the /usr/local
version.
Also, refer both to OpenSSL and libressl in comments and messages.
Newer versions of the Geneve protocol draft have defined additional
option classes. This updates the list so we can show the class name
instead of unknown.
Not all platforms have strcasecmp() (yes, it's in the Single UNIX
Specification, but not all platforms are UNIX or even UN*X; there's some
obscure company in Redmond, Washington who have an OS on which we run),
and on those that do, there's no guarantee that strcasecmp() will treate
A-Z and a-z as being equivalent ("I" and "i" aren't equivalent in a
Turkish locale, for example).
Fix indentation while we're at it.
Rolling over into zero filesize makes no sense. Creating a rotating
buffer of zero files makes no sense.
Modify the checks for -C and -W to accept greater than one, not greater
than zero.
Signed-off-by: Jamie Bainbridge <jamie.bainbiridge@gmail.com>
It may not be necessary, but it makes the code a bit cleaner, even if
you spend a few extra microseconds per file fetching the name of the
link-layer header type even if the new file has the same header type.
In 1.1.x, EVP_CIPHER_CTX is an opaque structure, so we can't declare it
on the stack.
Instead, if we don't have EVP_CIPHER_CTX_new() and EVP_CIPHER_CTX_free()
in libcrypto, define our own versions, with the same signatures as the
ones in OpenSSL 1.1.x's libcrypto, and have the code use
EVP_CIPHER_CTX_new() to allocate the structure and EVP_CIPHER_CTX_free()
to free it.