Commit Graph

327 Commits

Author SHA1 Message Date
John Thacker c7a136a5c0 epan: Rearrange column includes
Move all the declarations of routines that are internal and
not for use by dissectors from column-utils.h column-info.h
Move the column max length defines into column-utils.h because
dissectors might need that

Since packet.h already includes column-utils.h, dissectors don't
need to include column-utils.h anymore.
Remove or downgrade a few other column header includes that are
unnecessary.
2022-08-13 19:37:28 +00:00
Guy Harris 20a013a8af Qt: fix speling. 2022-08-02 23:31:44 -07:00
Guy Harris 71f32ef2a8 Make sure we don't create comment options longer than 65535 bytes.
Check in both editcap and Wireshark to make sure that comments have
fewer than 65536 bytes before accepting them.

This shoudl fix #18235, although there should also be checks in
libwiretap to catch cases where the user interface code doesn't do the
check (it should be done in the UI so that the user gets notified
appropriately).
2022-08-02 16:38:49 -07:00
Roland Knall b90fb0da55 Qt: Fix jump on packetlist
If the packetlist is navigated via the up/down keys, the viewport
may jump, if the cell that is being navigated to, has content that
is greated than what is currently displayed

Fixes #16363
2022-07-18 15:25:12 +02:00
Tomasz Moń d1f7aa5acb
Qt: Do not spin new event loop on menu show
There is no need for nesting event loops when showing menus. Show menus
asynchronously to limit possibilities of hard to debug problems related
to re-entering event loop.
2022-07-03 13:41:30 +02:00
Roland Knall 413b383224 Qt: Reduce PacketListHeader complexity
Propagating the capture_file was required for a single
function as was the cast for the model. Both are not
needed, as the functionality can be either moved to
PacketListModel or was already included in PacketList
2022-06-29 14:47:05 +02:00
Roland Knall c3b2cec3f2 Ui: Cleanup row number and select packet
Remove unneeded row number in capture file. The packet list is
the only object that should know the correct number, propagating
it further only complicates things. At the same time, rework
cf_select_packet to select the packet based on frame_data not on
the row (which can be unreliable).
2022-06-28 14:56:06 +02:00
Roland Knall f210edeaf0 Ui: Further simplify ws_ui_util
Remove duplicate functionality for jumping to packet and
remove unused function to move to the end. Furthermore
move the code for redraws of visible packets directly
into the calling code
2022-06-28 14:39:27 +02:00
Roland Knall ef8ed9dff9 Ui: Remove time column reformat callback
The code can be placed directly to packet list model
and does not need to be a generic callback
2022-06-28 14:23:05 +02:00
Roland Knall 1d42fcdd76 Ui: Remove call to recoloring
No callback needed, we can call the model directly
2022-06-28 14:06:49 +02:00
Roland Knall b6226cb136 Qt: Better handle sort restriction
Setting sorting enabled/disabled resorts the list. If this happens
too often, sometimes it can lead to the physical view models
not present anymore and therefore crashing.

Ping #18159
2022-06-28 10:12:24 +02:00
Gerald Combs 73770c61b4 Qt: Add a null pointer check.
Don't assume the main window has an SCTP menu.
2022-04-08 19:57:13 +00:00
Gerald Combs 80de95ca71 Qt: Split MainApplication out from WiresharkApplication.
Move WiresharkApplication.{cpp,h} to MainApplication.{cpp,h}. Add back
WiresharkApplication as a thin superclass of MainApplication, similar to
LogsharkApplication. Change all of our wsApp references to mainApp. We
will likely have to change many or most of them back, but that's a
commit for another time.
2022-04-04 09:39:27 -07:00
Gerald Combs 067b3805b7 Qt: Add float suffixes.
Fix

ui\qt\packet_list.cpp(2101,33): warning C4305: 'argument': truncation from 'double' to 'float' [c:\Users\gerald\Development\wireshark\build\ui\qt\qtui.vcxproj]
    ui\qt\packet_list.cpp(2101,33): warning C4305:         tick_color.setAlphaF(0.3); [c:\Users\gerald\Development\wireshark\build\ui\qt\qtui.vcxproj]
    ui\qt\packet_list.cpp(2101,33): warning C4305:         ^ [c:\Users\gerald\Development\wireshark\build\ui\qt\qtui.vcxproj]
