Commit Graph

54 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
1cfd6cd2ac Use more the EXTRACT_U_1() macro (51/n)
Moreover: Use more the ND_ISPRINT() macro.
2017-12-09 11:46:15 +01:00
Francois-Xavier Le Bail
451ac4c753 Use more the ND_TCHECK_1() macro 2017-12-04 21:00:57 +01:00
Francois-Xavier Le Bail
d2def296e9 Use more the EXTRACT_U_1() macro (41/n)
In: switch (... *(p) ...) ...
2017-12-01 23:48:54 +01:00
Francois-Xavier Le Bail
f085c93f59 Use more the EXTRACT_U_1() macro (31/n)
In ND_PRINT() macro call(s) (step 9).

*(p)
2017-11-27 20:57:24 +01:00
Francois-Xavier Le Bail
2858e729ed Use more the EXTRACT_U_1() macro (29/n)
In ND_PRINT() macro call(s) (step 8).

*(p + e)
2017-11-26 21:33:24 +01:00
Francois-Xavier Le Bail
39c8c55aa9 Use more ND_TCHECK_n()/ND_TTEST_n() macros 2017-11-24 22:48:55 +01:00
Francois-Xavier Le Bail
da20bc56d6 Rename EXTRACT_ macros
Now all the macros have a name meaning a count in bytes.

With _S_: signed, _U_: unsigned

e.g.:
EXTRACT_BE_32BITS -> EXTRACT_BE_U_4
EXTRACT_LE_32BITS -> EXTRACT_LE_U_4
...
EXTRACT_BE_INT32 -> EXTRACT_BE_S_4

and have:
EXTRACT_8BITS -> EXTRACT_U_1
EXTRACT_INT8  -> EXTRACT_S_1
2017-11-22 23:54:09 +01:00
Francois-Xavier Le Bail
cb9b665059 Use more the EXTRACT_8BITS() macro to fetch a one-byte value (18/n)
Assignment, *(p op e)

Partial list.
2017-11-21 22:23:47 +01:00
Francois-Xavier Le Bail
ea759b171c Use more the EXTRACT_8BITS() macro to fetch a one-byte value (2/n)
In tok2str() calls.
2017-11-19 13:26:02 +01:00
Francois-Xavier Le Bail
577621026d Rename EXTRACT_nBITS() macros to EXTRACT_BE_nBITS()
It indicates clearly that these macros are used to extract big-endian
integral values.
2017-11-18 13:56:40 +01:00
Francois-Xavier Le Bail
45c9c5e5c2 Put some function definition names at the beginning of line 2017-11-16 08:46:28 +01:00
Francois-Xavier Le Bail
11d3a01319 Move the printer summaries from INSTALL.txt to each printer
with the tag '\summary:' for greping.
Remark: Currently some printers have no summary line.

Moreover:
Summarize all printers with a single line in INSTALL.txt
2016-08-14 17:03:43 +02:00
Guy Harris
83b356e177 Don't overwrite the destination IPv6 address for routing headers.
If we have a routing header, instead of overwriting the packet's IPv6
destination address in the packet with the final destination, so that
the next protocol's checksum routine can use it, we do as we do for
IPv4, and, in the "next protocol checksum" routine, scan the headers
looking for a routing header and, if we find one, copy the final
destination from it.

