Qt: Keep extcap control channels when capturing to multiple files

When using the "Create a new file automatically" feature the capture in
Wireshark will stop and start, but the extcap utility will continue run
as normal. Ensure the control channels are kept when doing this.

Rename the unused capture_session.session_started to session_will_restart
to detect this.

Bug: 16178
Change-Id: I6797c982760a1013fca2a24699befff1dc82f28c
Reviewed-on: https://code.wireshark.org/review/35013
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Stig Bjørlykke 2019-11-07 11:35:47 +00:00 committed by Roland Knall
parent f75f128462
commit abfa0d6218
6 changed files with 21 additions and 14 deletions

View File

@ -48,7 +48,7 @@ typedef struct _capture_session {
uid_t owner; /**< owner of the cfile */
gid_t group; /**< group of the cfile */
#endif
gboolean session_started;
gboolean session_will_restart; /**< Set when session will restart */
guint32 count; /**< Total number of frames captured */
capture_options *capture_opts; /**< options for this capture */
capture_file *cf; /**< handle to cfile */

View File

@ -128,7 +128,7 @@ capture_session_init(capture_session *cap_session, capture_file *cf)
cap_session->group = getgid();
#endif
cap_session->count = 0;
cap_session->session_started = FALSE;
cap_session->session_will_restart = FALSE;
}
/* Append an arg (realloc) to an argc/argv array */

View File

@ -414,6 +414,7 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
/* (we can only have an open capture file in real_time_mode!) */
if( ((capture_file *) cap_session->cf)->state != FILE_CLOSED) {
if(capture_opts->real_time_mode) {
cap_session->session_will_restart = TRUE;
capture_callback_invoke(capture_cb_capture_update_finished, cap_session);
cf_finish_tail((capture_file *)cap_session->cf,
&cap_session->rec, &cap_session->buf, &err);
@ -714,6 +715,7 @@ capture_input_closed(capture_session *cap_session, gchar *msg)
/* Tell the GUI we are not doing a capture any more.
Must be done after the cf_finish_tail(), so file lengths are
correctly displayed */
cap_session->session_will_restart = FALSE;
capture_callback_invoke(capture_cb_capture_update_finished, cap_session);
/* Finish the capture. */

View File

@ -2517,7 +2517,7 @@ void MainWindow::changeEvent(QEvent* event)
}
/* Update main window items based on whether there's a capture in progress. */
void MainWindow::setForCaptureInProgress(bool capture_in_progress, GArray *ifaces)
void MainWindow::setForCaptureInProgress(bool capture_in_progress, bool handle_toolbars, GArray *ifaces)
{
setMenusForCaptureInProgress(capture_in_progress);
@ -2532,12 +2532,14 @@ void MainWindow::setForCaptureInProgress(bool capture_in_progress, GArray *iface
// set_capture_if_dialog_for_capture_in_progress(capture_in_progress);
#endif
QList<InterfaceToolbar *> toolbars = findChildren<InterfaceToolbar *>();
foreach(InterfaceToolbar *toolbar, toolbars) {
if (capture_in_progress) {
toolbar->startCapture(ifaces);
} else {
toolbar->stopCapture();
if (handle_toolbars) {
QList<InterfaceToolbar *> toolbars = findChildren<InterfaceToolbar *>();
foreach(InterfaceToolbar *toolbar, toolbars) {
if (capture_in_progress) {
toolbar->startCapture(ifaces);
} else {
toolbar->stopCapture();
}
}
}
}

View File

@ -268,7 +268,7 @@ private:
void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint depth);
void setForCaptureInProgress(bool capture_in_progress = false, GArray *ifaces = NULL);
void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
void captureFileReadStarted(const QString &action);

View File

@ -501,7 +501,8 @@ void MainWindow::captureCapturePrepared(capture_session *session) {
/* Disable menu items that make no sense if you're currently running
a capture. */
setForCaptureInProgress(true, session->capture_opts->ifaces);
bool handle_toolbars = (session->session_will_restart ? false : true);
setForCaptureInProgress(true, handle_toolbars, session->capture_opts->ifaces);
// set_capture_if_dialog_for_capture_in_progress(TRUE);
// /* Don't set up main window for a capture file. */
@ -515,12 +516,13 @@ void MainWindow::captureCaptureUpdateStarted(capture_session *session) {
switching to the next multiple file. */
setTitlebarForCaptureInProgress();
setForCaptureInProgress(true, session->capture_opts->ifaces);
bool handle_toolbars = (session->session_will_restart ? false : true);
setForCaptureInProgress(true, handle_toolbars, session->capture_opts->ifaces);
setForCapturedPackets(true);
}
void MainWindow::captureCaptureUpdateFinished(capture_session *) {
void MainWindow::captureCaptureUpdateFinished(capture_session *session) {
/* The capture isn't stopping any more - it's stopped. */
capture_stopping_ = false;
@ -530,7 +532,8 @@ void MainWindow::captureCaptureUpdateFinished(capture_session *) {
/* Enable menu items that make sense if you're not currently running
a capture. */
setForCaptureInProgress(false);
bool handle_toolbars = (session->session_will_restart ? false : true);
setForCaptureInProgress(false, handle_toolbars);
setMenusForCaptureFile();
setWindowIcon(wsApp->normalIcon());