2022-03-25 13:36:07 -07:00
Roland Knall f0e4cedd69 Qt: Fix most of Qt6 compile warnings and issues 2022-03-25 11:16:18 -07:00
Roland Knall 9d11321385 Qt: Disable Sorting for the packet List
Allows the sorting to be disabled to avoid painful recalculations if the
sorting has been clicked on by accident.

Fixes #16786
2022-03-17 16:52:53 +01:00
Roland Knall 33151dc928 Qt: Fix overlay scrollbar indicator
The indicator for selected packets is not reflecting the relative
size of that packet inside the map
2022-03-08 10:31:25 +00:00
John Thacker 52955b9c43 Qt: highlight when search result is in the current packet.
Calling setCurrentIndex with QItemSelectionModel::ClearAndSelect clears
the currentIndex, but not the selection, so it doesn't trigger
selectionChanged. However, highlighting depends on the selectionChanged
signal, not currentChanged(), and it's not emitted if we're still on the
same packet/row as the current selection (which can occur if searching
for something that occurs in exactly one packet in a capture.)

Since packet_list_select_row_from_data() cares about where the data
is within the packet, it needs to clear the selection.  Fix #8269
2022-02-11 18:21:35 +00:00
Gerald Combs 6d319297ae Qt: Add a common hover color. 2022-01-03 19:03:46 +00:00
João Valverde 504de90a3c wsutil: Split format_size() enum
Use an enum to select units and a bit flag for the other options,
currently only prefix type.
2021-11-29 22:13:32 +00:00
Tomasz Moń 890555b8bd Qt: Qt6.2 compatibility fixes
Wireshark successfully compiles on Windows with Qt6.2 with following
cmake options:
  -DUSE_qt6=ON -DDISABLE_ERROR=ON

QCustomPlot QT 6.2 patch is taken from QCustomPlot forum post by miccs.
2021-11-29 04:55:12 +00:00
David Perry 389a603fdb Allow adding comments to all selected packets
Allow the user to select multiple packets, and

* add the same comment to all selected packets
* remove all comments from selected packets

A new comment is added to each packet, now that we support multiple
comments per packet.

This is one potential way to address #8713.
2021-09-10 20:47:12 +00:00
Guy Harris dd5907d2a3 Consistently refer to blocks that have been modified as "modified".
"User" sounds as if the blocks belong to the user; at most, the current
user might have modified them directly, but they might also have, for
example, run a Lua script that, unknown to them, modified comments.
Also, a file might have "user comments" added by a previous user, who
them wrote the file and and provided it to the current user.

"Modified" seems a bit clearer than "changed".
2021-07-08 00:05:35 -07:00
David Perry 73087d6fb4 Use wtap_blocks for packet comments
Mostly functioning proof of concept for #14329. This work is intended to
allow Wireshark to support multiple packet comments per packet.

Uses and expands upon the `wtap_block` API in `wiretap/wtap_opttypes.h`.
It attaches a `wtap_block` structure to `wtap_rec` in place of its
current `opt_comment` and `packet_verdict` members to hold OPT_COMMENT
and OPT_PKT_VERDICT option values.
2021-07-07 18:40:24 +00:00
João Valverde 8cf9791679 Replace some lingering references to g_log() 2021-06-19 02:34:36 +00:00
Jim Young d42042fcbb Qt: Add checkbox for enabling/disabling packet-list hover_style
At times the presence of the packet-list hover_style colorization can make
it difficult to determine the state of the packet directly under the mouse
cursor. This forces the user to move the mouse cursor away from the
packet-list row to reveal the next colorization state. The packet-list row
colorization style precedence, from highest to lowest, is: hover_style,
Selected, Ignored, Marked and then coloring rules.

This patch adds a new 'Packet List settings:' checkbox option 'Enable
mouse-over colorization'. By default the supporting preference
`gui.packet_list_hover_style.enabled` will be enabled (TRUE). When this
checkbox is disabled, the packet-list hover_style (mouse-over)
colorization will not be used.
2021-04-21 08:36:27 +00:00
Jim Young 56c540159d packet_list: Promptly reflect changes to frame.marked field
Add redrawVisiblePackets() to respond to user triggered event to
promptly trigger updates to the frame.marked field text when displayed
in the packet list.

