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