Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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#include <QTextCodec>
57
58#ifdef _WIN32
59# include <QTimer>
60#else
61# include <QSocketNotifier>
62#endif
63
64#include "capture_file_dialog.h"
68#include "main_window.h"
69#include "rtp_stream_dialog.h"
70#include "rtp_analysis_dialog.h"
72
73class AccordionFrame;
74class ByteViewTab;
75class CaptureOptionsDialog;
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 virtual QMenu *createPopupMenu();
115
116 CaptureFile *captureFile() { return &capture_file_; }
117
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
126protected:
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
135private:
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 QMap<QString, QTextCodec *> text_codec_map_;
157#if defined(HAVE_LIBNL) && defined(HAVE_NL80211)
158 WirelessFrame *wireless_frame_;
159#endif
160 QWidget *previous_focus_;
161 FileSetDialog *file_set_dialog_;
162 QActionGroup *show_hide_actions_;
163 QActionGroup *time_display_actions_;
164 QActionGroup *time_precision_actions_;
165 FunnelStatistics *funnel_statistics_;
166 QList<QPair<QAction *, bool> > freeze_actions_;
167 QPointer<QWidget> freeze_focus_;
168 QMap<QAction *, ts_type> td_actions;
169 QMap<QAction *, ts_precision> tp_actions;
170 bool was_maximized_;
171
172 /* the following values are maintained so that the capture file name and status
173 is available when there is no cf structure available */
174 QString mwFileName_;
175
176 bool capture_stopping_;
177 bool capture_filter_valid_;
178#ifdef HAVE_LIBPCAP
179 capture_session cap_session_;
180 CaptureOptionsDialog *capture_options_dialog_;
181 info_data_t info_data_;
182#endif
183
184#if defined(Q_OS_MAC)
185 QMenu *dock_menu_;
186#endif
187
188#ifdef HAVE_SOFTWARE_UPDATE
189 QAction *update_action_;
190#endif
191
192 QPoint dragStartPosition;
193
194 QPointer<TLSKeylogDialog> tlskeylog_dialog_;
195
196 void freeze();
197 void thaw();
198
199 void mergeCaptureFile();
200 void importCaptureFile();
201 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
202 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
203 void exportSelectedPackets();
204 void exportDissections(export_type_e export_type);
205
206#ifdef Q_OS_WIN
207 void fileAddExtension(QString &file_name, int file_type, wtap_compression_type compression_type);
208#endif // Q_OS_WIN
209 bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
210 void captureStop(bool discard = false);
211
212 void findTextCodecs();
213
214 void initMainToolbarIcons();
215 void initShowHideMainWidgets();
216 void initTimeDisplayFormatMenu();
217 void initTimePrecisionFormatMenu();
218 void initFreezeActions();
219
220 void setMenusForCaptureFile(bool force_disable = false);
221 void setMenusForCaptureInProgress(bool capture_in_progress = false);
222 void setMenusForCaptureStopping();
223 void setForCapturedPackets(bool have_captured_packets);
224 void setMenusForFileSet(bool enable_list_files);
225 void setWindowIcon(const QIcon &icon);
226 void updateStyleSheet();
227
228 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, int depth);
229
230 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
231 QMenu* findOrAddMenu(QMenu *parent_menu, const QStringList& menu_parts);
232
233 void captureFileReadStarted(const QString &action);
234
235 void addMenusandSubmenus(QAction *action, QMenu *cur_menu);
236 void removeMenusandSubmenus(QAction *action, QMenu *cur_menu);
237 void addMenuActions(QList<QAction *> &actions, int menu_group);
238 void removeMenuActions(QList<QAction *> &actions, int menu_group);
239 void goToConversationFrame(bool go_next, bool start_current = true);
240 void colorizeWithFilter(QByteArray filter, int color_number = -1);
241
242signals:
243 void setDissectedCaptureFile(capture_file *cf);
244 void closePacketDialogs();
245 void reloadFields();
246 void packetInfoChanged(struct _packet_info *pinfo);
247 void fieldFilterChanged(const QByteArray field_filter);
248
249 void selectRtpStream(rtpstream_id_t *id);
250 void deselectRtpStream(rtpstream_id_t *id);
251
252#ifdef HAVE_LIBPCAP
253 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
254#endif
255
256public slots:
257 // Qt lets you connect signals and slots using functors (new, manual style)
258 // and strings (old style). Functors are preferred since they're connected at
259 // compile time and less error prone.
260 //
261 // If you're manually connecting a signal to a slot, don't prefix its name
262 // with "on_". Otherwise Qt will try to automatically connect it and you'll
263 // get runtime warnings.
264
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 layoutToolbars();
279 void updatePreferenceActions();
280 void updateRecentActions();
281
282 void setTitlebarForCaptureFile();
283
284 void showCaptureOptionsDialog();
285
286#ifdef HAVE_LIBPCAP
287 void captureCapturePrepared(capture_session *);
288 void captureCaptureUpdateStarted(capture_session *);
289 void captureCaptureUpdateFinished(capture_session *);
290 void captureCaptureFixedFinished(capture_session *cap_session);
291 void captureCaptureFailed(capture_session *);
292#endif
293
294 void captureFileOpened();
295 void captureFileReadFinished();
296 void captureFileClosing();
297 void captureFileClosed();
298
299 void launchRLCGraph(bool channelKnown, uint8_t RAT, uint16_t ueid, uint8_t rlcMode,
300 uint16_t channelType, uint16_t channelId, uint8_t direction);
301
302 void rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
303 void rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
304 void rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
305 void rtpAnalysisDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
306 void rtpAnalysisDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
307 void rtpAnalysisDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
308 void rtpStreamsDialogSelectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
309 void rtpStreamsDialogDeselectRtpStreams(QVector<rtpstream_id_t *> stream_ids);
310
311private slots:
312
313 void captureEventHandler(CaptureEvent ev);
314
315 void initViewColorizeMenu();
316 void initConversationMenus();
317 static bool addExportObjectsMenuItem(const void *key, void *value, void *userdata);
318 void initExportObjectsMenus();
319 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
320 void initFollowStreamMenus();
321
322 // in main_window_slots.cpp
328 void startCapture(QStringList);
329 void startCapture();
330 void pushLiveCaptureInProgress();
331 void popLiveCaptureInProgress();
332 void stopCapture();
333
334 void loadWindowGeometry();
335 void saveWindowGeometry();
336 void mainStackChanged(int);
337 void updateRecentCaptures();
338 void recentActionTriggered();
339 void addPacketComment();
340 void editPacketComment();
341 void deletePacketComment();
342 void deleteCommentsFromPackets();
343 QString commentToMenuText(QString text, int max_len = 40);
344 void setEditCommentsMenu();
345 void setMenusForSelectedPacket();
346 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
347 void interfaceSelectionChanged();
348 void captureFilterSyntaxChanged(bool valid);
349 void redissectPackets();
350 void checkDisplayFilter();
351 void fieldsChanged();
352 void reloadLuaPlugins();
353 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
354 void showColumnEditor(int column);
355 void showPreferenceEditor(); // module_t *, pref *
356 void addStatsPluginsToMenu();
357 void addDynamicMenus();
358 void reloadDynamicMenus();
359 void addPluginIFStructures();
360 QMenu * searchSubMenu(QString objectName);
361 void activatePluginIFToolbar(bool);
362
363 void startInterfaceCapture(bool valid, const QString capture_filter);
364
365 void applyGlobalCommandLineOptions();
366 void setFeaturesEnabled(bool enabled = true);
367
368 void on_actionNewDisplayFilterExpression_triggered();
369 void onFilterSelected(QString, bool);
370 void onFilterPreferences();
371 void onFilterEdit(int uatIndex);
372
373 // Handle FilterAction signals
374 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
375
381 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
382
388 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
389 void openTapParameterDialog();
390
391#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
392 void softwareUpdateRequested();
393#endif
394
395 // If you're manually connecting a signal to a slot, don't prefix its name
396 // with "on_". Otherwise you'll get runtime warnings.
397
398 void connectFileMenuActions();
399 void exportPacketBytes();
400 void exportPDU();
401 void stripPacketHeaders();
402 void exportTLSSessionKeys();
403 void printFile();
404
405 void connectEditMenuActions();
406 void copySelectedItems(WiresharkMainWindow::CopySelected selection_type);
407 void findPacket();
408 void editTimeShift();
409 void editConfigurationProfiles();
410 void editTimeShiftFinished(int);
411 void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
412 void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, unsigned nComment);
413 void deleteAllPacketComments();
414 void deleteAllPacketCommentsFinished(int result);
415 void injectSecrets();
416 void discardAllSecrets();
417 void discardAllSecretsFinished(int result);
418 void showPreferencesDialog(QString module_name);
419
420 void connectViewMenuActions();
421 void showHideMainWidgets(QAction *action);
422 void setTimestampFormat(QAction *action);
423 void setTimestampPrecision(QAction *action);
424 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
425 void editResolvedName();
426 void setNameResolution();
427 void zoomText();
428 void showColoringRulesDialog();
429 void colorizeConversation(bool create_rule = false);
430 void colorizeActionTriggered();
431 void openPacketDialog(bool from_reference = false);
432 void reloadCaptureFileAsFormatOrCapture();
433 void reloadCaptureFile();
434
435 void connectGoMenuActions();
436
437 void setPreviousFocus();
438 void resetPreviousFocus();
439
440 void connectCaptureMenuActions();
441 void startCaptureTriggered();
442
443 void connectAnalyzeMenuActions();
444
445 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
446 void applyFieldAsColumn();
447
448 void filterMenuAboutToShow();
449
450 void applyConversationFilter();
451 void applyExportObject();
452
453 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
454 void openFollowStreamDialog(int proto_id);
455 void openIOGraph(bool filtered, QVector<uint> conv_ids, QVector<QVariant> conv_agg);
456
457 void statCommandExpertInfo(const char *, void *);
458
459 void connectHelpMenuActions();
460
461#ifdef HAVE_SOFTWARE_UPDATE
462 void checkForUpdates();
463#endif
464
465 void goToCancelClicked();
466 void goToGoClicked();
467 void goToLineEditReturnPressed();
468
469 void connectStatisticsMenuActions();
470
471 void showResolvedAddressesDialog();
472 void showConversationsDialog();
473 void showEndpointsDialog();
474
475 void openTcpStreamDialog(int graph_type);
476 void openSCTPAllAssocsDialog();
477 void on_actionSCTPShowAllAssociations_triggered();
478 void on_actionSCTPAnalyseThisAssociation_triggered();
479 void on_actionSCTPFilterThisAssociation_triggered();
480 void statCommandMulticastStatistics(const char *arg, void *);
481
482 void statCommandWlanStatistics(const char *arg, void *);
483
484 void openStatisticsTreeDialog(const char *abbr);
485 void statCommandIOGraph(const char *, void *);
486 void showIOGraphDialog(io_graph_item_unit_t value_units, QString);
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 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:51
Definition main_window.h:46
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:102
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: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