Commit Graph

3721 Commits

Author SHA1 Message Date
Alexis La Goutte 123a5f4e13 libpcap(wiretap): Fix unreachable-code
libpcap.c:1007:19: warning: code will never be executed [-Wunreachable-code]
2022-02-13 10:23:43 +00:00
Alexis La Goutte f5eceb4ad0 blf: fix Wunreachable-code
blf.c:764:47: warning: code will never be executed [-Wunreachable-code]
2022-02-13 10:23:42 +00:00
David Perry 1e0d117eb7 Specify directory for temporary captures 2022-02-09 14:32:28 +00:00
Guy Harris 0d357951c3 pflog: byte swap UID and PID fields in the header if necessary. 2022-02-01 16:20:21 -08:00
Vladimir Bespalov 5ecb57cb90 Add ZBOSS NCP protocol dissector 2022-01-30 09:34:26 +00:00
Gerald Combs 46cb5d5252 BLF: Make sure a struct is completely initialized.
Initialize infstream. Fixes

```
*** CID 1497282:    (UNINIT)
/builds/wireshark/wireshark/wiretap/blf.c: 506 in blf_pull_logcontainer_into_memory()
500             }
501
502             int ret = inflate(&infstream, Z_NO_FLUSH);
503             /* Z_OK should not happen here since we know how big the buffer should be */
504             if (Z_STREAM_END != ret) {
505                 ws_debug("inflate failed (return code %d) for LogContainer %d", ret, index_log_container);
>>>     CID 1497282:    (UNINIT)
>>>     Using uninitialized value "infstream.msg".
506                 if (infstream.msg != NULL) {
507                     ws_debug("inflate returned: \"%s\"", infstream.msg);
508                 }
509                 return FALSE;
510             }
511
/builds/wireshark/wireshark/wiretap/blf.c: 514 in blf_pull_logcontainer_into_memory()
508                 }
509                 return FALSE;
510             }
511
512             if (Z_OK != inflateEnd(&infstream)) {
513                 ws_debug("inflateEnd failed for LogContainer %d", index_log_container);
>>>     CID 1497282:    (UNINIT)
>>>     Using uninitialized value "infstream.msg".
514                 if (infstream.msg != NULL) {
515                     ws_debug("inflateEnd returned: \"%s\"", infstream.msg);
516                 }
517                 return FALSE;
518             }
519
/builds/wireshark/wireshark/wiretap/blf.c: 496 in blf_pull_logcontainer_into_memory()
490             infstream.avail_out = (unsigned int)tmp.real_length;
491             infstream.next_out  = buf;
492
493             /* the actual DE-compression work. */
494             if (Z_OK != inflateInit(&infstream)) {
495                 ws_debug("inflateInit failed for LogContainer %d", index_log_container);
>>>     CID 1497282:    (UNINIT)
>>>     Using uninitialized value "infstream.msg".
496                 if (infstream.msg != NULL) {
497                     ws_debug("inflateInit returned: \"%s\"", infstream.msg);
498                 }
499                 return FALSE;
500             }
501
```
2022-01-18 00:15:36 +00:00
Dr. Lars Völker 268582b553 Frame: Parsing of PCAPNG Option Block PEN 46254 2022-01-17 10:54:57 +00:00
Guy Harris c8c7479ace libpcap: set wth->priv to the libpcap_t before returning errors.
That ensures that it'll be freed on an error, fixing Coverity CID
1497311.
2022-01-16 11:25:48 -08:00
Guy Harris a9490f354c libpcap (wiretap): reorganize the file open code. 2022-01-16 10:06:50 +00:00
Dr. Lars Völker ef43fd48b4 tshark: improve robustness for PCAPNGs not starting with IDBs
The PCAPNG code assumes that PCAPNGs start with IDBs, which might not be
true. This patch adds a workaround for Tshark to process such files.
2022-01-16 08:55:24 +00:00
Dr. Lars Völker 4107d5dd6e BLF: improved checks to avoid hangs
Improvements to fix a few hang scenarios found by fuzzing.
2022-01-16 07:44:19 +00:00
Alexis La Goutte 112af30dd9 erf(wiretap): Fix Clang Warning Uninitialized argument value 2022-01-15 08:41:12 +00:00
Dr. Lars Völker dd663c8c7f BLF: Improve handling of zlib errors 2022-01-15 08:30:36 +00:00
Dr. Lars Völker e9d650362c BLF: improve debug log output 2022-01-14 21:51:29 +01:00
John Thacker 203820f3d0 wiretap: Register a systemd Journal Export Block
The block is lightweight and doesn't have any options so the create
function doesn't really do anything, but it needs to be registered
so that when systemd journal files are opened, the wtap_block_create()
call works and doesn't segfault. Fix #17875
2022-01-14 03:07:05 +00:00
Guy Harris 7da31cb139 libpcap: remove definition of unused structure.
We don't allocate a per-dumper private data structure, so there's no
need to define a structure type.
2022-01-13 11:46:36 -08:00
John Thacker a9e6f2660e wiretap: Fix description of Custom Block 2022-01-13 14:02:55 +00:00
Jérôme HAMM 7356889242 Adding secret management in DSB. 2022-01-07 13:42:33 +00:00
Роман Донченко 6b8c32fa7a rfc7468: allow multiple structures per file
It's common to put multiple certificates in one RFC 7468 file in order to store
a certificate chain, as described in the introduction to RFC 7468 itself.
Support this usage by presenting each such certificate (or any other encoded
structure - the code doesn't discriminate) as a separate packet.

The new parsing code supports arbitrary line lengths, so update the detection
code to support arbitrary line lengths as well. Instead of probing up to 20
lines, we now try to find the first pre-encapsulation boundary in the first
2048 bytes of the file. I chose this new limit so that it works roughly the
same in practice as the old one (it's equal to 20 lines times 80 characters
per line, rounded to a power of two).
2022-01-06 06:29:54 +00:00
Gerald Combs 27ccf26b4b BLF: Fix a coverity warning.
Fix

```
*** CID 1496851:  Resource leaks  (RESOURCE_LEAK)
/builds/wireshark/wireshark/wiretap/blf.c: 1621 in blf_read_apptextmessage()
1615         }
1616
1617         gchar *text = g_try_malloc0((gsize)apptextheader.textLength);
1618
1619         if (!blf_read_bytes(params, data_start + sizeof(apptextheader), text, apptextheader.textLength, err, err_info)) {
1620             ws_debug("not enough bytes for apptext text in file");
>>>     CID 1496851:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "text" going out of scope leaks the storage it points to.
1621             return FALSE;
1622         }
1623
1624         /* returns a NULL terminated array of NULL terminates strings */
1625         gchar **tokens = g_strsplit_set(text, ";", -1);
```
2022-01-05 05:21:25 +00:00
Dr. Lars Völker 19ed057563 BLF: Adding support to read interface names
This patch reads out the interface of the meta data in BLF to set the
interface names in Wireshark to these values.
2022-01-03 07:58:47 +00:00
João Valverde 12d39efdca Revert "epan: Initialize wiretap"
This reverts commit c15f2aadc1.

Crashes on exit. Needs more work.

Fixes #17821.
2022-01-01 16:23:04 +00:00
Gerald Combs 4e417b8e7c Windows: UTF-8 harder.
Set the process code page in wireshark.exe.manifest to UTF-8 as
described at

https://docs.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

Make sure each of our command line resource files includes our main
manifest. Rename wiretap.rc to libwiretap.rc to match our other libraries.
2022-01-01 08:09:12 +00:00
Moshe Kaplan 69d54d6f8e Corrects repeated words throughout the code.
Repeated words were found with:
egrep "(\b[a-zA-Z]+) +\1\b" . -Ir
and then manually reviewed.
Non-displayed strings (e.g., in comments)
were also corrected, to ease future review.
2021-12-22 11:01:11 +00:00
João Valverde 4448b6494e Add a ws_posix_compat.h header
Currently used to define ssize_t on platforms that lack it.

Fix some Windows build errors caused by moving the definition into a
separate header.

Fix some narrowing warnings on Windows x64 from changing the definition
of ssize_t from long int to int64_t.

The casts in dumpcap are ugly but necessary. The whole code needs
to be rewritten for portability, or the warnings disabled.
2021-12-21 01:30:06 +00:00
João Valverde ce1dc88173 Fix stdio.h conversions to use the scanf macros 2021-12-19 23:49:55 +00:00
João Valverde 0ccd69e530 Replace g_strdup_printf() with ws_strdup_printf()
Use macros from inttypes.h.
2021-12-19 21:21:58 +00:00
João Valverde 22ee2764a7 Replace g_snprintf() with snprintf() (dissectors)
Use macros from inttypes.h with format strings.
2021-12-19 20:25:11 +00:00
João Valverde fe5248717f Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.
2021-12-19 20:06:13 +00:00
John Thacker 67a4e70382 wiretap: have dummy IDBs set OPT_IDB_TSRESOL if needed
In wtap_dump_init_dumper(), when constructing a dummy IDB for files
that don't have one, if the tsprecision value is anything other than
the default, then the OPT_IDB_TSRESOL option also needs to be set.
Without it, for a pcapng the timestamps will be written according to the
tsprecision and time_units_per_second values, but when it is read,
the values will be interpreted incorrectly.

It would probably be better if the consistency of these values were enforced.
2021-12-15 14:04:58 +00:00
John Thacker 85a8de25a4 blf: Set OPT_IDB_TSRESOL
In addition to setting tsprecision and time_units_per_second, add
the OPT_IDB_TSRESOL option as well, because pcapng expects that to
be set if tsprecision is anything other than the default.
2021-12-15 07:22:51 +00:00
Gerald Combs fcf945f747 wiretap: Fix an underflow in pcapng.
Make sure account for our rounded option length when we process
opt_endofopt. Fixes #17755.
2021-12-02 04:06:59 +00:00
John Thacker cf0ecc4fe1 nstime: Support ISO 8601 basic format
Add support in iso8601_to_nstime for the ISO 8601 Basic date/time
format that lacks the - and : separators.
2021-12-01 20:50:37 -05:00
Moshe Kaplan 34454a5037 wiretap: Add header files to Doxygen
Add @file markers for wiretap
headers so that Doxygen will
generate documentation for them.
2021-11-29 21:59:23 -05:00
Moshe Kaplan 1c3a9af869 Add files with WS_DLL_PUBLIC to Doxygen
Add @file markers for most files that
contain functions exported with
WS_DLL_PUBLIC so that Doxygen will
generate documentation for them.
2021-11-29 21:27:45 +00:00
João Valverde c15f2aadc1 epan: Initialize wiretap
Clients of libwireshark should not be required to initialize
explicitly wiretap, if they don't use it themselves.
2021-11-27 08:41:01 +00:00
Michael Tuexen 2b52d14d62 BBLog: Fix the handling of skipped blocks 2021-11-20 00:10:28 +01:00
Michael Tuexen d11c069786 BBLog: Fix support of TCP window scaling
Rcv.Wind.Shift and Snd.Wind.Shift were not displayed correctly by
the BBLog dissector and the TCP dissector was not using the
information about the shift values available in the BBLog file.
2021-11-08 23:05:20 +00:00
Anders Broman 94b28aa79a Ericsson ENB log reader: Check the whole line for the magic string. 2021-11-03 05:04:38 +00:00
Federico Di Pierro d95935d969 dissectors: support sysdig new block type BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE
The new block type enlarge payload lens up to 4B,
to support larger payload sizes.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-10-29 08:04:21 +00:00
Dr. Lars Völker c44e14a4ba BLF: Direction is not ignored anymore (BUGFIX)
This patch adds direction support, so that incoming and outgoing frames
can be differentiated.
2021-10-26 20:45:33 +00:00
Aidan MacDonald 9c322f5b55 Increase max packet size for all USB encapsulation formats
Each "packet" in the USB encapsulation formats for at least
Linux and Darwin corresponds to an OS-level USB request, so
the packets can be much larger than a USB-level packet.

The default max packet length of 256 KiB prevents Wireshark
from loading capture files that contain requests >256 KiB.
(Saving such a capture already works fine.)

Fix this by making the Linux, Darwin, and FreeBSD formats
use the same max packet length as the USBPCap format, which
is 128 MiB.
2021-10-24 22:48:20 +01:00
João Valverde 1acae21bcd Windows: Fix warnings using flex
Fix some warnings complaining of macro redefinitions with stdint.h.
Include stdint.h via wireshark.h everywhere so it stays fixed.
2021-10-22 06:41:44 +00:00
João Valverde 59c082c046 Add new global header wireshark.h with guideline
Remove ws_diag_control.h from config.h because that was a workaround
for the lack of a public global header. Fix the resultant build errors.
2021-10-22 06:41:44 +00:00
Guy Harris 3fe96028d2 Add a comment to explain a cast done in file_fdopen(). 2021-10-18 16:22:33 -07:00
Nardi Ivan a2e877d397 wiretap: fix a warning on Raspberry 4
/home/pi/wireshark/wiretap/file_wrappers.c: In function ‘file_fdopen’:
/home/pi/wireshark/wiretap/file_wrappers.c:1136:27: error: comparison of integer expressions of different signedness: ‘__blksize_t’ {aka ‘long int’} and ‘unsigned int’ [-Werror=sign-compare]
         if (st.st_blksize <= MAX_READ_BUF_SIZE)
                           ^~
cc1: all warnings being treated as errors
2021-10-18 22:23:33 +00:00
Stig Bjørlykke bb0b4ad4b3 eNode-B: Fix check for eri_enb_log_magic
Files not having the eri_enb_log_magic should not be opened as a
eNode-B raw log file format.
2021-10-13 12:06:44 +02:00
Anders Broman eb9ae2ffd5 Read eNode-B raw logs 2021-10-04 16:08:27 +00:00
John Thacker e05f704606 wiretap: camins, vwr: Stop heuristics after 1GiB
Very large 64 bit files are supported, so the CAM Inspector and
Ixia Veriwave heuristics, which are fairly weak and either always
(CAM Inspector) or possibly (Veriwave) try to read the entire file
should stop their heuristics and make a decision after some reasonable
length.

Without this, the GUI freezes for seconds, minutes, or even hours
by merely clicking on a large file in the file chooser, as
wtap_open_offline attempts to determine the file type. The same issue
occurs in capinfos, captype, tshark, editcap, etc.

In addition, previously the CAM Inspector heuristics could give the wrong
result on very large files, because 10 * invalid_pairs could overflow
its guint32 and then end up comparing as less than valid_pairs.

Fix #17620
2021-10-03 20:01:37 +00:00
João Valverde 5362d0c31b ws_getopt: Rename struct and macros
This is part of the API and should also be renamed to avoid conflicts.
2021-09-30 13:59:28 +00:00
Stig Bjørlykke 96cfaf67a3 Qt: Reload Lua FileHandler when having a capture file
Support reloading a Lua FileHandler when this is in use for a
loaded capture file. Prompt to save the file if having unsaved
changes because the file must be reloaded.

Fixes #17615
2021-09-30 11:07:08 +00:00
Guy Harris 92d77cef7a libwiretap: fix test for built-in file types.
The file type/subtype for built-in types are <=
wtap_num_builtin_file_types_subtypes - the plugin types are given
type/subtype values after the last built-in type/subtype value.

Fixes #17614.
2021-09-25 14:09:41 -07:00
Erik Rigtorp 4ebd927ccd Support LZ4 versions earlier than 1.8.0 2021-09-15 19:09:30 +00:00
Guy Harris 9fcc11cc9b blf: report a bunch of errors. 2021-09-12 01:21:31 -07:00
Guy Harris fdf2d78d9a blf: most reads in a packet are errors even if they get an EOF.
If the *first* read for a packet gets an EOF, it means that there is an
EOF right at the point where you're reading, which means "no more
packets".

If you get an EOF on any *subsequent* reads for the packet, it means the
file was cut off in the middle of the packet's record, which is an error.
2021-09-12 00:47:07 -07:00
Guy Harris b6d1806053 blf: remove the function name from ws_debug() calls.
ws_debug() inserts the file name, line number, and function name into
the ws_debug() message (assuming the function name can be obtained from
a macro), so there's no need to include it in the text of the message
(we don't do so elsewhere).
2021-09-12 00:07:55 -07:00
Guy Harris 89368f9d28 blf: do more work in blf_init_rec().
Set the block, presence flags, capture length, and length there.
2021-09-11 18:48:55 -07:00
Guy Harris 5aad28d773 blf: use common code to read the log object header. 2021-09-11 17:04:23 -07:00
John Thacker 6fe68991df wiretap: Add zstd and lz4 as WTAP compression types
This has a few effects on the behavior of wtap_get_compression_type()
and wtap_get_all_compression_type_extensions():

Make capinfos correctly report the compression type (instead of
saying gzip compressed for zstd and lz4 compressed files).

Makes files with the .zstd and .lz4 extension show up in the file
chooser when "Files of type" is set to something other than "All Files",
such as "All Capture Files" or "Wireshark/... pcapng"

Makes the UI not default to gzip compression when saving a file
compressed as zstd or lz4 (write support for zstd and lz4 doesn't
exist yet, and the GUI doesn't have hooks for it anyway, though
this can help as a prerequisite for later support for writing.)

Also replace a couple of assert() with ws_assert().

Update the PURPOSE in CMakeLists for zstd and lz4 to note that they
can be used to read compressed capture files.
2021-09-11 22:37:25 +00:00
Guy Harris 8307d5d9be blf: fix indentation.
Fix indentation of a while() clause, so that it's indented less than the
body of the while() loop.
2021-09-11 14:27:48 -07:00
Guy Harris 8b614c6a1c blf: make blf_read_block() static.
It's not used outside blf.c.
2021-09-11 13:23:18 -07:00
Guy Harris 76b08ea083 Fix spelling errors.
The Ubuntu build commented on some spelling errors in executable code
files.  Fix the errors that don't come from external files containing
the spelling errors (USB product and vendor IDs, PCI IDs, ASN.1
specifications), and fix some errors that don't show up in the
executable code files (e.g., in comments and variable names).
2021-09-11 10:01:27 +00:00
Guy Harris dee79a0c81 wtap_opttypes: move more if_filter and packet_verdict stuff together.
As we did in earlier changes.
2021-09-09 15:12:05 -07:00
Dr. Lars Völker be7b4163de BLF: Adding LIN support
This patch adds support for LIN Messages in BLF.
2021-09-09 09:19:36 +00:00
Guy Harris a4a571e680 wtap_opttypes: move the specialized options after the custom options.
Move the if_filter and packet_verdict option stuff after the custom
option stuff in various places.

Fix some comments while we're at it.
2021-09-09 01:33:47 -07:00
Guy Harris 58d053923e pcapng: clean up block length checks.
Use the same style of message for too-short block errors ("pcapng: total
block length XXX of {a,an} XXX is too small...").

Add an additional check for the "skip" Netflix cutom block, to make sure
it has enough room for the 4-byte "skipped" value.
2021-09-09 00:19:36 -07:00
Nardi Ivan 197b67cf8c Fix two memory leaks on ZSTD and LZ4 decompression 2021-09-08 21:08:41 +00:00
Pascal Quantin 98faf05b6b file_wrappers.c: use LZ4 if the library is 1.7.3 or later 2021-09-07 21:40:44 +02:00
Alexis La Goutte 5fc6549178 pcapng: Fix Branch condition evaluate to a garbage value
wblock->internal is not initialized on pcapng_read_custom_block function
pcapng.c:3747:9: warning: Branch condition evaluates to a garbage value [core.uninitialized.Branch]
2021-09-07 05:56:36 +00:00
Alexis La Goutte 7740e9ae27 pcapng(wiretap): Fix Dead Store found by Clang Analyzer
pcapng.c:2675:5: warning: Value stored to 'opt_cont_buf_len' is never read [deadcode.DeadStores]
2021-09-06 04:21:14 +00:00
Alexis La Goutte 203e082a50 nettrace_3gpp (wiretap): Fix Dead Store found by Clang Analyzer
nettrace_3gpp_32_423.c:256:2: warning: Value stored to 'prev_pos' is never read [deadcode.DeadStores]
nettrace_3gpp_32_423.c:295:2: warning: Value stored to 'next_msg_pos' is never read [deadcode.DeadStores]
nettrace_3gpp_32_423.c:487:4: warning: Value stored to 'port_type_defined' is never read [deadcode.DeadStores]
2021-09-06 04:21:14 +00:00
Tomas Kukosa dde6fde173 Vector BLF: add WLAN interface name 2021-09-03 05:03:48 +00:00
Tomas Kukosa bf1039a529 Vector BLF: WLAN frame supported 2021-09-03 05:03:48 +00:00
Guy Harris 7083e70842 Remove an out-of-date comment.
(It appears gsize/gssize are now the same size as size_t, even on 64-bit
Windows, i.e. they're long longs on 64-bit Windows.)
2021-09-02 15:33:55 -07:00
Dario Lombardo 2e9f33fe09 file_wrapper: fix compilation without LZ4. 2021-09-02 15:17:05 +00:00
Guy Harris e998a4cc02 Clean up handling of buffer size/offset/etc. types.
Use guint for them, and don't let the buffer sizes get bigger than 2^30,
so they all fit in a guint.
2021-09-02 02:14:28 -07:00
Erik Rigtorp 341a9d099c Fix build for debian and macOS 2021-09-01 23:16:59 +02:00
Erik Rigtorp 5844c469f0 Add support for ZSTD and LZ4 decompression
- Describe zstd and lz4 support in man pages
- Update AUTHORS
- Update mime types to recognize zstd and lz4
2021-09-01 20:59:07 +02:00
Guy Harris 030b06ba3c pcapng: write packet and Netflix custom blocks the same as other blocks.
Use compute_options_size() to get the total size of all the options, and
use write_options() to write out the options for those blocks, as we do
for other blocks.

Get rid of wtap_block_option_get_value_size() and
wtap_block_get_options_size_padded(); they're no longer needed, and
their notion of an option's "size" is "size in a pcapng file", so that
doesn't belong in code that's intended to support all file types.
2021-08-30 16:29:04 -07:00
Guy Harris 510c088ce6 ngsniffer: fix a routine name.
That routine now only processes frame records; call it
process_frame_record().
2021-08-30 20:45:52 +00:00
Guy Harris dcfa3ec835 ngsniffer: clean up the read process.
Have a routine to read the Sniffer record header, and call that in
ngsniffer_read() and ngsniffer_seek_read().  Only call
ngsniffer_process_record() for frame records that we understand, so that
we only allocate a block for those rather than for records we don't
understand or for EOF records, potentially leaking them.
2021-08-30 12:47:38 -07:00
Guy Harris 3cb6403a4c wiretap: always allocate a block for a record.
Without that, you could add a comment to a record in a file format the
reading code for which doesn't allocate blocks, but the comment doesn't
get saved, as there's no block in which to save the comment option.

This simplifies some code paths, as we're either using the record's
modified block or we're using the block as read from the file, there's
no third possibility.

If we attempt to read a record, and we get an error, and a block was
allocated for the record, unreference it, so the individual file readers
don't have to worry about it.
2021-08-29 19:12:13 -07:00
Guy Harris dd8c23c83d pcapng: remove include of wtap_opttypes.h.
It's already included by wtap/wtap.h, which this file includes, and it
doesn't need to be included that early, so that #include isn't
necessary.
2021-08-29 01:00:02 -07:00
Guy Harris 07416c01dc peektagged: set rec->block right after rec->rec_type.
That's how it's done in other files, and the two are somewhat connected
(the record type and block type are somewhat correlated).
2021-08-29 00:33:22 -07:00
Guy Harris 266d707dff pcapng: whitespace and other cleanups.
Remove some extra blank lines, add a blank line where it belongs, and
get rid of a stray #-only line.
2021-08-28 22:29:21 -07:00
Guy Harris 10be4d1611 pcapng: fix handling of byte-swapped sysdig event blocks.
We weren't setting wblock->rec->rec_header.syscall_header.nparams for
byte-swapped event blocks.
2021-08-28 16:00:41 -07:00
Guy Harris 9b132c2353 pcapng: fix output of comment and DNS server name options.
Copy to the buffer the string value, not the structure that contains it.
2021-08-27 18:14:02 -07:00
Guy Harris 5536ca319a wtap_opttypes: fix a typo. 2021-08-27 12:54:02 -07:00
Guy Harris 4b7bfe35c5 pcapng: process uint32 options like uint64 options.
Move the extraction of the option value from the option content from the
callers of pcapng_process_uint32_option() to
pcapng_process_uint32_option() itself.
2021-08-27 08:58:13 +00:00
Guy Harris a21972d6b9 pcapng: remove some old code left behind by the previous change. 2021-08-27 00:33:09 -07:00
Guy Harris 8acd0d1151 pcapng: export routines to do the option-section processing.
That way, add-on modules to handle block types not handled by the core
pcapng code can use pcap_process_options() to process a block's options
and can use the routines to handle the "standard" option value types to
handle particular options.

Also, allow both everything-is-little-endian and
everything-is-big-endian Custom Block types in pcap_process_options().
2021-08-27 06:48:47 +00:00
Michael Tuexen b17f354304 Add initial support for BBLog files 2021-08-27 04:48:21 +02:00
Dr. Lars Völker 0091a83e31 BLF: adding Interface blocks (bugfix)
This patch adds code to add the interface blocks, so that the packets
read by blf can be written again (e.g., to pcapng).
2021-08-23 21:19:29 +02:00
Dr. Lars Völker 5de353f324 BLF: WTAP_BLOCK_PACKET should have been MULTIPLE_BLOCKS_SUPPORTED 2021-08-23 20:30:12 +02:00
Guy Harris 4e80643cc0 Move LINKTYPE_WIRESHARK_UPPER_PDU definitions to a separate header.
Have wsutil/exported_pdu_tlvs.h define the LINKTYPE_WIRESHARK_UPPER_PDU
TLV type and length values, as well as the port type values written to
files in EXP_PDU_TAG_PORT_TYPE TLVs.

Update the comment that describes the LINKTYPE_WIRESHARK_UPPER_PDU TLVs
to more completely and correctly reflect reality (it was moved from
epan/exported_pdu.h to wsutil/exported_pdu_tlvs.h).

Rename those port type values from OLD_PT_ to EXP_PDU_PT_; there is
nothing "old" about them - yes, they originally had the same numerical
values as the PT_ enum values in libwireshark, but that's no longer the
case, and the two are now defined independently.  Rename routines that
map between libwireshark PT_ values and EXP_PDU_PT_ values to remove
"old" from the name while we're at it.

Don't include epan/exported_pdu.h if we only need the
LINKTYPE_WIRESHARK_UPPER_PDU definitions - just include
wsutil/exported_pdu_tlvs.h.

In extcap/udpdump.c, include wsutil/exported_pdu_tlvs.h rather than
defining the TLV types ourselves.
2021-08-20 02:18:19 -07:00
Guy Harris d679564d7b Use the wsutil/pint.h functions to fill in "exported PDU" headers.
That makes the code cleaner, including making it clearer that the fields
in those headers are big-endian.
2021-08-20 00:35:33 -07:00
David Perry 6e12643f19 [#17478] free blocks in more places
Bug 17478 was caused by `wtap_rec.block` being allocated for each
packet, but not freed when it was done being used -- typically at the
end of a loop.

Rather than requiring each caller of `wtap_read()` to know to free a
member of `rec`, I added a new function `wtap_rec_reset()` for a
slightly cleaner API. Added calls to it everywhere that seemed to make
sense.

Fixes #17478
2021-08-10 00:08:15 +00:00
Gerald Combs dead9f13e9 wiretap: Fix some BLF warnings.
Make a bunch of functions in blf.c static.
2021-08-04 09:51:05 -07:00
Dr. Lars Völker f27c98ad2b BLF: Cleanup and fix for start time 2021-08-04 14:58:03 +02:00
Jaap Keuter 85586f4b43 Fix header documentation and style
Fix some documentation found by in code check pipeline, and apply
code wrapping style consistently.
2021-08-04 06:00:28 +00:00