From 22b5ffad861b2efede6d64d16e38710d2c713ba1 Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Sun, 7 Jan 2018 22:06:13 +0100 Subject: [PATCH] extcap: add preference to prevent interfaces loading. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia5865a40c75e582f28408a0515c5c0b38e43a916 Reviewed-on: https://code.wireshark.org/review/25188 Reviewed-by: Stig Bjørlykke Petri-Dish: Dario Lombardo Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- epan/prefs.c | 3 +++ epan/prefs.h | 1 + extcap.c | 3 +++ ui/qt/capture_preferences_frame.cpp | 8 ++++++++ ui/qt/capture_preferences_frame.h | 2 ++ ui/qt/capture_preferences_frame.ui | 9 ++++++++- 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/epan/prefs.c b/epan/prefs.c index b06e7dfb30..f0edfcbb24 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -3470,6 +3470,9 @@ prefs_register_modules(void) prefs_register_bool_preference(capture_module, "real_time_update", "Update packet list in real time during capture", "Update packet list in real time during capture?", &prefs.capture_real_time); + prefs_register_bool_preference(capture_module, "no_extcap", "Disable Extcap interfaces", + "Disable external capture modules (Extcap)", &prefs.capture_no_extcap); + /* We might want to make this a "recent" setting. */ prefs_register_bool_preference(capture_module, "auto_scroll", "Scroll packet list during capture", "Scroll packet list during capture?", &prefs.capture_auto_scroll); diff --git a/epan/prefs.h b/epan/prefs.h index 2eb7fbbfbd..de3b239d3f 100644 --- a/epan/prefs.h +++ b/epan/prefs.h @@ -213,6 +213,7 @@ typedef struct _e_prefs { gboolean capture_pcap_ng; gboolean capture_real_time; gboolean capture_auto_scroll; + gboolean capture_no_extcap; gboolean capture_show_info; GList *capture_columns; guint rtp_player_max_visible; diff --git a/extcap.c b/extcap.c index 03aada8a9f..44ed5b5ad2 100644 --- a/extcap.c +++ b/extcap.c @@ -506,6 +506,9 @@ append_extcap_interface_list(GList *list, char **err_str _U_) extcap_interface *data = NULL; GList *ifutilkeys_head = NULL, *ifutilkeys = NULL; + if (prefs.capture_no_extcap) + return list; + /* Update the extcap interfaces and get a list of their if_infos */ if ( !_loaded_interfaces || g_hash_table_size(_loaded_interfaces) == 0 ) extcap_load_interface_list(); diff --git a/ui/qt/capture_preferences_frame.cpp b/ui/qt/capture_preferences_frame.cpp index 2a7baf9c5d..2fd6aadea6 100644 --- a/ui/qt/capture_preferences_frame.cpp +++ b/ui/qt/capture_preferences_frame.cpp @@ -50,6 +50,7 @@ CapturePreferencesFrame::CapturePreferencesFrame(QWidget *parent) : pref_pcap_ng_ = prefFromPrefPtr(&prefs.capture_pcap_ng); pref_real_time_ = prefFromPrefPtr(&prefs.capture_real_time); pref_auto_scroll_ = prefFromPrefPtr(&prefs.capture_auto_scroll); + pref_no_extcap_ = prefFromPrefPtr(&prefs.capture_no_extcap); // Setting the left margin via a style sheet clobbers its // appearance. @@ -117,6 +118,7 @@ void CapturePreferencesFrame::updateWidgets() ui->captureRealTimeCheckBox->setChecked(prefs_get_bool_value(pref_real_time_, pref_stashed)); ui->captureAutoScrollCheckBox->setChecked(prefs_get_bool_value(pref_auto_scroll_, pref_stashed)); #endif // HAVE_LIBPCAP + ui->captureNoExtcapCheckBox->setChecked(prefs_get_bool_value(pref_no_extcap_, pref_stashed)); } void CapturePreferencesFrame::on_defaultInterfaceComboBox_editTextChanged(const QString &new_iface) @@ -144,6 +146,12 @@ void CapturePreferencesFrame::on_captureAutoScrollCheckBox_toggled(bool checked) prefs_set_bool_value(pref_auto_scroll_, checked, pref_stashed); } +void CapturePreferencesFrame::on_captureNoExtcapCheckBox_toggled(bool checked) +{ + prefs_set_bool_value(pref_no_extcap_, checked, pref_stashed); + wsApp->refreshLocalInterfaces(); +} + /* * Editor modelines * diff --git a/ui/qt/capture_preferences_frame.h b/ui/qt/capture_preferences_frame.h index 1932396a9a..0806436b89 100644 --- a/ui/qt/capture_preferences_frame.h +++ b/ui/qt/capture_preferences_frame.h @@ -47,6 +47,7 @@ private slots: void on_capturePcapNgCheckBox_toggled(bool checked); void on_captureRealTimeCheckBox_toggled(bool checked); void on_captureAutoScrollCheckBox_toggled(bool checked); + void on_captureNoExtcapCheckBox_toggled(bool checked); private: Ui::CapturePreferencesFrame *ui; @@ -56,6 +57,7 @@ private: pref_t *pref_pcap_ng_; pref_t *pref_real_time_; pref_t *pref_auto_scroll_; + pref_t *pref_no_extcap_; void updateWidgets(); }; diff --git a/ui/qt/capture_preferences_frame.ui b/ui/qt/capture_preferences_frame.ui index 66d56bc550..9e15529339 100644 --- a/ui/qt/capture_preferences_frame.ui +++ b/ui/qt/capture_preferences_frame.ui @@ -7,7 +7,7 @@ 0 0 354 - 194 + 220 @@ -97,6 +97,13 @@ + + + + Disable Extcap interfaces + + +