3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include "ui/ui_util.h"
35 #include <epan/prefs.h>
36 #include <epan/plugin_if.h>
37 #include <epan/timestamp.h>
40 #include "capture_opts.h"
42 #include <capchild/capture_session.h>
44 #include <QMainWindow>
50 # include <QSocketNotifier>
53 #include "capture_file.h"
54 #include "capture_file_dialog.h"
55 #include "capture_file_properties_dialog.h"
56 #include "capture_interfaces_dialog.h"
57 #include "display_filter_combo.h"
58 #include "file_set_dialog.h"
59 #include "filter_action.h"
60 #include "follow_stream_dialog.h"
61 #include "preferences_dialog.h"
65 class FunnelStatistics;
78 class MainWindow : public QMainWindow
83 explicit MainWindow(QWidget *parent = 0);
85 void setPipeInputHandler(gint source, gpointer user_data, ws_process_id *child_process, pipe_input_cb_t input_cb);
89 capture_session *captureSession() { return &cap_session_; }
90 info_data_t *captureInfoData() { return &info_data_; }
93 virtual QMenu *createPopupMenu();
95 void gotoFrame(int packet_num);
96 CaptureFile *captureFile() { return &capture_file_; }
99 bool eventFilter(QObject *obj, QEvent *event);
100 void keyPressEvent(QKeyEvent *event);
101 void closeEvent(QCloseEvent *event);
102 void dragEnterEvent(QDragEnterEvent *event);
103 void dropEvent(QDropEvent *event);
106 // XXX Move to FilterUtils
108 MatchSelectedReplace,
118 CopyAllVisibleSelectedTreeItems,
119 CopySelectedDescription,
120 CopySelectedFieldName,
124 enum FileCloseContext {
130 Ui::MainWindow *main_ui_;
131 QMenu *open_recent_menu_;
132 QSplitter master_split_;
133 QSplitter extra_split_;
134 QVector<unsigned> cur_layout_;
135 MainWelcome *main_welcome_;
136 DisplayFilterCombo *df_combo_box_;
137 CaptureFile capture_file_;
139 WirelessFrame *wireless_frame_;
140 // XXX - packet_list_, proto_tree_, and byte_view_tab_ should
141 // probably be full-on values instead of pointers.
142 PacketList *packet_list_;
143 ProtoTree *proto_tree_;
144 QWidget *previous_focus_;
145 FileSetDialog file_set_dialog_;
146 ByteViewTab *byte_view_tab_;
148 QActionGroup *show_hide_actions_;
149 QActionGroup *time_display_actions_;
150 QActionGroup *time_precision_actions_;
151 FunnelStatistics *funnel_statistics_;
152 QList<QPair<QAction *, bool> > freeze_actions_;
153 QWidget *freeze_focus_;
154 QMap<QAction *, ts_type> td_actions;
155 QMap<QAction *, ts_precision> tp_actions;
157 bool capture_stopping_;
158 bool capture_filter_valid_;
160 capture_session cap_session_;
161 CaptureInterfacesDialog capture_interfaces_dialog_;
162 info_data_t info_data_;
167 gpointer pipe_user_data_;
168 ws_process_id *pipe_child_process_;
169 pipe_input_cb_t pipe_input_cb_;
173 QSocketNotifier *pipe_notifier_;
176 QWidget* getLayoutWidget(layout_pane_content_e type);
181 void mergeCaptureFile();
182 void importCaptureFile();
183 void saveCaptureFile(capture_file *cf, bool dont_reopen);
184 void saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
185 void exportSelectedPackets();
186 void exportDissections(export_type_e export_type);
188 void fileAddExtension(QString &file_name, int file_type, bool compressed);
189 bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
192 void initMainToolbarIcons();
193 void initShowHideMainWidgets();
194 void initTimeDisplayFormatMenu();
195 void initTimePrecisionFormatMenu();
196 void initFreezeActions();
198 void setTitlebarForCaptureInProgress();
199 void setMenusForCaptureFile(bool force_disable = false);
200 void setMenusForCaptureInProgress(bool capture_in_progress = false);
201 void setMenusForCaptureStopping();
202 void setForCapturedPackets(bool have_captured_packets);
203 void setMenusForFileSet(bool enable_list_files);
204 void setWindowIcon(const QIcon &icon);
205 QString replaceWindowTitleVariables(QString title);
207 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint depth);
209 void setForCaptureInProgress(gboolean capture_in_progress = false);
210 QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
212 void recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level);
213 void captureFileReadStarted(const QString &action);
215 void addMenuActions(QList<QAction *> &actions, int menu_group);
216 void removeMenuActions(QList<QAction *> &actions, int menu_group);
217 void goToConversationFrame(bool go_next);
220 void setCaptureFile(capture_file *cf);
221 void setDissectedCaptureFile(capture_file *cf);
222 void displayFilterSuccess(bool success);
223 void monospaceFontChanged(const QFont &mono_font);
224 void closePacketDialogs();
228 // in main_window_slots.cpp
230 * Open a capture file.
231 * @param cf_path Path to the file.
232 * @param display_filter Display filter to apply. May be empty.
233 * @param type File type.
234 * @return True on success, false on failure.
236 // XXX We might want to return a cf_read_status_t or a CaptureFile.
237 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type);
238 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
239 void filterPackets(QString new_filter = QString(), bool force = false);
240 void updateForUnsavedChanges();
242 void applyRecentPaneGeometry();
243 void layoutToolbars();
244 void updatePreferenceActions();
245 void updateRecentActions();
247 void setTitlebarForCaptureFile();
248 void setWSWindowTitle(QString title = QString());
250 void captureCapturePrepared(capture_session *);
251 void captureCaptureUpdateStarted(capture_session *);
252 void captureCaptureUpdateFinished(capture_session *);
253 void captureCaptureFixedStarted(capture_session *);
254 void captureCaptureFixedFinished(capture_session *cap_session);
255 void captureCaptureStopping(capture_session *);
256 void captureCaptureFailed(capture_session *);
258 void captureFileOpened();
259 void captureFileReadStarted() { captureFileReadStarted(tr("Loading")); }
260 void captureFileReadFinished();
261 void captureFileReloadStarted() { captureFileReadStarted(tr("Reloading")); }
262 void captureFileRescanStarted() { setMenusForCaptureFile(true); captureFileReadStarted(tr("Rescanning")); }
263 void captureFileRetapStarted();
264 void captureFileRetapFinished();
265 void captureFileFlushTapsData();
266 void captureFileClosing();
267 void captureFileClosed();
268 void captureFileSaveStarted(const QString &file_path);
270 void filterExpressionsChanged();
272 void launchRLCGraph(bool channelKnown, guint16 ueid, guint8 rlcMode,
273 guint16 channelType, guint16 channelId, guint8 direction);
276 // Manually connected slots (no "on_<object>_<signal>").
278 void initViewColorizeMenu();
280 // in main_window_slots.cpp
283 void pipeActivated(int source);
284 void pipeNotifierDestroyed();
287 void loadWindowGeometry();
288 void saveWindowGeometry();
289 void mainStackChanged(int);
290 void updateRecentFiles();
291 void recentActionTriggered();
292 void setMenusForSelectedPacket();
293 void setMenusForSelectedTreeRow(field_info *fi = NULL);
294 void interfaceSelectionChanged();
295 void captureFilterSyntaxChanged(bool valid);
296 void redissectPackets();
297 void checkDisplayFilter();
298 void fieldsChanged();
299 void reloadLuaPlugins();
300 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
301 void showColumnEditor(int column);
302 void showPreferenceEditor(); // module_t *, pref *
303 void addStatsPluginsToMenu();
304 void addDynamicMenus();
305 void reloadDynamicMenus();
306 void addExternalMenus();
307 QMenu * searchSubMenu(QString objectName);
309 void startInterfaceCapture(bool valid);
311 void setFeaturesEnabled(bool enabled = true);
313 void on_actionDisplayFilterExpression_triggered();
314 void on_actionNewDisplayFilterExpression_triggered();
315 void displayFilterButtonClicked();
317 // Handle FilterAction signals
318 void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
320 /** Pass stat cmd arguments to a slot.
321 * @param menu_path slot Partial slot name, e.g. "StatisticsIOGraph".
322 * @param arg "-z" argument, e.g. "io,stat".
323 * @param userdata Optional user data.
325 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
327 /** Pass tap parameter arguments to a slot.
328 * @param cfg_str slot Partial slot name, e.g. "StatisticsAFPSrt".
329 * @param arg "-z" argument, e.g. "afp,srt".
330 * @param userdata Optional user data.
332 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
333 void openTapParameterDialog();
335 // Automatically connected slots ("on_<object>_<signal>").
337 // The slots below follow the naming conventaion described in
338 // http://doc.qt.io/qt-4.8/qmetaobject.html#connectSlotsByName and are
339 // automatically connected at initialization time via main_ui_->setupUi,
340 // which in turn calls connectSlotsByName.
342 // If you're manually connecting a signal to a slot, don't prefix its name
343 // with "on_". Otherwise you'll get runtime warnings.
345 // We might want move these to main_window_actions.cpp similar to
346 // gtk/main_menubar.c
348 void on_actionFileOpen_triggered();
349 void on_actionFileMerge_triggered();
350 void on_actionFileImportFromHexDump_triggered();
351 void on_actionFileClose_triggered();
352 void on_actionFileSave_triggered();
353 void on_actionFileSaveAs_triggered();
354 void on_actionFileSetListFiles_triggered();
355 void on_actionFileSetNextFile_triggered();
356 void on_actionFileSetPreviousFile_triggered();
357 void on_actionFileExportPackets_triggered();
358 void on_actionFileExportAsPlainText_triggered();
359 // We're dropping PostScript exports
360 void on_actionFileExportAsCSV_triggered();
361 void on_actionFileExportAsCArrays_triggered();
362 void on_actionFileExportAsPSML_triggered();
363 void on_actionFileExportAsPDML_triggered();
364 void on_actionFileExportPacketBytes_triggered();
365 void on_actionFileExportObjectsDICOM_triggered();
366 void on_actionFileExportObjectsHTTP_triggered();
367 void on_actionFileExportObjectsSMB_triggered();
368 void on_actionFileExportObjectsTFTP_triggered();
369 void on_actionFilePrint_triggered();
371 void on_actionFileExportPDU_triggered();
372 void on_actionFileExportSSLSessionKeys_triggered();
374 void actionEditCopyTriggered(MainWindow::CopySelected selection_type);
375 void on_actionCopyAllVisibleItems_triggered();
376 void on_actionCopyAllVisibleSelectedTreeItems_triggered();
377 void on_actionEditCopyDescription_triggered();
378 void on_actionEditCopyFieldName_triggered();
379 void on_actionEditCopyValue_triggered();
380 void on_actionEditCopyAsFilter_triggered();
381 void on_actionEditFindPacket_triggered();
382 void on_actionEditFindNext_triggered();
383 void on_actionEditFindPrevious_triggered();
384 void on_actionEditMarkPacket_triggered();
385 void on_actionEditMarkAllDisplayed_triggered();
386 void on_actionEditUnmarkAllDisplayed_triggered();
387 void on_actionEditNextMark_triggered();
388 void on_actionEditPreviousMark_triggered();
389 void on_actionEditIgnorePacket_triggered();
390 void on_actionEditIgnoreAllDisplayed_triggered();
391 void on_actionEditUnignoreAllDisplayed_triggered();
392 void on_actionEditSetTimeReference_triggered();
393 void on_actionEditUnsetAllTimeReferences_triggered();
394 void on_actionEditNextTimeReference_triggered();
395 void on_actionEditPreviousTimeReference_triggered();
396 void on_actionEditTimeShift_triggered();
397 void on_actionEditPacketComment_triggered();
398 void on_actionEditConfigurationProfiles_triggered();
399 void showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane = PreferencesDialog::ppAppearance);
400 void showPreferencesDialog(QString module_name);
401 void on_actionEditPreferences_triggered();
403 void showHideMainWidgets(QAction *action);
404 void setTimestampFormat(QAction *action);
405 void setTimestampPrecision(QAction *action);
406 void on_actionViewTimeDisplaySecondsWithHoursAndMinutes_triggered(bool checked);
407 void on_actionViewEditResolvedName_triggered();
408 void setNameResolution();
409 void on_actionViewNameResolutionPhysical_triggered();
410 void on_actionViewNameResolutionNetwork_triggered();
411 void on_actionViewNameResolutionTransport_triggered();
412 // XXX We're not porting the concurrency action from GTK+ on purpose.
414 void on_actionViewZoomIn_triggered();
415 void on_actionViewZoomOut_triggered();
416 void on_actionViewNormalSize_triggered();
417 void on_actionViewColorizePacketList_triggered(bool checked);
418 void on_actionViewColoringRules_triggered();
419 void colorizeConversation(bool create_rule = false);
420 void colorizeWithFilter();
421 void on_actionViewColorizeResetColorization_triggered();
422 void on_actionViewColorizeNewColoringRule_triggered();
423 void on_actionViewResizeColumns_triggered();
425 void on_actionViewInternalsConversationHashTables_triggered();
426 void on_actionViewInternalsDissectorTables_triggered();
427 void on_actionViewInternalsSupportedProtocols_triggered();
429 void openPacketDialog(bool from_reference = false);
430 void on_actionViewShowPacketInNewWindow_triggered();
431 void on_actionContextShowLinkedPacketInNewWindow_triggered();
432 void on_actionViewReload_triggered();
433 void on_actionViewReload_as_File_Format_or_Capture_triggered();
435 void on_actionGoGoToPacket_triggered();
436 void on_actionGoGoToLinkedPacket_triggered();
437 void on_actionGoNextConversationPacket_triggered();
438 void on_actionGoPreviousConversationPacket_triggered();
439 void on_actionGoAutoScroll_toggled(bool checked);
440 void resetPreviousFocus();
443 void on_actionCaptureOptions_triggered();
444 void on_actionCaptureRefreshInterfaces_triggered();
446 void on_actionCaptureCaptureFilters_triggered();
448 void on_actionAnalyzeDisplayFilters_triggered();
449 void on_actionAnalyzeDisplayFilterMacros_triggered();
450 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
451 void on_actionAnalyzeCreateAColumn_triggered();
452 void on_actionAnalyzeAAFSelected_triggered();
453 void on_actionAnalyzeAAFNotSelected_triggered();
454 void on_actionAnalyzeAAFAndSelected_triggered();
455 void on_actionAnalyzeAAFOrSelected_triggered();
456 void on_actionAnalyzeAAFAndNotSelected_triggered();
457 void on_actionAnalyzeAAFOrNotSelected_triggered();
458 void on_actionAnalyzePAFSelected_triggered();
459 void on_actionAnalyzePAFNotSelected_triggered();
460 void on_actionAnalyzePAFAndSelected_triggered();
461 void on_actionAnalyzePAFOrSelected_triggered();
462 void on_actionAnalyzePAFAndNotSelected_triggered();
463 void on_actionAnalyzePAFOrNotSelected_triggered();
465 void applyConversationFilter();
467 void on_actionAnalyzeEnabledProtocols_triggered();
468 void on_actionAnalyzeDecodeAs_triggered();
469 void on_actionAnalyzeReloadLuaPlugins_triggered();
471 void openFollowStreamDialog(follow_type_t type);
472 void on_actionAnalyzeFollowTCPStream_triggered();
473 void on_actionAnalyzeFollowUDPStream_triggered();
474 void on_actionAnalyzeFollowSSLStream_triggered();
475 void on_actionAnalyzeFollowHTTPStream_triggered();
476 void statCommandExpertInfo(const char *, void *);
477 void on_actionAnalyzeExpertInfo_triggered();
479 void on_actionHelpContents_triggered();
480 void on_actionHelpMPWireshark_triggered();
481 void on_actionHelpMPWireshark_Filter_triggered();
482 void on_actionHelpMPCapinfos_triggered();
483 void on_actionHelpMPDumpcap_triggered();
484 void on_actionHelpMPEditcap_triggered();
485 void on_actionHelpMPMergecap_triggered();
486 void on_actionHelpMPRawShark_triggered();
487 void on_actionHelpMPReordercap_triggered();
488 void on_actionHelpMPText2cap_triggered();
489 void on_actionHelpMPTShark_triggered();
490 void on_actionHelpWebsite_triggered();
491 void on_actionHelpFAQ_triggered();
492 void on_actionHelpAsk_triggered();
493 void on_actionHelpDownloads_triggered();
494 void on_actionHelpWiki_triggered();
495 void on_actionHelpSampleCaptures_triggered();
496 void on_actionHelpAbout_triggered();
498 #ifdef HAVE_SOFTWARE_UPDATE
499 void checkForUpdates();
502 void on_goToCancel_clicked();
503 void on_goToGo_clicked();
504 void on_goToLineEdit_returnPressed();
505 void on_actionCaptureStart_triggered();
506 void on_actionCaptureStop_triggered();
507 void on_actionCaptureRestart_triggered();
509 void on_actionStatisticsCaptureFileProperties_triggered();
510 void on_actionStatisticsResolvedAddresses_triggered();
511 void on_actionStatisticsProtocolHierarchy_triggered();
512 void on_actionStatisticsFlowGraph_triggered();
513 void openTcpStreamDialog(int graph_type);
514 void on_actionStatisticsTcpStreamStevens_triggered();
515 void on_actionStatisticsTcpStreamTcptrace_triggered();
516 void on_actionStatisticsTcpStreamThroughput_triggered();
517 void on_actionStatisticsTcpStreamRoundTripTime_triggered();
518 void on_actionStatisticsTcpStreamWindowScaling_triggered();
519 void openSCTPAllAssocsDialog();
520 void on_actionSCTPShowAllAssociations_triggered();
521 void on_actionSCTPAnalyseThisAssociation_triggered();
522 void on_actionSCTPFilterThisAssociation_triggered();
523 void statCommandMulticastStatistics(const char *arg, void *);
524 void on_actionStatisticsUdpMulticastStreams_triggered();
526 void statCommandWlanStatistics(const char *arg, void *);
527 void on_actionWirelessWlanStatistics_triggered();
529 void openStatisticsTreeDialog(const gchar *abbr);
530 void on_actionStatistics29WestTopics_Advertisements_by_Topic_triggered();
531 void on_actionStatistics29WestTopics_Advertisements_by_Source_triggered();
532 void on_actionStatistics29WestTopics_Advertisements_by_Transport_triggered();
533 void on_actionStatistics29WestTopics_Queries_by_Topic_triggered();
534 void on_actionStatistics29WestTopics_Queries_by_Receiver_triggered();
535 void on_actionStatistics29WestTopics_Wildcard_Queries_by_Pattern_triggered();
536 void on_actionStatistics29WestTopics_Wildcard_Queries_by_Receiver_triggered();
537 void on_actionStatistics29WestQueues_Advertisements_by_Queue_triggered();
538 void on_actionStatistics29WestQueues_Advertisements_by_Source_triggered();
539 void on_actionStatistics29WestQueues_Queries_by_Queue_triggered();
540 void on_actionStatistics29WestQueues_Queries_by_Receiver_triggered();
541 void on_actionStatistics29WestUIM_Streams_triggered();
542 void on_actionStatistics29WestUIM_Stream_Flow_Graph_triggered();
543 void on_actionStatistics29WestLBTRM_triggered();
544 void on_actionStatistics29WestLBTRU_triggered();
545 void on_actionStatisticsANCP_triggered();
546 void on_actionStatisticsBACappInstanceId_triggered();
547 void on_actionStatisticsBACappIP_triggered();
548 void on_actionStatisticsBACappObjectId_triggered();
549 void on_actionStatisticsBACappService_triggered();
550 void on_actionStatisticsCollectd_triggered();
551 void statCommandConversations(const char *arg = NULL, void *userdata = NULL);
552 void on_actionStatisticsConversations_triggered();
553 void statCommandEndpoints(const char *arg = NULL, void *userdata = NULL);
554 void on_actionStatisticsEndpoints_triggered();
555 void on_actionStatisticsHART_IP_triggered();
556 void on_actionStatisticsHTTPPacketCounter_triggered();
557 void on_actionStatisticsHTTPRequests_triggered();
558 void on_actionStatisticsHTTPLoadDistribution_triggered();
559 void on_actionStatisticsPacketLengths_triggered();
560 void statCommandIOGraph(const char *, void *);
561 void on_actionStatisticsIOGraph_triggered();
562 void on_actionStatisticsSametime_triggered();
563 void on_actionStatisticsDNS_triggered();
564 void actionStatisticsPlugin_triggered();
565 void on_actionStatisticsHpfeeds_triggered();
566 void on_actionStatisticsHTTP2_triggered();
568 void openVoipCallsDialog(bool all_flows = false);
569 void on_actionTelephonyVoipCalls_triggered();
570 void on_actionTelephonyGsmMapSummary_triggered();
571 void statCommandLteMacStatistics(const char *arg, void *);
572 void on_actionTelephonyLteRlcStatistics_triggered();
573 void statCommandLteRlcStatistics(const char *arg, void *);
574 void on_actionTelephonyLteMacStatistics_triggered();
575 void on_actionTelephonyLteRlcGraph_triggered();
576 void on_actionTelephonyIax2StreamAnalysis_triggered();
577 void on_actionTelephonyISUPMessages_triggered();
578 void on_actionTelephonyMtp3Summary_triggered();
579 void on_actionTelephonyRTPStreams_triggered();
580 void on_actionTelephonyRTPStreamAnalysis_triggered();
581 void on_actionTelephonyRTSPPacketCounter_triggered();
582 void on_actionTelephonySMPPOperations_triggered();
583 void on_actionTelephonyUCPMessages_triggered();
584 void on_actionTelephonySipFlows_triggered();
586 void on_actionBluetoothATT_Server_Attributes_triggered();
587 void on_actionBluetoothDevices_triggered();
588 void on_actionBluetoothHCI_Summary_triggered();
590 void externalMenuItem_triggered();
592 void on_actionContextCopyBytesHexTextDump_triggered();
593 void on_actionContextCopyBytesHexDump_triggered();
594 void on_actionContextCopyBytesPrintableText_triggered();
595 void on_actionContextCopyBytesHexStream_triggered();
596 void on_actionContextCopyBytesBinary_triggered();
598 void on_actionContextWikiProtocolPage_triggered();
599 void on_actionContextFilterFieldReference_triggered();
601 void changeEvent(QEvent* event);
604 void extcap_options_finished(int result);
605 void showExtcapOptionsDialog(QString & device_name);
609 #endif // MAINWINDOW_H
617 * indent-tabs-mode: nil
620 * ex: set shiftwidth=4 tabstop=8 expandtab:
621 * :indentSize=4:tabSize=8:noTabs=true: