Commit Graph

31 Commits

Author SHA1 Message Date
John Thacker 42084c2d17 text2pcap: Move SHB and IDB setup to ui/text_import
Move the parameter setup to text_import, so that later it can
be called from the GUI, including the interface name. (This has
to be a separate function because these parameters need to be
set before the call to wtap_dump_open, which is different for
regular files vs temp files vs stdout.)
2021-12-30 17:05:06 +00:00
John Thacker 021c25e22c text2pcap: Use standard log debug level
Remove the '-d' option from text2pcap, and move the two levels
of debug messages in text2pcap and text_import to either
LOG_LEVEL_DEBUG or LOG_LEVEL_NOISY as appropriate.
2021-12-30 01:17:06 +00:00
John Thacker 23355cddf6 import_text: Add ASCII identification checkbox
Add a checkbox for the extra detection for ASCII in a hex+ASCII
hexdump even when the text looks like hexbytes to Import from Hex
Dump. Save and restore it from the settings. Work towards #16724.
2021-12-26 19:13:25 -05:00
John Thacker 9e7b5c9189 text2pcap: Use debug level
Pass the debug level parameter from text2pcap to text_import
so that it is used as it was before to print internal parsing
information.
2021-12-25 15:52:46 -05:00
John Thacker 96c299c6b8 text_import: Reduce globals
A bunch of the globals are simply copied from the input parameter
text_import_info_t, just use them directly.

Move the count for packets read and written into the info type,
so that callers like text2pcap can access them as results.
2021-12-24 08:20:27 -05:00
John Thacker bc4b27bbe2 text_import: Report failure to write
Use report_message and report wtap_dump failures. Pass in
the output filename and keep track of the frame numbers for
the message parameters.

Report failure to initialize the lex scanner in text_import
instead of in the GUI, so that it would be reported from text2pcap,
and because text_import might have other failure cases that are
not the scanner.

The regex parser returns a positive number of packets processed
on success; save that number in text_import, and return zero on
success to our callers.
2021-12-23 15:49:04 +00:00
John Thacker 8d421de42c text_import: port ASCII identification from text2pcap
This is the special check for canonical hex+ASCII textdump
files that looks for the edge case where the beginning of the
ASCII column has strings that can be mistaken by the parser for
additional hex bytes. Not implemented in the GUI yet. Preparing
for text2pcap switchover. Related to #16724.
2021-12-22 20:08:29 -05:00
John Thacker 6a74dae750 text_import: Add interface and internals for IPv6
Add IPv6 handling to text_import, including the ability to
handle dummy IPv6 addresses instead of IPv4. GUI support is
still TBD. This further reduces the number of text2pcap features
that ui/text_import does not yet support. Related to #16724.
2021-12-22 05:13:17 +00:00
John Thacker 3ff0c753a1 text_import: Add interface and internals for dummy IPv4 addresses
Add dummy IPv4 addresses to the text_import_info_t struct, and
use them if set in the same way text2pcap does. GUI support in
"Import from Hex Dump" is not added yet. This is also part of the
work for text2pcap to eventually call text_import. Related to #16724.
2021-12-22 02:41:11 +00:00
Moshe Kaplan 3953ddcf57 Add UI header files to Doxygen
Add @file markers for UI
header files so that Doxygen will
generate documentation for them.
2021-11-30 08:01:36 -05: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
Gerald Combs 9222bd77cd Remove unneeded modelines in ui.
Remove the editor modeline blocks from the source files in ui that use 4
space indentation by running

perl -i -p0e 's{ \n+ /[ *\n]+ editor \s+ modelines .* shiftwidth= .* \*/ \s+ } {\n}gsix' $( ag -l shiftwidth=4 $( ag -g '\.(c|cpp|h|m|mm)') )

This gives us one source of indentation truth for these files, and it
*shouldn't* affect anyone since

- These files match the default in our top-level .editorconfig.

- The one notable editor that's likely to be used on these files and
*doesn't* support EditorConfig (Qt Creator) defaults to 4 space
indentation.
2021-04-20 07:43:39 +00:00
Paul Weiß 8c1b29a597 Regex based textfile import
Modularized the parser backend slightly to have the needed hooks
Modified the timestamp format slightly to enable arbitrary postion for
second fractions
Added a regex based seeking parser for textfiles as frontend alternative
to text_import_scanner.l
Regex is using the GLib implementation
Supported frame-data formats are bin, hex, oct and base64
Regex based importing UI
Fixed Meory-leak in ImportTextDialog::exec()
A new tab was added to the text_import ui to accomodate the new fields
Hints are available and styled accordingly
2021-03-26 06:44:25 +00:00
Jaap Keuter 020c90fd36 Text Import: update code comments and help texts
From the updates to text2pcap take the updates to the code comments and
apply them here as well. This also applies to the User Guide help texts.

Change-Id: I4e73fb1372ea0c1866c6d0fee7c14bc645fbe1b1
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/31636
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-21 21:03:49 +00:00
Guy Harris 0946518780 Update comments, get rid of IMPORT_MAX_PACKET.
Get rid of the IMPORT_MAX_PACKET #define; just directly use
WTAP_MAX_PACKET_SIZE_STANDARD, to match what text2pcap.c does.

Update comments in text2pcap.c and ui/text_import.c to say the maximum
packet size is WTAP_MAX_PACKET_SIZE_STANDARD.

