aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/packet_list.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-02-24Qt: Only set Packet List style sheet when relevant prefs changeJohn Thacker1-3/+0
Add a colorsChanged signal/slot, more precise than the generic preferencesChanged signal, and only call it when one of the color related preferences have changed. Connect it to the packetList::colorsChanged() function, instead of calling that whenever preferencesChanged() is called. We could eventually move the signals and slots some of the other GUI widgets to this. Send that signal before handling preferences that change dissection and freeze the packet list, so that when we restore the column widths due to Qt bug 122109 it takes effect. The packet_list_hover_style preference affects colors, not the layout, despite its presence in the GUI layout module.
2024-02-24Qt: Work around QTBUG-122109 when applying packet list style sheetJohn Thacker1-1/+18
https://bugreports.qt.io/browse/QTBUG-122109 A bug introduced by the fix for https://bugreports.qt.io/browse/QTBUG-116013 causes all visible sections to reset to the default section size whenever a style sheet is applied (even if defaultSectionSize didn't change.) Make sure that before applying a style sheet we prevent our recent column widths from being updated, and then restore column widths from the recent values afterwards. This affects versions 6.5.4 (commercial only, 6.5.3 is the last free release) and 6.6.1 and 6.6.2.
2024-02-09recent: Keep recent column width in sync with prefsJohn Thacker1-2/+10
Keep the recent column width list in sync with the order of the prefs.col_list by appending, inserting, and moving the recent column width list at the same time, instead of allowing them to get out of sync (as we use the format for a key.) Fix an issue where column_prefs_add_custom did not always return the position of the column added (when a column number was passed in that was less than the maximum number of columns.) Preparation for the width and alignment part of #15529
2024-02-07Logray: UI updatesGerald Combs1-11/+13
Change some instances of "packet" to "event" in Logray's menu items. Remove "Export Objects" and "Export PDUs" and associated code. Remove the packet diagram menu items and associated code. Remove the "Decode as" menu items and associated code. Use "Selected" instead of the parenthetical plural "Packet(s)" for marking and ignoring. Remove an attempt at plural translation which apparently doesn't work if we don't have a "%n" in the translation string.
2024-01-17Qt: Always enable our "Follow" menu itemsGerald Combs1-3/+0
Disabling them breaks discoverability.
2024-01-11Logray: Add back the "Follow Stream" dialogGerald Combs1-0/+3
Manually revert cd9f7b64c7 and update it to match the changes in 537b49ee41. Disable the packet list and detail follow menus if we don't have any matching protocols.
2024-01-07Qt: Packet List vertical autoscroll onlyJohn Thacker1-1/+13
There are other situations where we want vertical Packet List autoscroll (like keyboard navigation, which is implemented that way), so a1b2a14ad3e185f17042689f817d88b8df3a9c52 isn't quite right. There doesn't seem to be a way to have QTreeView (or anything that inherits QAbstractItemView) scroll vertically but not horizontally. So, let the Packet List autoscroll, and when scrolling just restore the horizontal value back to whatever it was before.
2023-12-23Qt: Set Packet List autoscroll offJohn Thacker1-19/+2
We generally want Qt (horizontal) auto scroll off in the Packet List (56625dd4562d89f711ab68caa8cf849509b0970f) but reverted that change in (df83e45084f7a8430225f646a03d1974b188d3ca) because we needed to scroll vertically for Go To Packet and a few other cases when selecting a packet, and auto scrolling did that for us. Commit 97ae7cdf2fa1172ae6e0bcb6533bcb8a6b3b085e made it so that we manually position the selected packet at the center, so we can turn autoScroll off since we're doing it ourselves. By doing so, we can remove our workarounds for preventing horizontal autoscroll. Fix #19551
2023-11-02Qt: Enforce Minimum Qt version 5.11John Thacker1-10/+0
We already strongly recommend Qt version 5.12 and enforce 5.10. Commit 06cd84a6e9f8bd0807cca35595b94b07de254b07 said "[a]lthough build support for 5.10 and 5.11 is not being removed at this point, it might be for 4.x at a later time." Move to enforcing 5.11, and update macos-setup for that as well. Remove the QT_VERSION_CHECKs for 5.10 and 5.11 (except in qcustomplot.) Hold off on enforcing 5.12 for now, because there isn't any code that needs 5.12 or greater (there are two places for a workaround for Qt 5.12.0 through 5.12.5), and because Debian Buster is on Qt 5.11.3. There are not any known supported OS distributions on Qt 5.10.
2023-10-15Lua context commands: only populate for single frame selectionMartin Mathieson1-1/+3
2023-10-03Find: Switch search_pos to the start byteJohn Thacker1-2/+10
There's a lot of potentially confusing arithmetic from setting search_pos to the last byte of a match. We can always test search_len against zero to see if we actually had a match for hightlighting purposes. (The ordinary byte searches won't find zero length matches, but the regex search might, and not even necessarily at the start of the bytes if there's a lookbehind term, and currently they're handled incorrectly.) We can't find fields with length zero based on an offset currently anyway. (If we tried, would we match fields that contained the byte before or after the zero length offset?) Perhaps we shouldn't allow zero length regex matches for packet byte searches at all; PCRE2 has an option to prevent such matches.
2023-10-01Find Packet: Find packet details multiple matches in a frameJohn Thacker1-0/+22
When searching packet details with Find Packet, step through each field that matches the search, using the currently selected field as a starting point for searching the current frame before going onto another frame. Handle both forwards and backwards, so that backwards searching initially finds the last match in each frame. Part of #11269. (Packet bytes searching should presumably also be handled.)
2023-08-18Qt: Remove tail update timer from packet listJohn Thacker1-34/+17
We have a preference that controls how often we get capture updates, so there's no reason (nor CPU savings) to have a separate timer checking for when to auto scroll. We can just scroll to the bottom whenever we insert new rows (which doesn't happen any faster than prefs.capture_update_interval, which the user can change.) This makes the auto scrolling smoother, instead of having a gap where rows have been inserted but not scrolled yet. If the scrolling is too fast, a user can change the preference.
2023-08-18Qt: Preserve horizontal scroll extent for Home/EndJohn Thacker1-1/+3
Preserve the horizontal scroll extent when scrolling with Home/End, the same as for other keyboard movement.
2023-08-18Move autoscroll preference behavior to recentJohn Thacker1-5/+5
Make whether or not we are autoscrolling a "recent" item. Make the selection of automatically scrolling in the Capture Options tab actually have an effect (right now it does nothing.) Switching to a recent also means that the command line "-l" option actually turns on automatic scrolling if the recent value is off (currently it has no effect because it is always later overridden by the preference value). Document our behavior that autoscrolling, if turned on, temporarily turns off when manually scrolling upwards or Go'ing directly to a packet (so that a user can examine a chosen packet.) This temporary effect does not change the "recent" status, which changes only when the user directly turns the behavior on or off (through the capture window, the button or menu item, or the -l command line option.)
2023-08-12Qt: Fix Go First Packet turning off autoscrollJohn Thacker1-4/+2
An uncheckable QAction always passes "false" as a parameter when sending the triggered signal. That means that even when the actionGoFirstPacket was user selected, it was still calling PacketList::goFirstPacket with user_selected as false, so auto scrolling was never being turned off. The user selected parameter was only added to goFirstPacket in commit d8565d8f1b8bf9653e0ff8847b72765861eff5c2 to distinguish the action being triggered by the user from packet_list_select_first_row being called programmatically when starting a new capture. However, f210edeaf04c17da1e209518aae0e009e1164a73 removed packet_list_select_first_row() and instead packet_list_select_row_from_data(NULL) is called, which does not call goFirstPacket. So the user selected parameter is no longer needed, and removing it makes the goFirstPacket behavior turn off autoscrolling as desired. Related to #19274
2023-08-12Qt: Turn off autoscroll when the preference is offJohn Thacker1-3/+17
The preference prefs.capture_auto_scroll affects the initial state of actionGoAutoScroll, but actionGoAutoScroll can be triggered without changing the preference, which means it's possible to be autoscrolling with the preference off. In such a case, we still want to turn off autoscrolling when scrolling up or using a Go to Packet action. Eventually the "are we actually autoscrolling" should be a recent setting, and the preference should just control the "start auto scroll when the user sets the vertical scrollbar to the end" behavior. Related to #19274
2023-07-25epan: Register dynamic column fields and make them filterableJohn Thacker1-0/+2
Make the text of each registered column a FT_STRING field that can be filtered, prefixed with _ws.col - these work in display filters, filters in taps, coloring rules, Wireshark read filters, and in the -Y, -R, -e, and -j options to tshark. Use them as the default "Apply as Filter" value for the columns that aren't handled by anything else currently. Because only the columns formats that actually correspond to columns get filled in (invisible columns work), register and deregister the fields when the columns change. Use the lower case version of the rest of the COL_* define for each column as the field name. This adds a number of conditions to "when are the columns needed", including when the main display filter or any filter on a tap is using one of these fields. Custom columns are currently not implemented. For custom columns, the tree then has to be further primed with any fields used by the custom columns as well. (Perhaps that should happen in epan_dissect_run() - are there any cases where we construct the columns and don't want to prime with any field that custom columns contains? Possibly in taps that we know only use build in columns.) Thus, for performance reasons, you're better off matching an ordinary field if possible; it takes extra time to generate the columns and many of them are numeric types. (Note that you can always convert a non-string field to a string field if you want regex matching, consult the *wireshark-filter(4)* man page.) It does save a bit on typing (especially for a multifield custom column) and remembering the column title might be easier in some cases. The columns are set before the color filters, which means that you can have a color filter that depends on a built-in column like Info or Protocol. Remove the special handling for the -e option to tshark. Note that the behavior is a little different now, because fixed field names are used instead of the titles (using the titles allowed illegal filter names, because it wasn't going through the filter engine.) For default names, this means that they're no longer capitalized, so "_ws.col.info" instead of "_ws.col.Info" - hopefully a small price in exchange for the filters working everywhere. The output format for -T fields remains the same; all that special handling is removed (except for remembering if someone asked for a column field to know that columns should be constructed.) They're also set before the postdissectors, so postdissectors can have access. Anything that depends on whether a packet and previous packets are displayed (COL_DELTA_TIME_DIS or COL_CUMULATIVE_BYTES) doesn't work the way most people expect, so don't register fields for those. (The same is already true of color filters that use those, along with color filters that use the color filter fields.) Fix #16576. Fix #17971. Fix #4684. Fix #13491. Fix #13941.
2023-06-20Qt: Freeze packet list early on preferences changeStig Bjørlykke1-6/+39
Freeze the packet list early when changing profile and when closing the preferences dialog to avoid updating column data before doing a full redissection. The packet list will be thawed when redissection is done. Related to #19079.
2023-06-14Qt: Use selectionModel() to fetch selected rowsStig Bjørlykke1-1/+1
Change to use selectionModel()->selectedRows() to fetch the frozen selected rows used when moving a column.
2023-06-13Add a capture file state for a pending readJohn Thacker1-1/+1
When not updating the packet list during a capture, the capture file structure isn't set up, but there is a pending capture. We currently treat that as "finished reading", but that means that other code assumes that all the structures are set up and can crash, and also don't prompt regarding unsaved packets when trying to close Wireshark. Add a state for FILE_READ_PENDING that sometimes should be treated similar to FILE_CLOSED and sometimes should be treated similar to FILE_READ_IN_PROGRESS. This fixes a crash when enabling "update packet list during a capture" while a capture is in progress, as well a crash when applying a filter while a capture is in progress but real time packet list updates are off. Keep track of the number of packets that the capture child has reported that haven't been read yet, so that the capture statistics stay accurate even if the pref is toggled. Also run the main status bar statistics at the end, so that if any packets are processed in cf_finish_tail() they are reported. This also restores status bar statistics for when update packet list during a capture is off, which 461fb517d1f75f607eb3cb670b87754bc24b82ca accidentally disabled. Fix #4035
2023-06-12Qt: Position selected packet at centerStig Bjørlykke1-0/+3
Position selected packet at center after setCurrentIndex() when Go To Packet, after redissect packets and after moving column. This is better than position at bottom in most cases.
2023-05-28Qt: Scroll to selected packet after column moveStig Bjørlykke1-5/+9
Restore current index after moving a column to fix scroll back to the selected packet. Fixes #16251
2023-05-24Fix build on case-sensitive filesystemsJoão Valverde1-1/+1
Rename some files to match case-sensitive paths on Fedora.
2023-05-16Qt: Redissect packets when applying a time shiftJohn Thacker1-1/+1
Packet fields like tcp.time_relative, smb2.time, and SRT tables depend on file-scoped data from other frames often computed in the first pass. Thus redissection is necessary after applying a time shift. Fix #18999
2023-05-08prefs: Remove type of GUI preferenceStig Bjørlykke1-2/+2
The type of GUI preference is unused. Remove prefs.gui and rename prefs.gui_qt_* to prefs.gui_*.
2023-04-05TCP: Fix coredumps related to 'Force interpretation to selected packet(s)'Eugène Adell1-0/+5
2023-03-25Fix leak in Find Packet searching tree detailsJohn Thacker1-4/+1
The string used to search the selected packet's protocol tree for the field we already found is leaked. The function prototype is prone to leaks; all the components of the match_data are filled in inside the function, and it only needs to return the field info. Restructure it so that the match_data is created (and the string freed) inside the function, and only the field_info is returned.
2023-03-12Qt: Create Follow Stream menu dynamicallyJohn Thacker1-9/+9
Remove follow_type_t and use proto IDs in its place, since follow streams are registered via proto ID. Add looking up registered follow stream types by proto ID, and creating FollowStreamDialog using proto ID. Dynamically create the Follow actions based on the registered follow streams. Dissectors, including plugins, can now self-contain everything necessary in order to add follow support (though shortcuts, overriding the menu name, and special handling for "is the protocol in the frame" still requires a few manual changes.) The Conversation (and Endpoints) Dialog no longer need to know anything special about whether UDP and TCP can be followed. For example, this means that DCCP streams can automatically be followed from the Conversation window.
2023-02-17Qt: Ensure that add frame comments trigger recoloring, count updatesJohn Thacker1-96/+36
Add functions to PacketListRecord to invalidate a single record's colorization and column strings, used for a record is modified in a way that needs to trigger redrawing, but we don't need to redraw all packets. Move the functionality for adding, deleting, and setting frame comments into PacketListModel, operating on QModelIndexes (or on all physical rows in the case of deleting all comments from a file.) Trigger recolorization of any record with an updated comment. Only set a block as modified when deleting comments if we actually deleted comments. This avoids marking a file as modified if we delete all comments from all frames, or all comments from selected frames, when those comments do not actually have frames. If cf_set_modified_block is used to modify a block that is already modified, it can't update the comment count. In that case, return false and have the callers update the comment count. (It already has a return value, which is always true.) This avoids having the GUI warning about saving into a format that doesn't support comments when comments have been added and then removed. Note that, unlike with time references and time shifts, there are no fields (and hence no columns nor color filters) that depend on whether other fields have comments. If for some reason some were added, then the model data for all frames would have to be updated instead. Since there aren't, we don't need to redrawVisiblePackets, but we do need to drawCurrentPacket to ensure the packet details are redissected. Fix #12519
2023-02-15Qt: Fix scrollbar vanishing when adding columnsJohn Thacker1-8/+3
Don't call resize in applyRecentColumnWidths(). It doesn't seem to be necessary in Qt5 or Qt6 to stretch the packet list last column when the main window is wider than the total columns, and it doesn't seem to be necessary to get the horizontal scroll bar to appear if the columns are wider than the window frame either. (When adding and removing columns, resizing the main window, etc., the columns all behave as expected, including if the wide Info column is removed). Resizing the packet list makes the scrollbar (and minimap) disappear. It reappears when selecting another packet, but since it's not necessary to resize, don't. Fix #13597
2023-02-08Qt: Fencepost error in minimap/intelligent scrollbarJohn Thacker1-1/+1
The location of the next line should be based off one row larger than the current row. This fixes an issue where all the lines drawn in the intelligent scrollbar are off by one - the color intended to be drawn for the first packet never appears, the first packet corresponds to the line for the second packet, etc., and there is a line at the bottom that can never be colored in. Fix #18850
2023-02-07Qt: Add ability to cancel sortingJohn Thacker1-0/+7
Add the ability to cancel sorting. Since we now parse user inputs during the sort, test and set the capture file read lock. Try to sort in PacketList::captureFileReadFinished, since now sorting during thawing won't happen if it's in the middle of a rescan. Fix #17640
2023-01-22Logray: Remove the "Follow Stream" dialogGerald Combs1-11/+13
We don't reassemble log data into streams, so remove the "Follow" dialog (for now, at least).
2023-01-19Qt: Clear selection, not current, in drawCurrentPacketJohn Thacker1-1/+1
QItemSelectionModel tracks both the selected index and the current index. PacketList redraws when the *selected* index changes, not the current index. Clearing the current index, and then marking the same packet as selected and current fires currentChanged but not selectionChanged. So drawCurrentPacket needs to call clearSelection(), not clearCurrentIndex(), in order to trigger a redissection of the currently selected packet and update the packet details. For example, if you mark or unmark the currently selected frame, this causes the packet details to update. Cf 52955b9c43a99942b3, which fixed the same issue but for Find Packet. Fix #14330.
2023-01-19Add follow websocket stream supportMikael Kanstrup1-0/+1
The websocket protocol masking feature makes follow TCP stream on websocket traffic show masked payload. To easily view unmasked and reassembled websocket payload add follow websocket stream support.
2023-01-07Qt: Add a pref for column text caching, and have it affect sortingJohn Thacker1-0/+6
Introduce a preference for the number of rows whose column text can be cached, and allow sorting of the packet list only when the number of displayed rows can fit in the cache. This preference only has an effect for sorting based on columns that require dissection and caching the column text. This reduces the number of dissections from O(N log N) to N. Subsequent sorts are even faster. Columns based on frame data are unaffected, as they sort much faster as dissection is not required. Set the size of the QCache introduced in 8c6854fb653cf58df39 based on this preference. Send a temporary status message to the status bar if we try to sort but there are too many rows, explaining why sorting did not happen and that the layout preferences can be changed. Ping #18741
2022-12-07WSLUA: Add new lua function register_packet_menu()Moshe Kaplan1-3/+26
This adds support to Wireshark for custom context menus for packets, so that when a packet's context menu is opened (e.g., by right-clicking), Wireshark can support doing things like "run a program" or "open a URL" with a field from the packet as a parameter. Note that this is similar to ArcSight's integration commands feature. For example, it could be used like the following: ``` ROBTEX_URL = "https://www.robtex.com/dns-lookup/" local function search_robtex(...) local fields = {...}; for i, field in ipairs( fields ) do if (field.name == 'http.host') then browser_open_url(ROBTEX_URL .. field.value) break end end end register_packet_menu("Search host in Robtex", search_robtex, "http.host"); ``` Fixes issue #14998
2022-12-06Qt: Don't use QString::toLocal8Bit().Gerald Combs1-2/+2
As the QString::toLocal8Bit() documentation says, "On Unix systems this is equivalen to toUtf8(), on Windows the systems current code page is being used." This is problematic for the Packet Comments dialog, since the comments need to be UTF-8 as per the pcapng specification. Use toUtf8() instead there and in the Import Text dialog. Remove the toLocal8Bit() calls from the Extcap Options dialog since they weren'nt needed. Blind attempt at fixing #18698.
2022-11-05Packet List: preserve horizontal scroll extent for PgUp/PgDnMartin Mathieson1-1/+4
2022-11-02epan: Properly generate filter expressions for custom columnsJohn Thacker1-40/+11
Properly generate filter expressions for custom columns by using proto_construct_match_selected_string on each value and then joining them together later instead of trying to split the column expression value. This ensures that escaping is done properly for display filter strings, that commas internal to field values are not confused with commas between occurrences, that for multifield columns we can distinguish which field each value matches, etc. It's not entirely clear whether AND or OR logic is appropriate for multiple occurrences; currently OR is used. Bump glib requirement to 2.54 for g_ptr_array_find_with_equal_func (this doesn't drop support for any major distribution that already meets our other library requirements, like Qt.) Fix #18001.
2022-10-31Qt: Generate filter expressions for columns with multiple occurrencesJohn Thacker1-9/+23
Generate filter expressions for columns with multiple occurrences by using the membership operator (which is semantically OR). It's not clear if this approach makes more sense than AND; there's use cases for both. Don't do this for multifield custom columns, since we don't know which values were found by which field. That takes changing the column logic in several places. Ping #18001
2022-08-13epan: Rearrange column includesJohn Thacker1-1/+0
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-02Qt: fix speling.Guy Harris1-2/+2
2022-08-02Make sure we don't create comment options longer than 65535 bytes.Guy Harris1-1/+26
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-07-18Qt: Fix jump on packetlistRoland Knall1-1/+13
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-03Qt: Do not spin new event loop on menu showTomasz Moń1-1/+2
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-06-29Qt: Reduce PacketListHeader complexityRoland Knall1-2/+2
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-28Ui: Cleanup row number and select packetRoland Knall1-12/+5
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-28Ui: Further simplify ws_ui_utilRoland Knall1-18/+6
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