aboutsummaryrefslogtreecommitdiffstats
path: root/rawshark.c
AgeCommit message (Collapse)AuthorFilesLines
2019-01-03rawshark: remove redundant cast.Dario Lombardo1-1/+1
Found by clang-tidy. Change-Id: I50912055e0230173af3a6b008fafb12144b02f8d Reviewed-on: https://code.wireshark.org/review/31335 Petri-Dish: Dario Lombardo <lomato@gmail.com> Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-02cli_main: remove real_main from stack traces for non-WindowsPeter Wu1-1/+1
Restore the "main" name since that is used everywhere else except for Windows. On Windows, "main" is renamed via a macro to avoid a conflict with "wmain" and to allow it to be called in cli_main.c. For those wondering, GUI applications (such as Qt) have a different entry point, namely WinMain. In Qt5, src/winmain/qtmain_win.cpp defines WinMain, but seems to convert its arguments from Unicode to CP_ACP (ASCII). It might not support UTF-8, but I did not verify this. Change-Id: I93fa59324eb2ef95a305b08fc5ba34d49cc73bf0 Reviewed-on: https://code.wireshark.org/review/31208 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-01Add a "failed" return for tap packet routines.Guy Harris1-3/+3
This allows taps that can fail to report an error and fail; a failed tap's packet routine won't be called again, so they don't have to keep track of whether they've failed themselves. We make the return value from the packet routine an enum. Don't have a separate type for the per-packet routine for "follow" taps; they're expected to act like tap packet routines, so just use the type for tap packet routines. One tap packet routine returned -1; that's not a valid return value, and wasn't one before this change (the return value was a boolean), so presume the intent was "don't redraw". Another tap routine's early return, without doing any work, returned TRUE; this is presumably an error (no work done, no need to redraw), so presumably it should be "don't redraw". Clean up some white space while we're at it. Change-Id: Ia7d2b717b2cace4b13c2b886e699aa4d79cc82c8 Reviewed-on: https://code.wireshark.org/review/31283 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-01Move some command-line-oriented routines from wsutil to ui.Guy Harris1-2/+2
cmdarg_err() is for reporting errors for command-line programs and command-line errors in GUI programs; it's not something for any of the Wireshark libraries to use. The various routines for parsing numerical command-line arguments are not for general use, they're just for use when parsing arguments. Change-Id: I100bd4a55ab8ee4497f41d9651b0c5670e6c1e7f Reviewed-on: https://code.wireshark.org/review/31281 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-13Move more version-info-related stuff to version_info.c.Guy Harris1-23/+6
Have a ws_init_version_info() routine that, given an application name string: constructs the app-name-and-version-information string, and saves it; adds the initial crash information on platforms that support it, and saves it. Have show_version() use the saved information and take no arguments. Add a show_help_header() routine to print the header for --help command-line options, given a description of the application; it prints the application name and version information, the description, and the "See {wireshark.org URL}" line. Use those routines in various places, including providing the "application name" string in pcapng SHBs. Change-Id: I0042a8fcc91aa919ad5c381a8b8674a007ce66df Reviewed-on: https://code.wireshark.org/review/31029 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-13Put the main() and wmain() routines for CLI programs into a separate file.Guy Harris1-20/+3
That means that code is only in one place, rather than having copies of it in each of those programs. CLI programs that, on Windows, should get UTF-8 arguments rather than arguments in the local code page should: include the top-level cli_main.h header; define the main function as real_main(); be built with the top-level cli_main.c file. On UN*X, cli_main.c has a main() program, and just passes the arguments on to real_main(). On Windows, cli_main.c has a wmain() function that converts the UTF-16 arguments it's handed to UTF-8 arguments, using WideCharToMultiByte() so that it doesn't use any functions other than those provided by the system, and then calls real_main() with the argument count and UTF-8 arguments. Change-Id: I8b11f01dbc5c63fce599d1bef9ad96cd92c3c01e Reviewed-on: https://code.wireshark.org/review/31017 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-01Move condition logic to dumpcap.cGerald Combs1-2/+0
Move the condition logic from capture_stop_conditions.c to dumpcap.c. Remove capture_stop_conditions.[ch] and conditions.[ch]. Switch duration values to doubles. Change-Id: Ifa74fb13ec8fc923b0721597a6cf071d72069ea0 Reviewed-on: https://code.wireshark.org/review/30440 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-08Bring back arg_list_utf_16to8(), but have it just do UTF-16-to-UTF-8 mapping.Guy Harris1-7/+4
Call it from wmain() in the command-line tools, passing it the input argument count and vector, and call it from main() in Wireshark, after getting a UTF-16 argument vector from passing the result of GetCommandLineW() to CommandLineToArgvW(). Change-Id: I0e51703c0a6c92f7892d196e700ab437bd702514 Reviewed-on: https://code.wireshark.org/review/30063 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-07Use wsetargv.obj, and wmain() rather than main(), on Windows.Guy Harris1-3/+22
Doing so for command-line programs means that the argument list doesn't ever get converted to the local code page; converting to the local code page can mangle file names that *can't* be converted to the local code page. Furthermore, code that uses setargv.obj rather than wsetargv.obj has issues in some versions of Windows 10; see bug 15151. That means that converting the argument list to UTF-8 is a bit simpler - we don't need to call GetCommandLineW() or CommandLineToArgvW(), we just loop over the UTF-16LE argument strings in argv[]. While we're at it, note in Wireshark's main() why we discard argv on Windows (Qt does the same "convert-to-the-local-code-page" stuff); that means we *do* need to call GetCommandLineW() and CommandLineToArgvW() in main() (i.e., we duplicate what Qt's WinMain() does, but converting to UTF-8 rather than to the local code page). Change-Id: I35b57c1b658fb3e9b0c685097afe324e9fe98649 Ping-Bug: 15151 Reviewed-on: https://code.wireshark.org/review/30051 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-05*shark: Update help and manpage for name resolvingUli Heilmeier1-1/+1
Add 'v' option for VLAN ID resolving and get rid of deprecated 'C' option. Bug: 14826 Change-Id: I63104f4a465d251048693ad02882ea7eb2c4d926 Reviewed-on: https://code.wireshark.org/review/30029 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-09-20rawshark: avoid RVALS for casting hfinfo->stringsPeter Wu1-2/+2
No functional change, it just makes gcc -Wc++-compat happy. Change-Id: I9001373686ccafd3252089ced8e5b630efbcaca2 Reviewed-on: https://code.wireshark.org/review/29760 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-09-09epan: Add argument to epan_init() to disable pluginsJoão Valverde1-1/+1
Change-Id: I8dc76e6bf8c4d5a3081cbdc1d47b88e857415d29 Reviewed-on: https://code.wireshark.org/review/29498 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-08-29epan: Remove unnecessary all protocols registration callbackJoão Valverde1-3/+1
We are exporting a registration function from libwireshark just to have it passed back as a callback. Seems unnecessary. Change-Id: I7621005c9be11691d319102326824c5e3520a6f3 Reviewed-on: https://code.wireshark.org/review/29328 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-08-24rawshark: Free pipe name and version info stringsVasil Velichkov1-2/+3
The comp_info_str and runtime_info_str are always allocated but were only freed when the -v parameter is specified. ../test/util_dump_dhcp_pcap.py raw | valgrind --tool=memcheck --leak-check=full \ run/rawshark -r - -n -dencap:1 -R "udp.port==68" Change-Id: I6e641ae1dbb428e4dd29c2027f6a4b2305e7bcaa Reviewed-on: https://code.wireshark.org/review/29269 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-07-21Add a tap "finish" callback, called when a listener is removed.Guy Harris1-1/+1
Change-Id: Ic6c23dbd39d1adf8f730f1c866e409f731947475 Reviewed-on: https://code.wireshark.org/review/28786 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-05Don't use dladdr() to get a pathname for the current executable().Guy Harris1-1/+1
Change-Id: I24ad11a659c2cb936f873339dc2b36ac9944280a Reviewed-on: https://code.wireshark.org/review/27359 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-24remove redundant break statementchinarulezzz1-2/+0
Change-Id: Ib6d4bbb1662d921fc4b5920b50e47d2b30ebb95c Reviewed-on: https://code.wireshark.org/review/27103 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-22rawshark(.c): fix parameter 'phdr' not found in the function declaration ↵Alexis La Goutte1-1/+0
[-Wdocumentation] Change-Id: If5c8fbb77acdf75ba273a6b77d7f338381c229f6 Reviewed-on: https://code.wireshark.org/review/25983 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-18We don't do taps in rawshark, so there are no taps to start.Guy Harris1-5/+0
Change-Id: I53c75a91f11bf885e227c133dea8c546e751b274 Reviewed-on: https://code.wireshark.org/review/25888 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-09Generalize wtap_pkthdr into a structure for packet and non-packet records.Guy Harris1-27/+29
Separate the stuff that any record could have from the stuff that only particular record types have; put the latter into a union, and put all that into a wtap_rec structure. Add some record-type checks as necessary. Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2 Reviewed-on: https://code.wireshark.org/review/25696 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
The first is deprecated, as per https://spdx.org/licenses/. Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed Reviewed-on: https://code.wireshark.org/review/25661 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-09wiretap: add a parameter to wtap_init() indicating whether plugins must be ↵Pascal Quantin1-1/+1
loaded g995812c5f1 moved wiretap plugins registration from applications to wiretap library init function. As we do not want to load plugins for all users of libwiretap, let's make it configurable. Bug: 14314 Change-Id: Id8fdcc484e2d0d31d3ab0bd357d3a6678570f700 Reviewed-on: https://code.wireshark.org/review/25194 Reviewed-by: Dario Lombardo <lomato@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-08extcap: remove conditional compilation.Dario Lombardo1-4/+0
Change-Id: Ia54bba388755cf27a343fe6d69d244bf1ab897f9 Reviewed-on: https://code.wireshark.org/review/25186 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-08Have the frame_tvbuff.c routines not use the global cfile.Guy Harris1-1/+3
Have the routines that create them take a pointer to a struct packet_provider_data, store that in the tvbuff data, and use it to get the wtap from which packets are being read. While we're at it, don't include globals.h in any header files, and include it in source files iff the source file actually uses cfile. Add whatever includes that requires. Change-Id: I9f1ee391f951dc427ff62c80f67aa4877a37c229 Reviewed-on: https://code.wireshark.org/review/24733 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-08Hand the packet provider functions to epan_new().Guy Harris1-9/+8
Have separate packet_provider_data structures and packet_provider_funcs structures; the latter holds a table of functions that libwireshark can call for information about packets, the latter holds the data that those functions use. This means we no longer need to expose the structure of an epan_t outside epan/epan.c; get rid of epan/epan-int.h. Change-Id: I381b88993aa19e55720ce02c42ad33738e3f51f4 Reviewed-on: https://code.wireshark.org/review/24732 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-08Move the frame_set stuff back into the capture_file structure.Guy Harris1-20/+19
libwireshark now expects an epan_t to be created with a pointer to a "packet provider" structure; that structure is opaque within libwireshark, and a pointer to it is passed to the callbacks that provide interface names, interface, descriptions, user comments, and packet time stamps, and that set user comments. The code that calls epan_new() is expected to provide those callbacks, and to define the structure, which can be used by the providers. If none of the callbacks need that extra information, the "packet provider" structure can be null. Have a "file" packet provider for all the programs that provide packets from a file. Change-Id: I4b5709a3dd7b098ebd7d2a7d95bcdd7b5903c1a0 Reviewed-on: https://code.wireshark.org/review/24731 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-04Move the parts of a capture_file used by libwireshark to a new structure.Guy Harris1-19/+19
Embed one of those structures in a capture_file, and have a struct epan_session point to that structure rather than to a capture_file. Pass that structure to the routines that fetch data that libwireshark uses when dissecting. That separates the stuff that libwireshark expects from the stuff that it doesn't look at. Change-Id: Ia3cd28efb9622476437a2ce32204597fae720877 Reviewed-on: https://code.wireshark.org/review/24692 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-04Use cfile fields for some frame_data pointers.Guy Harris1-19/+17
Those fields weren't being used in TShark/TFShark/rawshark/sharkd, so we can use them, instead of defining our own static variables. This makes the non-Wireshark code paths a bit more like the Wireshark code paths. Change-Id: I55da4cf525e37598f314efca22f20d3e80cb547c Reviewed-on: https://code.wireshark.org/review/24691 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-03Use cfile.h to define the capture_file type.Guy Harris1-1/+1
Have cfile-int.h declare the structure, and use it in files that directly access the structure. Have cfile.h just incompletely declare the structure and include it rather than explicitly declaring it in source files or other header files. Never directly refer to struct _capture_file except when typedeffing capture_file. Add #includes as necessary, now that cfile.h doesn't drag in a ton of Change-Id: I7931c8039d75ff7c980b0f2a6e221f20e602a556 Reviewed-on: https://code.wireshark.org/review/24686 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-01Get rid of some void pointers.Gerald Combs1-2/+2
Explictly struct _capture_file * in epan_session and its callbacks. Change-Id: I63703015c661a08f3350a7448a7bcdaf98f119dc Reviewed-on: https://code.wireshark.org/review/24675 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-21Move the protocol registration routines back into libwiresharkJoão Valverde1-1/+1
Follow-up to b695b3e2f72998d66ca4b7a6826d4ce1688060c8. Change-Id: I7e36519f2c3806c1205d05437671325080974257 Reviewed-on: https://code.wireshark.org/review/24524 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2017-11-09Start using SPDX license identifiers.Gerald Combs1-13/+1
A while back Graham pointed out the SPDX project (spdx.org), which is working on standardizing license specifications: https://www.wireshark.org/lists/wireshark-dev/201509/msg00119.html Appendix V of the specification describes a short identifier (SPDX-License-Identifier) that you can use in place of boilerplate in your source files: https://spdx.org/spdx-specification-21-web-version#h.twlc0ztnng3b Start the conversion process with our top-level C and C++ files. Change-Id: Iba1d835776714deb6285e2181e8ca17f95221878 Reviewed-on: https://code.wireshark.org/review/24302 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Balint Reczey <balint@balintreczey.hu> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-09-26Rename "ws_version_info.h", also .cJoão Valverde1-1/+1
It's not installed so like most other files it doesn't need or benefit from the prefix. Change-Id: I01517e06f12b3101fee21b68cba3bc6842bbef5c Reviewed-on: https://code.wireshark.org/review/23751 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
2017-09-25Docbook: Automatically generate the tools help output.Gerald Combs1-1/+1
Add a CMake target that dumps the help output for our command line tools to individual files. Include those files in the tools appendix instead of pasting them in manually. Fixup the output of some tools so that they pass the pre-commit checks. Change-Id: I925f24818422a190927a96531c21f4d16d3fe5b5 Reviewed-on: https://code.wireshark.org/review/23737 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2017-06-05Allow bigger snapshot lengths for D-Bus captures.Guy Harris1-4/+3
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except for D-Bus captures. Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for them, because that's the largest possible D-Bus message size. See https://bugs.freedesktop.org/show_bug.cgi?id=100220 for an example of the problems caused by limiting the snapshot length to 256KB for D-Bus. Have a snapshot length of 0 in a capture_file structure mean "there is no snapshot length for the file"; we don't need the has_snap field in that case, a value of 0 mean "no, we don't have a snapshot length". In dumpcap, start out with a pipe buffer size of 2KB, and grow it as necessary. When checking for a too-big packet from a pipe, check against the appropriate maximum - 128MB for DLT_DBUS, 256KB for everything else. Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20 Reviewed-on: https://code.wireshark.org/review/21952 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-26Report syntax errors in UAT prefs parsingPeter Wu1-3/+11
Add the cause for a syntax error while parsing UATs. Example output: $ tshark -ouat:ssl_keys:, tshark: Invalid -o flag "uat:ssl_keys:,": ssl_keys:1: No IP address given. $ tshark -ouat:unknown:, tshark: Invalid -o flag "uat:unknown:,": Unknown preference Change-Id: I549406c4e31a81d29f487ef47bdb3c22da084947 Reviewed-on: https://code.wireshark.org/review/21748 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jakub Zawadzki <darkjames-ws@darkjames.pl> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-04-20Add common routines for command-line libwiretap error reporting.Guy Harris1-33/+2
These are similar to the routines added to ui/alert_box.c for dialog-box libwiretap error reporting. This centralizes the knowledge about what to say for various libwiretap errors, removing some duplicate code, and giving more details in some programs. Change-Id: I737405c4edaa0e6c27840f78a8c587a8b3ee120b Reviewed-on: https://code.wireshark.org/review/21234 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-15Squelch some compiler warnings.Guy Harris1-3/+3
Cast an ssize_t value to unsigned int before subtracting it from an unsigned int. The value is already known to be >= 0 and <= the value from which we're subtracting it, and that latter value is an unsigned int, so it's guaranteed to fit into an unsigned int. (ssize_t can be bigger than unsigned int.) Change-Id: I5c4d3c7fa4bf241c9ea72661beca89bc30495a3b Reviewed-on: https://code.wireshark.org/review/21114 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-14Remove some unused code.Guy Harris1-11/+3
It's copied-and-pasted from {somethingelse}shark.c, such as tshark.c; it's not needed here. Fixes CID 1405103. Clean up indentation while we're at it. Change-Id: Ia3ab41f64f055fcebeac6e49ebf5f5581125b960 Reviewed-on: https://code.wireshark.org/review/21082 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-12Rename routines to clarify what they do.Guy Harris1-1/+1
XXX_prime_with_YYY makes it a bit clearer than does XXX_prime_YYY that we're not priming YYY, we're priming XXX *using* YYY. Change-Id: I1686b8b5469bc0f0bd6db8551fb6301776a1b133 Reviewed-on: https://code.wireshark.org/review/21031 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-09Pull all the "load settings" calls into a epan_load_settings() routine.Guy Harris1-7/+2
That way, nothing using libwireshark needs to know what settings need to be loaded, they just call epan_load_settings(). Change-Id: I9390e259e286fc4f5acaeaac2767e4c3c4b656af Reviewed-on: https://code.wireshark.org/review/20983 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-09Pull the error-reporting code for preference files into read_prefs().Guy Harris1-27/+1
No need to duplicate it in N different programs. Update comments while we're at it. Change-Id: I3096cbe5448a19363eff6303bdd54e522dae9336 Reviewed-on: https://code.wireshark.org/review/20973 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-09Pull the code to save enabled/disabled lists into libwireshark.Guy Harris1-1/+1
It's identical in the GTK+ and Qt UIs, and it should just be done in libwireshark. Rename some routines to just speak of enabled_and_disabled_lists, so we don't have to say enabled_and_disabled_protos_and_heuristic_dissectors or something such as that. Clean up indentation. Change-Id: Ief2e612d9e1b60d8d0123b6bd3409dce5faf6495 Reviewed-on: https://code.wireshark.org/review/20970 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-08Clean up handling of enabled/disabled protocols/heuristic dissectors.Guy Harris1-56/+28
Add a "report a warning message" routine to the "report_err" code in libwsutil, and rename files and routines appropriately, as they don't only handle errors any more. Have a routine read_enabled_and_disabled_protos() that reads all the files that enable or disable protocols or heuristic dissectors, enables and disables them based on the contents of those files, and reports errors itself (as warnings) using the new "report a warning message" routine. Fix that error reporting to report separately on the disabled protocols, enabled protocols, and heuristic dissectors files. Have a routine to set up the enabled and disabled protocols and heuristic dissectors from the command-line arguments, so it's done the same way in all programs. If we try to enable or disable an unknown heuristic dissector via a command-line argument, report an error. Update a bunch of comments. Update the name of disabled_protos_cleanup(), as it cleans up information for disabled *and* enabled protocols and for heuristic dissectors. Support the command-line flags to enable and disable protocols and heuristic dissectors in tfshark. Change-Id: I9b8bd29947cccdf6dc34a0540b5509ef941391df Reviewed-on: https://code.wireshark.org/review/20966 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-28rawshark: Move large data (WTAP_MAX_PACKET_SIZE) to the heap.Michael Mann1-2/+3
Change-Id: Ib525d35b6a0fa58602d30fda701b0cce5f05b322 Reviewed-on: https://code.wireshark.org/review/20756 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-27Check for return value of WSAStartup on all executables.Michael Mann1-1/+7
Windows vscodeanalysis complains even though the event is probably very unlikely. Change-Id: Iafe158eea5586908209d6bfe1e45540117558673 Reviewed-on: https://code.wireshark.org/review/20727 Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-17Rawshark: Try to avoid a VC runtime crash.Gerald Combs1-5/+22
The MSDN documentation for _read says "If fd is invalid, the file is not open for reading, or the file is locked, the invalid parameter handler is invoked, as described in Parameter Validation." This means that on Windows, if our parent has closed stdin when we call _read we'll crash. Add a check to bail out early if that's happened. Fix a sign cast while we're here. Change-Id: I8afb75f6e56c6a6c2b62103ba7e2fb635dc85702 Reviewed-on: https://code.wireshark.org/review/20153 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2017-02-14rawshark: add initializer.Dario Lombardo1-1/+1
Change-Id: I696b1cfd7cf226d07918cca708a3463db3114333 Reviewed-on: https://code.wireshark.org/review/20100 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-14wiretap: add cleanup routine.Dario Lombardo1-39/+51
The cleanup routine has been added to exit section of the applications. Those which required a exit restyle have been patched as well. Change-Id: I3a8787f0718ac7fef00dc58176869c7510fda7b1 Reviewed-on: https://code.wireshark.org/review/19949 Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-09Make the capture file's interface description filterableJim Young1-0/+1
This patch introduces the frame.interface_description field. While testing this new functionality it became obvious that we have a non-optimal interaction between the existing cfile.c's cap_file_get_interface_name(), the recently added frame.interface_name field and this new frame.interface_description field. The string returned from cap_file_get_interface_name() may in fact come from one of three different sources: the idb's interface name (if it exists) or the idb's interface description (if that exists) or a default text of "unknown". The string ultimately becomes the rame.interface_name whether or not the idb had an interface name option to begin with. This behavior does not allow one to test for the simple presence of frame.interface_name. The new peer function cap_file_get_interface_description() added by this patch returns NULL instead of "unknown" if the idb does not have an interface description. Should cap_file_get_interface_name() be similarly modified to return NULL if the idb does not have an interface name? Bug: 9781 Change-Id: Ie479f373c5080c004dd22bd88919838feca71e95 Reviewed-on: https://code.wireshark.org/review/19861 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>