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