Commit Graph

51 Commits

Author SHA1 Message Date
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
Denis Ovsienko
eb02553274 ForCES: Fix undefined behaviour in op_valid().
[print-forces.c:316] -> [print-forces.c:323]: (warning) Shifting 32-bit
value by 32767 bits is undefined behaviour. See condition at line 323.
[print-forces.c:316]: (error) Shifting by a negative value is undefined
behaviour
2017-09-06 00:52:57 +01:00
Denis Ovsienko
2dfa645e86 ForCES: Fixup a cppcheck style notice.
[print-forces.c:281]: (style) Checking if unsigned variable 'opt' is
less than zero.
2017-09-06 00:31:29 +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
89789e51d5 Fix used but marked unused parameters 2016-08-19 01:58:35 +02:00
Francois-Xavier Le Bail
b38f324af9 Add a summary comment in all other printers
Moreover:
Remove some redundant comments
Update some summary comments
Update the specification URL for ATA over Ethernet (AoE) protocol
2016-08-15 22:42:38 +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
Francois-Xavier Le Bail
c6637a835d Fix warnings as "comma at end of enumerator list"
The warnings were:
comma at end of enumerator list [-Wpedantic]
2015-08-19 16:44:52 +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
Michael Richardson
1d1e1d9196 enumerate F_OP values explicitely, provide reference to where they are defined.
guard against case where ops->print is nil
2015-03-10 23:11:55 -07:00
Guy Harris
382bd1e639 No OPER-TLV are "empty TLVs".
As section 7 of RFC 5810 says, an OPER-TLV is 1*PATH-DATA-TLV, so it
always has at least one PATH-DATA-TLV.  Remove the ZERO_TTLV check - the
old one was bogus ((!ops->flags & ZERO_TTLV) means ((!ops->flags) &
ZERO_TTLV), and if ops->flags is non-zero, !ops->flags is zero, and the
test fails), and the new one causes tests to fail, revealing that the
whole "empty TLVs like COMMIT and TRCOMMIT are empty, we stop here"
think is wrong, so we remove it.
2015-01-08 13:22:29 -08:00
Guy Harris
e07d011c23 Properly test ZERO_TTLV flag in otlv_print().
If that flag is set, the TLV in question is empty, so don't process
anything further - and if it's *not* empty, report an error.

Thanks to Maks Naumov for finding this.
2015-01-08 13:22:29 -08:00
Francois-Xavier Le Bail
6fe428bcec ForCES: update reference from draft to RFC5810
Acked-by: Jamal Hadi Salim
2014-12-17 14:43:28 +01: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
Denis Ovsienko
62a5184ed4 NDOize ForCES, MPLS LSP ping and OLSR decoders 2014-03-27 14:58:23 +04:00
Denis Ovsienko
f1ba3be396 refine the previous change
This time eliminate a few instances of the code initializing struct tok
with negative values and squelch the warnings like below:

warning: initializer will be sign-extended: -1
2014-02-26 16:15:28 +04:00
fxlb
eb610a0d63 print-forces: print_metailv(): unused parameter 'len' 2014-02-05 21:38:30 +01:00
Michal Sekletar
7de3de06e7 print-forces: remove unused variable 2014-01-16 14:43:46 +01: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
eb2001628c Use struct toks for various enumerated fields. 2013-12-31 11:59:18 -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
0d72e56a57 Not all compilers that can be used support C++/C99-style comments.
Use #if 0/#endif, rather than a // comment, to keep a line of code from
being compiled.
2013-10-16 12:54:06 -07: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
c951c5012e Fix ForCES warnings, clean up a bit.
Move forces.h into print-forces.c, make a bunch of routines static, and
fix some warnings.
2013-07-23 13:12:54 -07:00
Jamal Hadi Salim
571bf538d8 add support for appending table rows 2013-07-16 09:38:25 -04:00
Jamal Hadi Salim
ec92c2539f Add support for getting table ranges Fixup get by key formatting while at it 2013-07-16 09:38:25 -04:00
Jamal Hadi Salim
93e641bdc0 Print redirect data and metadata details only when verbosity is at least at level 3 2013-07-16 09:38:25 -04:00
Jamal Hadi Salim
0ee9e1a26b Print redirect packetdata correctly 2013-07-16 09:38:25 -04:00
Jamal Hadi Salim
871b4b4d7c Print redirect Metadata correctly 2013-07-16 09:38:25 -04:00
Guy Harris
5bc4bf28c9 Check the return value of some print routines.
Some routines return -1 on error; bail and return -1 if they do.
2012-06-08 19:14:06 -07:00
Guy Harris
f6d40d5bb8 Fix printing of 64-bit quantities.
Do *NOT* assume that "%l[doxu]x" - or "%ll[doxu]" - is the way to print
a 64-bit quantity; on UN*X, it might be a "long" or a "long long",
depending on whether you're on a 32-bit or 64-bit platform and, on
Windows with MSVC++, it's not a long (even in 64-bit mode) and doesn't
use "%ll[doxu]", either.  Instead, use PRI[doxu]64; that's what C99
defines, and what we define ourselves if the C environment doesn't
define it.
2012-06-07 22:12:28 -07:00
Michael Richardson
e3581ca17e fixes from Jamal Hadi Salim <hadi@mojatatu.com> for forces: SPARSE data (per RFC 5810) 2012-03-29 16:08:35 +02:00
Jamal Hadi Salim
f65274c570 Use proper type (16bit) when extracting path id count
Signed-off-by: Jamal Hadi Salim <hadi@mojatatu.com>
Signed-off-by: Michael Richardson <mcr@sandelman.ca>
2011-01-25 19:59:44 -05:00
Jamal Hadi Salim
a9de1ae94e Fix mixing recursive and flat Path Data
+--PD
 .  +--PD
 .  |
 .  |
 .  +--PD
 .
 .
 +--PD
 |
 |
 +--PD

