summaryrefslogtreecommitdiff
path: root/print-loopback.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce and use ND_LONGJMP_FROM_TCHECK.Denis Ovsienko2020-09-271-6/+1
| | | | | | | | | | | | | 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.
* Loopback/CTP: Modernize packet parsing style.Denis Ovsienko2020-09-181-17/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove 96 assorted ND_TCHECK calls.Denis Ovsienko2020-09-081-1/+0
| | | | | | | 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.)
* Remove many (762) now redundant ND_TCHECK_n() callsFrancois-Xavier Le Bail2020-09-061-3/+0
| | | | | | | | | | | 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.
* More bounds checking when fetching addresses and converting to strings.Guy Harris2020-01-191-1/+1
| | | | | | | | | | | | | | 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.
* Use more HTTPS in URLsFrancois-Xavier Le Bail2019-08-191-1/+1
| | | | [skip ci]
* Use the new GET_ macros instead of the EXTRACT_ onesFrancois-Xavier Le Bail2019-03-261-3/+3
| | | | | | | 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.
* Add the nd_print_invalid() functionFrancois-Xavier Le Bail2018-09-111-2/+2
| | | | | | | It prints " (invalid)", used for malformed or corrupted packets. Moreover: Update CONTRIBUTING.
* Print truncations with nd_print_trunc() instead of tstr[] stringsFrancois-Xavier Le Bail2018-05-041-3/+2
| | | | | | | | Remove the tstr[] strings. Update the output of some tests accordingly. Moreover: Add or update some ndo_protocol fields.
* Add the ndo_protocol field in the netdissect_options structureFrancois-Xavier Le Bail2018-03-161-0/+1
| | | | | Update this field in printer entry functions. It will be used for some printings.
* Loopback: Fix the uses of the pointer to the end of current packetFrancois-Xavier Le Bail2018-03-011-2/+2
| | | | Must be based on packet header caplen.
* Always include <config.h> rather than "config.h".Guy Harris2018-01-211-1/+1
| | | | | | | | 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.
* Use quoted include netdissect-stdinc.h instead of angle-bracketed oneFrancois-Xavier Le Bail2018-01-211-1/+1
|
* Update ND_PRINT() as a variadic macroFrancois-Xavier Le Bail2018-01-071-12/+12
|
* Use nd_ types in 802.x and FDDI headers.Guy Harris2017-12-121-3/+2
| | | | | | | | | | | | | | | | | | | 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.
* Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)Francois-Xavier Le Bail2017-12-111-6/+6
| | | | | ND_TTEST2(var, l) -> ND_TTEST_LEN(p, l) ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
* Use more ND_TCHECK_n()/ND_TTEST_n() macrosFrancois-Xavier Le Bail2017-11-241-3/+3
|
* Rename EXTRACT_ macrosFrancois-Xavier Le Bail2017-11-221-3/+3
| | | | | | | | | | | | | | | | 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
* Add a summary comment in all other printersFrancois-Xavier Le Bail2016-08-151-5/+7
| | | | | | | Moreover: Remove some redundant comments Update some summary comments Update the specification URL for ATA over Ethernet (AoE) protocol
* Change istr[] (for invalid string) to be globalFrancois-Xavier Le Bail2016-01-281-1/+0
|
* Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'Francois-Xavier Le Bail2015-09-101-1/+1
| | | | Get the full log via: git log --follow netdissect-stdinc.h
* Rename cstr[] to istr[] like invalid stringFrancois-Xavier Le Bail2015-09-061-3/+3
| | | | | | Moreover: Hamonise the output for error messages Add istr[] in print-babel.c
* Use the word 'invalid' for 'malformed' or 'corrupted' packetsFrancois-Xavier Le Bail2015-09-061-8/+8
| | | | | | An invalid packet could be: 1) built malformed originally by the sender or a fuzz tester, 2) became corrupted in transit.
* Printers must include 'netdissect.h', not 'interface.h'Francois-Xavier Le Bail2015-09-051-1/+1
|
* dismiss NETDISSECT_REWORKED macroDenis Ovsienko2015-03-221-1/+0
| | | | | | | 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.
* Merge remote-tracking branch 'bpf/master'Denis Ovsienko2014-04-061-1/+1
|\
| * Netdissectify the to-name resolution routines.Guy Harris2014-04-041-1/+1
| | | | | | | | | | | | | | | | 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.
* | fix a couple typosDenis Ovsienko2014-04-061-1/+1
|/
* make use of NETDISSECT_REWORKEDDenis Ovsienko2014-03-151-1/+2
| | | | | Update the already converted decoders to define the macro and to include interface.h instead of netdissect.h. Fix incurred compile errors.
* add a decoder for Loopback/CTPDenis Ovsienko2014-01-091-0/+135
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).