The warnings were:
./print-isoclns.c: In function 'osi_print_cksum':
./print-isoclns.c:3107:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
|| length > ndo->ndo_snaplen
^
./print-isoclns.c:3108:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
|| checksum_offset > ndo->ndo_snaplen
^
Guy Harris [Mon, 13 Jul 2015 19:50:01 +0000 (12:50 -0700)]
We're not doing setjmp/longjmp, so no need for static variables.
We stopped doing setjmp/longjmp a while ago (it could cause issues on
multiple platforms), so we don't need to make pointer variables static
in the lookup routines.
Move the port number #define's to the TCP and UDP files such that they
don't require nameser.h anymore. Update the TCP printer to disregard the
multicast DNS port as it is UDP-only.
Fix warnings as "declaration of 'x' shadows a global declaration"
The warnings were:
./tcpdump.c: In function 'show_tstamp_types_and_exit':
./tcpdump.c:220:56: warning: declaration of 'pd' shadows a global declaration [-Wshadow]
show_tstamp_types_and_exit(const char *device, pcap_t *pd)
^
./tcpdump.c:200:16: warning: shadowed declaration is here [-Wshadow]
static pcap_t *pd;
^
./tcpdump.c: In function 'show_dlts_and_exit':
./tcpdump.c:253:48: warning: declaration of 'pd' shadows a global declaration [-Wshadow]
show_dlts_and_exit(const char *device, pcap_t *pd)
^
./tcpdump.c:200:16: warning: shadowed declaration is here [-Wshadow]
static pcap_t *pd;
^
RX: Fix 168 warnings as "declaration of 'x' shadows a previous local"
An example of these warnings is:
./print-rx.c: In function 'fs_print':
./print-rx.c:774:35: warning: declaration of 'i' shadows a previous local [-Wshadow]
#define UINTOUT() { unsigned long i; \
^
./print-rx.c:916:4: note: in expansion of macro 'UINTOUT'
UINTOUT();
^
./print-rx.c:883:16: warning: shadowed declaration is here [-Wshadow]
unsigned long i;
^
Gisle Vanem [Fri, 10 Jul 2015 10:39:10 +0000 (12:39 +0200)]
Update print-dccp.c
Fix warning:
```
print-dccp.c(500): warning C4456: declaration of 'cp' hides previous local declaration
print-dccp.c(277): note: see declaration of 'cp'
```
Denis Ovsienko [Mon, 29 Jun 2015 15:06:31 +0000 (16:06 +0100)]
BGP: add decoding of ADD-PATH capability
This implements the capability part of draft-ietf-idr-add-paths-10 and
seems to work for a packet capture I am looking into. The problem with
the "extended NLRI encodings" defined in the same document is that they
are going to use a different structure for the two previously assigned
path attributes, which makes decoding of an UPDATE difficult without
having both relevant OPENs from the same session.
Denis Ovsienko [Mon, 29 Jun 2015 14:53:06 +0000 (15:53 +0100)]
refine tok2str() buffer use
Switch RRCP and BGP functions from tok2strbuf() to tok2str() to avoid
unnecessary local buffer management. The latter function does it in a
way to allow up to 4 calls to itself from printf(). After that
tok2strbuf() remains used by tok2str() only and can be refined later.
Remove a duplicate macro and place the remaining definition into the
right file.
Francois-Xavier Le Bail [Fri, 19 Jun 2015 07:28:47 +0000 (09:28 +0200)]
Fix a non-reentrant code in a function
Delete the 'static char buf' array in ts_format().
buf is now a parameter of ts_format().
Moreover:
Decrease a too long string.
Fix a space in a comment.
Duane Wessels [Thu, 18 Jun 2015 17:27:34 +0000 (10:27 -0700)]
For DNS messages, represent the "DNSSEC OK" bit as "DO" instead of "OK"
"DO" is a better description of the DNSSEC OK bit in the EDNS0 OPT record. See RFC 3225 section 3. There may be other bits allocated in the future that call themselves "Something OK".
Guy Harris [Thu, 11 Jun 2015 22:47:44 +0000 (15:47 -0700)]
Do case-insensitive comparisons assuming ASCII strings.
Do the case-insensitive comparisons in a locale-independent fashion that
only maps ASCII letters, in the standard English-language fashion; that
way, we don't get bitten by, for example, Turkish having separate "i
with dot" and "i without dot" letters, with lower-case "i with dot" being
mapped to upper-case "I with dot" rather than being mapped to "I".
Guy Harris [Sat, 2 May 2015 17:15:42 +0000 (10:15 -0700)]
Fix checksumming of PIMv2 Register messages.
The checksum only covers the header, not the encapsulated packet, so
only checksum that. However, if that checksum fails, try checksumming
the entire packet, as, according to RFC 4601, packets with the entire
packet checksummed should also be accepted, for interoperability.
Add IS_NOT_NEGATIVE macro.
Avoid these warnings:
- comparison of unsigned expression >= 0 is always true [-Wtype-limits],
- comparison is always true due to limited range of data type [-Wtype-limits].
Guy Harris [Mon, 27 Apr 2015 07:02:31 +0000 (00:02 -0700)]
Clean up To DS and From DS checks.
Rewrite get_data_src_dst_mac() to test To DS and From DS only once; that
also more clearly means that there's no way to escape from that function
without setting both pointers, so the compiler doesn't think there's a
way to do so.
and, hopefully, will prevent more from creeping in.
There are some remaining ones - and they represent attempts to overwrite
the packet bytes handed to tcpdump by libpcap, which could well *fail*
with, for example, memory-mapped capture mechanisms!
Guy Harris [Mon, 27 Apr 2015 01:42:23 +0000 (18:42 -0700)]
Don't cast away warnings for ether_ntohost().
We have a choice between "your OS's header files suck" warnings on HP-UX
and -Wcast-qual warnings on all platforms. I vote for the former, as
the latter let us find cases where we're casting constness away, and we
really don't want to cast constness away if we can possibly avoid it.
Guy Harris [Mon, 27 Apr 2015 00:09:16 +0000 (17:09 -0700)]
Fix heuristic not to be byte-order-dependent.
I'm *guessing* that the item being fetched is big-endian; the "vt"
protocol might be old enough that they developed it on (non-Sun386i) Sun
workstations, assuming they didn't just say "this is an Internet
protocol, hence fields are big-endian").
That also prevents problems on platforms that don't support unaligned
accesses.
Guy Harris [Mon, 27 Apr 2015 00:03:32 +0000 (17:03 -0700)]
Fetch a 32-bit big-endian quantity with EXTRACT_32BITS().
*Don't* fetch it with a pointer cast and dereference! That will fail on
little-endian machines and may fail on machines that don't handle
unaligned references.
Andrew Lunn [Sun, 19 Apr 2015 20:35:00 +0000 (15:35 -0500)]
Add support for the Marvell Extended Distributed Switch Architecture header
This header can be used with Marvell switches to direct packets in/out
of a specific port in a tree of interconnected switches. The header
uses its own Ethertype of 0xdada.
By default, only brief output is printed, showing the switch device,
port, and vlan the packet is to/from. However if -e is given, to print
the link-level header, all fields are printed.
Guy Harris [Sun, 19 Apr 2015 02:56:49 +0000 (19:56 -0700)]
Use unsigned values in tok2str and bittok2str routines.
This prevents the compiler issue mentioned in GitHub issue #451, and
also cleans up some other signed vs. unsigned stuff.
While we're at it, clean up bittok2str_internal() (just pass it the
separator string, not a Boolean value that's tested to choose the
separator string), and print unknown arguments to the bittok2str
routines in hex, not decimal.
Guy Harris [Sat, 18 Apr 2015 06:42:22 +0000 (23:42 -0700)]
Skip the LLC and SNAP headers with -x.
Have llc_print() return the length of the LLC header, plus the length of
the SNAP header, if available - or, if it couldn't dissect the payload,
return the *negative* of that sum. Use that return value in link-layer
printers.
Guy Harris [Sat, 18 Apr 2015 01:38:46 +0000 (18:38 -0700)]
Clean up printing of LLC packets.
Don't print LLC header information for SNAP packets; if we have a SNAP
header, just call snap_print() and return its return value, regardless
of whether it's 1 or 0, don't fall into the code to print raw LLC header
information - and don't print it with -e, either.
If llc_print() returns 0, just call the default packet printer, don't
print the MAC-layer header or the extracted ethertype - llc_print() will
print the source and destination MAC addresses and whatever type
information is in the LLC or SNAP headers.
If we don't know the DSAP/LSAP, and it's an information frame (numbered
or not) and not an XID frame, return 0, so that we give a hex dump of
the raw payload.
In addition, print the length when printing SNAP header information with
-e.