Commit Graph

33 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
94a3708f00 Include <config.h> unconditionally
Builds using Autotools or CMake generate config.h, thus remove the
'#ifdef HAVE_CONFIG_H'/'#endif'.

Remove also the 'add_definitions(-DHAVE_CONFIG_H)' in CMakeLists.txt.
2024-03-28 05:34:34 +00:00
Francois-Xavier Le Bail
15db4f5164 Loopback/CTP: Use the Wayback Machine for the removed specification
[skip ci]
2023-10-08 20:34:25 +02:00
Guy Harris
7865163989 Speak of MAC-48s rather than MAC or Ethernet addresses.
Not all MAC-48s are Ethernet addresses; a lot of them are IEEE 802.11
addresses, for example.

Use the IEEE term.
2023-07-14 00:27:39 -07:00
Denis Ovsienko
424961546a Introduce and use ND_LONGJMP_FROM_TCHECK.
Apply this to the 4 the recently converted protocols.

HOW TO USE:

Define this in a print-*.c file before including netdissect.h to make
all its ND_TCHECK*() instances longjmp(). Only do this after verifying
that every ND_TCHECK*() in the file is correct and that in every
possible case it is safe to call longjmp() without incurring resource
leaks or any other problems. If it is not safe or feasible to convert
whole file, consider converting one function at a time.
2020-09-27 21:45:46 +01:00
Denis Ovsienko
5c6c98f2c5 Loopback/CTP: Modernize packet parsing style.
The change made in commit bdd97f54 was safe, but was slightly incorrect.

Before the change the decoder used the _declared_ end of packet (the
initial "cp" + the initial "len") as the target of how much data to try
to decode, and whilst trying to do that it could cross the _captured_ end
of packet (ndo_snapend) and give up complaining, so the output would
correctly indicate there was supposed to be more data beyond the
unexpected snapshot end.

After the change the decoder started to use the captured end of packet to
tell where the packet ends, so it would never cross ndo_snapend, but it
would interpret the packet data as if the missing part was never supposed
to be there and would thus decode truncated packets incorrectly.

In order to eliminate this space for misinterpretation, remove the "ep"
pointer and change the code both to advance "cp" and to decrease "len" as
it is going through the protocol structures, so the part of the packet
that is supposed to be present but has not been decoded yet can be
addressed by just "cp" and "len" (like it is done in many functions
elsewhere). Let the GET_ macros guard the snapshot end and use nd_trunc()
to handle the remaining ND_TCHECK_LEN() instances.

Articulate the part of the message sized by skipCount.
2020-09-18 22:24:09 +01:00
Denis Ovsienko
51e180c4fb Remove 96 assorted ND_TCHECK calls.
Remove a number of instances that do not match common patterns and have
the only substantial effect on the code flow that a truncated packet
triggers "goto trunc" instead of longjmp(). (In a few cases this change
can increase the number of fields printed before giving up.)
2020-09-08 05:04:58 +01:00
Francois-Xavier Le Bail
abc8c2d61c Remove many (762) now redundant ND_TCHECK_n() calls
ND_TCHECK_n(e), n in { 1, 2, 3, 4, 8 }.

They are redundant because they are followed by a GET_.*_n(e) call,
same n, same e, which do the bounds check.

Remove unused 'trunc' labels and most associated codes.

Update the outputs of some tests accordingly.
2020-09-06 20:22:29 +02:00
Guy Harris
306c2a0384 More bounds checking when fetching addresses and converting to strings.
Replace more calls to ipaddr_string()/ip6addr_string() with calls to
GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds
checking.

Add similar bounds-checking inline functions and macros to wrap
linkaddr_string(), etheraddr_string(), and isonsap_string() and convert
calls to them to use the macros as well.

Shuffle the inline functions in addrtoname.h around a bit, so that the
inline functions, external declarations, and macros are all in the same
order.
2020-01-19 19:55:38 -08:00
Francois-Xavier Le Bail
8534f3b7bf Use more HTTPS in URLs
[skip ci]
2019-08-19 15:49:21 +02:00
Francois-Xavier Le Bail
ee68aa3646 Use the new GET_ macros instead of the EXTRACT_ ones
The exceptions are currently:
Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer.
An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer
pointer.
2019-03-26 21:06:24 +01:00
Francois-Xavier Le Bail
77a49fcb6e Add the nd_print_invalid() function
It prints " (invalid)", used for malformed or corrupted packets.

Moreover:
Update CONTRIBUTING.
2018-09-11 13:09:05 +02:00
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
bdd97f5422 Loopback: Fix the uses of the pointer to the end of current packet
Must be based on packet header caplen.
2018-03-01 16:40:04 +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
Francois-Xavier Le Bail
e2982e7f6f Update ND_PRINT() as a variadic macro 2018-01-07 13:36:41 +01:00
Guy Harris
7068209574 Use nd_ types in 802.x and FDDI headers.
Use EXTRACT_U_1() as required by those changes.  Remove
no-longer-necessary & operators from other EXTRACT_ calls.

While we're at it, add MAC_ADDR_LEN to netdissect.h, and use it instead
of ETHER_ADDR_LEN; eliminate ETHER_ADDR_LEN.

Move the maximum Ethernet length field value to ethertype.h, under the
name MAX_ETHERNET_LENGTH_VAL.

Move the Ethernet header structure, and the #define for the Ethernet
header length, to print-ether.c; in non-Ethernet dissectors that were
using the Ethernet header structure, just declare two nd_mac_addr
variables for the source and destination MAC addresses and use them
instead of the Ethernet header (we don't need the type field there).

These changes leave nothing in ether.h, so eliminate it.
2017-12-12 10:36:21 -08: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
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
436ced3bd8 Change istr[] (for invalid string) to be global 2016-01-28 14:24:19 +01: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
3fb4560e1e Rename cstr[] to istr[] like invalid string
Moreover:
Hamonise the output for error messages
Add istr[] in print-babel.c
2015-09-06 20:47:42 +02:00
Francois-Xavier Le Bail
7ea344d76a Use the word 'invalid' for 'malformed' or 'corrupted' packets
An invalid packet could be:
1) built malformed originally by the sender or a fuzz tester,
2) became corrupted in transit.
2015-09-06 13:44:54 +02:00
Francois-Xavier Le Bail
c1c3c77463 Printers must include 'netdissect.h', not 'interface.h' 2015-09-05 23:35:58 +02: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
bbedebc666 Merge remote-tracking branch 'bpf/master' 2014-04-06 21:22:43 +04:00
Denis Ovsienko
d802a5d6cd fix a couple typos 2014-04-06 21:22:10 +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
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
db8077a114 add a decoder for Loopback/CTP
tcpdump used to print an empty line for a Loopback (CTP) packet, which
many Cisco switches send by default every 10 seconds. This commit adds
a decoder for the protocol and a test case, which uses the sample
capture from Wireshark wiki (configuration_test_protocol_aka_loop.pcap).
2014-01-09 16:59:33 +04:00