summaryrefslogtreecommitdiff
path: root/print-tcp.c
Commit message (Collapse)AuthorAgeFilesLines
* TCP: Fix an invalid checkFrancois-Xavier Le Bail2022-03-021-1/+1
| | | | | | | | Fix this cppcheck warning: print-tcp.c:711:20: warning: Checking if unsigned expression 'length' is less than zero. [unsignedLessThanZero] if (length <= 0) ^
* WHOIS: Add its own printer source file and printer functionFrancois-Xavier Le Bail2022-01-141-2/+1
| | | | | | Like all other text protocols. This is a follow-up to 185b7ce04b182d2d7e490f23a3f0c7b9ea5916e4.
* Suppress "casting away const" warnings in missing/getopt_long.c.Guy Harris2021-07-241-2/+4
| | | | | | | | | | | | | | | | | It's explicitly cheating in some places; just cast away the warnings. Add a Clang version testing macro to compiler-tests.h. Move the diagnostic control #defines from netdissect-stdinc.h to diag-control.h, libpcap-style, so that they can be used by code that doesn't use (or need) netdissect-stdinc.h. This also means that we can limit the inclusion of diag-control.h, and the definition of those Do them more libpcap-style, with separate DIAG_OFF/DIAG_ON pairs for particular issues, rather than having DIAG_OFF() and DIAG_ON() macros that take -W option names as arguments; that way, if we need to define them for compilers that don't have the GCC/Clang syntax for those pragmas, e.g. MSVC, we can do so.
* TCP: Add a commentFrancois-Xavier Le Bail2021-02-161-0/+7
| | | | | | This is a follow-up to commit 568d18f6eafb8df0d2500652b1cad49618051349. [skip ci]
* TCP: Add a bounds check before decoding the payloadFrancois-Xavier Le Bail2021-02-121-2/+13
| | | | | | | | At least the header data is required. Moreover: Update the output of a test accordingly. Fix indentation.
* TCP: Update the snapend before decoding a MPTCP optionFrancois-Xavier Le Bail2021-02-121-1/+11
| | | | | | | Update the snapend to the end of the option before calling mptcp_print(). Some options (MPTCP or others) may be present after a MPTCP option. This prevents that, in mptcp_print(), the remaining length < the remaining caplen.
* TCP: Modernize packet parsing style.Denis Ovsienko2021-01-171-28/+24
| | | | | | | | | | Enable ND_LONGJMP_FROM_TCHECK. Report invalid packets as invalid. Remove most ND_TCHECK*() instances as they were redundant. Update a custom snapend guard to use nd_trunc_longjmp(). Reduce arity of print_tcp_fastopen_option(). Use ND_TTEST_LEN() in tcp_verify_signature() and nd_printn() in print_tcp_rst_data(). For NFS_PORT remove ND_TTEST_4() from the test condition as it is not a valid factor, there is the subsequent GET_BE_U_4() to check bounds.
* NetFlow: Use tcp_flag_values[] for TCP flags.Denis Ovsienko2021-01-171-1/+1
| | | | This way there is less code duplication and more consistency.
* Use __func__ from C99 in error messages. [skip ci]Denis Ovsienko2020-10-081-2/+2
| | | | | This automatically fixes a few error messages that would tell an incorrect function name.
* TCP: Use GET_IPADDR_STRING()/GET_IP6ADDR_STRING() callsFrancois-Xavier Le Bail2020-09-231-8/+8
| | | | | | Replace the calls to ipaddr_string()/ip6addr_string() with calls to GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds checking.
* Remove many (762) now redundant ND_TCHECK_n() callsFrancois-Xavier Le Bail2020-09-061-2/+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.
* TCP: Remove an useless testFrancois-Xavier Le Bail2020-07-051-1/+1
| | | | The length is tested in ldp_print().
* DNS: Do the 'over TCP' processing in the printerFrancois-Xavier Le Bail2020-06-101-15/+5
| | | | | | | | Add the parameter 'over_tcp'. Move the shift by 2 bytes from the TCP printer to the DNS printer. Move adding a prepended space from the TCP printer to the DNS printer. Add a length check. Add some comments about 'over_tcp' and 'is_mdns' call values.
* TCP: Update styleFrancois-Xavier Le Bail2020-06-091-6/+4
| | | | [skip ci]
* Add "domain" as an option for -TFrancois-Xavier Le Bail2020-03-021-0/+4
| | | | | | This allows tcpdump to handle DNS running on non-standard ports. Add two test files with DNS over TCP and DNS over UDP, port 8053.
* More use of %zu to print sizeof values.Guy Harris2019-08-111-2/+2
|
* Use nd_ipv6 rather than struct in6_addrFrancois-Xavier Le Bail2019-06-101-2/+2
|
* Use nd_ipv4 rather than struct in_addrFrancois-Xavier Le Bail2019-06-101-2/+2
|
* Add dissector for SSH version exchangeAndreas Jaggi2019-05-081-0/+2
|
* Remove the IPv6 payload length checks for checksumming.Guy Harris2019-05-011-1/+1
| | | | | | If there isn't an IPv6 payload, there isn't any TCP or UDP packet, and there's no TCP or UDP header to checksum, so there's no need for the check (it's not there for IPv4).
* TCP: Fix fetching the header payload lengthFrancois-Xavier Le Bail2019-04-301-1/+1
| | | | | | | | | | | ... and a Clang warning. The warning was: ./print-tcp.c:402:120: warning: address of array 'ip6->ip6_ctlun.ip6_un1.ip6_un1_plen' will always evaluate to 'true' [-Wpointer-bool-conversion] ...& 0xf0) >> 4) == 6 && ip6->ip6_ctlun.ip6_un1.ip6_un1_plen) { ~~ ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
* Use the new GET_ macros instead of the EXTRACT_ onesFrancois-Xavier Le Bail2019-03-261-37/+41
| | | | | | | 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.
* Use the ndo->ndo_protocol field instead of the protoname parameterFrancois-Xavier Le Bail2019-03-081-2/+3
| | | | | | | Moreover: Fix a truncated string: "[!" is not the prefix for a truncated string. Add two comments. Clean up a whitespace.
* Fix a typoFrancois-Xavier Le Bail2019-03-071-1/+1
|
* TCP: Fix an undefined behavior at runtimeFrancois-Xavier Le Bail2019-03-061-1/+2
| | | | | | The error was: print-tcp.c:831:22: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'u_int' (aka 'unsigned int')
* Squelch a narrowing warning.Guy Harris2018-12-111-1/+1
| | | | | Use a u_char variable for characters in the RST string; no need for it to be an int.
* Have all Internet-checksum computing routines return a uint16_t.Guy Harris2018-12-111-2/+2
| | | | | Those checksums are 16-bit; change the return types of those routines appropriately.
* Use more nd_print_invalid()Francois-Xavier Le Bail2018-11-021-3/+3
|
* Clean up whitespacesFrancois-Xavier Le Bail2018-10-271-43/+43
|
* Fix spacesFrancois-Xavier Le Bail2018-09-031-1/+1
|
* Add a missing space for DNS over TCP (GH #688)Denis Ovsienko2018-07-061-0/+6
| | | | [skip ci]
* Cast dport and sport to u_int before shifting them.Guy Harris2018-05-241-4/+4
| | | | | | | | The result of the expression is ultimately going to be put into a u_int; cast them to u_int so that we'll be shifting unsigned values left rather than int values, to avoid undefined behavior. This should fix GitHub issue #681.
* TCP: Fix a closing stringFrancois-Xavier Le Bail2018-05-181-1/+1
| | | | | | It was ">", it must be "]" Update the output of some tests accordingly.
* Add more nd_print_trunc() callsFrancois-Xavier Le Bail2018-05-181-3/+4
| | | | Update the output of some tests accordingly.
* TCP: Add a missing 'truncated' messageFrancois-Xavier Le Bail2018-05-181-1/+1
|
* Remove the safeputchar() functionFrancois-Xavier Le Bail2018-05-021-1/+1
| | | | | | Print the characters filtering out non-printable with fn_print_char(). Update the output of some tests accordingly.
* Remove useless commentsFrancois-Xavier Le Bail2018-03-191-7/+0
|
* 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.
* Add a status exit code to the function ndo_error()Francois-Xavier Le Bail2018-02-251-2/+4
| | | | | | | The status are defined in an enum in status-exit-codes.h. Moreover: Use ndo_error() instead of ndo_warning() for malloc() errors in print-esp.c.
* Add comments on some memory allocations we cannot freeFrancois-Xavier Le Bail2018-02-231-0/+4
|
* Style updateFrancois-Xavier Le Bail2018-02-061-10/+10
| | | | Use parens around the sizeof argument, to match the style used elsewhere.
* Remove unneeded '&' when getting a pointer to a nd_ipv6 typeFrancois-Xavier Le Bail2018-01-311-2/+2
|
* Remove unneeded '&' when getting a pointer to a nd_ipv4 typeFrancois-Xavier Le Bail2018-01-311-5/+9
|
* Have ip{6}addr_string take a u_char * as the second argument.Guy Harris2018-01-311-7/+13
| | | | Fix warnings that introduces.
* 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
|
* Clean up signed vs. unsigned.Guy Harris2018-01-111-8/+8
|
* TCP: Use more ND_TTEST_n() macrosFrancois-Xavier Le Bail2018-01-081-2/+2
|
* Remove unneeded '&' when getting a pointer to an nd_uintN_t typeFrancois-Xavier Le Bail2018-01-081-3/+5
|
* Update ND_PRINT() as a variadic macroFrancois-Xavier Le Bail2018-01-071-87/+87
|