Commit Graph

225 Commits

Author SHA1 Message Date
Guy Harris
3f3f2505f2 Make nd_uint8_t and nd_int8_t arrays, to catch direct references.
This catches direct references, so we can change them to use EXTRACT_U_1
or EXTRACT_S_1.

Also, change some structures to use the nd_ types that weren't already
using them.

Then make the appropriate EXTRACT_{U,S}_1() changes.
2017-12-10 16:23:34 -08:00
Francois-Xavier Le Bail
6bb65331a5 Use more the EXTRACT_U_1() macro (53/n)
Assignment, p[n], (more)
2017-12-10 11:40:35 +01:00
Francois-Xavier Le Bail
07ac438e08 Use more the EXTRACT_U_1() macro (52/n)
Assignment, p[n]
2017-12-09 14:05:25 +01:00
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
00b189d27c Use more the ND_TCHECK_1() macro 2017-12-04 17:50:29 +01:00
Francois-Xavier Le Bail
4166458a2a Use more the EXTRACT_U_1() macro (46/n)
In: if (... p[n] ...) ...
2017-12-03 21:51:36 +01:00
Francois-Xavier Le Bail
61c422a88c Use more the EXTRACT_U_1() macro (43/n)
In: if (... p[n] ...) ...
2017-12-03 13:35:26 +01:00
Francois-Xavier Le Bail
97de8ca7bd Use more the EXTRACT_U_1() macro (35/n)
In some safeputchar() calls, *(p).
2017-11-30 23:08:07 +01:00
Francois-Xavier Le Bail
415160c0c2 Use more ND_TCHECK_n() macros 2017-11-29 21:06:51 +01:00
Francois-Xavier Le Bail
dde3aa9975 Use more the EXTRACT_U_1() macro (32/n)
In: while (... *(p) ...) ...,
    while (... *(p + e) ...) ...
2017-11-28 22:22:35 +01:00
Francois-Xavier Le Bail
1a90fd99d2 Use more the EXTRACT_U_1() macro (28/n)
In ND_PRINT() macro call(s) (step 7).

p[n] ...
2017-11-26 15:44:43 +01:00
Francois-Xavier Le Bail
575188b5bf Use pointer expressions like in most similar cases 2017-11-25 18:21:18 +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
8d3c7406c4 Use more the EXTRACT_U_1() macro to fetch a one-byte value (23/n)
Reminder: EXTRACT_8BITS is now EXTRACT_U_1.

In tok2str() calls (step 4).
2017-11-23 15:05:08 +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
01cd3621f1 Use more the EXTRACT_8BITS() macro to fetch a one-byte value (22/n)
In ND_PRINT() macro calls, *p++.

Partial list.
2017-11-22 16:02:02 +01:00
Francois-Xavier Le Bail
c8e0a4a168 Use more the EXTRACT_8BITS() macro to fetch a one-byte value (20/n)
e op *p

Partial list.
2017-11-22 10:36:51 +01:00
Francois-Xavier Le Bail
a7a76012a1 Use more the EXTRACT_8BITS() macro to fetch a one-byte value (17/n)
Assignment, *p++ -> EXTRACT_8BITS(p); p++;

Partial list.
2017-11-21 20:30:12 +01:00
Francois-Xavier Le Bail
93bee24026 Use pointer expressions like in most similar cases 2017-11-20 22:58:59 +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
Guy Harris
f4b9e24c73 CVE-2017-13041/ICMP6: Add more bounds checks.
This fixes a buffer over-read discovered by Kim Gwan Yeong.

Add a test using the capture file supplied by the reporter(s).
2017-09-13 12:25:44 +01:00
Guy Harris
67c7126062 CVE-2017-13021/ICMP6: Add a missing bounds check.
This fixes a buffer over-read discovered by Bhargava Shastry,
SecT/TU Berlin.

