Commit Graph

28 Commits

Author SHA1 Message Date
Guy Harris
1c803f7812 Squelch annoying bogus Clang warnings. 2018-11-09 12:54:00 -08:00
Guy Harris
1c30d69b97 Fix nd_snprintf(buf, buflen, "string");
If this is VS prior to 2015 or MinGW, we can't trust snprintf(); we have
to use _snprintf_s(), but that requires us to insert _TRUNCATE as an
argument after the buffer and buffer length and before the format string
and arguments, if any, to the format string.

That means we need to use a vararg macro; however, if we make the format
string a regular argument to the macro, that means that, if there are no
arguments *after* the format string, you end up with an argument list to
_snprintf_s() that ends with "fmt, ", and that's not valid C.

*If* we knew this was GCC or Clang, we could use a GNU C-specific hack,
wherein, if __VA_ARGS__ is preceded by ## and there's a comma before
that, the comma is removed if __VA_ARGS__ is empty, but this might be
Microsoft's C compiler in a version of Visual Studio prior to VS 2015,
which might not support that.

So we have to just have the macro take, as the ... arguments, the format
string and its arguments.

Addresses GitHub issue #713.
2018-10-13 22:51:54 -07:00
Daniel Miller
30618d8d9a Ensure isatty is defined on Win32. 2018-10-02 09:52:40 -05:00
Guy Harris
c499612a7f Add nd_{v}snprintf() routines/wrappers.
Some versions of the MSVC runtime library have a non-C99-compliant
vsnprintf(), which we want to avoid.  On Windows, use snprintf() and
vsnprintf() for VS 2015 and later, where they both exist in
C99-compliant forms, and wrap _{v}snprintf_s() otherwise (they're
guaranteed to do the null termination that we want).
2018-01-29 15:48:55 -08:00
Guy Harris
1e120597d2 Don't define {v}snprintf() as _{v}snprintf(); they're not the same.
They don't behave exactly like ISO C {v}snprintf(), so, on Windows, we
have wrappers around _{v}snprintf() that behave the way {v}snprintf()
are supposed to work.
2018-01-29 13:55:08 -08:00
Guy Harris
6ed7ed4711 Another UN*Xism we need - isascii().
I guess it's not in ISO C because the character set of an ISO C
implementation isn't necessarily ASCII (EBCDIC, in IBM's C for z/OS and
IBM i).
2018-01-29 01:44:30 -08:00
Guy Harris
c1094815c3 Let CMake figure out whether we have snprintf() or not.
Now that we're using check_symbol_exists(), CMake can find it, so we
don't need to check the compiler version - and this avoids a warning
about redefining HAVE_SNPRINTF.
2018-01-29 01:10:25 -08:00
Guy Harris
be658698f9 Include funcattrs.h before you use stuff in it. 2018-01-28 21:09:03 -08:00
Guy Harris
b3703ed9cf Pick up Windows snprintf and strdup replacements from libpcap. 2018-01-28 20:57:15 -08:00
Guy Harris
a909db55eb Declare ND_UNALIGNED in netdissect.h.
It's netdissect-specific, and there are some files that include
netdissect.h, that don't include netdissect-stdinc.h, and that include
files that define structures using ND_UNALIGNED.
2018-01-28 20:16:36 -08:00
Guy Harris
45fc519a2a Don't test for __attribute__ in the configure script.
Instead, use compiler test macros to check whether *particular*
attributes are supported, and set various #defines appropriately, in
header files.

Rename the UNALIGNED structure attribute to ND_UNALIGNED, and ask
whether we still need it.
2018-01-21 17:57:20 -08:00
Francois-Xavier Le Bail
5b45260126 Remove min() and max() macros from netdissect-stdinc.h
They are already defined in netdissect.h.
2018-01-20 16:47:38 +01:00
Guy Harris
3bc62cd35f Use pcapng as the name of the file format.
At one point, I remember a discussion resulting in the official name of
the next-generation replacement for pcap format being changed to
"pcapng", with no hyphen.

Make tcpdump reflect that.

While we're at it, uppdate to use "macOS" as the name of Apple's
UNIX-for-Macs, as appropriate (don't use it for versions that were still
called Mac OS X or OS X).
2018-01-08 18:50:06 -08:00
Ali Abdulkadir
9b939ac5a3 improved check for ipv6 support on windows (autotools) 2017-11-06 01:42:13 +03:00
Francois-Xavier Le Bail
99b16dee90 Fix the macros for controlling warnings
The current clang compilers also set __GNUC__ and __GNUC_MINOR__ thus
we need to test the clang case before the GCC one.

Moreover:
Add DIAG_OFF_CLANG and DIAG_ON_CLANG macros for clang specific
warnings.
Add a comment.
2017-10-21 20:01:02 +02:00
Guy Harris
370cb54503 Fix 64-bit maximum file size argument stuff.
Define strtoint64_t as appropriate in netdissect-stdinc.h.