Change-Id: I34118f76426d1416fccf43b2a356ad8d200de19b
Ping-Bug: 15292
Reviewed-on: https://code.wireshark.org/review/30945
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-06 16:39:17 +00:00
Dario Lombardo e655b9acf9 import: add export_pdu dummy header feature.
When importing a file from hex dump, this change adds a way to
add a custom dummy header. It's an export_pdu header which uses
one single tag: the protocol name. This allows to call directly
a dissector without more dummy headers.

Example: it can be used to call the DNS dissector without fake
eth/ip/udp headers.

Change-Id: I12fd6d09a131acd9bd1f0d7c4c8aefcd0d718b26
Reviewed-on: https://code.wireshark.org/review/30403
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-31 13:17:10 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
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-02-08 14:57:36 +00:00
Dario Lombardo e5f4ef0c42 ui: use SPDX identifiers.
Change-Id: I6b05399395bcc35e59b73b4030ba4a05711a7b1a
Reviewed-on: https://code.wireshark.org/review/25565
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-02 13:39:04 +00:00
Guy Harris d0865fd619 Allow bigger snapshot lengths for D-Bus captures.
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-06-05 05:28:26 +00:00
Pascal Quantin e1b14fbcfe text_import: the maximum frame length should be WTAP_MAX_PACKET_SIZE
Change-Id: I41989e8b5fd273c518f786ca74683b9284d9403e
Reviewed-on: https://code.wireshark.org/review/20747
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-03-28 05:06:58 +00:00
Guy Harris 59816ef00c Make the Flex scanners and YACC parser in libraries reentrant.
master-branch libpcap now generates a reentrant Flex scanner and
Bison/Berkeley YACC parser for capture filter expressions, so it
requires versions of Flex and Bison/Berkeley YACC that support that.

We might as well do the same.  For libwiretap, it means we could
actually have multiple K12 text or Ascend/Lucent text files open at the
same time.  For libwireshark, it might not be as useful, as we only read
configuration files at startup (which should only happen once, in one
thread) or on demand (in which case, if we ever support multiple threads
running libwireshark, we'd need a mutex to ensure that only one file
reads it), but it's still the right thing to do.

We also require a version of Flex that can write out a header file, so
we change the runlex script to generate the header file ourselves. This
means we require a version of Flex new enough to support --header-file.

Clean up some other stuff encountered in the process.

Change-Id: Id23078c6acea549a52fc687779bb55d715b55c16
Reviewed-on: https://code.wireshark.org/review/14719
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-03 22:21:29 +00:00
Guy Harris dd6a74894f Pull the invocation of the Lex scanner into common code.
Instead of text_import_setup() and text_import_cleanup() routines, and
the actual scanner invocation being done in the dialog box, have a
text_import() routine that does all the work.

Change-Id: Ifd8a999618dbb411d613e6596484e4c2e013431d
Reviewed-on: https://code.wireshark.org/review/14647
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-27 02:21:19 +00:00
Guy Harris 71c603b2fc Clean up more includes of wtap.h.
Change-Id: Ie53b64f7e5b39a50dffb62fc0b886da71e0a3bd2
Reviewed-on: https://code.wireshark.org/review/13066
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-06 00:25:19 +00:00
Guy Harris a1b1c8bed5 Revert "Refactor Wiretap"
This reverts commit 1abeb277f5.

This isn't building, and looks as if it requires significant work to fix.

Change-Id: I622b1bb243e353e874883a302ab419532b7601f2
Reviewed-on: https://code.wireshark.org/review/1568
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-05-09 05:21:01 +00:00
Michael Mann 1abeb277f5 Refactor Wiretap
Start of refactoring Wiretap and breaking structures down into "generally useful fields for dissection" and "capture specific". Since this in intended as a "base" for Wiretap and Filetap, the "wft" prefix is used for "common" functionality.

The "architectural" changes can be found in cfile.h, wtap.h, wtap-int.h and (new file) wftap-int.h. Most of the other (painstaking) changes were really just the result of compiling those new architecture changes.

bug:9607
Change-Id: Ife858a61760d7a8a03be073546c0e7e582cab2ae
Reviewed-on: https://code.wireshark.org/review/1485
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-05-09 03:04:39 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Chris Maynard 2603ad7e44 Match the new text2pcap max packet import size of 65KiB-1 from r48738.
svn path=/trunk/; revision=48750
2013-04-05 14:30:33 +00:00
Michael Tüxen 26bdb4f056 Add support for the initial direction indication. Irene will hook
it up to the GUI soon.

svn path=/trunk/; revision=48696
2013-04-02 12:15:42 +00:00
Alexis La Goutte 96cebe806a Fix indent and add Modelines info for new common ui source file(s)
svn path=/trunk/; revision=45763
2012-10-24 15:52:08 +00:00
Gerald Combs 3069f22bd1 Add a text import dialog. Use libui.
svn path=/trunk/; revision=44956
2012-09-17 23:40:53 +00:00
Gerald Combs 762e5ac93f Create a common libui using CMake similar to what we do with Autotools.
Move the GTK+ text import code to the common UI directory. Create
wtap_encap_requires_phdr() from code in file_import_dlg.c.

svn path=/trunk/; revision=44904
2012-09-14 20:23:18 +00:00