| 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
49#include <epan/plugin_if.h>
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 virtual QMenu *createPopupMenu();
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 virtual bool eventFilter(QObject *obj, QEvent *event);
128 virtual bool event(QEvent *event);
129 virtual void keyPressEvent(QKeyEvent *event);
130 virtual void closeEvent(QCloseEvent *event);
131 virtual void dragEnterEvent(QDragEnterEvent *event);
132 virtual void dropEvent(QDropEvent *event);
133 virtual void changeEvent(QEvent* event);
134
135 private:
136 // XXX Move to FilterUtils
137 enum MatchSelected {
138 MatchSelectedReplace,
139 MatchSelectedAnd,
140 MatchSelectedOr,
141 MatchSelectedNot,
142 MatchSelectedAndNot,
143 MatchSelectedOrNot
144 };
145
146 enum FileCloseContext {
147 Default,
148 Quit,
149 Restart,
150 Reload,
151 Update
152 };
153
154 Ui::WiresharkMainWindow *main_ui_;
155 QFont mono_font_;
156#if defined(HAVE_LIBNL) && defined(HAVE_NL80211)
157 WirelessFrame *wireless_frame_;
158#endif
159 QWidget *previous_focus_;
160 FileSetDialog *file_set_dialog_;
161 QActionGroup *show_hide_actions_;
162 QActionGroup *time_display_actions_;
163 QActionGroup *time_precision_actions_;
164 FunnelStatistics *funnel_statistics_;
165 QList<QPair<QAction *, bool> > freeze_actions_;
166 QPointer<QWidget> freeze_focus_;
167 QMap<QAction *, ts_type> td_actions;
168 QMap<QAction *, ts_precision> tp_actions;
169 bool was_maximized_;
170
171 /* the following values are maintained so that the capture file name and status
172 is available when there is no cf structure available */
173 QString mwFileName_;
174
175 bool capture_stopping_;
176 bool capture_filter_valid_;
177#ifdef HAVE_LIBPCAP
178 capture_session cap_session_;
179 CaptureOptionsDialog *capture_options_dialog_;
180 info_data_t info_data_;
181#endif
182
183#if defined(Q_OS_MAC)
184 QMenu *dock_menu_;
185#endif
186
187#ifdef HAVE_SOFTWARE_UPDATE
188 QAction *update_action_;
189#endif
190
191 QPoint dragStartPosition;
192
193 QPointer<TLSKeylogDialog> tlskeylog_dialog_;
194
195 void freeze();
196 void thaw();
197
198 void mergeCaptureFile();
199 void importCaptureFile();
200 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
201 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
202 void exportSelectedPackets();
203 void exportDissections(export_type_e export_type);
204
205#ifdef Q_OS_WIN
206 void fileAddExtension(QString &file_name, int file_type, ws_compression_type compression_type);
207#endif // Q_OS_WIN
208 bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
209 void captureStop(bool discard = false);
210
211 void initMainToolbarIcons();
212 void initShowHideMainWidgets();
213 void initTimeDisplayFormatMenu();
214 void initTimePrecisionFormatMenu();
215 void initFreezeActions();
216
217 void setMenusForCaptureFile(bool force_disable = false);
218 void setMenusForCaptureInProgress(bool capture_in_progress = false);
219 void setMenusForCaptureStopping();
220 void setForCapturedPackets(bool have_captured_packets);
221 void setMenusForFileSet(bool enable_list_files);
222 void setWindowIcon(const QIcon &icon);
223 void updateStyleSheet();
224
225 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, int depth);
226
227 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
228 QMenu* findOrAddMenu(QMenu *parent_menu, const QStringList& menu_parts);
229 QMenu* findOrAddMenubar(const QString menu_text);
230
231 void captureFileReadStarted(const QString &action);
232
233 void addMenusandSubmenus(QAction *action, QMenu *cur_menu);
234 void removeMenusandSubmenus(QAction *action, QMenu *cur_menu);
235 void addMenuActions(QList<QAction *> &actions, int menu_group);
236 void removeMenuActions(QList<QAction *> &actions, int menu_group);
237 void goToConversationFrame(bool go_next, bool start_current = true);
238 void colorizeWithFilter(QByteArray filter, int color_number = -1);
239
240signals:
241 void setDissectedCaptureFile(capture_file *cf);
242 void closePacketDialogs();
243 void reloadFields();
244 void packetInfoChanged(struct _packet_info *pinfo);
245 void fieldFilterChanged(const QByteArray field_filter);
246
247 void selectRtpStream(rtpstream_id_t *id);
248 void deselectRtpStream(rtpstream_id_t *id);
249
250#ifdef HAVE_LIBPCAP
251 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
252#endif
253
254 public slots:
255 // Qt lets you connect signals and slots using functors (new, manual style)
256 // and strings (old style). Functors are preferred since they're connected at
257 // compile time and less error prone.
258 //
259 // If you're manually connecting a signal to a slot, don't prefix its name
260 // with "on_". Otherwise Qt will try to automatically connect it and you'll
261 // get runtime warnings.
262
263 // in main_window_slots.cpp
272 // XXX We might want to return a cf_read_status_t or a CaptureFile.
273 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
274 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
275 void filterPackets(QString new_filter = QString(), bool force = false);
276 void layoutToolbars();
277 void updatePreferenceActions();
278 void updateRecentActions();
279
280 void setTitlebarForCaptureFile();
281
282 void showCaptureOptionsDialog();
283
284#ifdef HAVE_LIBPCAP
285 void captureCapturePrepared(capture_session *);
286 void captureCaptureUpdateStarted(capture_session *);
287 void captureCaptureUpdateFinished(capture_session *);
288 void captureCaptureFixedFinished(capture_session *cap_session);
289 void captureCaptureFailed(capture_session *);
290#endif
291
292 void captureFileOpened();
293 void captureFileReadFinished();
294 void captureFileClosing();
295 void captureFileClosed();
296
297 void launchRLCGraph(bool channelKnown, uint8_t RAT, uint16_t ueid, uint8_t rlcMode,
298 uint16_t channelType, uint16_t channelId, uint8_t direction);
299
300 void rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
301 void rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
302 void rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
303 void rtpAnalysisDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
304 void rtpAnalysisDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
305 void rtpAnalysisDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
306 void rtpStreamsDialogSelectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
307 void rtpStreamsDialogDeselectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
308
309 private slots:
310
311 void captureEventHandler(CaptureEvent ev);
312
313 void initViewColorizeMenu();
314 void initConversationMenus();
315 static bool addExportObjectsMenuItem(const void *key, void *value, void *userdata);
316 void initExportObjectsMenus();
317 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
318 void initFollowStreamMenus();
319
320 // in main_window_slots.cpp
326 void startCapture(QStringList);
327 void startCapture();
328 void pushLiveCaptureInProgress();
329 void popLiveCaptureInProgress();
330 void stopCapture();
331 void aggregationViewChanged(bool enable) const;
332
333 void loadWindowGeometry();
334 void saveWindowGeometry();
335 void mainStackChanged(int);
336 void updateRecentCaptures();
337 void recentActionTriggered();
338 void addPacketComment();
339 void editPacketComment();
340 void deletePacketComment();
341 void deleteCommentsFromPackets();
342 QString commentToMenuText(QString text, int max_len = 40);
343 void setEditCommentsMenu();
344 void setMenusForSelectedPacket();
345 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
346 void interfaceSelectionChanged();
347 void captureFilterSyntaxChanged(bool valid);
348 void redissectPackets();
349 void checkDisplayFilter();
350 void fieldsChanged();
351 void reloadLuaPlugins();
352 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
353 void showColumnEditor(int column);
354 void showPreferenceEditor(); // module_t *, pref *
355 void addStatsPluginsToMenu();
356 void addDynamicMenus();
357 void reloadDynamicMenus();
358 void addPluginIFStructures();
359 QMenu * searchSubMenu(QString objectName);
360 void activatePluginIFToolbar(bool);
361
362 void startInterfaceCapture(bool valid, const QString capture_filter);
363
364 void applyGlobalCommandLineOptions();
365 void setFeaturesEnabled(bool enabled = true);
366
367 void on_actionNewDisplayFilterExpression_triggered();
368 void onFilterSelected(QString, bool);
369 void onFilterPreferences();
370 void onFilterEdit(int uatIndex);
371
372 // Handle FilterAction signals
373 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
374
380 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
381
387 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
388 void openTapParameterDialog();
389
390#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
391 void softwareUpdateRequested();
392#endif
393
394 // If you're manually connecting a signal to a slot, don't prefix its name
395 // with "on_". Otherwise you'll get runtime warnings.
396
397 void connectFileMenuActions();
398 void exportPacketBytes();
399 void exportPDU();
400 void stripPacketHeaders();
401 void exportTLSSessionKeys();
402 void printFile();
403
404 void connectEditMenuActions();
405 void copySelectedItems(WiresharkMainWindow::CopySelected selection_type);
406 void findPacket();
407 void editTimeShift();
408 void editConfigurationProfiles();
409 void editTimeShiftFinished(int);
410 void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
411 void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, unsigned nComment);
412 void deleteAllPacketComments();
413 void deleteAllPacketCommentsFinished(int result);
414 void injectSecrets(const char* proto_name, const char* wiki_link);
415 void discardAllSecrets();
416 void discardAllSecretsFinished(int result);
417 void showPreferencesDialog(QString module_name);
418
419 void connectViewMenuActions();
420 void showHideMainWidgets(QAction *action);
421 void setTimestampFormat(QAction *action);
422 void setTimestampPrecision(QAction *action);
423 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
424 void editResolvedName();
425 void setNameResolution();
426 void zoomText();
427 void showColoringRulesDialog();
428 void colorizeConversation(bool create_rule = false);
429 void colorizeActionTriggered();
430 void openPacketDialog(bool from_reference = false);
431 void reloadCaptureFileAsFormatOrCapture();
432 void reloadCaptureFile();
433
434 void connectGoMenuActions();
435
436 void setPreviousFocus();
437 void resetPreviousFocus();
438
439 void connectCaptureMenuActions();
440 void startCaptureTriggered();
441
442 void connectAnalyzeMenuActions();
443
444 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
445 void applyFieldAsColumn();
446
447 void filterMenuAboutToShow();
448
449 void applyConversationFilter();
450 void applyExportObject();
451
452 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
453 void openFollowStreamDialog(int proto_id);
454 void openIOGraph(bool filtered, QVector<uint> conv_ids, QVector<QVariant> conv_agg);
455
456 void statCommandExpertInfo(const char *, void *);
457
458 void connectHelpMenuActions();
459
460#ifdef HAVE_SOFTWARE_UPDATE
461 void checkForUpdates();
462#endif
463
464 void goToCancelClicked();
465 void goToGoClicked();
466 void goToLineEditReturnPressed();
467
468 void connectStatisticsMenuActions();
469
470 void showResolvedAddressesDialog();
471 void showConversationsDialog();
472 void showEndpointsDialog();
473
474 void openTcpStreamDialog(int graph_type);
475 void openSCTPAllAssocsDialog();
476 void on_actionSCTPShowAllAssociations_triggered();
477 void on_actionSCTPAnalyseThisAssociation_triggered();
478 void on_actionSCTPFilterThisAssociation_triggered();
479 void statCommandMulticastStatistics(const char *arg, void *);
480
481 void statCommandWlanStatistics(const char *arg, void *);
482
483 void openStatisticsTreeDialog(const char *abbr);
484 void statCommandIOGraph(const char *, void *);
485 void showIOGraphDialog(io_graph_item_unit_t value_units, QString);
486
487 void showPlotDialog(const QString& y_field = QString(), bool filtered = false);
488
489 void connectTelephonyMenuActions();
490
491 RtpStreamDialog *openTelephonyRtpStreamsDialog();
492 RtpPlayerDialog *openTelephonyRtpPlayerDialog();
493 RtpAnalysisDialog *openTelephonyRtpAnalysisDialog();
494 void statCommandLteMacStatistics(const char *arg, void *);
495 void statCommandLteRlcStatistics(const char *arg, void *);
496 void openRtpStreamAnalysisDialog();
497 void openRtpPlayerDialog();
498
499 void connectWirelessMenuActions();
500
501 void connectToolsMenuActions();
502
503 void externalMenuItemTriggered();
504
505 void on_actionContextWikiProtocolPage_triggered();
506 void on_actionContextFilterFieldReference_triggered();
507
508 void extcap_options_finished(int result);
509 void showExtcapOptionsDialog(QString & device_name, bool startCaptureOnClose);
510
511 QString findRtpStreams(QVector<rtpstream_id_t *> *stream_ids, bool reverse);
512
513 void openTLSKeylogDialog();
514
515 friend class MainApplication;
516};
517
518#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:51
MainWindow
Definition main_window.h:47
PacketCommentDialog
Definition packet_comment_dialog.h:20
PacketDiagram
Definition packet_diagram.h:26
PacketList
Definition packet_list.h:40
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:195
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