| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
wireshark_main_window.h
Go to the documentation of this file.
1
10#ifndef WIRESHARK_MAIN_WINDOW_H
11#define WIRESHARK_MAIN_WINDOW_H
12
39#include <stdio.h>
40
41#include <config.h>
42
43#include "ui/ws_ui_util.h"
44#include "ui/iface_toolbar.h"
45#ifdef HAVE_LIBPCAP
46#include "ui/capture_opts.h"
47#endif
48#include "ui/plugins/include/plugin_if.h"
49
50#include <epan/timestamp.h>
51
52#include <capture/capture_session.h>
53
54#include <QMainWindow>
55#include <QPointer>
56
57#ifdef _WIN32
58# include <QTimer>
59#else
60# include <QSocketNotifier>
61#endif
62
63#include "capture_file_dialog.h"
64#include "capture_file_properties_dialog.h"
65#include <ui/qt/utils/field_information.h>
66#include <ui/qt/widgets/display_filter_combo.h>
67#include "main_window.h"
68#include "rtp_stream_dialog.h"
69#include "rtp_analysis_dialog.h"
70#include "tlskeylog_launcher_dialog.h"
71
72 class AccordionFrame;
73 class DataSourceTab;
74 class CaptureOptionsDialog;
75 class PrintDialog;
76 class FileSetDialog;
77 class FilterDialog;
78 class FunnelStatistics;
79 class WelcomePage;
80 class PacketCommentDialog;
81 class PacketDiagram;
82 class PacketList;
83 class ProtoTree;
84#if defined(HAVE_LIBNL) && defined(HAVE_NL80211)
85 class WirelessFrame;
86#endif
87 class FilterExpressionToolBar;
88 class WiresharkApplication;
89
90 class QAction;
91 class QActionGroup;
92
93 namespace Ui {
94 class WiresharkMainWindow;
95}
96
97Q_DECLARE_METATYPE(ts_type)
98Q_DECLARE_METATYPE(ts_precision)
99
100class WiresharkMainWindow : public MainWindow
101{
102 Q_OBJECT
103
104 public:
105 explicit WiresharkMainWindow(QWidget *parent = nullptr);
106 ~WiresharkMainWindow();
107
108#ifdef HAVE_LIBPCAP
109 capture_session *captureSession() { return &cap_session_; }
110 info_data_t *captureInfoData() { return &info_data_; }
111#endif
112
113 QMenu *createPopupMenu() override;
114
115 CaptureFile *captureFile() { return &capture_file_; }
116
117 void setFunnelMenus(void);
118 void removeAdditionalToolbar(QString toolbarName);
119
120 void addInterfaceToolbar(const iface_toolbar *toolbar_entry);
121 void removeInterfaceToolbar(const char *menu_title);
122
123 QString getMwFileName();
124 void setMwFileName(QString fileName);
125
126 protected:
127 bool eventFilter(QObject *obj, QEvent *event) override;
128 bool event(QEvent *event) override;
129 void keyPressEvent(QKeyEvent *event) override;
130 void closeEvent(QCloseEvent *event) override;
131 void dragEnterEvent(QDragEnterEvent *event) override;
132 void dropEvent(QDropEvent *event) override;
133 void changeEvent(QEvent* event) override;
134 void openRecentCaptureFile(const QString &filename) override;
135
136 private:
137 // XXX Move to FilterUtils
138 enum MatchSelected {
139 MatchSelectedReplace,
140 MatchSelectedAnd,
141 MatchSelectedOr,
142 MatchSelectedNot,
143 MatchSelectedAndNot,
144 MatchSelectedOrNot
145 };
146
147 enum FileCloseContext {
148 Default,
149 Quit,
150 Restart,
151 Reload,
152 Update,
153 Export
154 };
155
156 Ui::WiresharkMainWindow *main_ui_;
157 QFont mono_font_;
158#if defined(HAVE_LIBNL) && defined(HAVE_NL80211)
159 WirelessFrame *wireless_frame_;
160#endif
161 QWidget *previous_focus_;
162 FileSetDialog *file_set_dialog_;
163 QActionGroup *show_hide_actions_;
164 QActionGroup *time_display_actions_;
165 QActionGroup *time_precision_actions_;
166 FunnelStatistics *funnel_statistics_;
167 QList<QPair<QAction *, bool> > freeze_actions_;
168 QPointer<QWidget> freeze_focus_;
169 QMap<QAction *, ts_type> td_actions;
170 QMap<QAction *, ts_precision> tp_actions;
171 bool was_maximized_;
172
173 /* the following values are maintained so that the capture file name and status
174 is available when there is no cf structure available */
175 QString mwFileName_;
176
177 bool capture_stopping_;
178 bool capture_filter_valid_;
179#ifdef HAVE_LIBPCAP
180 capture_session cap_session_;
181 CaptureOptionsDialog *capture_options_dialog_;
182 info_data_t info_data_;
183#endif
184
185#ifdef HAVE_SOFTWARE_UPDATE
186 QAction *update_action_;
187#endif
188
189 QPoint dragStartPosition;
190
191 QPointer<TLSKeylogDialog> tlskeylog_dialog_;
192
193 void freeze();
194 void thaw();
195
196 void mergeCaptureFile();
197 void importCaptureFile();
198 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
199 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
200 void exportSelectedPackets();
201 void exportDissections(export_type_e export_type);
202
203#ifdef Q_OS_WIN
204 void fileAddExtension(QString &file_name, int file_type, ws_compression_type compression_type);
205#endif // Q_OS_WIN
206 bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
207 void captureStop(bool discard = false);
208
209 void initMainToolbarIcons();
210 void initShowHideMainWidgets();
211 void initTimeDisplayFormatMenu();
212 void initTimePrecisionFormatMenu();
213 void initFreezeActions();
214
215 void setMenusForCaptureFile(bool force_disable = false) override;
216 void setMenusForCaptureInProgress(bool capture_in_progress = false);
217 void setMenusForCaptureStopping();
218 void setForCapturedPackets(bool have_captured_packets);
219 void setMenusForFileSet(bool enable_list_files);
220 void updateStyleSheet();
221
222 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, int depth);
223
224 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
225 QMenu* findOrAddMenu(QMenu *parent_menu, const QStringList& menu_parts);
226 QMenu* findOrAddMenubar(const QString menu_text);
227
228 void captureFileReadStarted(const QString &action);
229
230 void addMenusandSubmenus(QAction *action, QMenu *cur_menu);
231 void removeMenusandSubmenus(QAction *action, QMenu *cur_menu);
232 void addMenuActions(QList<QAction *> &actions, int menu_group);
233 void removeMenuActions(QList<QAction *> &actions, int menu_group);
234 void goToConversationFrame(bool go_next, bool start_current = true);
235 void colorizeWithFilter(QByteArray filter, int color_number = -1);
236
237signals:
238 void setDissectedCaptureFile(capture_file *cf);
239 void closePacketDialogs();
240 void reloadFields();
241 void packetInfoChanged(struct _packet_info *pinfo);
242 void fieldFilterChanged(const QByteArray field_filter);
243
244 void selectRtpStream(rtpstream_id_t *id);
245 void deselectRtpStream(rtpstream_id_t *id);
246
247#ifdef HAVE_LIBPCAP
248 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
249#endif
250
251 public slots:
252 // Qt lets you connect signals and slots using functors (new, manual style)
253 // and strings (old style). Functors are preferred since they're connected at
254 // compile time and less error prone.
255 //
256 // If you're manually connecting a signal to a slot, don't prefix its name
257 // with "on_". Otherwise Qt will try to automatically connect it and you'll
258 // get runtime warnings.
259
260 // in main_window_slots.cpp
269 // XXX We might want to return a cf_read_status_t or a CaptureFile.
270 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
271 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
272 void filterPackets(QString new_filter = QString(), bool force = false) override;
273 void layoutToolbars();
274 void updatePreferenceActions();
275 void updateRecentActions();
276
277 void setTitlebarForCaptureFile();
278
279 void showCaptureOptionsDialog();
280
281#ifdef HAVE_LIBPCAP
282 void captureCapturePrepared(capture_session *);
283 void captureCaptureUpdateStarted(capture_session *);
284 void captureCaptureUpdateFinished(capture_session *);
285 void captureCaptureFixedFinished(capture_session *cap_session);
286 void captureCaptureFailed(capture_session *);
287#endif
288
289 void captureFileOpened();
290 void captureFileReadFinished();
291 void captureFileClosing();
292 void captureFileClosed();
293
294 void launchRLCGraph(bool channelKnown, uint8_t RAT, uint16_t ueid, uint8_t rlcMode,
295 uint16_t channelType, uint16_t channelId, uint8_t direction);
296
297 void rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
298 void rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
299 void rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
300 void rtpAnalysisDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
301 void rtpAnalysisDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
302 void rtpAnalysisDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
303 void rtpStreamsDialogSelectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
304 void rtpStreamsDialogDeselectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
305
306 private slots:
307
308 void captureEventHandler(CaptureEvent ev);
309
310 void initViewColorizeMenu();
311 void initConversationMenus();
312 static bool addExportObjectsMenuItem(const void *key, void *value, void *userdata);
313 void initExportObjectsMenus();
314 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
315 void initFollowStreamMenus();
316
317 // in main_window_slots.cpp
323 void startCapture(QStringList);
324 void startCapture();
325 void pushLiveCaptureInProgress();
326 void popLiveCaptureInProgress();
327 void stopCapture();
328 void aggregationViewChanged(bool enable) const;
329
330 void loadWindowGeometry();
331 void saveWindowGeometry();
332 void mainStackChanged(int);
333 void updateRecentCaptures();
334 void addPacketComment();
335 void editPacketComment();
336 void deletePacketComment();
337 void deleteCommentsFromPackets();
338 QString commentToMenuText(QString text, int max_len = 40);
339 void setEditCommentsMenu();
340 void setMenusForSelectedPacket();
341 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
342 void interfaceSelectionChanged();
343 void captureFilterSyntaxChanged(bool valid);
344 void redissectPackets();
345 void checkDisplayFilter();
346 void fieldsChanged();
347 void reloadLuaPlugins();
348 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
349 void showColumnEditor(int column);
350 void showPreferenceEditor(); // module_t *, pref *
351 void addStatsPluginsToMenu();
352 void addDynamicMenus();
353 void reloadDynamicMenus();
354 void addPluginIFStructures();
355 QMenu * searchSubMenu(QString objectName);
356 void activatePluginIFToolbar(bool);
357
358 void startInterfaceCapture(bool valid, const QString capture_filter);
359
360 void applyGlobalCommandLineOptions();
361 void setFeaturesEnabled(bool enabled = true);
362
363 void on_actionNewDisplayFilterExpression_triggered();
364 void onFilterSelected(QString, bool);
365 void onFilterPreferences();
366 void onFilterEdit(int uatIndex);
367
368 // Handle FilterAction signals
369 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
370
376 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
377
383 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
384 void openTapParameterDialog();
385
386#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
387 void softwareUpdateRequested();
388#endif
389
390 // If you're manually connecting a signal to a slot, don't prefix its name
391 // with "on_". Otherwise you'll get runtime warnings.
392
393 void connectFileMenuActions();
394 void exportPacketBytes();
395 void exportPDU();
396 void stripPacketHeaders();
397 void exportTLSSessionKeys();
398 void printFile();
399
400 void connectEditMenuActions();
401 void copySelectedItems(WiresharkMainWindow::CopySelected selection_type);
402 void findPacket();
403 void editTimeShift();
404 void editConfigurationProfiles();
405 void editTimeShiftFinished(int);
406 void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
407 void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, unsigned nComment);
408 void deleteAllPacketComments();
409 void deleteAllPacketCommentsFinished(int result);
410 void injectSecrets(const char* proto_name, const char* wiki_link);
411 void discardAllSecrets();
412 void discardAllSecretsFinished(int result);
413 void showPreferencesDialog(QString module_name) override;
414
415 void connectViewMenuActions();
416 void showHideMainWidgets(QAction *action);
417 void setTimestampFormat(QAction *action);
418 void setTimestampPrecision(QAction *action);
419 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
420 void editResolvedName();
421 void setNameResolution();
422 void zoomText();
423 void showColoringRulesDialog();
424 void colorizeConversation(bool create_rule = false);
425 void colorizeActionTriggered();
426 void openPacketDialog(bool from_reference = false);
427 void reloadCaptureFileAsFormatOrCapture();
428 void reloadCaptureFile();
429
430 void connectGoMenuActions();
431
432 void setPreviousFocus();
433 void resetPreviousFocus();
434
435 void connectCaptureMenuActions();
436 void startCaptureTriggered();
437
438 void connectAnalyzeMenuActions();
439
440 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
441 void applyFieldAsColumn();
442
443 void filterMenuAboutToShow();
444
445 void applyConversationFilter();
446 void applyExportObject();
447
448 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
449 void openFollowStreamDialog(int proto_id);
450 void openIOGraph(bool filtered, QVector<uint> conv_ids, QVector<QVariant> conv_agg);
451
452 void statCommandExpertInfo(const char *, void *);
453
454 void connectHelpMenuActions();
455
456#ifdef HAVE_SOFTWARE_UPDATE
457 void checkForUpdates();
458#endif
459
460 void goToCancelClicked();
461 void goToGoClicked();
462 void goToLineEditReturnPressed();
463
464 void connectStatisticsMenuActions();
465
466 void showResolvedAddressesDialog();
467 void showConversationsDialog();
468 void showEndpointsDialog();
469
470 void openTcpStreamDialog(int graph_type);
471 void openSCTPAllAssocsDialog();
472 void on_actionSCTPShowAllAssociations_triggered();
473 void on_actionSCTPAnalyseThisAssociation_triggered();
474 void on_actionSCTPFilterThisAssociation_triggered();
475 void statCommandMulticastStatistics(const char *arg, void *);
476
477 void statCommandWlanStatistics(const char *arg, void *);
478
479 void openStatisticsTreeDialog(const char *abbr);
480 void statCommandIOGraph(const char *, void *);
481 void showIOGraphDialog(io_graph_item_unit_t value_units, QString) override;
482
483 void showPlotDialog(const QString& y_field = QString(), bool filtered = false) override;
484
485 void connectTelephonyMenuActions();
486
487 RtpStreamDialog *openTelephonyRtpStreamsDialog();
488 RtpPlayerDialog *openTelephonyRtpPlayerDialog();
489 RtpAnalysisDialog *openTelephonyRtpAnalysisDialog();
490 void statCommandLteMacStatistics(const char *arg, void *);
491 void statCommandLteRlcStatistics(const char *arg, void *);
492 void openRtpStreamAnalysisDialog();
493 void openRtpPlayerDialog();
494
495 void connectWirelessMenuActions();
496
497 void connectToolsMenuActions();
498
499 void externalMenuItemTriggered();
500
501 void on_actionContextWikiProtocolPage_triggered();
502 void on_actionContextFilterFieldReference_triggered();
503
504 void extcap_options_finished(int result);
505 void showExtcapOptionsDialog(QString & device_name, bool startCaptureOnClose);
506
507 QString findRtpStreams(QVector<rtpstream_id_t *> *stream_ids, bool reverse);
508
509 void openTLSKeylogDialog();
510
511 friend class MainApplication;
512};
513
514#endif // WIRESHARK_MAIN_WINDOW_H
capture_file_dialog.h
capture_file_properties_dialog.h
capture_opts.h
capture_session.h
AccordionFrame
Definition accordion_frame.h:18
CaptureEvent
Definition capture_event.h:21
CaptureFile
Definition capture_file.h:21
DataSourceTab
Definition data_source_tab.h:28
FieldInformation
Definition field_information.h:23
FileSetDialog
Definition file_set_dialog.h:29
FilterDialog
Definition filter_dialog.h:28
FilterExpressionToolBar
Definition filter_expression_toolbar.h:18
FunnelStatistics
Definition funnel_statistics.h:32
MainApplication
Definition main_application.h:36
MainWindow
Definition main_window.h:48
PacketCommentDialog
Definition packet_comment_dialog.h:20
PacketDiagram
Definition packet_diagram.h:26
PacketList
Definition packet_list.h:41
PrintDialog
Definition print_dialog.h:27
ProtoTree
Definition proto_tree.h:27
RtpAnalysisDialog
Definition rtp_analysis_dialog.h:65
RtpPlayerDialog
Definition rtp_player_dialog.h:81
RtpStreamDialog
Definition rtp_stream_dialog.h:29
WelcomePage
Definition welcome_page.h:27
WirelessFrame
Definition wireless_frame.h:22
WiresharkApplication
Definition wireshark_application.h:16
WiresharkMainWindow
Definition wireshark_main_window.h:101
WiresharkMainWindow::openCaptureFile
bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile=false)
Definition wireshark_main_window_slots.cpp:198
WiresharkMainWindow::openRecentCaptureFile
void openRecentCaptureFile(const QString &filename) override
Definition wireshark_main_window_slots.cpp:1066
display_filter_combo.h
field_information.h
iface_toolbar.h
main_window.h
plugin_if.h
rtp_analysis_dialog.h
rtp_stream_dialog.h
_capture_file
Definition cfile.h:67
_capture_session
Definition capture_session.h:136
_ext_menubar_t
Definition plugin_if.h:53
_iface_toolbar
Definition iface_toolbar.h:60
_info_data
Definition capture_info.h:40
_packet_info
Definition packet_info.h:43
_rtpstream_id
Definition rtp_stream_id.h:33
timestamp.h
tlskeylog_launcher_dialog.h
ws_ui_util.h