Check HAVE_PCAP_DUMP_FTELL64, not HAVE_PCAP_FTELL64, to see whether we
have pcap_dump_ftell64().
2017-10-20 12:15:26 -07:00
Guy Harris
d230f8b687 Get rid of obsolescent configure test.
All UN*Xes, these days, let you include both <time.h> and <sys/time.h>.
2017-10-16 13:48:40 -07:00
Guy Harris
fdd0467bcd On UN*X, always use sigaction(), and always have signal handlers return void.
Some time between the mid 1980's and 1990 called; they want their
old-fashioned UNIX signal handling back.  ANSI C has had signal handlers
returning void sincer, well, 1989, and POSIX has had sigaction() since
close to forever.  No need to worry about really old UN*Xes here.

On Windows, it's also void (as per ANSI C); use signal().
2017-10-15 22:36:07 -07:00
Guy Harris
893b1b1cfb Make the delta between 1970 and 1900 a 64-bit signed integral constant.
It doesn't fit in a 32-bit signed integral constant, so make sure it's
64-bit; the only use is to subtract it from a 64-bit signed integral
value.
2017-09-21 10:05:33 -07:00
Guy Harris
14c81f0a4a Clean up the stuff we do to get <inttypes.h> stuff defined.
If we have a libpcap with <pcap/pcap-inttypes.h>, include it, so that we
don't have to worry about definitions colliding if we later include a
pcap header file that includes pcap/pcap-inttypes.h.

Otherwise, do the same stuff pcap-inttypes.h does.  This means that, on
UN*X, we require that there be an <inttypes.h> that defines everything
we need.

Don't bother doing checks that are no longer necessary as a result of
those changes.
2017-09-14 18:53:34 -07:00
Guy Harris
141c1c6f49 Suppress UBSan warnings from EXTRACT_.
Yes, the behavior of an access with an improperly-aligned pointer is
undefined according to the C standard, but if we're doing that in an
EXTRACT_ function/macro, we're doing it because we know it's safe and
because it's faster than picking the bytes out one by one and assembling
them, so suppress those warnings.

Pull over libpcap's funcattrs.h and use it to do a bunch of checks for
various function attributes; that defines __has_attribute(), so we can
use it to check for the "suppress sanitizer warnings" attribute.

While we're at it, use other things it defines to specify "this function
never returns", "this function is printf-like", and "this function
argument is a printf-style format argument", rather than using various
configure-script checks.  That should let us declare some function
attributes with Microsoft Visual Studio's compilers.
2017-08-18 20:11:43 -07:00
Denis Ovsienko
6df678ca31 Check for __attribute__ ((fallthrough)) (GCC 7).
The documentation claims that recent GCC is now better by default at
spotting cases of code flow falling through (which is true) and that it
avoids false positives by matching nearby source code comments with
regexps. However, the latter feature doesn't seem to work as reliably
as the manual describes it, so let's have a macro for this purpose.

Tested to work on:
* x86_64, Fedora 26, GCC 7.1.1 (w/__attribute__, w/fallthrough)
* x86_64, Ubuntu 16.04, GCC 5.4.0 (w/__attribute__, w/o fallthrough)
* x86_64, FreeBSD 11.0, CLang 3.8.0 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SolStudio 12.4 (w/__attribute__, w/o fallthrough)
* SPARC, Solaris 10, SunStudio 11 (w/o __attribute__)
2017-07-22 19:33:49 +01:00
Francois-Xavier Le Bail
c94fccbfce Fix a file mode
A header file does not need an executable mode.
(old mode 100755 ; new mode 100644)
2016-09-26 12:49:41 +02:00
Michael Richardson
a9f4d1c299 added some minor protection against multiple inclusion 2016-07-09 17:22:18 -04:00
Guy Harris
de7c6192e4 Additional Windows cleanups.
Don't import stuff from WinPcap that it really shouldn't be exporting.

Define HAVE_U_INT{N}_T,to suppress definition of intN_t in bittypes.h, as
included by <pcap/pcap.h> on Windows.

Define HAVE_OS_IPV6_SUPPORT if AF_INET6 is defined, so that if we're
building with a VC+SDK combination that defines it and struct in6_addr,
we don't define them ourselves.
2015-09-18 17:24:23 -07:00
Guy Harris
4841fc240d We don't define our own inet_aton() any more, so don't declare it. 2015-09-18 13:19:32 -07:00
Guy Harris
11f73ad248 Don't require IPv6 library support in order to support IPv6 addresses.
Have our own routines to convert between IPv4/IPv6 addresses and
strings; that helps if, for example, we want to build binary versions of
tcpdump for Windows that can run both on NT 5 (W2K/WXP), which doesn't
have inet_ntop() or inet_pton(), and NT 6 (Vista/7/8/10), which do.  It
also means that we don't require IPv6 library support on UN*X to print
addresses (if somebody wants to build tcpdump for older UN*Xes lacking
IPv6 support in the system library or in add-on libraries).

Get rid of files in the missing directory that we don't need, and
various no-longer-necessary autoconf tests.
2015-09-17 14:56:44 -07:00
Francois-Xavier Le Bail
99c91c3aec Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'
Get the full log via: git log --follow netdissect-stdinc.h
2015-09-10 08:50:40 +02:00