Add a test using the capture file supplied by the reporter(s), modified
so the capture file won't be rejected as an invalid capture.
2017-09-13 12:25:44 +01:00
Denis Ovsienko
21c80eab75 fix alignment issues with GCC on Solaris 10 SPARC
When compiled with the Solaris Studio 12.3 compiler (as in the OpenCSW
buildbot system at the time), tcpdump passed all the tests. When
compiled with GCC 5.2.0 on the same host, the following tests failed
because tcpdump terminated with SIGILL (Bus Error - core dumped):
icmpv6, icmpv6_opt24-v, dhcpv6-aftr-name, dhcpv6-ia-na, dhcpv6-ia-pd,
dhcpv6-ia-ta, dhcpv6-ntp-server, dhcpv6-sip-server-d,
dhcpv6-domain-list, kday1. This change fixes the issue with the method
suggested in commit 1376682.
2016-10-09 11:44:19 +01:00
Francois-Xavier Le Bail
ca54d72376 Declare some variables as static 2016-09-11 21:45:26 +02: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
Denis Ovsienko
865ce57cf6 ICMP6 RPL: don't use inet_ntop()
No other code uses it, there is the ip6addr_string() wrapper. This
switch also makes it possible to avoid some array management.
2016-07-11 12:00:01 +01:00
Denis Ovsienko
f991a6948d use a mnemonic constant in rpl_daoack_print() 2016-07-11 11:57:20 +01:00
Denis Ovsienko
bd2b067d7b call ipaddr_string() instead of getname()
Same as in the previous commit.
2016-07-11 11:56:53 +01:00
Denis Ovsienko
d2aa4eec28 call ip6addr_string() instead of getname6()
This replaces a few explicit type casts with one type cast in the macro
and makes the source code mean one thing with one term instead of two.
2016-07-11 11:56:29 +01:00
Michael Richardson
292d58b784 dagid is always an IPv6 address, not an opaque 128-bit string 2016-07-09 17:22:18 -04: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
c1c3c77463 Printers must include 'netdissect.h', not 'interface.h' 2015-09-05 23:35:58 +02:00
Francois-Xavier Le Bail
e847135d66 Functions in libnetdissect must use ndo_error() function 2015-09-05 22:52:11 +02:00
Francois-Xavier Le Bail
2c24bfd00c RPL: Fix suboption print 2015-05-04 23:05:23 +02:00
Guy Harris
69cb46af91 Fix a bunch of de-constifications. 2015-04-26 17:24:42 -07:00
Guy Harris
7ac62c7158 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.
2015-04-26 17:03:32 -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
Denis Ovsienko
d0fab6bf83 ICMPv6: fix RPL DAGID printing (GH #418)
Allow an extra byte in the buffer for snprintf()'s null character,
otherwise it does not work as intended (issue spotted by Gisle Vanem on
Windows, where snprintf() behaviour seems to be different). Update the
tests.
2015-01-03 07:29:12 +00:00
Michael Richardson
817ec9f27e RPL: print DAO flags (acK, DagID)
remove DAO messages from DIO test data
2014-07-02 18:00:30 -04: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
51670d1949 NDOize safeputs() and safeputchar() 2014-04-01 19:46:05 +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
59690cf6b7 NDOize BOOTP, DHCPv6, DNS, PIM and sFlow decoders
Also add/remove tabs in a few involved functions to justify indentation.
2014-03-25 23:27:23 +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
83bec9d56c refine some past NDO conversions
Don't include unneeded headers and replace a few remaining printf's.
2014-03-12 18:11:23 +04:00
Francois-Xavier Le Bail
3625533c9a fix partial checksum errors in DCCP decoder, IPv6 case 2014-02-16 18:29:37 +01:00
fxlb
80d2e0ef55 print-icmp6: remove useless break 2014-02-05 14:46:07 +01:00
Guy Harris
89e2444c8b Don't assume snprintf() returns the number of characters formatted.
On some UN*Xes (such as some versions of HP-UX), it doesn't.
2014-02-02 15:02:33 -08:00
Guy Harris
4552271323 Multi-byte fields are in network byte order; fetch them appropriately. 2014-01-15 12:04:39 -08:00
Guy Harris
a403881e82 Various fixes.
Get rid of zero-length arrays; not all compilers support them.

Get rid of __attribute__((packed)); not all compilers support it, so we
can't depend on it.

Use explicit constants for sizes, just in case some compilers pad
structures.

Add some length checks.

Make some ND_TTEST2 calls ND_TCHECK2 calls instead, so they report
truncation if they fail.

Constify some pointers.
2014-01-08 16:59:07 -08:00
Michael Richardson
5637910a9d RPL: test data and fix for printing DAO messages 2014-01-05 11:38:28 -05:00
Michael Richardson
9df6f2ccb4 make sure that DAOACK option printer gets accurate length, and does not indicate truncated spuriously 2014-01-05 00:20:52 -05:00
Michael Richardson
defc20085e added test case for a DAO-ACK with no options 2014-01-04 23:31:47 -05:00
Michael Richardson
1658db5ec3 added decoding of RPL DAO and DAOACK sub-options 2014-01-04 10:56:41 -05:00
Michael Richardson
2f1714e728 added RPL decode for DAO and DAOACK, refactor out option printer 2014-01-04 10:52:11 -05:00
Michael Richardson
87c7396593 switch rpl_dio_print to use tok2str 2014-01-03 11:13:16 -05:00
Michael Richardson
d823987428 clear up errors from more -W options: disambiguate length variables 2014-01-03 11:04:15 -05:00
Michael Richardson
df9a394126 correct typo in RPL DIO PRF mask.
updated 19-pickdag, as this pcap file now has correct PRF/MOP value to show this fault.
2014-01-02 22:39:14 -05:00
Michael Richardson
585ac3db06 Merge branch 'master' of git+ssh://bpf.tcpdump.org/tcpdump/master/git/tcpdump 2014-01-02 22:07:47 -05:00
Michael Richardson
35e21565de added hexprint of suboptions payload on three -v
move rpl dio print to subfunction to keep it at 80columns
2014-01-02 22:07:38 -05:00
Michael Richardson
82ede46025 updated RPL printer from draft-07 to rfc6550 for DIO message.
Decode the DIO suboptions as well, added new test case
2014-01-02 21:33:26 -05: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
Denis Ovsienko
0b7b6192c6 fix a few compiler warnings about prototypes
print-ascii.c needs prototypes of ascii_print(),
hex_and_ascii_print_with_offset() and hex_and_ascii_print().

print-icmp6.c needs prototypes of in_cksum_shouldbe() and ns_nprint().
2014-01-02 16:27:14 +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
ac910c086e ndo-ize print-ascii: hex_print_with_offset() 2014-01-01 21:31:18 -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
Gleb Smirnoff
4aec74ccc4 Fix compilation warnings: set but unused variables. 2013-11-26 00:16:47 +04:00
Denis Ovsienko
7de355927b justify declarations of struct tok arrays
Make sure all of them are declared const and most of them -- static.
Proper declaration of token arrays is a common review point for new code
that is based on existing decoders. Thus fix the issue at its root.
2013-09-24 20:54:03 +04:00
Stephane Bortzmeyer
0569b61886 Typo in displayed text 2013-06-19 10:18:17 +02:00
Tillmann Karras
7c73910217 Fix display of MLDv2 queries 2013-01-18 02:23:33 +01:00
Denis Ovsienko
e2eff503d6 fix printing of infinite lifetime in ICMPv6
icmp6_opt_print() in the case of ND_OPT_PREFIX_INFORMATION always
appended "s" (seconds) to the returned string result of get_lifetime(),
which could be either a printed number or the "infinite" word. This
change leaves it up to get_lifetime() to decide if "s" is necessary.
This also improves the ND_OPT_ROUTE_INFO case, where route information
lifetime has the same type and semantics.
2012-06-21 17:14:55 +04:00
Denis Ovsienko
8c31bfcebe add DNSSL (RFC6106) support
The most notable difference between RFC5006 and RFC6106 is the addition
of DNSSL RA option. This commit adds DNSSL handling code to make tcpdump
fully RFC6106-aware. This code has been tested against RA packets
generated by Quagga and radvd.
2012-04-13 16:32:40 +04:00
Denis Ovsienko
91045106fb ND_OPT_ADVINTERVAL is in milliseconds, not seconds
RFC 6275 7.3. New Advertisement Interval Option Format

   Advertisement Interval

      32-bit unsigned integer.  The maximum time, in milliseconds,
      between successive unsolicited Router Advertisement messages sent
      by this router on this network interface.
2011-12-29 20:46:02 +04:00
Guy Harris
879217e502 Handle ICMP6 checksums more like TCP checksums.
Instead of printing the result of icmp6_cksum() if it's non-zero, print
the checksum field value and the value it should have had.  That means
that what we print is the same regardless of whether we're running on a
big-endian or little-endian machine.
2011-06-17 01:17:47 -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
Michael Richardson
3e508b0074 mistype of RPL type codes: off by one. fixed 2010-12-31 12:36:24 -05:00
Michael Richardson
d1088041e2 updated RPL type code to RPL-17 draft
added secure bit
updated single test case
2010-12-31 12:28:43 -05:00
Guy Harris
020b16ec4f Correctly check for various values of the ICMP type field.
clang+llvm warnings pointed out some incorrect code - you can't, in C,
check for multiple values for a variable that way.
2010-08-19 19:23:08 -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
David Horn
2a7e2246c7 RFC 5006 support.
Reviewed-By: Guy Harris <guy@alum.mit.edu>
2010-02-07 14:52:07 -08:00
Guy Harris
b050a1e4e0 Squelch a couple of compiler warnings. 2009-11-27 12:03:25 -08:00
Michael Richardson
1a2cbb1112 initial printing of RPL DIO messages 2009-11-14 22:17:12 -05:00
Michael Richardson
27e7cefadd netdisect converted icmp6_print() 2009-11-14 21:36:05 -05:00
Guy Harris
df3cb44f79 On some platforms we appear to get a warning because dnsname_print() is
declared static and later defined without static.  Define it with
static.
2009-09-21 10:16:14 -07:00
guy
947533a7fc "rr_maxdelay" is a 16-bit field, and "rr_reserved" is a 32-bit field, in
a router renumbering message; process them correctly.
2008-02-05 19:36:13 +00:00
guy
167c740563 From Michael Shields <shields@msrl.com> via Roman Francoise: spelling
fixes.
2005-09-05 09:29:00 +00:00
hannes
67eb31b994 code cosmetics:
at places where the entity to print / or increment
  shares the semantics of an IPv4 or IPv6 address
  use sizeof(in_addr) and sizeof(in6_addr),
  rather than a hardcoded 4 or 16
2005-07-11 20:15:31 +00:00
guy
dcd2814277 "ipproto.h" uses "struct tok", and "interface.h" defines it; always
include "interface.h" before "ipproto.h".
2005-05-14 00:42:28 +00:00
guy
34d2498d7f Get rid of some extra blanks. 2005-04-25 17:29:51 +00:00
guy
30555e8172 Get rid of, or use, unused variables. 2005-04-20 22:30:53 +00:00
guy
655c706df5 Get rid of unused variables. 2005-04-20 22:18:50 +00:00
hannes
932c88e772 rework the ICMP6 decoder:
-replace private flag printers and replace them with bittok2str()
  -remove some flesh from inline printf() statements make more use of tok2str()
  -option printer gets a multiline output (behind vflag)
   -context hexdump for options
  -replace some u_int32 with u_int8[4] to get around compiler padding issues
2005-01-14 10:41:50 +00:00
guy
20d2f6830e From Shinsuke Suzuki: fix a boundary check, and add some additional
boundary checks.
2004-07-28 19:59:24 +00:00
guy
010fcafbc5 From Shinsuke Suzuki <suz@kame.net>: a patch to sync ICMPv6-Type number
with the current IANA assignment (Apr 13 2004).  It consists of the
following four parts:

	- added inverse-neighbor-discovery (RFC3122)
	- shift MTRACE-related type numbers, since it collides
	  with inverse-neighbor-discovery.
	- added MLDv2 (draft-vida-mld-v2-08.txt)
	- shifted Mobile-IPv6 numbers from interim value to the
	  official one. (draft-ietf-mobile-ipv6-24.txt)
2004-06-16 00:06:28 +00:00
guy
33ede7fbea Add bounds checking. 2004-03-24 00:06:26 +00:00