From 11a9a501fb004bd3259f457714670ffb6d3d21e9 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 31 Oct 2018 10:03:04 +0100 Subject: Dumpcap+Qt: Add support for `-a packets:NUM` and `-b packets:NUM`. Add the ability to rotate files after a specified number of packets (`-b packets:NUM`). Move some condition checks to capture_loop_write_packet_cb. Add `-a packets:NUM` in order to be consistent. It is functionally equivalent to the `-c` flag. Add a corresponding "packets" option to the Capture Interfaces dialog Output tab. Add initial tests for autostop and ringbuffer conditions. Change-Id: I66eb968927ed287deb8edb96db96d7c73526c257 Reviewed-on: https://code.wireshark.org/review/30534 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/capture_interfaces_dialog.cpp | 15 ++++- ui/qt/capture_interfaces_dialog.ui | 120 ++++++++++++++++++++++-------------- 2 files changed, 88 insertions(+), 47 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index 0bef6cba84..b9dc86ff9c 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -549,6 +549,10 @@ void CaptureInterfacesDialog::updateInterfaces() } ui->gbNewFileAuto->setChecked(global_capture_opts.multi_files_on); + ui->PktCheckBox->setChecked(global_capture_opts.has_file_packets); + if (global_capture_opts.has_file_packets) { + ui->PktSpinBox->setValue(global_capture_opts.file_packets); + } ui->MBCheckBox->setChecked(global_capture_opts.has_autostop_filesize); ui->SecsCheckBox->setChecked(global_capture_opts.has_file_interval); if (global_capture_opts.has_autostop_filesize) { @@ -850,6 +854,10 @@ bool CaptureInterfacesDialog::saveOptionsToPreferences() break; } } + global_capture_opts.has_file_packets = ui->PktCheckBox->isChecked(); + if (global_capture_opts.has_file_packets) { + global_capture_opts.file_packets = ui->PktSpinBox->value(); + } global_capture_opts.has_autostop_filesize = ui->MBCheckBox->isChecked(); if (global_capture_opts.has_autostop_filesize) { global_capture_opts.autostop_filesize = ui->MBSpinBox->value(); @@ -878,9 +886,12 @@ bool CaptureInterfacesDialog::saveOptionsToPreferences() QMessageBox::warning(this, tr("Error"), tr("Multiple files: No capture file name given. You must specify a filename if you want to use multiple files.")); return false; - } else if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_interval) { + } else if (!global_capture_opts.has_autostop_filesize && + !global_capture_opts.has_file_interval && + !global_capture_opts.has_file_duration && + !global_capture_opts.has_file_packets) { QMessageBox::warning(this, tr("Error"), - tr("Multiple files: No file limit given. You must specify a file size or interval at which is switched to the next capture file\n if you want to use multiple files.")); + tr("Multiple files: No file limit given. You must specify a file size, interval, or number of packets for each file.")); g_free(global_capture_opts.save_file); global_capture_opts.save_file = NULL; return false; diff --git a/ui/qt/capture_interfaces_dialog.ui b/ui/qt/capture_interfaces_dialog.ui index 7d3c416f27..181f5df332 100644 --- a/ui/qt/capture_interfaces_dialog.ui +++ b/ui/qt/capture_interfaces_dialog.ui @@ -262,10 +262,38 @@ true - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + + + - <html><head/><body><p>If the selected file size is exceeded, capturing switches to the next file.</p><p>PLEASE NOTE: One option MUST be selected.</p></body></html> + If the selected file size is exceeded, capturing switches to the next file. +PLEASE NOTE: One option MUST be selected. true @@ -284,30 +312,7 @@ - - - - If the selected file size is exceeded, capturing switches to the next file. -PLEASE NOTE: One option MUST be selected. - - - - kilobytes - - - - - megabytes - - - - - gigabytes - - - - - + If the selected file size is exceeded, capturing switches to the next file. @@ -331,10 +336,9 @@ PLEASE NOTE: One option MUST be selected. - + - If the selected file size is exceeded, capturing switches to the next file. -PLEASE NOTE: One option MUST be selected. + <html><head/><body><p>If the selected file size is exceeded, capturing switches to the next file.</p><p>PLEASE NOTE: One option MUST be selected.</p></body></html> true @@ -353,30 +357,56 @@ PLEASE NOTE: One option MUST be selected. - - - - Qt::Horizontal - - - - 40 - 20 - + + + + If the selected file size is exceeded, capturing switches to the next file. +PLEASE NOTE: One option MUST be selected. - + + + kilobytes + + + + + megabytes + + + + + gigabytes + + + - + - - + + + + Switch to the next file after the specified number of packets have been captured. + + + QAbstractSpinBox::PlusMinus + + + 2147483647 + + + 100000 + + + + + - + packets -- cgit v1.2.3