Without this patch, if frame.marked is added as a custom column, updates
to the packet lists's frame.marked field text of packets will not be
immediately reflected in the packet list until some other event such as
adding a packet comment or ignoring a frame ultimately triggers
redrawVisiblePackets().
2021-04-04 17:18:13 +00:00
Jirka Novak e75e1fb580 Follow SIP Call: Added Follow SIP Call to Follow menu
Changes:
- epan/follow.c: follow_conv_filter_func has new parameter
  epan_dissect_t *edt, so filter can be generated based on decoded tree
of packet below the cursor
- menu Follow/SIP Call is enabled when sip packet is selected
- value of sip.Call-ID is used as filter for SIP call
- for sharkd it generates filter just 'sip.Call-ID' with no value
2021-03-27 09:02:14 +00:00
Gerald Combs d3f17ee08a Remove modelines in ui/qt.
Remove the editor modeline blocks from most of the source files in ui/qt
by running

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

then cleaning up the remaining files by hand.

This *shouldn't* affect anyone since

- All of the source files in ui/qt use 4 space indentation, which
  matches 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-03-08 18:11:32 +00:00
Thomas Dreibholz 2e7f2ffb7a
Added "Follow DCCP stream" feature.
This pull request includes:
* The "Follow DCCP stream" feature.
* Updated docbook documentation for the "Follow DCCP stream" feature.
* Test for the feature.
* Corresponding packet trace for the test.
2021-02-22 12:48:46 +01:00
Martin Kaiser 0f0b340aa5 PacketList: mouseMoveEvent: fix memory leak
We allocate a QMimeData object at the beginning of PacketList::mouseMoveEvent.
Usually, this object is passed to a QDrag object by calling drag->setMimeData.
In this case, the QDrag object owns the mime data object and frees it when
it's no longer required.

If the mime data object contains no data that can be dragged and dropped, we
reach the end of PacketList::mouseMoveEvent without anyone taking care of
the mime object. We have to free it ourselves in this case.

The problem can be reproduced if you add a custom column for an element that
does not exist in your capture file. Left-click onto the empty column and
drag the empty column entry somewhere. An asan build will then show the
memory leak

Indirect leak of 240 byte(s) in 2 object(s) allocated from:
    #0 0x7f351e153d30 in operator new(unsigned long) (...)
    #1 0x7f3500b79802 in QMimeData::QMimeData() (...)

Indirect leak of 32 byte(s) in 2 object(s) allocated from:
    #0 0x7f351e153d30 in operator new(unsigned long) (...)
    #1 0x5635156dfbc7 in PacketList::mouseMoveEvent(QMouseEvent*) ...
    #2 0x7f3502eb94d7 in QWidget::event(QEvent*) (...)
2021-02-21 13:29:11 +00:00
Stig Bjørlykke 7980f25f99 Qt: Fetch OverlayScrollBar sliderPosition from the real ScrollBar
In OverlayScrollBar return the real ScrollBar sliderPosition to ensure
the correct value is used when handling the actionTriggered signal in
vScrollBarActionTriggered().

This improves turning on and off auto scroll during capture when page
stepping using the packet list slider, because the value is propagated
after this signal.
2021-01-05 08:04:14 +00:00
Pascal Quantin fb2414ae6d Qt: fix some Qt 5.15.2 deprecation warnings 2020-11-25 07:23:21 +00:00
Gerald Combs 1c2fd68e26 Qt: Fix saving+restoring frozen packet list rows.
Use the packet list selection model to save and restore selected rows
when freezing and thawing. Fixes #16770.
2020-10-28 15:36:07 +00:00
Gerald Combs d2da4c7afb Qt: Use … instead of UTF8_HORIZONTAL_ELLIPSIS in translated strings.
Run

$ gsed -i -e 's/\(tr *(.*".*\)" *UTF8_HORIZONTAL_ELLIPSIS/\1…"/' $( ag -l 'tr *\(.*" *UTF8_HORIZONTAL_ELLIPSIS' )
$ gsed -i -e 's/\(tr *( *\)UTF8_HORIZONTAL_ELLIPSIS *"/\1"…/' $( ag -l 'tr *\( *UTF8_HORIZONTAL_ELLIPSIS *"' )

