aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
AgeCommit message (Collapse)AuthorFilesLines
2020-04-06CMake: remove ENABLE_PCAP_NG_DEFAULT optionPeter Wu1-8/+0
pcapng has been the compile-time default since 2011. If there are any users who would like to use the libpcap format, then they should use runtime options instead (e.g. `tshark -P` or `editcap -F pcap`). Change-Id: I54b70368cdc3ca78bc8617bc488cc687740a1eb9 Reviewed-on: https://code.wireshark.org/review/36721 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-02-24editcap: Remove an arbitrary time boundary.Gerald Combs1-17/+10
As pointed out by @debookee in https://twitter.com/debookee/status/1229711779648933888 if you pass a start time (-A) and no stop time (-B) to editcap, it will set the stop time to December 31, 2035. Adjust our logic to work without a stop time instead. Change-Id: Ic724ce8ee6d8c346be1d4caf2899d3e10e68fa94 Reviewed-on: https://code.wireshark.org/review/36138 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>
2019-12-15Reorganize long option valuesJaap Keuter1-5/+7
For long options, without corresponding short options, to be processed they need to be assigned a value, preferably outside of the range of all possible short options. The code in various places tries to stay clear of these low values, but further coordination is missing, easily leading to issues when option processing code gets extended and/or reorganized. This change introduces a single location from where each catagory of command line long option can derive a base value, which should minimize potential option value collisions. Change-Id: Ic8861a347d0050f74002de3aa1fcfb01202866e5 Reviewed-on: https://code.wireshark.org/review/35459 Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl> Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-07-26HTTPS (almost) everywhere.Guy Harris1-1/+1
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-16Editcap: Allow floating point split intervals.Gerald Combs1-15/+26
Update the `-i` option to allow floating point values as suggested at https://stackoverflow.com/questions/57004719/split-wireshark-to-miliseconds Change-Id: I24028d409bc441ed3b45ac2179f7c42b2bc424bc Reviewed-on: https://code.wireshark.org/review/33938 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>
2019-06-26With -T, change the packet's encapsulation type as well.Guy Harris1-1/+12
Bug: 15873 Change-Id: I8d36b0fba42481b5e27e9ad9643d3603486c3645 Reviewed-on: https://code.wireshark.org/review/33745 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-06-17Add support for embedding WireGuard keys in a pcapng filePeter Wu1-1/+2
pcapng spec update is here: https://github.com/pcapng/pcapng/pull/62 Bug: 15571 Change-Id: I2f1921b1da70ac0bab8c38dd5138a9dfe7843fea Reviewed-on: https://code.wireshark.org/review/33300 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-11Small cleanups.Guy Harris1-5/+5
Rename a variable to reflect the final name given to the option to get rid of decryption secrets stored in the file. Fix whitespace. Change-Id: I19ea14fa205369500790adaa00244a15412548eb Reviewed-on: https://code.wireshark.org/review/33154 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-061514 is a better initial Buffer size than 1500.Guy Harris1-1/+1
Ethernet packets without the CRC are 1514 bytes long, not 1500 bytes long; using 1514 bytes will avoid a reallocation for a full-sized Ethernet packet. Change-Id: Ie8da3f13bf3df07e23e4478b7dcf84f06dec6a9d Reviewed-on: https://code.wireshark.org/review/32761 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-05Have wtap_read() fill in a wtap_rec and Buffer.Guy Harris1-4/+10
That makes it - and the routines that implement it - work more like the seek-read routine. Change-Id: I0cace2d0e4c9ebfc21ac98fd1af1ec70f60a240d Reviewed-on: https://code.wireshark.org/review/32727 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-19Add --discard-all-secrets to remove decryption secrets.Guy Harris1-0/+28
Bug: 15435 Change-Id: I78503c9c31ab3eda39908b91dca3ef3fb9af34bf Reviewed-on: https://code.wireshark.org/review/32100 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-19Use #defines for long-option codes.Guy Harris1-8/+12
Change-Id: Ife800efd4d2621b295a1c07ae182758a3b6f276c Reviewed-on: https://code.wireshark.org/review/32095 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-19Clean up indentation.Guy Harris1-17/+17
Change-Id: I28280eddda1c318ba82ec8f0372e38093abbaa14 Reviewed-on: https://code.wireshark.org/review/32091 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-05editcap: warn when --inject-secrets is given a RSA private keyPeter Wu1-0/+21
While the documentation of "editcap --inject-secrets" mentions support for key log files only, people might misinterpret that and assume support for RSA private keys. This is explicitly not supported due to the sensitivity of these files. In order to be helpful, print a warning. Change-Id: Ia7b464c17f1dfb550729dd35775290ed28e14510 Reviewed-on: https://code.wireshark.org/review/31893 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-25wiretap: fix memleaks with wtap_rec::opt_commentPeter Wu1-1/+2
The memory ownership of wtap_rec::opt_comment was not clear. Users of wtap were leaking memory (editcap.c). wtap readers were not sure about freeing old comments (erf) or simply ignored memleaks (pcapng). To fix this, ensure opt_comment is owned by wtap_rec and free it with wtap_rec_cleanup. The erf issue was already addressed since cf_get_packet_comment properly duplicates wth.opt_comment memory. - wtap file formats (readers): - Should allocate memory for new comments. - Should free a comment from an earlier read before writing a new one. - Users of wth: - Can only assume that opt_comment remains valid until the next read. - Can assume that wtap_dump does not modify the comment. - For random access (wtap_seek_read): should call wtap_rec_cleanup to free the comment. The test_tshark_z_expert_comment and test_text2pcap_sip_pcapng tests now pass when built with ASAN. This change was created by carefully looking at all users opt "opt_comment" and cf_get_packet_comment. Thanks to Vasil Velichkov for an initial patch which helped validating this version. Bug: 7515 Change-Id: If3152d1391e7e0d9860f04f3bc2ec41a1f6cc54b Reviewed-on: https://code.wireshark.org/review/31713 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-22Fix error checking for --inject-secrets argument.Guy Harris1-5/+9
If there was no secrets type specified, say so. Otherwise, if the secrets type wasn't valid, report the correct string as the invalid secrets type. Change-Id: I3cd7d419ce3577fc176a256069456c5b49e81608 Reviewed-on: https://code.wireshark.org/review/31667 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-22editcap: document --inject-secrets in --helpPeter Wu1-0/+2
Change-Id: Icc027f3c53e1da580c2e49042134b1075ad65cf2 Reviewed-on: https://code.wireshark.org/review/31666 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-09Clarify the name and description for a link-layer encapsulation type.Guy Harris1-5/+5
What we were calling the "name" is actually a description to show to users; what were calling the "short name" is just the name to use on the command line. Rename some routines and structure members, and put the name first and description second in the table. Expand some descriptions to give more details (e.g., to be more than just a capitalized version of the name). Fix the CamelCase capitalization of InfiniBand. Change-Id: I060b8bd86573880efd0fab044401b449469563eb Reviewed-on: https://code.wireshark.org/review/31472 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-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-32/+5
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-19/+2
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-12-12Add the VCS version number to the appname option if it's a Git build.Guy Harris1-4/+8
Change-Id: I193db5d5c7bd3668d096c72dc231ea43fa4894ec Reviewed-on: https://code.wireshark.org/review/31013 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-07PCAP/PCAPNG: Be consistent in documentation, etcJaap Keuter1-2/+6
1) The default build configuration is to select PCAPNG as output format, but it can be selected as PCAP. Some of the command line tools have the option to select the output format and default towards the build configuration. This has to be reflected in their help output also. 2) Various documentation files are still stating that PCAP is the default format of various tools. With the default build configuration being PCAPNG these have to be adjusted as well. (with lack of dynamic content the documentation can only refer to the default build configuration format). Change-Id: I51d19642a7ed8c99817971c1f25d20972095021e Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/30951 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20editcap: add --inject-secrets optionPeter Wu1-0/+103
Add a new option to insert decryption secrets into a pcapng file. Change-Id: I0e024585cac9a8a328e88d32f9eb03d37d350e2a Ping-Bug: 15252 Reviewed-on: https://code.wireshark.org/review/30693 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-16Use an enum for compression types in various interfaces.Guy Harris1-4/+2
This: 1) means that we don't have to flag the compression argument with a comment to indicate what it means (FALSE doesn't obviously say "not compressed", WTAP_UNCOMPRESSED does); 2) leaves space in the interfaces in question for additional compression types. (No, this is not part 1 of an implementation of additional compression types, it's just an API cleanup. Implementing additional compression types involves significant work in libwiretap, as well as UI changes to replace "compress the file" checkboxes with something to indicate *how* to compress the file, or to always use some other form of compression). Change-Id: I1d23dc720be10158e6b34f97baa247ba8a537abf Reviewed-on: https://code.wireshark.org/review/30660 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-16Use the dump parameters structure for non-pcapng-specific stuff.Guy Harris1-28/+31
Use it for all the per-file information, including the per-file link-layer type and the per-file snapshot length. Change-Id: Id75687c7faa6418a2bfcf7f8198206a9f95db629 Reviewed-on: https://code.wireshark.org/review/30616 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-13Give an error if an output file isn't specified.Guy Harris1-393/+390
Just silently not bothering to do any work isn't all that useful in that case; giving the usage message indicates that you need both input and output files. Change-Id: I9512d3e45e1e9a9d4bccb28b49aeea8c12ad0100 Reviewed-on: https://code.wireshark.org/review/30614 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-13Don't have _ng versions of the dumper open routines.Guy Harris1-6/+6
Have the routines always take a parameters pointer; pass either null or a pointer to an initialized-to-nothing structure in cases where we were calling the non-_ng versions. Change-Id: I23b779d87f3fbd29306ebe1df568852be113d3b2 Reviewed-on: https://code.wireshark.org/review/30590 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-12wiretap: refactor common parameters for pcapng dump routinesPeter Wu1-20/+14
Four variants of wtap_dump_open_ng exists, each of them take the same three parameters for the SHB, IDB and NRB blocks that has to be written before packets are even written. Similarly, a lot of tools always create these arguments based on an existing capture file session (wth). Address the former duplication by creating a new data structure to hold the arguments. Address the second issue by creating new helper functions to initialize the parameters based on a wth. This refactoring should make it easier to add the new Decryption Secrets Block (DSB). No functional change intended. Change-Id: I42c019dc1d48a476773459212ca213de91a55684 Reviewed-on: https://code.wireshark.org/review/30578 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
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-09-26Make systemd journal entries events.Gerald Combs1-0/+6
Treat systemd journal entries filetype-specific events instead of packets. Add support for reading and writing systemd journal entries to pcapng. Note that pcapng IDBs should be optional. Add support for REC_TYPE_FT_SPECIFIC_EVENT where needed. Change-Id: Ided999b1732108f480c6c75323a0769a9d9ef09f Reviewed-on: https://code.wireshark.org/review/29611 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-08-31editcap: add seed optionNils Björklund1-2/+30
Implement a --seed option to be used in conjunction with -E. The option allows the user to set the seed for the pseudo-random number generator, which can be useful for recreating a particular sequence of errors. Change-Id: Id427ab5fd7711652ad56c72271b2e0acb7380858 Reviewed-on: https://code.wireshark.org/review/29306 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>
2018-08-06editcap: Add ability to skip radiotap header.Alexis Green1-0/+37
This is useful when processing packets that were captured by multiple radios on the same channel. Change-Id: I9dacc35294a4ed4e817014e563e7c9a54ee05e40 Reviewed-on: https://code.wireshark.org/review/28843 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-06-28Add macros to initialize nstime_t values and use them.Guy Harris1-4/+4
This allows code to initialize them without having to know the details of the structure; the initializes should, and will, be changed if the members of the structure are changed. Change-Id: I93e6ebfcde9ceca17df696fcba4e8410c5afb175 Reviewed-on: https://code.wireshark.org/review/28501 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-27editcap: move -I and -a options description to packet manipulation sectionPascal Quantin1-11/+9
Change-Id: I090c214eeb636ec8f769ee133e2f12825802335e Reviewed-on: https://code.wireshark.org/review/28472 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-06-22The fractional part of a secs+nsecs time adjustment must be < 10^9.Guy Harris1-3/+3
One billion nanoseconds is 1 second, so that should just be expressed as 1 second. Change-Id: I0d49838141fa877168d068a2e27b3dcc104c0cef Reviewed-on: https://code.wireshark.org/review/28380 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-22editcap: ifix time shift with useconds carryYour Name1-3/+3
time shift to a whole number of seconds need to carry the seconds Change-Id: I188d915bca8f86a2cc19fc603bf472f461e8beea Reviewed-on: https://code.wireshark.org/review/28372 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-09Always explicitly set tm_isdst before calling mktime().Guy Harris1-0/+1
Except in rare cases, we want to set it to -1 so that we let mktime() determine whether DST/Summer Time was in effect at the given date and time rather than pretending that we know whether it's in effect or not. Change-Id: I0ea75317dd308a515cedf4d1260b583e1592cc9b Reviewed-on: https://code.wireshark.org/review/27431 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-02-09Remove redundant members from wtap_syscall_header.Guy Harris1-1/+1
No need for len, and call caplen event_filelen and move it after event_len. Change-Id: I8b3825d4022ee083ee52f83f7a69f22829ed9fc4 Reviewed-on: https://code.wireshark.org/review/25698 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-09Generalize wtap_pkthdr into a structure for packet and non-packet records.Guy Harris1-151/+183
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-18Don't overwrite the struct wtap_pkthdr; copy and change it instead.Guy Harris1-3/+15
Do as we do in other cases - copy the current struct wtap_pkthdr to a temporary one (which might copy the temporary one to itself), modify it, and set the pointer to the struct wtap_pkthdr to point to the temporary one. Note all the places wherw we do this with a comment. Change-Id: Ia11df6b997a5369d96436d3bd825ab0138742504 Reviewed-on: https://code.wireshark.org/review/25377 Reviewed-by: Guy Harris <guy@alum.mit.edu>
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>
2017-12-14Refactor plugin registration and loadingJoão Valverde1-18/+1
Put different types of plugins (libwiretap, libwireshark) in different subdirectories, give libwiretap and libwireshark init routines that load the plugins, and have them scan the appropriate subdirectories so that we don't even *try* to, for example, load libwireshark plugins in programs that only use libwiretap. Compiled plugins are stored in subfolders of the plugin folders, with the subfolder name being the Wireshark minor version number (X.Y). There is another hierarchical level for each Wireshark library (libwireshark, libwscodecs and libwiretap). The folder names are respectively plugins/X.Y/{epan,codecs,wiretap}. Currently we only distribute "epan" (libwireshark) plugins. Change-Id: I3438787a6f45820d64ba4ca91cbe3c8864708acb Reviewed-on: https://code.wireshark.org/review/23983 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2017-11-14CMake,editcap: avoid noise with editcap -F and -T optionsPeter Wu1-1/+7
Avoid printing a noisy "option requires an argument" error when using '-T' and '-F' as documented. Fix warning that started showing on macOS with CMake 3.9.4 about CMP0058 since v2.5.0rc0-1180-g799f4f0e14. Change-Id: Ie0cc352c6b0b2724997e7fe6b49fd5b1f02d1e07 Reviewed-on: https://code.wireshark.org/review/24404 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Ahmad Fatoum <ahmad@a3f.at> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
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-10-26CMake: Don't check for windows.h or winsock2.h.Gerald Combs1-2/+0
If we're building on Windows we're going to have windows.h and winsock2.h. Don't bother checking for them. Change-Id: I0004c44d7364ab3f41682f34b8c84cd8617c9603 Reviewed-on: https://code.wireshark.org/review/24068 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>