or
 +--PD
 .  +--PD
 .     +
 .     |
 .     +--PD
 .         +
 .         |
 .         +-- PD
 .         +
 .         |
 .         +-- PD
 +--PD
 |
 |
 +--PD

etc

Signed-off-by: Jamal Hadi Salim <hadi@mojatatu.com>
Signed-off-by: Michael Richardson <mcr@sandelman.ca>
2011-01-25 19:57:55 -05:00
Jamal Hadi Salim
375352c72b Fix indent space when we have padded data
See if you can spot the difference between

    Pathdata: Flags 0x0 ID count 1
      ID#01: 3
     FULLDATA TLV (Length 10 DataLen 6 pad 2 Bytes)
       [
       0x0000:  0002 0406 080a 0000
       ]

and:
    Pathdata: Flags 0x0 ID count 1
      ID#01: 3
      FULLDATA TLV (Length 10 DataLen 6 pad 2 Bytes)
       [
       0x0000:  0002 0406 080a 0000
       ]

Signed-off-by: Jamal Hadi Salim <hadi@mojatatu.com>
Signed-off-by: Michael Richardson <mcr@sandelman.ca>
2011-01-25 19:56:52 -05:00
Guy Harris
72de6e8bc3 Use rlen rather than tll as the name of "remaining length" variables. 2010-02-07 18:02:41 -08:00
Guy Harris
606a29c55c Check the containing item length in some loops.
In some loops, don't loop just until we get an error, stop when we run
out of data to parse.

Also, add some comments to indicate what we know about lengths at
various points, before we do something with the length that happens to
assume what we know.  Add some checks that this auditing found
necessary.
2010-02-07 17:47:31 -08:00
Guy Harris
7906cae611 Use #defines rather than sizeof.
Use ForCES_HDRL, TLV_HDRL, and ILV_HDRL instead of various sizeof's, to
make it clearer what certain tests ensure are true (as, in other cases,
the #defines are subtracted from values that should be, at that point,
ensured not to be less than the #define in question).
2010-02-07 16:05:46 -08:00
Guy Harris
20194339f9 Constify a bunch of stuff. 2010-01-26 20:14:23 -08:00
Guy Harris
44c1734ba8 Put PRIu64 on the same line as the rest of the format string. 2010-01-26 18:50:53 -08:00
Guy Harris
6ee5663a02 Add TCHECKs, make length variables 32 bits.
Add TCHECK/TCHECK2 calls to make sure we are within the packet boundary
before fetching data.  Make some length variables that could in theory
have values that don't fit in 16 bits 32 bits long.

Get rid of blanks before newlines.
2010-01-26 18:43:22 -08:00
Guy Harris
67c76d583f Use EXTRACT_16BITS() and EXTRACT_32BITS() to fetch integral values.
Use EXTRACT_16BITS() and EXTRACT_32BITS() to fetch 16-bit and 32-bit
big-endian quantities from the packet, as there's no guarantee that a
given 16-bit quantity will be aligned on a 2-byte boundary or that a
given 32-bit quantity will be aligned on a 4-byte boundary, nor is there
a guarantee that unaligned accesses will succeed (they might trap, or
they might not fetch an unaligned quantity).
2010-01-26 17:56:36 -08:00
Guy Harris
d033ee2f3e Squelch some int-vs-long errors. 2010-01-10 18:36:45 -08:00
Guy Harris
64d92662c3 Don't use bitfields in on-the-wire structures.
C doesn't guarantee that bit fields will be in any particular order.
2010-01-10 17:56:49 -08:00
Guy Harris
832716b73d Fix a bunch of warnings in the ForCES printer.
Get rid of C++/C99-style comments while we're at it; some C compilers
reject them.
2010-01-10 14:16:41 -08:00