in ui/qt. As discussed in #16812, the UTF8_ macros were required at one
time because we only allowed ASCII in our source code. However, that
requirement has since been relaxed and Qt's translation framework
doesn't handle concatenating strings and macros very well.
2020-10-01 06:40:14 +00:00
Stig Bjørlykke a6d8a2c118 Qt: List all protocols in PacketList "Protocol Preferences"
Show all protocols which has preferences in the packet list context
menu "Protocol Preferences".

Change-Id: I72e2ed95db36cc6d817ca44db214782f075d55d6
Reviewed-on: https://code.wireshark.org/review/37666
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2020-07-03 06:12:40 +00:00
Tomasz Moń 63a8ac5210 Qt: Respect user preference to hide packet list
Instead of hiding whole packet list widget when freezing, hide only the
header. This prevents unwanted column resizes while keeping the widget
on screen while capture file is loading.

Prevent flickering by showing master_split_ only after all widgets are
in correct place.

Ping-Bug: 16063
Ping-Bug: 16491
Change-Id: I3bb0763c44b23b1e4118003502d4bf3903591f34
Reviewed-on: https://code.wireshark.org/review/37159
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-08 04:07:35 +00:00
Tomasz Moń 1d0b233f12 Qt: Stretch last packet list header section
Programatically show the master split widget before elements are added
to prevent pending resize events from resizing packet columns to insane
widths (in my case orders of magnitude higher than display resolution)

Such resize was occuring when loading capture file if configuration file
included hidden columns (e.g. 55 defined columns, 8 visible). The resize
was not directly visible to user. Resize event call chain included calls
to recent_set_column_width() that changed width stored in configuration.
Modified configuration column width value would become effective after
user added or removed columns.

Hide PacketList when freezing and show it when thawing. Do not call
setUpdatesEnabled(false) as it leads to widget/preferences columns
missynchronization.

Clear packet list before freeing frame data. This prevents accessing
freed memory in ProtoTree on file close if packet list was in focus and
the next widget to get focus is packet details.

Ping-Bug: 16063
Bug: 16491
Change-Id: I2c21d928348681af1793b3263815c81ee73d41b0
Reviewed-on: https://code.wireshark.org/review/37029
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-06 03:50:18 +00:00
Martin Kaiser abcb95ffe2 PacketList: ignoreFrame: remove write-only variable
Like in markFrame, the integer list of selected rows is not used in
ignoreFrame. Remove it.

Change-Id: Ic2bf4b1d2d330767370a2e831e321e285cb00e91
Reviewed-on: https://code.wireshark.org/review/36805
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-13 10:20:24 +00:00
Martin Kaiser 7044c6101d PacketList: markFrame: remove write-only variable
The "rows" variable is populated with the indices of all selected rows.
It seems that rows is never read and can be removed.

(In parallel, there's QModelIndexList frames. This list is used
when it comes to actually marking the selected packets.)

Change-Id: If2b97a2f5d87fe24717b9ad56444e2a779e0b3fc
Reviewed-on: https://code.wireshark.org/review/36804
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-13 10:20:06 +00:00
Tomasz Moń 1d20a875e4 Qt: Fix bug causing hidden columns to be displayed
Set capture file for model and header before columnsChanged() is called
to prevent skipping model reset in PacketListModel::resetColumns() due
to cap_file_ being NULL.

Do not strech last section in packet list header. This prevents
QHeaderViewPrivate::resizeSections() from messing up the column sizes
via resize events. For some reason (unknown to me) underlying
QHeaderView implementation has different idea about the number of
visible columns than our code.

Ping-Bug: 16063
Change-Id: I482c1080adb418b7922ee99d357d4962dc086026
Reviewed-on: https://code.wireshark.org/review/36120
Petri-Dish: Tomasz Moń <desowin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2020-03-15 12:07:06 +00:00
Dario Lombardo a20fea02fc Qt: add initializers.
CID: 1457926, 1446253.

Change-Id: Ia9e727fd9d030b6a5db74aa5a9343c66df8c5e9b
Reviewed-on: https://code.wireshark.org/review/36065
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2020-02-09 17:27:48 +00:00
Peter Wu 6bbd61860b Qt: make Decode As from packet list functional again
The "create_new" property was never set which prevented a new row from
being created once the dialog is opened.

