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 "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
229 void captureFileReadStarted(const QString &action);
230
231 void addMenusandSubmenus(QAction *action, QMenu *cur_menu);
232 void removeMenusandSubmenus(QAction *action, QMenu *cur_menu);
233 void addMenuActions(QList<QAction *> &actions, int menu_group);
234 void removeMenuActions(QList<QAction *> &actions, int menu_group);
235 void goToConversationFrame(bool go_next, bool start_current = true);
236 void colorizeWithFilter(QByteArray filter, int color_number = -1);
237
238signals:
239 void setDissectedCaptureFile(capture_file *cf);
240 void closePacketDialogs();
241 void reloadFields();
242 void packetInfoChanged(struct _packet_info *pinfo);
243 void fieldFilterChanged(const QByteArray field_filter);
244
245 void selectRtpStream(rtpstream_id_t *id);
246 void deselectRtpStream(rtpstream_id_t *id);
247
248#ifdef HAVE_LIBPCAP
249 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
250#endif
251
252public slots:
253 // Qt lets you connect signals and slots using functors (new, manual style)
254 // and strings (old style). Functors are preferred since they're connected at
255 // compile time and less error prone.
256 //
257 // If you're manually connecting a signal to a slot, don't prefix its name
258 // with "on_". Otherwise Qt will try to automatically connect it and you'll
259 // get runtime warnings.
260
261 // in main_window_slots.cpp
270 // XXX We might want to return a cf_read_status_t or a CaptureFile.
271 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
272 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
273 void filterPackets(QString new_filter = QString(), bool force = false);
274 void layoutToolbars();
275 void updatePreferenceActions();
276 void updateRecentActions();
277
278 void setTitlebarForCaptureFile();
279
280 void showCaptureOptionsDialog();
281
282#ifdef HAVE_LIBPCAP
283 void captureCapturePrepared(capture_session *);
284 void captureCaptureUpdateStarted(capture_session *);
285 void captureCaptureUpdateFinished(capture_session *);
286 void captureCaptureFixedFinished(capture_session *cap_session);
287 void captureCaptureFailed(capture_session *);
288#endif
289
290 void captureFileOpened();
291 void captureFileReadFinished();
292 void captureFileClosing();
293 void captureFileClosed();
294
295 void launchRLCGraph(bool channelKnown, uint8_t RAT, uint16_t ueid, uint8_t rlcMode,
296 uint16_t channelType, uint16_t channelId, uint8_t direction);
297
298 void rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
299 void rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
300 void rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
301 void rtpAnalysisDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
302 void rtpAnalysisDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
303 void rtpAnalysisDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
304 void rtpStreamsDialogSelectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
305 void rtpStreamsDialogDeselectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
306
307private slots:
308
309 void captureEventHandler(CaptureEvent ev);
310
311 void initViewColorizeMenu();
312 void initConversationMenus();
313 static bool addExportObjectsMenuItem(const void *key, void *value, void *userdata);
314 void initExportObjectsMenus();
315 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
316 void initFollowStreamMenus();
317
318 // in main_window_slots.cpp
324 void startCapture(QStringList);
325 void startCapture();
326 void pushLiveCaptureInProgress();
327 void popLiveCaptureInProgress();
328 void stopCapture();
329
330 void loadWindowGeometry();
331 void saveWindowGeometry();
332 void mainStackChanged(int);
333 void updateRecentCaptures();
334 void recentActionTriggered();
335 void addPacketComment();
336 void editPacketComment();
337 void deletePacketComment();
338 void deleteCommentsFromPackets();
339 QString commentToMenuText(QString text, int max_len = 40);
340 void setEditCommentsMenu();
341 void setMenusForSelectedPacket();
342 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
343 void interfaceSelectionChanged();
344 void captureFilterSyntaxChanged(bool valid);
345 void redissectPackets();
346 void checkDisplayFilter();
347 void fieldsChanged();
348 void reloadLuaPlugins();
349 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
350 void showColumnEditor(int column);
351 void showPreferenceEditor(); // module_t *, pref *
352 void addStatsPluginsToMenu();
353 void addDynamicMenus();
354 void reloadDynamicMenus();
355 void addPluginIFStructures();
356 QMenu * searchSubMenu(QString objectName);
357 void activatePluginIFToolbar(bool);
358
359 void startInterfaceCapture(bool valid, const QString capture_filter);
360
361 void applyGlobalCommandLineOptions();
362 void setFeaturesEnabled(bool enabled = true);
363
364 void on_actionNewDisplayFilterExpression_triggered();
365 void onFilterSelected(QString, bool);
366 void onFilterPreferences();
367 void onFilterEdit(int uatIndex);
368
369 // Handle FilterAction signals
370 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
371
377 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
378
384 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
385 void openTapParameterDialog();
386
387#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
388 void softwareUpdateRequested();
389#endif
390
391 // If you're manually connecting a signal to a slot, don't prefix its name
392 // with "on_". Otherwise you'll get runtime warnings.
393
394 void connectFileMenuActions();
395 void exportPacketBytes();
396 void exportPDU();
397 void stripPacketHeaders();
398 void exportTLSSessionKeys();
399 void printFile();
400
401 void connectEditMenuActions();
402 void copySelectedItems(WiresharkMainWindow::CopySelected selection_type);
403 void findPacket();
404 void editTimeShift();
405 void editConfigurationProfiles();
406 void editTimeShiftFinished(int);
407 void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
408 void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, unsigned nComment);
409 void deleteAllPacketComments();
410 void deleteAllPacketCommentsFinished(int result);
411 void injectSecrets();
412 void discardAllSecrets();
413 void discardAllSecretsFinished(int result);
414 void showPreferencesDialog(QString module_name);
415
416 void connectViewMenuActions();
417 void showHideMainWidgets(QAction *action);
418 void setTimestampFormat(QAction *action);
419 void setTimestampPrecision(QAction *action);
420 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
421 void editResolvedName();
422 void setNameResolution();
423 void zoomText();
424 void showColoringRulesDialog();
425 void colorizeConversation(bool create_rule = false);
426 void colorizeActionTriggered();
427 void openPacketDialog(bool from_reference = false);
428 void reloadCaptureFileAsFormatOrCapture();
429 void reloadCaptureFile();
430
431 void connectGoMenuActions();
432
433 void setPreviousFocus();
434 void resetPreviousFocus();
435
436 void connectCaptureMenuActions();
437 void startCaptureTriggered();
438
439 void connectAnalyzeMenuActions();
440
441 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
442 void applyFieldAsColumn();
443
444 void filterMenuAboutToShow();
445
446 void applyConversationFilter();
447 void applyExportObject();
448
449 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
450 void openFollowStreamDialog(int proto_id);
451 void openIOGraph(bool filtered, QVector<uint> conv_ids, QVector<QVariant> conv_agg);
452
453 void statCommandExpertInfo(const char *, void *);
454
455 void connectHelpMenuActions();
456
457#ifdef HAVE_SOFTWARE_UPDATE
458 void checkForUpdates();
459#endif
460
461 void goToCancelClicked();
462 void goToGoClicked();
463 void goToLineEditReturnPressed();
464
465 void connectStatisticsMenuActions();
466
467 void showResolvedAddressesDialog();
468 void showConversationsDialog();
469 void showEndpointsDialog();
470
471 void openTcpStreamDialog(int graph_type);
472 void openSCTPAllAssocsDialog();
473 void on_actionSCTPShowAllAssociations_triggered();
474 void on_actionSCTPAnalyseThisAssociation_triggered();
475 void on_actionSCTPFilterThisAssociation_triggered();
476 void statCommandMulticastStatistics(const char *arg, void *);
477
478 void statCommandWlanStatistics(const char *arg, void *);
479
480 void openStatisticsTreeDialog(const char *abbr);
481 void statCommandIOGraph(const char *, void *);
482 void showIOGraphDialog(io_graph_item_unit_t value_units, QString);
483
484 void showPlotDialog(const QString& y_field = QString(), bool filtered = false);
485
486 void connectTelephonyMenuActions();
487
488 RtpStreamDialog *openTelephonyRtpStreamsDialog();
489 RtpPlayerDialog *openTelephonyRtpPlayerDialog();
490 RtpAnalysisDialog *openTelephonyRtpAnalysisDialog();
491 void statCommandLteMacStatistics(const char *arg, void *);
492 void statCommandLteRlcStatistics(const char *arg, void *);
493 void openRtpStreamAnalysisDialog();
494 void openRtpPlayerDialog();
495
496 void connectWirelessMenuActions();
497
498 void connectToolsMenuActions();
499
500 void externalMenuItemTriggered();
501
502 void on_actionContextWikiProtocolPage_triggered();
503 void on_actionContextFilterFieldReference_triggered();
504
505 void extcap_options_finished(int result);
506 void showExtcapOptionsDialog(QString & device_name, bool startCaptureOnClose);
507
508 QString findRtpStreams(QVector<rtpstream_id_t *> *stream_ids, bool reverse);
509
510 void openTLSKeylogDialog();
511
512 friend class MainApplication;
513};
514
515#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:192
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