Commit Graph

64 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
ba8936b39b Print truncations with nd_print_trunc() instead of tstr[] strings
Remove the tstr[] strings.
Update the output of some tests accordingly.

Moreover:
Add or update some ndo_protocol fields.
2018-05-04 13:47:49 +02:00
Francois-Xavier Le Bail
546558eabd Add the ndo_protocol field in the netdissect_options structure
Update this field in printer entry functions.
It will be used for some printings.
2018-03-16 19:44:47 +01:00
Francois-Xavier Le Bail
ef987f720c Rename some printer functions to *_print
Moreover:
Fix spaces.
2018-02-22 14:19:42 +01:00
Francois-Xavier Le Bail
5dfebc9722 OSPFv3: More nd_ipv6-ification 2018-01-31 20:40:45 +01:00
Guy Harris
0dad1934af Have ip{6}addr_string take a u_char * as the second argument.
Fix warnings that introduces.
2018-01-31 00:43:45 -08:00
Guy Harris
398ef7f336 A bit more nd_ipv4-ification. 2018-01-30 17:30:54 -08:00
Guy Harris
3db38df8ed Use nd_ipv6 rather than struct in6_addr in packet-layout structures.
Also, use it, and nd_ipv4, in sizeof() operations.
2018-01-30 17:29:33 -08:00
Francois-Xavier Le Bail
5791511faa OSPFv3: Use more ND_TCHECK_n() and ND_TCHECK_SIZE() macros 2018-01-24 06:50:17 +01:00
Francois-Xavier Le Bail
6e15ad4b99 Use more ND_TCHECK_n() macros 2018-01-22 21:51:29 +01:00
Guy Harris
fb2479d733 Always include <config.h> rather than "config.h".
This can prevent bizarre failures if, for example, you've done a
configuration in the top-level source directory, leaving behind one
config.h file, and then do an out-of-tree build in another directory,
with different configuration options.  This way, we always pick up the
same config.h, in the build directory.
2018-01-21 12:27:28 -08:00
Francois-Xavier Le Bail
513f782ae1 Use quoted include netdissect-stdinc.h instead of angle-bracketed one 2018-01-21 10:28:15 +01:00
Guy Harris
64677b0d78 Clean up signed vs. unsigned. 2018-01-11 11:52:30 -08:00
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Francois-Xavier Le Bail
d526e47658 Use ND_TTEST_SIZE()/ND_TCHECK_SIZE() macros (1/n) 2018-01-03 21:32:07 +01:00
Francois-Xavier Le Bail
ce4e690346 OSPFv3: Replace ND_TCHECK2 call by ND_TCHECK_LEN call 2017-12-14 22:41:15 +01:00
Guy Harris
41b9478cc8 Use nd_ types for OSPF and OSPF6 packets.
And add EXTRACT_ calls as required.

Remove no-longer-necessary & operators in EXTRACT_ calls.
2017-12-14 10:28:57 -08:00
Francois-Xavier Le Bail
5cea270318 Remove all storage class specifier 'register'
Let the compiler do the optimizations (or not) based on build options.

Avoid 'value has been optimized out' messages in gdb using '-O0'.
2017-12-13 19:17:47 +01:00
Francois-Xavier Le Bail
84ef17ac0e Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)
ND_TTEST2(var, l)  -> ND_TTEST_LEN(p, l)
ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
2017-12-11 22:11:01 +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
3c8f3e13b0 Rename ND_TCHECK_/ND_TTEST_ macros
Now all the macros have a name meaning a count in bytes.

e.g.:
ND_TCHECK_32BITS -> ND_TCHECK_4
ND_TTEST_32BITS -> ND_TTEST_4
2017-11-22 21:58:44 +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
d4aeb0e54a OSPFv3: More bounds checks. 2017-09-13 12:25:44 +01:00
Francois-Xavier Le Bail
88b2dac837 CVE-2017-13036/OSPFv3: Add a bounds check before fetching data
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
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
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
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
Guy Harris
f149d769de Split the OSPFv3 header and bodies into separate structures.
Some compilers appear to put some padding before the ospf6_un union, so
the OSPFv3 packets aren't dissected correctly.  Pull the members of
that union into separate structures, and find the pointer to the OSPFv6
body by adding the header length to the pointer to the beginning of the
header.
2014-05-01 19:48:10 -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
20ecf8fafe Squelch a Coverity warning.
Make the lsa_p_prefix field as large as the largest possible prefix, so
that Coverity doesn't complain about going past the end of an array.
2014-04-18 17:43:09 -07:00
Denis Ovsienko
50905f4d0a OSPFv3: fix SEGV on SPARCv9 (concurs with 8f6bca3)
This bug arose on the OpenCSW build farm:

    ospf3_auth-vv                 : TEST FAILED

Dagobert Michelsen had helped to use the farm servers to debug.
2014-04-11 13:18:20 +04: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
2b753f8058 NDOize DECnet, OSPF and TCP decoders 2014-04-02 14:24:56 +04:00
Denis Ovsienko
b46194277a spell "%s" format strings (complements 708a68a)
Make "%s" format string always reside in the print function call
explicitly such that the reader doesn't have to assess its safety.
2014-03-31 15:43:22 +04:00
Denis Ovsienko
c91ffeae22 NDOize OSPFv3 decoder 2014-03-27 10:21:14 +04: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
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
Denis Ovsienko
35c5cd9911 OSPFv3: add crypto authentication (RFC6506) support
* Update ospf6_print() to distinguish packet length and OSPFv3 data
  length.
* Fix ospf6_print_lshdr(), ospf6_print_lsa() and ospf6_decode_v3() to
  print the variable-sized part of DBDesc, LS-Upd and LS-Ack packets
  with the declared length of the OSPFv3 data in mind.
* Implement as little LLS decoding in ospf6_print_lls() as necessary to
  indicate and skip an LLS data block.
* Implement normal AT decoding in ospf6_decode_at().
* Add ospf6_decode_v3_trailer() to couple the above with ospf6_print().

This commit doesn't include a sample capture as the only existing RFC6506
implementation is not yet ready to serve as a reference.
2013-12-29 18:02:29 +04:00
Denis Ovsienko
47cd247bea OSPFv3: fix more minor issues
* Add 3 more LS types and the M6-bit.
* Print multicast LS type and prefix option as deprecated.
* Remove needless forward declarations.
* Make ospf6_decode_v3() consider vflag for every packet type and raise
  the margin from "> 0" to "> 1" because it is already "> 0" that far.
* Fix a message to refer to packet type instead of LS type.
* Remove irrelevant comment.
* Don't print unknown protocol version 2nd time.
2013-12-28 13:01:58 +04: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
Denis Ovsienko
ae1fdebb64 OSPFv3: refresh options and flags 2013-12-23 21:04:46 +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
Guy Harris
a16fe011b1 Use __inline with MSVC for all source files. 2013-06-09 18:05:37 -07:00
Guy Harris
36b75f7121 Redo length checks in ospf6_print_lsa().
Check to make sure we haven't run past the end of the LSA by doing
length checks - and be a bit fussier about length checks.  Do more
end-of-packet checks as well.
2011-10-13 21:59:57 -07:00
guy
d7da1619b5 Cast "sizeof" to a "u_int"; it's not guaranteed to be "int" in size (it
could be "long", for example, and probably *is* "long" on LP64
platforms), so you can't print it with "%u", but, in this particular
case, it's going to fit in a 32-bit quantity.
2006-09-13 06:31:11 +00:00