Change-Id: I19c793ebd219bb58cb34f4d67451660ace51aa32
Fixes: v3.1.1rc0-254-gf402b4cdaa72 ("Qt: PacketList call DecodeAsDialog directly")
Reviewed-on: https://code.wireshark.org/review/36020
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-02-05 04:34:20 +00:00
Dylan Ulis d5cfa99217 Allow Multiselection of packets to work during live captures
During live capture, the previous logic was to jump to row 1 when there is no
'current_frame'. When multiselect is active, there is no 'current_frame', so
it would always jump back to row 1, when >1 packet was selected.

Bug: 16293
Change-Id: Id1c9eb36fcae83f67ae342be6f9dfc1405ce7025
Reviewed-on: https://code.wireshark.org/review/35747
Reviewed-by: Michael Mann <mmann78@netscape.net>
2020-01-12 22:33:42 +00:00
Peter Wu 2d12ec67a3 Qt: fix erratic expansion of tree item when switching packets
ProtoTree::setRootNode() is designed to update the model with the new
packet tree, and additionally expand tree items in its view. When the
current selected packet is changed, it must use this method to ensure
that collapsed trees are properly expanded. Fix this regression.

It was not entirely clear that framesSelected can no longer use previous
state, so document it explicitly. Remove the call to QTreeView::reset(),
it ends up calling QAbstractItemView::reset() which touches the
selection model that refers invalidated proto_node memory. The reset
function of the view is automatically called the model is reset, so the
call was not needed anyway.

Test: open test/captures/tls13-rfc8446.pcap, expand TLS, TLS Record, and
select "Content Type". Change from frame 1 to 2, and then 3. Observe
that the expanded state remains constant with no flickering. In frame 3,
observe that the tree remains expanded even if no item is selected.

Change-Id: I0c820711f1a62aa51ac100f8ac5c89265c51eb18
Fixes: v3.3.0rc0-6-gcfee0f8082 ("Qt: Remove frameSelect signal")
Reviewed-on: https://code.wireshark.org/review/35230
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-28 14:13:57 +00:00
Peter Wu 076334a70c Qt: fix packet selection when modifiers are pressed
When the Conversation Shortcut (Ctrl-1) was pressed, the current packet
suddenly became deselected. Similarly for Go to First Packet (Ctrl-Home)
and Go To Next Packet (Ctrl-.).

Changing the selection mode to ExtendedSelection has as side-effect that
setCurrentIndex is affected by modifiers such as Ctrl and Shift. Since
Ctrl acts as a toggle, the current selection becomes empty and no
packets are selected. Fix this by explicitly requesting the selection to
be replaced.

Tested as follows:

 1. wireshark -r test/captures/dhcp.pcap
 2. Select packet 3.
 3. Press Ctrl-1, Ctrl-2. (Colors change, the packet remains selected.)
 4. Press Ctrl-Home, Ctrl-Down, Ctrl-.
 5. Observe that the packet details list is populated.

Change-Id: I17f00e7fbc6e63ad52b6a0543fd850b473e506a2
Fixes: v3.1.1rc0-762-gb3f240dbf8 ("Qt: Multiselection in PacketList")
Reviewed-on: https://code.wireshark.org/review/35203
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-25 13:38:37 +00:00
Roland Knall cfee0f8082 Qt: Remove frameSelect signal
As all frameSelect signals now transport a QList<int> of selected
frames, use this instead

Change-Id: I1888e45a4df997920aebde9706ca0ae803bdba03
Reviewed-on: https://code.wireshark.org/review/35176
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-21 10:59:05 +00:00
Roland Knall f211624fa6 Qt: Display selected rows in overlay bar
Indicate all selected rows in the overlay bar for the PacketList

Change-Id: Icddf8607b59bde12701a7e7983df6acbf26e0d23
Reviewed-on: https://code.wireshark.org/review/35161
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-20 16:22:02 +00:00
Roland Knall 0d534873dc Qt: Speed up selection handling
Improve the speed for selection checks in PacketList and MainWindow

Change-Id: Ic3a413624463a798b5d13102965f75c7b1347b5f
Reviewed-on: https://code.wireshark.org/review/35160
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-20 16:21:51 +00:00
Mike78 b7ce4e3f7a Qt: Include Column Headings with Edit -> Copy -> Plain Text / CSV
Bug: 16215
Change-Id: Ie59aa354be055831055a294724f8d7b800d35d90
Reviewed-on: https://code.wireshark.org/review/35153
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-11-20 15:04:15 +00:00