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