ServiceResponseTimeDialog::ServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, register_srt *srt, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), srt_(srt) { QString subtitle = QString("%1 Service Response Time Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)))); setWindowSubtitle(subtitle); // Add number of columns for this stats_tree QStringList header_labels; for (int col = 0; col < NUM_SRT_COLUMNS; col++) { header_labels.push_back(service_response_time_get_column_name(col)); } statsTreeWidget()->setColumnCount(header_labels.count()); statsTreeWidget()->setHeaderLabels(header_labels); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == SRT_COLUMN_PROCEDURE) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } QMenu *submenu; QAction *insert_action = ctx_menu_.actions().first(); FilterAction::Action cur_action = FilterAction::ActionApply; submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action)); foreach (FilterAction::ActionType at, FilterAction::actionTypes()) { FilterAction *fa = new FilterAction(submenu, cur_action, at); submenu->addAction(fa); connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered())); filter_actions_ << fa; }
ResponseTimeDelayDialog::ResponseTimeDelayDialog(QWidget &parent, CaptureFile &cf, register_rtd *rtd, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), rtd_(rtd) { QString subtitle = tr("%1 Response Time Delay Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd)))); setWindowSubtitle(subtitle); loadGeometry(0, 0, "ResponseTimeDelayDialog"); QStringList header_names = QStringList() << tr("Type") << tr("Messages") << tr("Min SRT") << tr("Max SRT") << tr("Avg SRT") << tr("Min in Frame") << tr("Max in Frame") << tr("Open Requests") << tr("Discarded Responses") << tr("Repeated Requests") << tr("Repeated Responses"); statsTreeWidget()->setHeaderLabels(header_names); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == col_type_) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } if (!filter.isEmpty()) { setDisplayFilter(filter); } }
ExpertInfoDialog::ExpertInfoDialog(QWidget &parent, CaptureFile &capture_file) : WiresharkDialog(parent, capture_file), ui(new Ui::ExpertInfoDialog), need_show_hide_(false), display_filter_(QString()) { ui->setupUi(this); setWindowSubtitle(tr("Expert Information")); // Clicking on an item jumps to its associated packet. Make the dialog // narrow so that we avoid obscuring the packet list. // XXX Use recent settings instead int dlg_width = parent.width() / 2; if (dlg_width < width()) dlg_width = width(); resize(dlg_width, parent.height()); severity_actions_ = QList<QAction *>() << ui->actionShowError << ui->actionShowWarning << ui->actionShowNote << ui->actionShowChat << ui->actionShowComment; QList<int> severities = QList<int>() << PI_ERROR << PI_WARN << PI_NOTE << PI_CHAT << PI_COMMENT; QMenu *severity_menu = new QMenu(); // It might be nice to color each menu item to match each severity. It // might also be nice if Qt supported that... foreach (QAction *sa, severity_actions_) { severity_menu->addAction(sa); sa->setData(QVariant(severities.takeFirst())); sa->setChecked(true); connect(sa, SIGNAL(toggled(bool)), this, SLOT(actionShowToggled())); }
ServiceResponseTimeDialog::ServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, register_srt *srt, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), srt_(srt) { QString subtitle = QString("%1 Service Response Time Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)))); setWindowSubtitle(subtitle); // Add number of columns for this stats_tree QStringList header_labels; for (int col = 0; col < NUM_SRT_COLUMNS; col++) { header_labels.push_back(service_response_time_get_column_name(col)); } statsTreeWidget()->setColumnCount(header_labels.count()); statsTreeWidget()->setHeaderLabels(header_labels); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == SRT_COLUMN_PROCEDURE) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } addFilterActions(); if (!filter.isEmpty()) { setDisplayFilter(filter); } connect(statsTreeWidget(), SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(statsTreeWidgetItemChanged())); }
CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget &parent, CaptureFile &capture_file) : WiresharkDialog(parent, capture_file), ui(new Ui::CaptureFilePropertiesDialog) { ui->setupUi(this); loadGeometry(parent.width() * 2 / 3, parent.height()); ui->detailsTextEdit->setAcceptRichText(true); QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Reset); if (button) { button->setText(tr("Refresh")); } button = ui->buttonBox->button(QDialogButtonBox::Apply); if (button) { button->setText(tr("Copy To Clipboard")); } button = ui->buttonBox->button(QDialogButtonBox::Save); if (button) { button->setText(tr("Save Comments")); } setWindowSubtitle(tr("Capture File Properties")); QTimer::singleShot(0, this, SLOT(updateWidgets())); }
CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget &parent, CaptureFile &capture_file) : WiresharkDialog(parent, capture_file), ui(new Ui::CaptureFilePropertiesDialog) { ui->setupUi(this); // XXX Use recent settings instead resize(parent.width() * 2 / 3, parent.height()); QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Reset); if (button) { button->setText(tr("Refresh")); } button = ui->buttonBox->button(QDialogButtonBox::Apply); if (button) { button->setText(tr("Copy To Clipboard")); } button = ui->buttonBox->button(QDialogButtonBox::Save); if (button) { button->setText(tr("Save Comments")); } setWindowSubtitle(tr("Capture File Properties")); updateWidgets(); }
Mtp3SummaryDialog::Mtp3SummaryDialog(QWidget &parent, CaptureFile &capture_file) : WiresharkDialog(parent, capture_file), ui(new Ui::Mtp3SummaryDialog) { ui->setupUi(this); setWindowSubtitle(tr("MTP3 Summary")); updateWidgets(); }
void StatsTreeDialog::fillTree() { GString *error_string; if (!st_cfg_ || file_closed_) return; gchar* display_name_temp = stats_tree_get_displayname(st_cfg_->name); QString display_name(display_name_temp); g_free(display_name_temp); // The GTK+ UI appends "Stats Tree" to the window title. If we do the same // here we should expand the name completely, e.g. to "Statistics Tree". setWindowSubtitle(display_name); st_cfg_->pr = &cfg_pr_; cfg_pr_.st_dlg = this; if (st_) { stats_tree_free(st_); } st_ = stats_tree_new(st_cfg_, NULL, ui->displayFilterLineEdit->text().toUtf8().constData()); // Add number of columns for this stats_tree QStringList headerLabels; for (int count = 0; count<st_->num_columns; count++) { headerLabels.push_back(stats_tree_get_column_name(count)); } ui->statsTreeWidget->setColumnCount(headerLabels.count()); ui->statsTreeWidget->setHeaderLabels(headerLabels); resize(st_->num_columns*80+80, height()); for (int count = 0; count<st_->num_columns; count++) { headerLabels.push_back(stats_tree_get_column_name(count)); } ui->statsTreeWidget->setSortingEnabled(false); error_string = register_tap_listener(st_cfg_->tapname, st_, st_->filter, st_cfg_->flags, resetTap, stats_tree_packet, drawTreeItems); if (error_string) { QMessageBox::critical(this, tr("%1 failed to attach to tap").arg(display_name), error_string->str); g_string_free(error_string, TRUE); reject(); } cf_retap_packets(cap_file_.capFile()); drawTreeItems(st_); ui->statsTreeWidget->setSortingEnabled(true); remove_tap_listener(st_); st_cfg_->pr = NULL; }
RpcServiceResponseTimeDialog::RpcServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, struct register_srt *srt, RpcFamily dlg_type, const QString filter) : ServiceResponseTimeDialog(parent, cf, srt, filter), dlg_type_(dlg_type) { setRetapOnShow(false); setHint(tr("<small><i>Select a program and version and enter a filter if desired, then press Apply.</i></small>")); QHBoxLayout *filter_layout = filterLayout(); program_combo_ = new QComboBox(this); version_combo_ = new QComboBox(this); filter_layout->insertStretch(0, 1); filter_layout->insertWidget(0, version_combo_); filter_layout->insertWidget(0, new QLabel(tr("Version:"))); filter_layout->insertWidget(0, program_combo_); filter_layout->insertWidget(0, new QLabel(tr("Program:"))); if (dlg_type == DceRpc) { setWindowSubtitle(tr("DCE-RPC Service Response Times")); g_hash_table_foreach(dcerpc_uuids, dce_rpc_add_program, this); // This is a loooooong list. The GTK+ UI addresses this by making // the program combo a tree instead of a list. We might want to add a // full-height list to the left of the stats tree instead. QStringList programs = dce_name_to_uuid_key_.keys(); std::sort(programs.begin(), programs.end(), qStringCaseLessThan); connect(program_combo_, SIGNAL(currentIndexChanged(QString)), this, SLOT(dceRpcProgramChanged(QString))); program_combo_->addItems(programs); } else { setWindowSubtitle(tr("ONC-RPC Service Response Times")); g_hash_table_foreach(rpc_progs, onc_rpc_add_program, this); QStringList programs = onc_name_to_program_.keys(); std::sort(programs.begin(), programs.end(), qStringCaseLessThan); connect(program_combo_, SIGNAL(currentIndexChanged(QString)), this, SLOT(oncRpcProgramChanged(QString))); program_combo_->addItems(programs); } }
void StatsTreeDialog::fillTree() { if (!st_cfg_ || file_closed_) return; QString display_name = gchar_free_to_qstring(stats_tree_get_displayname(st_cfg_->name)); // The GTK+ UI appends "Stats Tree" to the window title. If we do the same // here we should expand the name completely, e.g. to "Statistics Tree". setWindowSubtitle(display_name); st_cfg_->pr = &cfg_pr_; cfg_pr_.st_dlg = this; if (st_) { stats_tree_free(st_); } QString display_filter = displayFilter(); st_ = stats_tree_new(st_cfg_, NULL, display_filter.toUtf8().constData()); // Add number of columns for this stats_tree QStringList header_labels; for (int count = 0; count<st_->num_columns; count++) { header_labels.push_back(stats_tree_get_column_name(count)); } statsTreeWidget()->setColumnCount(header_labels.count()); statsTreeWidget()->setHeaderLabels(header_labels); statsTreeWidget()->setSortingEnabled(false); if (!registerTapListener(st_cfg_->tapname, st_, st_->filter, st_cfg_->flags, resetTap, stats_tree_packet, drawTreeItems)) { reject(); // XXX Stay open instead? return; } cap_file_.retapPackets(); drawTreeItems(st_); statsTreeWidget()->setSortingEnabled(true); removeTapListeners(); st_cfg_->pr = NULL; }
SimpleStatisticsDialog::SimpleStatisticsDialog(QWidget &parent, CaptureFile &cf, struct _new_stat_tap_ui *stu, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), stu_(stu) { setWindowSubtitle(stu_->title); QStringList header_labels; for (int col = 0; col < (int) stu_->nfields; col++) { header_labels << stu_->fields[col].column_name; } statsTreeWidget()->setHeaderLabels(header_labels); for (int col = 0; col < (int) stu_->nfields; col++) { if (stu_->fields[col].align == TAP_ALIGN_RIGHT) { statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } } setDisplayFilter(filter); }
ResponseTimeDelayDialog::ResponseTimeDelayDialog(QWidget &parent, CaptureFile &cf, register_rtd *rtd, const QString filter, int help_topic) : TapParameterDialog(parent, cf, help_topic), rtd_(rtd) { QString subtitle = QString("%1 Response Time Delay Statistics") .arg(proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd)))); setWindowSubtitle(subtitle); statsTreeWidget()->setHeaderLabels(header_names_); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == col_type_) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } setDisplayFilter(filter); if (!filter.isEmpty()) { setDisplayFilter(filter); } }
ExpertInfoDialog::ExpertInfoDialog(QWidget &parent, CaptureFile &capture_file) : WiresharkDialog(parent, capture_file), ui(new Ui::ExpertInfoDialog), expert_info_model_(new ExpertInfoModel(capture_file)), proxyModel_(new ExpertInfoProxyModel(this)), display_filter_(QString()) { ui->setupUi(this); proxyModel_->setSourceModel(expert_info_model_); ui->expertInfoTreeView->setModel(proxyModel_); setWindowSubtitle(tr("Expert Information")); // Clicking on an item jumps to its associated packet. Make the dialog // narrow so that we avoid obscuring the packet list. int dlg_width = parent.width() * 3 / 5; if (dlg_width < width()) dlg_width = width(); loadGeometry(dlg_width, parent.height()); int one_em = fontMetrics().height(); ui->expertInfoTreeView->setColumnWidth(ExpertInfoProxyModel::colProxySummary, one_em * 25); // Arbitrary //Unfortunately this has to be done manually and not through .ui ui->severitiesPushButton->setMenu(ui->menuShowExpert); ui->expertInfoTreeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->expertInfoTreeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showExpertInfoMenu(QPoint))); QMenu *submenu; FilterAction::Action cur_action = FilterAction::ActionApply; submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action)); foreach (FilterAction::ActionType at, FilterAction::actionTypes()) { FilterAction *fa = new FilterAction(submenu, cur_action, at); submenu->addAction(fa); connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered())); }
ProtocolHierarchyDialog::ProtocolHierarchyDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf), ui(new Ui::ProtocolHierarchyDialog) { ui->setupUi(this); loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5); setWindowSubtitle(tr("Protocol Hierarchy Statistics")); ui->hierStatsTreeWidget->setItemDelegateForColumn(pct_packets_col_, &percent_bar_delegate_); ui->hierStatsTreeWidget->setItemDelegateForColumn(pct_bytes_col_, &percent_bar_delegate_); ph_stats_t *ph_stats = ph_stats_new(cap_file_.capFile()); if (ph_stats) { ui->hierStatsTreeWidget->invisibleRootItem()->setData(0, Qt::UserRole, VariantPointer<ph_stats_t>::asQVariant(ph_stats)); g_node_children_foreach(ph_stats->stats_tree, G_TRAVERSE_ALL, addTreeNode, ui->hierStatsTreeWidget->invisibleRootItem()); ph_stats_free(ph_stats); } ui->hierStatsTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->hierStatsTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showProtoHierMenu(QPoint))); ui->hierStatsTreeWidget->setSortingEnabled(true); ui->hierStatsTreeWidget->expandAll(); for (int i = 0; i < ui->hierStatsTreeWidget->columnCount(); i++) { ui->hierStatsTreeWidget->resizeColumnToContents(i); } QMenu *submenu; FilterAction::Action cur_action = FilterAction::ActionApply; submenu = ctx_menu_.addMenu(FilterAction::actionName(cur_action)); foreach (FilterAction::ActionType at, FilterAction::actionTypes()) { FilterAction *fa = new FilterAction(submenu, cur_action, at); submenu->addAction(fa); connect(fa, SIGNAL(triggered()), this, SLOT(filterActionTriggered())); }
bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index) { int tmp_fd; QString follow_filter; const char *hostname0 = NULL, *hostname1 = NULL; char *port0 = NULL, *port1 = NULL; QString server_to_client_string; QString client_to_server_string; QString both_directions_string; follow_stats_t stats; tcp_stream_chunk sc; size_t nchars; gboolean is_tcp = FALSE, is_udp = FALSE; beginRetapPackets(); resetStream(); if (file_closed_) { QMessageBox::warning(this, tr("No capture file."), tr("Please make sure you have a capture file opened.")); return false; } if (cap_file_.capFile()->edt == NULL) { QMessageBox::warning(this, tr("Error following stream."), tr("Capture file invalid.")); return false; } proto_get_frame_protocols(cap_file_.capFile()->edt->pi.layers, NULL, &is_tcp, &is_udp, NULL, NULL, NULL, NULL); switch (follow_type_) { case FOLLOW_TCP: if (!is_tcp) { QMessageBox::warning(this, tr("Error following stream."), tr("Please make sure you have a TCP packet selected.")); return false; } break; case FOLLOW_UDP: if (!is_udp) { QMessageBox::warning(this, tr("Error following stream."), tr("Please make sure you have a UDP packet selected.")); return false; } break; case FOLLOW_SSL: /* we got ssl so we can follow */ removeStreamControls(); if (!epan_dissect_packet_contains_field(cap_file_.capFile()->edt, "ssl")) { QMessageBox::critical(this, tr("Error following stream."), tr("Please make sure you have an SSL packet selected.")); return false; } break; } if (follow_type_ == FOLLOW_TCP || follow_type_ == FOLLOW_SSL) { /* Create a new filter that matches all packets in the TCP stream, and set the display filter entry accordingly */ reset_tcp_reassembly(); } else { reset_udp_follow(); } if (use_stream_index) { follow_filter = gchar_free_to_qstring( build_follow_index_filter((follow_type_ == FOLLOW_TCP) ? TCP_STREAM : UDP_STREAM)); } else { follow_filter = gchar_free_to_qstring(build_follow_conv_filter(&cap_file_.capFile()->edt->pi)); } if (follow_filter.isEmpty()) { QMessageBox::warning(this, tr("Error creating filter for this stream."), tr("A transport or network layer header is needed.")); return false; } if (follow_type_ == FOLLOW_TCP || follow_type_ == FOLLOW_SSL) { /* Create a temporary file into which to dump the reassembled data from the TCP stream, and set "data_out_file" to refer to it, so that the TCP code will write to it. XXX - it might be nicer to just have the TCP code directly append stuff to the text widget for the TCP stream window, if we can arrange that said window not pop up until we're done. */ gchar *data_out_filename; tmp_fd = create_tempfile(&data_out_filename, "follow"); data_out_filename_ = data_out_filename; if (tmp_fd == -1) { QMessageBox::warning(this, "Error", "Could not create temporary file %1: %2", data_out_filename_, g_strerror(errno)); data_out_filename_.clear(); return false; } data_out_file = fdopen(tmp_fd, "w+b"); if (data_out_file == NULL) { QMessageBox::warning(this, "Error", "Could not create temporary file %1: %2", data_out_filename_, g_strerror(errno)); //ws_close(tmp_fd); ws_unlink(data_out_filename_.toUtf8().constData()); data_out_filename_.clear(); return false; } } /* append the negation */ if(!previous_filter.isEmpty()) { filter_out_filter_ = QString("%1 and !(%2)") .arg(previous_filter).arg(follow_filter); } else { filter_out_filter_ = QString("!(%1)").arg(follow_filter); } switch (follow_type_) { case FOLLOW_TCP: { int stream_count = get_tcp_stream_count() - 1; ui->streamNumberSpinBox->blockSignals(true); ui->streamNumberSpinBox->setMaximum(stream_count); ui->streamNumberSpinBox->setValue(get_follow_index(TCP_STREAM)); ui->streamNumberSpinBox->blockSignals(false); ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count)); ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip()); break; } case FOLLOW_UDP: { /* data will be passed via tap callback*/ if (!registerTapListener("udp_follow", &follow_info_, follow_filter.toUtf8().constData(), 0, NULL, udp_queue_packet_data, NULL)) { return false; } int stream_count = get_udp_stream_count() - 1; ui->streamNumberSpinBox->blockSignals(true); ui->streamNumberSpinBox->setMaximum(stream_count); ui->streamNumberSpinBox->setValue(get_follow_index(UDP_STREAM)); ui->streamNumberSpinBox->blockSignals(false); ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count)); ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip()); break; } case FOLLOW_SSL: /* we got ssl so we can follow */ if (!registerTapListener("ssl", &follow_info_, follow_filter.toUtf8().constData(), 0, NULL, ssl_queue_packet_data, NULL)) { return false; } break; } /* Run the display filter so it goes in effect - even if it's the same as the previous display filter. */ emit updateFilter(follow_filter, TRUE); switch (follow_type_) { case FOLLOW_TCP: break; case FOLLOW_UDP: case FOLLOW_SSL: removeTapListeners(); break; } if (follow_type_ == FOLLOW_TCP) { /* Check whether we got any data written to the file. */ if (empty_tcp_stream) { QMessageBox::warning(this, "Error", "The packets in the capture file for that stream have no data."); //ws_close(tmp_fd); ws_unlink(data_out_filename_.toUtf8().constData()); data_out_filename_.clear(); return false; } /* Go back to the top of the file and read the first tcp_stream_chunk * to ensure that the IP addresses and port numbers in the drop-down * list are tied to the correct lines displayed by follow_read_stream() * later on (which also reads from this file). Close the file when * we're done. * * We read the data now, before we pop up a window, in case the * read fails. We use the data later. */ rewind(data_out_file); nchars=fread(&sc, 1, sizeof(sc), data_out_file); if (nchars != sizeof(sc)) { if (ferror(data_out_file)) { QMessageBox::warning(this, "Error", QString(tr("Could not read from temporary file %1: %2")) .arg(data_out_filename_) .arg(g_strerror(errno))); } else { QMessageBox::warning(this, "Error", QString(tr("Short read from temporary file %1: expected %2, got %3")) .arg(data_out_filename_) .arg((unsigned long)sizeof(sc)) .arg((unsigned long)nchars)); } //ws_close(tmp_fd); ws_unlink(data_out_filename_.toUtf8().constData()); data_out_filename_.clear(); return false; } fclose(data_out_file); data_out_file = NULL; } /* Stream to show */ follow_stats(&stats); if (stats.is_ipv6) { struct e_in6_addr ipaddr; memcpy(&ipaddr, stats.ip_address[0], 16); hostname0 = get_hostname6(&ipaddr); memcpy(&ipaddr, stats.ip_address[1], 16); hostname1 = get_hostname6(&ipaddr); } else { guint32 ipaddr; memcpy(&ipaddr, stats.ip_address[0], 4); hostname0 = get_hostname(ipaddr); memcpy(&ipaddr, stats.ip_address[1], 4); hostname1 = get_hostname(ipaddr); } switch (follow_type_) { case FOLLOW_TCP: port0 = tcp_port_to_display(NULL, stats.port[0]); port1 = tcp_port_to_display(NULL, stats.port[1]); break; case FOLLOW_UDP: port0 = udp_port_to_display(NULL, stats.port[0]); port1 = udp_port_to_display(NULL, stats.port[1]); break; case FOLLOW_SSL: port0 = tcp_port_to_display(NULL, stats.port[0]); port1 = tcp_port_to_display(NULL, stats.port[1]); break; } follow_info_.is_ipv6 = stats.is_ipv6; if (follow_type_ == FOLLOW_TCP) { /* Host 0 --> Host 1 */ if ((sc.src_port == stats.port[0]) && ((stats.is_ipv6 && (memcmp(sc.src_addr, stats.ip_address[0], 16) == 0)) || (!stats.is_ipv6 && (memcmp(sc.src_addr, stats.ip_address[0], 4) == 0)))) { server_to_client_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname0).arg(port0) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname1).arg(port1) .arg(gchar_free_to_qstring(format_size( stats.bytes_written[0], format_size_unit_bytes|format_size_prefix_si))); } else { server_to_client_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname1).arg(port1) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname0).arg(port0) .arg(gchar_free_to_qstring(format_size( stats.bytes_written[0], format_size_unit_bytes|format_size_prefix_si))); } /* Host 1 --> Host 0 */ if ((sc.src_port == stats.port[1]) && ((stats.is_ipv6 && (memcmp(sc.src_addr, stats.ip_address[1], 16) == 0)) || (!stats.is_ipv6 && (memcmp(sc.src_addr, stats.ip_address[1], 4) == 0)))) { client_to_server_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname0).arg(port0) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname1).arg(port1) .arg(gchar_free_to_qstring(format_size( stats.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); } else { client_to_server_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname1).arg(port1) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname0).arg(port0) .arg(gchar_free_to_qstring(format_size( stats.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); } } else { if ((follow_info_.client_port == stats.port[0]) && ((stats.is_ipv6 && (memcmp(follow_info_.client_ip.data, stats.ip_address[0], 16) == 0)) || (!stats.is_ipv6 && (memcmp(follow_info_.client_ip.data, stats.ip_address[0], 4) == 0)))) { server_to_client_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname0).arg(port0) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname1).arg(port1) .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0], format_size_unit_bytes|format_size_prefix_si))); client_to_server_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname1).arg(port1) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname0).arg(port0) .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); } else { server_to_client_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname1).arg(port1) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname0).arg(port0) .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0], format_size_unit_bytes|format_size_prefix_si))); client_to_server_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname0).arg(port0) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname1).arg(port1) .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); } } wmem_free(NULL, port0); wmem_free(NULL, port1); /* Both Stream Directions */ switch (follow_type_) { case FOLLOW_TCP: both_directions_string = QString("Entire conversation (%1)") .arg(gchar_free_to_qstring(format_size( stats.bytes_written[0] + stats.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); setWindowSubtitle(tr("Follow TCP Stream (%1)").arg(follow_filter)); break; case FOLLOW_UDP: both_directions_string = QString("Entire conversation (%1)") .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0] + follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); setWindowSubtitle(tr("Follow UDP Stream (%1)").arg(follow_filter)); break; case FOLLOW_SSL: both_directions_string = QString("Entire conversation (%1)") .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0] + follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); setWindowSubtitle(tr("Follow SSL Stream (%1)").arg(follow_filter)); break; } ui->cbDirections->clear(); ui->cbDirections->addItem(both_directions_string); ui->cbDirections->addItem(client_to_server_string); ui->cbDirections->addItem(server_to_client_string); followStream(); fillHintLabel(-1); if (data_out_file) { fclose(data_out_file); data_out_file = NULL; } endRetapPackets(); return true; }
// Constructor. LteMacStatisticsDialog::LteMacStatisticsDialog(QWidget &parent, CaptureFile &cf, const char *filter) : TapParameterDialog(parent, cf, HELP_STATS_LTE_MAC_TRAFFIC_DIALOG), commonStatsCurrent_(false) { setWindowSubtitle(tr("LTE Mac Statistics")); loadGeometry(parent.width() * 1, parent.height() * 3 / 4, "LTEMacStatisticsDialog"); clearCommonStats(); // Create common_stats_grid to appear just above the filter area. int statstree_layout_idx = verticalLayout()->indexOf(filterLayout()->widget()); QGridLayout *common_stats_grid = new QGridLayout(); // Insert into the vertical layout verticalLayout()->insertLayout(statstree_layout_idx, common_stats_grid); int one_em = fontMetrics().height(); common_stats_grid->setColumnMinimumWidth(2, one_em * 2); common_stats_grid->setColumnStretch(2, 1); common_stats_grid->setColumnMinimumWidth(5, one_em * 2); common_stats_grid->setColumnStretch(5, 1); // Create statistics label. commonStatsLabel_ = new QLabel(this); commonStatsLabel_->setObjectName("statisticsLabel"); commonStatsLabel_->setTextFormat(Qt::RichText); commonStatsLabel_->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse); common_stats_grid->addWidget(commonStatsLabel_); // Create a grid for filtering-related widgetsto also appear in layout. int filter_controls_layout_idx = verticalLayout()->indexOf(filterLayout()->widget()); QGridLayout *filter_controls_grid = new QGridLayout(); // Insert into the vertical layout verticalLayout()->insertLayout(filter_controls_layout_idx, filter_controls_grid); filter_controls_grid->setColumnMinimumWidth(2, one_em * 2); filter_controls_grid->setColumnStretch(2, 1); filter_controls_grid->setColumnMinimumWidth(5, one_em * 2); filter_controls_grid->setColumnStretch(5, 1); // Add individual controls into the grid showSRFilterCheckBox_ = new QCheckBox(tr("Include SR frames in filter")); filter_controls_grid->addWidget(showSRFilterCheckBox_); showRACHFilterCheckBox_ = new QCheckBox(tr("Include RACH frames in filter")); filter_controls_grid->addWidget(showRACHFilterCheckBox_); // Will set whole-UE headings originally. updateHeaderLabels(); statsTreeWidget()->setItemDelegateForColumn(col_ul_padding_percent_, new PercentBarDelegate()); statsTreeWidget()->setItemDelegateForColumn(col_dl_padding_percent_, new PercentBarDelegate()); statsTreeWidget()->sortByColumn(col_rnti_, Qt::AscendingOrder); // Set up column widths. // resizeColumnToContents doesn't work well here, so set sizes manually. for (int col = 0; col < statsTreeWidget()->columnCount() - 1; col++) { switch (col) { case col_rnti_: statsTreeWidget()->setColumnWidth(col, one_em * 8); break; case col_ul_frames_: statsTreeWidget()->setColumnWidth(col, one_em * 5); break; case col_ul_bytes_: statsTreeWidget()->setColumnWidth(col, one_em * 5); break; case col_ul_mb_s_: statsTreeWidget()->setColumnWidth(col, one_em * 4); break; case col_ul_padding_percent_: statsTreeWidget()->setColumnWidth(col, one_em * 6); break; case col_ul_retx_: statsTreeWidget()->setColumnWidth(col, one_em * 6); break; case col_dl_frames_: statsTreeWidget()->setColumnWidth(col, one_em * 5); break; case col_dl_bytes_: statsTreeWidget()->setColumnWidth(col, one_em * 5); break; case col_dl_mb_s_: statsTreeWidget()->setColumnWidth(col, one_em * 4); break; case col_dl_padding_percent_: statsTreeWidget()->setColumnWidth(col, one_em * 6); break; case col_dl_crc_failed_: statsTreeWidget()->setColumnWidth(col, one_em * 6); break; case col_dl_retx_: statsTreeWidget()->setColumnWidth(col, one_em * 6); break; default: // The rest are numeric statsTreeWidget()->setColumnWidth(col, one_em * 4); statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); break; } } addFilterActions(); if (filter) { setDisplayFilter(filter); } // Set handler for when the tree item changes to set the appropriate labels. connect(statsTreeWidget(), SIGNAL(itemSelectionChanged()), this, SLOT(updateHeaderLabels())); // Set handler for when display filter string is changed. connect(this, SIGNAL(updateFilter(QString)), this, SLOT(filterUpdated(QString))); }
PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata) : WiresharkDialog(parent, cf), ui(new Ui::PacketDialog), phdr_(wtap_pkthdr()), packet_data_(NULL) { ui->setupUi(this); loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5); ui->hintLabel->setSmallText(); setWindowSubtitle(tr("Packet %1").arg(fdata->num)); if (!cf_read_record(cap_file_.capFile(), fdata)) { reject(); return; } phdr_ = cap_file_.capFile()->phdr; packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_.capFile()->buf)), fdata->cap_len); /* proto tree, visible. We need a proto tree if there's custom columns */ epan_dissect_init(&edt_, cap_file_.capFile()->epan, TRUE, TRUE); col_custom_prime_edt(&edt_, &(cap_file_.capFile()->cinfo)); epan_dissect_run(&edt_, cap_file_.capFile()->cd_t, &phdr_, frame_tvbuff_new(&cap_file_.capFile()->provider, fdata, packet_data_), fdata, &(cap_file_.capFile()->cinfo)); epan_dissect_fill_in_columns(&edt_, TRUE, TRUE); proto_tree_ = new ProtoTree(ui->packetSplitter); proto_tree_->setRootNode(edt_.tree); byte_view_tab_ = new ByteViewTab(ui->packetSplitter); byte_view_tab_->setCaptureFile(cap_file_.capFile()); byte_view_tab_->selectedFrameChanged(0); ui->packetSplitter->setStretchFactor(1, 0); QStringList col_parts; for (int i = 0; i < cap_file_.capFile()->cinfo.num_cols; ++i) { // ElidedLabel doesn't support rich text / HTML col_parts << QString("%1: %2") .arg(get_column_title(i)) .arg(cap_file_.capFile()->cinfo.columns[i].col_data); } col_info_ = col_parts.join(" " UTF8_MIDDLE_DOT " "); ui->hintLabel->setText(col_info_); connect(wsApp, SIGNAL(zoomMonospaceFont(QFont)), proto_tree_, SLOT(setMonospaceFont(QFont))); connect(byte_view_tab_, SIGNAL(fieldSelected(FieldInformation *)), proto_tree_, SLOT(selectedFieldChanged(FieldInformation *))); connect(proto_tree_, SIGNAL(fieldSelected(FieldInformation *)), byte_view_tab_, SLOT(selectedFieldChanged(FieldInformation *))); connect(byte_view_tab_, SIGNAL(fieldHighlight(FieldInformation *)), this, SLOT(setHintText(FieldInformation *))); }
PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata) : WiresharkDialog(parent, cf), ui(new Ui::PacketDialog), packet_data_(NULL) { ui->setupUi(this); ui->hintLabel->setSmallText(); // XXX Use recent settings instead resize(parent.width() * 4 / 5, parent.height() * 4 / 5); setWindowSubtitle(tr("Packet %1").arg(fdata->num)); phdr_ = cap_file_.capFile()->phdr; packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_.capFile()->buf)), fdata->cap_len); if (!cf_read_record(cap_file_.capFile(), fdata)) reject(); /* proto tree, visible. We need a proto tree if there's custom columns */ epan_dissect_init(&edt_, cap_file_.capFile()->epan, TRUE, TRUE); col_custom_prime_edt(&edt_, &(cap_file_.capFile()->cinfo)); epan_dissect_run(&edt_, cap_file_.capFile()->cd_t, &phdr_, frame_tvbuff_new(fdata, packet_data_), fdata, &(cap_file_.capFile()->cinfo)); epan_dissect_fill_in_columns(&edt_, TRUE, TRUE); proto_tree_ = new ProtoTree(ui->packetSplitter); proto_tree_->fillProtocolTree(edt_.tree); proto_tree_->expandAll(); byte_view_tab_ = new ByteViewTab(ui->packetSplitter); byte_view_tab_->setCaptureFile(cap_file_.capFile()); byte_view_tab_->clear(); GSList *src_le; for (src_le = edt_.pi.data_src; src_le != NULL; src_le = src_le->next) { struct data_source *source; char* source_name; source = (struct data_source *)src_le->data; source_name = get_data_source_name(source); byte_view_tab_->addTab(source_name, get_data_source_tvb(source), edt_.tree, proto_tree_, cap_file_.capFile()->current_frame->flags.encoding); wmem_free(NULL, source_name); } byte_view_tab_->setCurrentIndex(0); ui->packetSplitter->setStretchFactor(0, 5); ui->packetSplitter->setStretchFactor(1, 1); QStringList col_parts; for (int i = 0; i < cap_file_.capFile()->cinfo.num_cols; ++i) { // ElidedLabel doesn't support rich text / HTML col_parts << QString("%1: %2") .arg(get_column_title(i)) .arg(cap_file_.capFile()->cinfo.col_data[i]); } col_info_ = col_parts.join(" " UTF8_MIDDLE_DOT " "); setHintText(); connect(this, SIGNAL(monospaceFontChanged(QFont)), proto_tree_, SLOT(setMonospaceFont(QFont))); connect(this, SIGNAL(monospaceFontChanged(QFont)), byte_view_tab_, SLOT(setMonospaceFont(QFont))); connect(proto_tree_, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), byte_view_tab_, SLOT(protoTreeItemChanged(QTreeWidgetItem*))); connect(byte_view_tab_, SIGNAL(byteFieldHovered(QString&)), this, SLOT(setHintText(QString&))); }
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, seq_analysis_info_t *sainfo) : WiresharkDialog(parent, cf), ui(new Ui::SequenceDialog), sainfo_(sainfo), num_items_(0), packet_num_(0), node_label_w_(20) { ui->setupUi(this); QCustomPlot *sp = ui->sequencePlot; setWindowSubtitle(sainfo ? tr("Call Flow") : tr("Flow")); if (!sainfo_) { sainfo_ = sequence_analysis_info_new(); sainfo_->type = SEQ_ANALYSIS_ANY; sainfo_->all_packets = TRUE; } else { num_items_ = sequence_analysis_get_nodes(sainfo_); } seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2); sp->addPlottable(seq_diagram_); sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis); sp->xAxis->setVisible(false); sp->xAxis->setPadding(0); sp->xAxis->setLabelPadding(0); sp->xAxis->setTickLabelPadding(0); sp->xAxis2->setVisible(true); sp->yAxis2->setVisible(true); one_em_ = QFontMetrics(sp->yAxis->labelFont()).height(); ui->horizontalScrollBar->setSingleStep(100 / one_em_); ui->verticalScrollBar->setSingleStep(100 / one_em_); sp->setInteractions(QCP::iRangeDrag); ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); ctx_menu_.addAction(ui->actionReset); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionMoveRight10); ctx_menu_.addAction(ui->actionMoveLeft10); ctx_menu_.addAction(ui->actionMoveUp10); ctx_menu_.addAction(ui->actionMoveDown10); ctx_menu_.addAction(ui->actionMoveRight1); ctx_menu_.addAction(ui->actionMoveLeft1); ctx_menu_.addAction(ui->actionMoveUp1); ctx_menu_.addAction(ui->actionMoveDown1); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionGoToPacket); ui->showComboBox->blockSignals(true); ui->showComboBox->setCurrentIndex(0); ui->showComboBox->blockSignals(false); ui->addressComboBox->blockSignals(true); ui->addressComboBox->setCurrentIndex(0); ui->addressComboBox->blockSignals(false); QComboBox *fcb = ui->flowComboBox; fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY); fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP); ui->flowComboBox->blockSignals(true); ui->flowComboBox->setCurrentIndex(sainfo_->type); if (sainfo_->type == SEQ_ANALYSIS_VOIP) { ui->controlFrame->hide(); } else { ui->flowComboBox->blockSignals(false); } QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS)); // XXX Use recent settings instead resize(parent.width(), parent.height() * 4 / 5); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int))); connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*))); connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int))); disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); fillDiagram(); }
Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf), ui(new Ui::Iax2AnalysisDialog), port_src_fwd_(0), port_dst_fwd_(0), port_src_rev_(0), port_dst_rev_(0) { ui->setupUi(this); setWindowSubtitle(tr("IAX2 Stream Analysis")); // XXX Use recent settings instead resize(parent.width() * 4 / 5, parent.height() * 4 / 5); ui->progressFrame->hide(); stream_ctx_menu_.addAction(ui->actionGoToPacket); stream_ctx_menu_.addAction(ui->actionNextProblem); stream_ctx_menu_.addSeparator(); stream_ctx_menu_.addAction(ui->actionSaveAudio); stream_ctx_menu_.addAction(ui->actionSaveForwardAudio); stream_ctx_menu_.addAction(ui->actionSaveReverseAudio); stream_ctx_menu_.addSeparator(); stream_ctx_menu_.addAction(ui->actionSaveCsv); stream_ctx_menu_.addAction(ui->actionSaveForwardCsv); stream_ctx_menu_.addAction(ui->actionSaveReverseCsv); stream_ctx_menu_.addSeparator(); stream_ctx_menu_.addAction(ui->actionSaveGraph); ui->forwardTreeWidget->installEventFilter(this); ui->forwardTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->forwardTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showStreamMenu(QPoint))); ui->reverseTreeWidget->installEventFilter(this); ui->reverseTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->reverseTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showStreamMenu(QPoint))); connect(ui->streamGraph, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*))); graph_ctx_menu_.addAction(ui->actionSaveGraph); QStringList header_labels; for (int i = 0; i < ui->forwardTreeWidget->columnCount(); i++) { header_labels << ui->forwardTreeWidget->headerItem()->text(i); } ui->reverseTreeWidget->setHeaderLabels(header_labels); memset(&src_fwd_, 0, sizeof(address)); memset(&dst_fwd_, 0, sizeof(address)); memset(&src_rev_, 0, sizeof(address)); memset(&dst_rev_, 0, sizeof(address)); QList<QCheckBox *> graph_cbs = QList<QCheckBox *>() << ui->fJitterCheckBox << ui->fDiffCheckBox << ui->rJitterCheckBox << ui->rDiffCheckBox; for (int i = 0; i < num_graphs_; i++) { QCPGraph *graph = ui->streamGraph->addGraph(); graph->setPen(QPen(ColorUtils::graph_colors_[i])); graph->setName(graph_cbs[i]->text()); graphs_ << graph; graph_cbs[i]->setChecked(true); graph_cbs[i]->setIcon(StockIcon::colorIcon(ColorUtils::graph_colors_[i], QPalette::Text)); } ui->streamGraph->xAxis->setLabel("Arrival Time"); ui->streamGraph->yAxis->setLabel("Value (ms)"); // We keep our temp files open for the lifetime of the dialog. The GTK+ // UI opens and closes at various points. QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath()); fwd_tempfile_ = new QTemporaryFile(tempname, this); fwd_tempfile_->open(); tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath()); rev_tempfile_ = new QTemporaryFile(tempname, this); rev_tempfile_->open(); if (fwd_tempfile_->error() != QFile::NoError || rev_tempfile_->error() != QFile::NoError) { err_str_ = tr("Unable to save RTP data."); ui->actionSaveAudio->setEnabled(false); ui->actionSaveForwardAudio->setEnabled(false); ui->actionSaveReverseAudio->setEnabled(false); } QMenu *save_menu = new QMenu(); save_menu->addAction(ui->actionSaveAudio); save_menu->addAction(ui->actionSaveForwardAudio); save_menu->addAction(ui->actionSaveReverseAudio); save_menu->addSeparator(); save_menu->addAction(ui->actionSaveCsv); save_menu->addAction(ui->actionSaveForwardCsv); save_menu->addAction(ui->actionSaveReverseCsv); save_menu->addSeparator(); save_menu->addAction(ui->actionSaveGraph); ui->buttonBox->button(QDialogButtonBox::Save)->setMenu(save_menu); const gchar *filter_text = "iax2 && (ip || ipv6)"; dfilter_t *sfcode; gchar *err_msg; if (!dfilter_compile(filter_text, &sfcode, &err_msg)) { QMessageBox::warning(this, tr("No IAX2 packets found"), QString("%1").arg(err_msg)); g_free(err_msg); close(); } if (!cap_file_.capFile() || !cap_file_.capFile()->current_frame) close(); frame_data *fdata = cap_file_.capFile()->current_frame; if (!cf_read_record(cap_file_.capFile(), fdata)) close(); epan_dissect_t edt; epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE); epan_dissect_prime_dfilter(&edt, sfcode); epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->phdr, frame_tvbuff_new_buffer(fdata, &cap_file_.capFile()->buf), fdata, NULL); // This shouldn't happen (the menu item should be disabled) but check anyway if (!dfilter_apply_edt(sfcode, &edt)) { epan_dissect_cleanup(&edt); dfilter_free(sfcode); err_str_ = tr("Please select an IAX2 packet"); updateWidgets(); return; } dfilter_free(sfcode); /* ok, it is a IAX2 frame, so let's get the ip and port values */ COPY_ADDRESS(&(src_fwd_), &(edt.pi.src)); COPY_ADDRESS(&(dst_fwd_), &(edt.pi.dst)); port_src_fwd_ = edt.pi.srcport; port_dst_fwd_ = edt.pi.destport; /* assume the inverse ip/port combination for the reverse direction */ COPY_ADDRESS(&(src_rev_), &(edt.pi.dst)); COPY_ADDRESS(&(dst_rev_), &(edt.pi.src)); port_src_rev_ = edt.pi.destport; port_dst_rev_ = edt.pi.srcport; #if 0 /* check if it is Voice or MiniPacket */ bool ok; getIntFromProtoTree(edt.tree, "iax2", "iax2.call", &ok); if (!ok) { err_str_ = tr("Please select an IAX2 packet."); updateWidgets(); return; } #endif #ifdef IAX2_RTP_STREAM_CHECK rtpstream_tapinfot tapinfo; /* Register the tap listener */ memset(&tapinfo, 0, sizeof(rtpstream_tapinfot)); tapinfo.tap_data = this; tapinfo.mode = TAP_ANALYSE; // register_tap_listener_rtp_stream(&tapinfo, NULL); /* Scan for RTP streams (redissect all packets) */ rtpstream_scan(&tapinfo, cap_file_.capFile(), NULL); int num_streams = 0; GList *filtered_list = NULL; for (GList *strinfo_list = g_list_first(tapinfo.strinfo_list); strinfo_list; strinfo_list = g_list_next(strinfo_list)) { rtp_stream_info_t * strinfo = (rtp_stream_info_t*)(strinfo_list->data); << address_to_qstring(&strinfo->dest_addr) << address_to_qstring(&src_rev_) << address_to_qstring(&dst_rev_); if (ADDRESSES_EQUAL(&(strinfo->src_addr), &(src_fwd_)) && (strinfo->src_port == port_src_fwd_) && (ADDRESSES_EQUAL(&(strinfo->dest_addr), &(dst_fwd_))) && (strinfo->dest_port == port_dst_fwd_)) { ++num_streams; filtered_list = g_list_prepend(filtered_list, strinfo); } if (ADDRESSES_EQUAL(&(strinfo->src_addr), &(src_rev_)) && (strinfo->src_port == port_src_rev_) && (ADDRESSES_EQUAL(&(strinfo->dest_addr), &(dst_rev_))) && (strinfo->dest_port == port_dst_rev_)) { ++num_streams; filtered_list = g_list_append(filtered_list, strinfo); } }
MulticastStatisticsDialog::MulticastStatisticsDialog(QWidget &parent, CaptureFile &cf, const char *filter) : TapParameterDialog(parent, cf) { setWindowSubtitle(tr("UDP Multicast Streams")); // XXX Use recent settings instead resize(parent.width() * 4 / 5, parent.height() * 3 / 4); tapinfo_ = new mcaststream_tapinfo_t(); tapinfo_->user_data = this; tapinfo_->tap_reset = tapReset; tapinfo_->tap_draw = tapDraw; QStringList header_names = QStringList() << tr("Source Address") << tr("Source Port") << tr("Destination Address") << tr("Destination Port") << tr("Packets") << tr("Packets/s") << tr("Avg BW (bps)") << tr("Max BW (bps)") << tr("Max Burst") << tr("Burst Alarms") << tr("Max Buffers (B)") << tr("Buffer Alarms"); statsTreeWidget()->setHeaderLabels(header_names); for (int col = 0; col < statsTreeWidget()->columnCount(); col++) { if (col == col_src_addr_ || col == col_dst_addr_) continue; statsTreeWidget()->headerItem()->setTextAlignment(col, Qt::AlignRight); } burst_measurement_interval_le_ = new SyntaxLineEdit(this); burst_alarm_threshold_le_ = new SyntaxLineEdit(this); buffer_alarm_threshold_le_ = new SyntaxLineEdit(this); stream_empty_speed_le_ = new SyntaxLineEdit(this); total_empty_speed_le_ = new SyntaxLineEdit(this); int filter_layout_idx = verticalLayout()->indexOf(filterLayout()->widget()); QGridLayout *param_grid = new QGridLayout(); int one_em = fontMetrics().height(); verticalLayout()->insertLayout(filter_layout_idx, param_grid); // Label | LineEdit | | Label | LineEdit | | Label | LineEdit // 0 1 2 3 4 5 6 7 param_grid->setColumnMinimumWidth(2, one_em * 2); param_grid->setColumnStretch(2, 1); param_grid->setColumnMinimumWidth(5, one_em * 2); param_grid->setColumnStretch(5, 1); param_grid->addWidget(new QLabel(tr("Burst measurement interval (ms):")), 0, 0, Qt::AlignRight); param_grid->addWidget(burst_measurement_interval_le_, 0, 1); param_grid->addWidget(new QLabel(tr("Burst alarm threshold (packets):")), 0, 3, Qt::AlignRight); param_grid->addWidget(burst_alarm_threshold_le_, 0, 4); param_grid->addWidget(new QLabel(tr("Buffer alarm threshold (B):")), 0, 6, Qt::AlignRight); param_grid->addWidget(buffer_alarm_threshold_le_, 0, 7); param_grid->addWidget(new QLabel(tr("Stream empty speed (Kb/s:")), 1, 0, Qt::AlignRight); param_grid->addWidget(stream_empty_speed_le_, 1, 1); param_grid->addWidget(new QLabel(tr("Total empty speed (Kb/s:")), 1, 3, Qt::AlignRight); param_grid->addWidget(total_empty_speed_le_, 1, 4); burst_measurement_interval_le_->setText(QString::number(mcast_stream_burstint)); burst_alarm_threshold_le_->setText(QString::number(mcast_stream_trigger)); buffer_alarm_threshold_le_->setText(QString::number(mcast_stream_bufferalarm)); stream_empty_speed_le_->setText(QString::number(mcast_stream_emptyspeed)); total_empty_speed_le_->setText(QString::number(mcast_stream_cumulemptyspeed)); line_edits_ = QList<QWidget *>() << burst_measurement_interval_le_ << burst_alarm_threshold_le_ << buffer_alarm_threshold_le_ << stream_empty_speed_le_ << total_empty_speed_le_; foreach (QWidget *line_edit, line_edits_) { line_edit->setMinimumWidth(one_em * 5); connect(line_edit, SIGNAL(textEdited(QString)), this, SLOT(updateWidgets())); }
bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index, int stream_num) { QString follow_filter; const char *hostname0 = NULL, *hostname1 = NULL; char *port0 = NULL, *port1 = NULL; QString server_to_client_string; QString client_to_server_string; QString both_directions_string; gboolean is_follower = FALSE; resetStream(); if (file_closed_) { QMessageBox::warning(this, tr("No capture file."), tr("Please make sure you have a capture file opened.")); return false; } if (cap_file_.capFile()->edt == NULL) { QMessageBox::warning(this, tr("Error following stream."), tr("Capture file invalid.")); return false; } is_follower = proto_is_frame_protocol(cap_file_.capFile()->edt->pi.layers, proto_get_protocol_filter_name(get_follow_proto_id(follower_))); if (!is_follower) { QMessageBox::warning(this, tr("Error following stream."), tr("Please make sure you have a %1 packet selected.").arg (proto_get_protocol_short_name(find_protocol_by_id(get_follow_proto_id(follower_))))); return false; } if (follow_type_ == FOLLOW_SSL) { /* we got ssl so we can follow */ removeStreamControls(); } follow_reset_stream(&follow_info_); /* Create a new filter that matches all packets in the TCP stream, and set the display filter entry accordingly */ if (use_stream_index) { follow_filter = gchar_free_to_qstring(get_follow_index_func(follower_)(stream_num)); } else { follow_filter = gchar_free_to_qstring(get_follow_conv_func(follower_)(&cap_file_.capFile()->edt->pi, &stream_num)); } if (follow_filter.isEmpty()) { QMessageBox::warning(this, tr("Error creating filter for this stream."), tr("A transport or network layer header is needed.")); return false; } /* append the negation */ if(!previous_filter.isEmpty()) { filter_out_filter_ = QString("%1 and !(%2)") .arg(previous_filter).arg(follow_filter); } else { filter_out_filter_ = QString("!(%1)").arg(follow_filter); } /* data will be passed via tap callback*/ if (!registerTapListener(get_follow_tap_string(follower_), &follow_info_, follow_filter.toUtf8().constData(), 0, NULL, get_follow_tap_handler(follower_), NULL)) { return false; } switch (follow_type_) { case FOLLOW_TCP: { int stream_count = get_tcp_stream_count(); ui->streamNumberSpinBox->blockSignals(true); ui->streamNumberSpinBox->setMaximum(stream_count-1); ui->streamNumberSpinBox->setValue(stream_num); ui->streamNumberSpinBox->blockSignals(false); ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count)); ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip()); break; } case FOLLOW_UDP: { int stream_count = get_udp_stream_count(); ui->streamNumberSpinBox->blockSignals(true); ui->streamNumberSpinBox->setMaximum(stream_count-1); ui->streamNumberSpinBox->setValue(stream_num); ui->streamNumberSpinBox->blockSignals(false); ui->streamNumberSpinBox->setToolTip(tr("%Ln total stream(s).", "", stream_count)); ui->streamNumberLabel->setToolTip(ui->streamNumberSpinBox->toolTip()); break; } case FOLLOW_SSL: case FOLLOW_HTTP: /* No extra handling */ break; } beginRetapPackets(); updateWidgets(true); /* Run the display filter so it goes in effect - even if it's the same as the previous display filter. */ emit updateFilter(follow_filter, TRUE); removeTapListeners(); hostname0 = address_to_name(&follow_info_.client_ip); hostname1 = address_to_name(&follow_info_.server_ip); port0 = get_follow_port_to_display(follower_)(NULL, follow_info_.client_port); port1 = get_follow_port_to_display(follower_)(NULL, follow_info_.server_port); server_to_client_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname0).arg(port0) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname1).arg(port1) .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0], format_size_unit_bytes|format_size_prefix_si))); client_to_server_string = QString("%1:%2 %3 %4:%5 (%6)") .arg(hostname1).arg(port1) .arg(UTF8_RIGHTWARDS_ARROW) .arg(hostname0).arg(port0) .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); wmem_free(NULL, port0); wmem_free(NULL, port1); both_directions_string = QString("Entire conversation (%1)") .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0] + follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); setWindowSubtitle(tr("Follow %1 Stream (%2)").arg(proto_get_protocol_short_name(find_protocol_by_id(get_follow_proto_id(follower_)))) .arg(follow_filter)); ui->cbDirections->clear(); ui->cbDirections->addItem(both_directions_string); ui->cbDirections->addItem(client_to_server_string); ui->cbDirections->addItem(server_to_client_string); followStream(); fillHintLabel(-1); updateWidgets(false); endRetapPackets(); return true; }
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info) : WiresharkDialog(parent, cf), ui(new Ui::SequenceDialog), info_(info), num_items_(0), packet_num_(0), sequence_w_(1) { ui->setupUi(this); loadGeometry(parent.width(), parent.height() * 4 / 5); QCustomPlot *sp = ui->sequencePlot; setWindowSubtitle(info_ ? tr("Call Flow") : tr("Flow")); if (!info_) { info_ = new SequenceInfo(sequence_analysis_info_new()); info_->sainfo()->type = SEQ_ANALYSIS_ANY; info_->sainfo()->all_packets = TRUE; } else { info_->ref(); num_items_ = sequence_analysis_get_nodes(info_->sainfo()); } seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2); sp->addPlottable(seq_diagram_); // When dragging is enabled it's easy to drag past the lower and upper // bounds of each axis. Disable it for now. //sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis); //sp->setInteractions(QCP::iRangeDrag); sp->xAxis->setVisible(false); sp->xAxis->setPadding(0); sp->xAxis->setLabelPadding(0); sp->xAxis->setTickLabelPadding(0); QPen base_pen(ColorUtils::alphaBlend(palette().text(), palette().base(), 0.25)); base_pen.setWidthF(0.5); sp->xAxis2->setBasePen(base_pen); sp->yAxis->setBasePen(base_pen); sp->yAxis2->setBasePen(base_pen); sp->xAxis2->setVisible(true); sp->yAxis2->setVisible(true); key_text_ = new QCPItemText(sp); key_text_->setText(tr("Time")); sp->addItem(key_text_); key_text_->setPositionAlignment(Qt::AlignRight | Qt::AlignVCenter); key_text_->position->setType(QCPItemPosition::ptAbsolute); key_text_->setClipToAxisRect(false); comment_text_ = new QCPItemText(sp); comment_text_->setText(tr("Comment")); sp->addItem(comment_text_); comment_text_->setPositionAlignment(Qt::AlignLeft | Qt::AlignVCenter); comment_text_->position->setType(QCPItemPosition::ptAbsolute); comment_text_->setClipToAxisRect(false); one_em_ = QFontMetrics(sp->yAxis->labelFont()).height(); ui->horizontalScrollBar->setSingleStep(100 / one_em_); ui->verticalScrollBar->setSingleStep(100 / one_em_); ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); ctx_menu_.addAction(ui->actionReset); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionMoveRight10); ctx_menu_.addAction(ui->actionMoveLeft10); ctx_menu_.addAction(ui->actionMoveUp10); ctx_menu_.addAction(ui->actionMoveDown10); ctx_menu_.addAction(ui->actionMoveRight1); ctx_menu_.addAction(ui->actionMoveLeft1); ctx_menu_.addAction(ui->actionMoveUp1); ctx_menu_.addAction(ui->actionMoveDown1); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionGoToPacket); ctx_menu_.addAction(ui->actionGoToNextPacket); ctx_menu_.addAction(ui->actionGoToPreviousPacket); ui->showComboBox->setCurrentIndex(0); ui->addressComboBox->setCurrentIndex(0); QComboBox *fcb = ui->flowComboBox; fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY); fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP); ui->flowComboBox->setCurrentIndex(info_->sainfo()->type); if (info_->sainfo()->type == SEQ_ANALYSIS_VOIP) { ui->flowComboBox->blockSignals(true); ui->controlFrame->hide(); } QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS)); ProgressFrame::addToButtonBox(ui->buttonBox, &parent); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int))); connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheeled(QWheelEvent*))); connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int))); disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); }