While we're at it, clean up a few things.
2016-02-12 20:26:39 -08: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
Francois-Xavier Le Bail
b638c78b40 Remove obsolete comments 2015-09-07 15:01:46 +02:00
Francois-Xavier Le Bail
c1c3c77463 Printers must include 'netdissect.h', not 'interface.h' 2015-09-05 23:35:58 +02:00
Gisle Vanem
b0f7b5cfea 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'
```
2015-07-10 12:39:10 +02:00
Guy Harris
69cb46af91 Fix a bunch of de-constifications. 2015-04-26 17:24:42 -07:00
Denis Ovsienko
38700c7f24 dismiss NETDISSECT_REWORKED macro
The purpose of this macro was to enable the file-by-file switch to NDO,
after which only tcpdump.c had a use of it and the definitions guarded
by it. Update tcpdump.c not to require them any more and dismiss the
unused definitions.
2015-03-22 10:06:15 +00:00
Francois-Xavier Le Bail
10124c32e7 DCCP: fix printing and indentation
- print missing protocol name
- print parentheses around generic header values in verbose mode
- fix indentation
2014-11-20 15:56:03 +01:00
Francois-Xavier Le Bail
2c909dc312 DCCP: update Packet Types with RFC4340/IANA names 2014-11-20 10:39:09 +01:00
Guy Harris
a2633f2f21 More fixes for uint8_t being shorter than u_int8_t.
Fix a typo while we're at it.
2014-04-23 11:53:22 -07:00
Guy Harris
ed85e20e4d u_intN_t is dead, long live uintN_t.
And, as we require at least autoconf 2.61, and as autoconf 2.61 and
later have AC_TYPE_UINTn_T and AC_TYPE_INTn_T macros, we use them to
define the uintN_t and intN_t macros if the system doesn't define them
for us.

This lets us get rid of bitypes.h as well.
2014-04-23 00:20:40 -07:00
Guy Harris
1cde6435df Netdissectify the to-name resolution routines.
Have them take a netdissect_options * argument, and get the "no name
resolution" flag from it.

Move the declaration of dnaddr_string to addrtoname.h, along with the
other XXX-to-string routines.
2014-04-04 00:43:46 -07:00
Denis Ovsienko
b6303af682 NDOize AODV, IPv4 and SCTP decoders 2014-03-26 15:49:27 +04:00
Denis Ovsienko
d6af516cbc finalize some previous NDO conversions
Eliminate a number of fputs(), putchar() and fflush() uses. Justify
preprocessor directives. Don't typecast ND_PRINT() to void and fix some
indentation.
2014-03-26 15:49:27 +04:00
Denis Ovsienko
1fe6e66ece make use of NETDISSECT_REWORKED
Update the already converted decoders to define the macro and to include
interface.h instead of netdissect.h. Fix incurred compile errors.
2014-03-15 14:19:49 +04:00
Denis Ovsienko
85a2dd977c NDOize DCCP, Linux socket and RPKI-Router decoders 2014-03-14 20:57:32 +04:00
Guy Harris
fe4aac1bbf Do a bunch more length checking.
Make sure we don't run past the end of the packet or, when processing
the packet header, run past the end of the header.
2014-02-16 14:40:16 -08:00
Francois-Xavier Le Bail
3625533c9a fix partial checksum errors in DCCP decoder, IPv6 case 2014-02-16 18:29:37 +01:00
Guy Harris
e9a1e0713b Fetch the sequence number the way we fetch the acknowledgment number.
Fetch 24 bits if the X bit isn't set, 48 bits if it is, using the
appropriate EXTRACT_ macros.

We do this with "struct dccp_hdr" being a header structure with a 24-bit
sequence number and "struct dccp_hdr_ext" being a header structure with
a 48-bit sequence number.
2014-02-16 02:21:28 -08:00
Guy Harris
a64aff7ef3 Use an 8-octet array when the ACK field is always 8 octets.
Get rid of "struct dccp_hdr_ack_bits" while we're at it.
2014-02-16 01:42:30 -08:00
Guy Harris
e039f35a0d Get rid of unused function. 2014-02-16 01:20:48 -08:00
Guy Harris
f5e2e1a4a5 Add {40,48,56}-bit big-endian extract macros and use them for DCCP ACKs.
Add macros to, given an octet pointer, extract 40-bit, 48-bit, and
56-bit big-endian numbers from the location pointed to by that pointer,
and use them when extracting ACK numbers from DCCP packets.  This fixes
problems on big-endian(!) machines.
2014-02-15 20:37:28 -08:00
Guy Harris
2c2d923201 Mark structures with UNALIGNED.
Maybe this will fix the crashes that appear to be occurring on the
opencsw.org buildbot; it's building with Sun/Oracle C, not GCC, but it's
at least worth a try.
2014-02-15 20:01:06 -08:00
Francois-Xavier Le Bail
c025e64b9e fix partial checksum errors in DCCP decoder, IPv4 case 2014-02-15 12:36:02 +01:00
Denis Ovsienko
fe3253b9b8 remove tcpdump's own CVS keywords
Remove lots of $Header's and a few $Id's that all belong to the former
CVS repository of tcpdump itself. These keywords have been frozen since
the migration to git in late 2008.
2014-01-03 00:59:08 +04:00
Michael Richardson
ad7a38341c Merge branch 'master' of git+ssh://bpf.tcpdump.org/tcpdump/master/git/tcpdump
Conflicts:
	enc.h
2014-01-01 21:32:05 -05:00
Michael Richardson
a97fb2f3ae whitespace changes 2014-01-01 21:31:18 -05:00
Guy Harris
27d428c0a1 Pull a bunch of headers into the only source file that includes them.
For headers included in only one source file, put the header contents in
the source file in question, and get rid of a bunch of stuff from the
header not used in the source file.
2013-12-30 22:52:15 -08:00
Denis Ovsienko
d8acd8f5d0 make consistent use of the "tstr" idiom
For each decoder that has more than one instance of truncation signaling
and prints the same string in each instance make sure that the string is
declared as "static const char tstr[]" right after the initial includes
block. Where necessary, replace fputs(s, stdout) with equivalent
printf("%s", s).
2013-12-26 18:19:50 +04:00
Guy Harris
57bfcb4ebe Add a routine to do the "checksum with pseudo-header" stuff for IPv4.
Clean up some other stuff while we're at it.
2011-06-17 01:09:16 -07:00
Guy Harris
d18bb2331d Use nextproto6_cksum() for XXX-over-IPv6 checksums.
Get rid of duplicated checksums with IPv6 pseudo-headers.
2011-06-17 00:51:47 -07:00
Guy Harris
94a4b46080 Go with Wireshark's Internet checksum routine.
The Wireshark routine is based on the BSD in-kernel portable checksum
routine (thus BSD-licensed); it takes a vector of pointers and lengths
and checksums the concatenation of the buffers in question (just as the
BSD in-kernel routine checksums a chain of mbufs).

This simplifies the "with a pseudo-header" checksums; hopefully it'll
fix up the problems being seen on some big-endian platforms, which might
be due to hand-calculating some or all of the checksum and doing so
incorrectly.  It also gets rid of some code that might be dereferencing
unaligned pointers.
2011-06-13 14:08:51 -07:00
Guy Harris
e8b5237589 Don't directly fetch multi-byte integers from packets.
Use the EXTRACT_ macros to extract multi-byte integral values from
packets, rather than just dereferencing pointers into the packet; there
is no guarantee that the packet data will be aligned on the right
boundary, and there is no guarantee that, if they're not, a direct
access will work correctly.
2010-02-21 00:27:00 -08:00
guy
7ea513de6d From Gerrit Renker:
don't compute checksums when the snapshot length is less than
	the packet length;

	combine duplicate code;

	eliminate unnecessary test.
2007-11-09 00:44:09 +00:00
hannes
8e396b5731 from Gerrit Renker <gerrit@erg.abdn.ac.uk>:
add support for variable-length checksum in DCCP, as per section 9 of RFC 4340.
remove duplicated code in dccp6_cksum (which just repeated the code of in_cksum
fix a bug in dccp.h -- the fields of CCVAL and CSCOV were swapped (see section 5.1 of RFC 4340)
fix a typo in the display of incorrect checksums
  old output `cksum xDEAD (incorrect (->  xBEEF)',
  new output `cksum xDEAD (incorrect -> xBEEF)'
2006-11-02 09:05:23 +00:00
guy
a328f56b0f From Andrea Bittau: fetch the service code in network byte order. 2006-02-19 05:08:25 +00:00
guy
5667a87a62 From Gisle Vanem: don't use GCC features such as the ability to declare
variables in the middle of the block., and #if out dccp_hdr_data()
(which is unused, and defined in such a fashion that it doesn't work on
MSVC++, with the structure name and the function name the same).
2005-12-05 21:36:24 +00:00