summaryrefslogtreecommitdiff
path: root/tcpdump.c
Commit message (Collapse)AuthorAgeFilesLines
* Make version and usage printing more consistent. [skip ci]Denis Ovsienko2020-09-101-26/+26
| | | | | | When there is an error, print to stderr and exit with a non-0 status. Otherwise print to stdout and exit with a status 0. See also tcpslice commit 5015245.
* Report periodic stats only when safe to do so. [skip ci]tcpdump-4.10.0-bpDenis Ovsienko2020-08-291-1/+4
| | | | | | | | | | | | | | | | As explained in GH #155, when tcpdump is given -r, -w and -v and it takes long enough to read from the input file (because it is stdin connected through network or a pipe to stdout of another tcpdump doing a live capture), pcap_loop() will error before long. One of the ways to reproduce the fault is as follows: $ tcpdump -i eno1 -w - | tcpdump -r - -w /tmp/tmp.pcap -v tcpdump: listening on eno1, link-type EN10MB (Ethernet), snapshot length 262144 bytes reading from file -, link-type EN10MB (Ethernet), snapshot length 262144 tcpdump: pcap_loop: error reading dump file: Interrupted system call Skip the verbose_stats_dump() timer setup in this specific corner case for the time being and document it.
* Apply the last step of the new way to update the link-layer header lengthFrancois-Xavier Le Bail2020-08-061-3/+3
| | | | | | | | | | | All the link-layer dissectors are now void functions. All the functions were moved to the void_printers[] array. Rename this array to printers[]. Remove the uint_printers[] array, now empty. Remove the 'ndo_void_printer' flag field, now useless, from netdissect_options. Remove other transitional code.
* Use \ rather than / as a pathname separator in Windows.Guy Harris2020-06-111-1/+11
|
* Set default linktype LINUX_SLL2 when capturing on the "any" deviceFrancois-Xavier Le Bail2020-05-081-1/+10
|
* Update the message about the verbose optionFrancois-Xavier Le Bail2020-04-241-1/+1
| | | | | | The -v (verbose) option can be repeated more than two times. [skip ci]
* Show MemorySanitizer presence in version outputFrancois-Xavier Le Bail2020-04-221-1/+3
| | | | | | | | | This may help to understand some bug reports. Moreover: s/CLang/Clang/ [skip ci]
* Update to avoid duplicate words detectionFrancois-Xavier Le Bail2020-03-301-1/+1
| | | | [skip ci]
* Add "domain" as an option for -TFrancois-Xavier Le Bail2020-03-021-0/+2
| | | | | | 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.
* Don't show in the usage the removed in 2003 -a optionFrancois-Xavier Le Bail2020-02-271-1/+1
|
* Print an optional packet count on stderr instead of printing packetsFrancois-Xavier Le Bail2020-02-261-2/+14
| | | | | | | | | | This change add an option to print only on stderr the packet count when reading capture file(s) instead of parsing/printing the packets. If a filter is specified on the command line, tcpdump counts only packets that were matched by the filter expression. The option name is '--count'.
* Autosar SOME/IP protocol supportFrancesco Fondelli2020-02-191-0/+2
|
* Push the floating-point test into a separate file.Guy Harris2020-02-041-8/+3
| | | | | | Hopefully, that will make sure we don't optimize away anything that will, for example, cause us not to do things differently on 32-bit x86 using the x87 instructions.
* Do the floating-point tests closer to what we need.Guy Harris2020-02-041-11/+7
| | | | | | | | | It's All Very Complicated, so mirror what print-lmp.c does - just do a calculation based on a particular input value and print the result using the same format print-lmp.c does, and have tests/TESTrun see what that result is. Just do that inside tcpdump.c, so we don't need the fptype stuff.
* Do some tests based on the type of floating-point arithmetic tcpdump does.Guy Harris2020-02-041-0/+24
| | | | | | | | | Add a --fp-type flag to tcpdump, which causes it to do a floating-point operation and, based on the result of the operation, prints out "FPTYPE{n}", where {n} is a number indicating the result. Have tests/TESTrun run "./tcpdump --fp-type" and set a HAVE_ key based on that. Run some tests only for FPTYPE1.
* Use a short timeout, rather than immediate mode, for text output.Guy Harris2020-01-191-13/+15
| | | | | | | | That means that we do some buffering of packets. It also means we don't depend on the immediate-mode APIs being available. While we're at it, use the short timeout if we're doing text output in "line-buffered mode" as well as if we're doing it to a terminal.
* Move some code to better show how to handle pcap_activate() failure.Guy Harris2019-11-231-2/+2
| | | | | | | | | | | | | | If you call pcap_activate() and it fails, you still have a pcap_t from pcap_create(), and should close it. Moving the code after the error() calls doesn't make a difference, as error() exits, but it may make it clearer to those reading tcpdump.c for help in figuring out how to use libpcap that you should close the pcap_t if pcap_activate() fails. (In the future, there may also be the option of changing some options and trying again, e.g. changing the user name or password for a remote capture.)
* The ptp (precision time protocol) with UDP as the transport protocol.Partha Ghosh2019-11-221-0/+2
| | | | | | | | | - the print routines for ptp different ptp messages - test completed for sync message, announce message, delay request message, delay response message and follow up message. - integration of the ptp v2 code with the tcpdump code. Signed-off-by: Partha S. Ghosh <psglinux@gmail.com>
* Do not open an interface if not needed for -dBill Fenner2019-11-131-0/+23
|
* libdnet has bugs, do not use it.Denis Ovsienko2019-11-031-3/+0
| | | | | | | | | | | | | | | | | | The only function tcpdump used in libdnet was dnet_htoa(), which tries to translate a binary DECnet address to a nodename through a lookup in /etc/decnet.conf. The translation is slow and has a bug, so stop using the function and remove the dependency on libdnet. This makes tcpdump always print DECnet addresses in numeric format, if anybody needs the translation back they are welcome to fix libdnet or (more realistically) add an implementation of dnet_htoa() to the tcpdump source code and use it. (This is a forward-port of commit 9a6eb27 from tcpdump-4.9 to master. Sadly, together with libdnet this change removes the fine work that Guy had done in the master branch in commits ebf3f19 and 4ef8d63 to put libdnet usage right whilst my original "do not use libdnet" commit was aging in the pipeline.)
* Fix -V to fail invalid input safelyDenis Ovsienko2019-10-271-2/+4
| | | | | | | | | | | | | | This change fixes CVE-2018-14879. get_next_file() did not check the return value of strlen() and underflowed an array index if the line read by fgets() from the file started with \0. This caused an out-of-bounds read and could cause a write. Add the missing check. This vulnerability was discovered by Brian Carpenter & Geeknik Labs. Cherry picked from 9ba91381954ad325ea4fd26b9c65a8bd9a2a85b6 in 4.9 branch.
* Use MAXIMUM_SNAPLEN macroFrancois-Xavier Le Bail2019-10-081-1/+1
|
* Remove more old-compiler compensation.Guy Harris2019-08-081-3/+3
| | | | | | | | | | | | We require an environment with a C99-compatible snprintf(), so we don't need to work around older implementations. Make the configuration process fail if we don't have snprintf() and vsnprintf(). We require at least VS 2015, so we don't have to check for _MSC_VER >= 1400. Make the build fail if we don't have at least VS 2015. We apparently do, however, have to use __inline, as the VS 2015 documentation doesn't meaning plain old "inline". Update a comment.
* Fix a warningFrancois-Xavier Le Bail2019-08-041-1/+1
| | | | | | | ./tcpdump.c:1951:13: warning: assigning to 'char *' from 'const char [7]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] username = WITH_USER; ^ ~~~~~~~~~
* Fix a warningFrancois-Xavier Le Bail2019-08-041-0/+2
| | | | | | | | No chroot on Windows. The warning was: C:\projects\tcpdump\tcpdump.c(1450): warning C4189: 'chroot_dir': local variable is initialized but not referenced
* Fix a warningFrancois-Xavier Le Bail2019-07-231-1/+1
| | | | | | | ./tcpdump.c:1940:15: warning: assigning to 'char *' from 'const char [5]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] chroot_dir = WITH_CHROOT; ^ ~~~~~~~~~~~
* Fix a warningFrancois-Xavier Le Bail2019-07-211-1/+1
| | | | | | | ./tcpdump.c:1731:23: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] ndo->ndo_snaplen = strtol(optarg, &end, 0); ~ ^~~~~~~~~~~~~~~~~~~~~~~
* Fix a warningFrancois-Xavier Le Bail2019-07-211-2/+3
| | | | | | | | The warning was: ./tcpdump.c:1059:7: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32] cc = read(fd, cp, (u_int)buf.st_size); ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Merge pull request #743 from taghos/masterGuy Harris2019-04-031-9/+19
|\ | | | | Add shortcuts for setting time stamp precision
| * Add shortcuts for setting time stamp precisionRicardo Nabinger Sanchez2019-04-031-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | Add two shortcuts (as long-options) for setting the time stamp precision: --micro and --nano. While adding these options, reshuffle the usage message to group up the options related to time stamp, and removing the macro TIME_STAMP_PRECISION_USAGE. If setting the time stamp precision is not supported by the available libpcap, the usage won't mention these options (including --time-stamp-precision), but they will still be presented in the manpage.
* | Explain why we're defining HAVE_REMOTE before including pcap.h.Guy Harris2019-04-031-0/+13
|/
* Squelch a clang warningFrancois-Xavier Le Bail2019-03-191-0/+1
| | | | | | The warning was: ./tcpdump.c:182:5: warning: no previous extern declaration for non-static variable 'dflag' [-Wmissing-variable-declarations]
* Handle rpcaps:// URLs as well, for rpcap-over-TLS.Guy Harris2019-01-061-2/+4
|
* Fix typo.Guy Harris2018-11-091-1/+1
|
* Include correct capsicum headerRenato Botelho2018-11-061-1/+1
| | | | | Current included header `sys/capability.h` is deprecated. All supported FreeBSD versions have now the proper header `sys/capsicum.h`
* Add an usage message for the -m optionFrancois-Xavier Le Bail2018-10-291-1/+9
| | | | | Moreover: Fix a space.
* return-checks: Added a return check for malloc and for strsepagnosticdev2018-10-081-0/+3
|
* Harmonize a messageFrancois-Xavier Le Bail2018-10-051-5/+5
| | | | | | s/capture size/snapshot length/ It's a follow-up to 8a54b2483b.
* Add the snapshot length to the "reading from file ..." messageFrancois-Xavier Le Bail2018-10-041-12/+11
|
* Use signed formats for signed valuesFrancois-Xavier Le Bail2018-10-041-2/+2
|
* Fix data types.Guy Harris2018-09-151-1/+1
| | | | | | If you're accumulating the lengths of strings, as returned by strlen(), and passing the result to malloc(), it should be accumulated in a size_t.
* Move getopt_long.h to missing.Guy Harris2018-09-141-1/+1
| | | | That's what we did for win_ether_ntohost.h.
* Make the invalid snaplen message clearerFrancois-Xavier Le Bail2018-09-101-1/+2
|
* Fix local time printingFrancois-Xavier Le Bail2018-08-071-9/+4
| | | | | | | | | | | | Using seconds offset from GMT to local time to compute local time give errors when printing times outside the same daylight saving time period. Use the localtime() function for default and -tttt cases. Use the gmtime() function for -ttt and -ttttt cases. Rename ts_hmsfrac_print() to ts_date_hmsfrac_print(). Remove some variables now useless. Update some comments.
* Clean up indentation.Guy Harris2018-07-311-8/+7
|
* Add check for pcap timestamp warnings. (GH #693)Greg Steinbrecher2018-07-311-0/+4
| | | | | Previously would silently accept any of "host", "adapter", or "adapter_unsynced" regardless of whether the interface supported the option.
* Surround some declarations/definitions with #ifdefs.Guy Harris2018-07-291-1/+7
| | | | | | | | Some variables are used only if certain pcap APIs are available; don't define them if the APIs aren't available. We don't define show_tstamp_types_and_exit() unless we have pcap_set_tstamp_type(); don't declare it if we don't define it.
* Display interface and index and name on DLT_LINUX_SLL2Petr Vorel2018-07-191-0/+4
| | | | | | | | | | | | | | | | | Index is displayed always, name only if available. Warn about possible wrong interfaces when in reading mode (pcap file can be displayed on a different host then where was captured) [1]. See: GH the-tcpdump-group/libpcap#127 [1] https://lists.sandelman.ca/pipermail/tcpdump-workers/2018-July/001019.html Signed-off-by: Petr Vorel <pvorel@suse.cz> Suggested-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Denis Ovsienko <denis@ovsienko.info> Reviewed-by: Guy Harris <guy@alum.mit.edu>
* Exit if capng_change_id() fails to change the uidFrancois-Xavier Le Bail2018-07-141-4/+3
| | | | | | | From Linux manual page of capng_change_id(): Note: the only safe action to do upon failure of this function is to probably exit. This is because you are likely in a situation with par- tial permissions and not what you intended.
* Use more the error() functionFrancois-Xavier Le Bail2018-07-141-21/+10
|