aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-03-26 14:52:39 -0700
committerGuy Harris <guy@alum.mit.edu>2019-03-26 21:53:20 +0000
commit5dfde7ff83a35bb7186cd05ce61f4b139ab01203 (patch)
treeda189e284802e0ddf7c5c7a27d4b28e0eaa7ed90 /extcap.c
parent4e688ec8dac91e0ae1887da189f301fcf12534d2 (diff)
Print extcap plugins with "tshark -G plugins".
This makes it match the "Plugins" tab of the "About" dialog. While we're at it, use the same code to enumerate extcap plugins in that dialog. Change-Id: I50f402a7ab5d83d46baab070d145558ed8f688f4 Reviewed-on: https://code.wireshark.org/review/32589 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c55
1 files changed, 50 insertions, 5 deletions
diff --git a/extcap.c b/extcap.c
index 5a2cdf2adb..58ebe8075f 100644
--- a/extcap.c
+++ b/extcap.c
@@ -40,6 +40,7 @@
#include <wsutil/file_util.h>
#include <wsutil/filesystem.h>
#include <wsutil/ws_pipe.h>
+#include <wsutil/ws_printf.h>
#include <wsutil/tempfile.h>
#include "capture_opts.h"
@@ -151,7 +152,7 @@ thread_pool_wait(thread_pool_t *pool)
g_mutex_clear(&pool->data_mutex);
}
-GHashTable *
+static GHashTable *
extcap_loaded_interfaces(void)
{
if (prefs.capture_no_extcap)
@@ -175,6 +176,53 @@ extcap_clear_interfaces(void)
_tool_for_ifname = NULL;
}
+static gint
+compare_tools(gconstpointer a, gconstpointer b)
+{
+ return g_strcmp0((*(extcap_info *const *)a)->basename, (*(extcap_info *const *)b)->basename);
+}
+
+void
+extcap_get_descriptions(plugin_description_callback callback, void *callback_data)
+{
+ GHashTable * tools = extcap_loaded_interfaces();
+ GPtrArray *tools_array = g_ptr_array_new();
+
+ if (tools && g_hash_table_size(tools) > 0) {
+ GList * walker = g_list_first(g_hash_table_get_keys(tools));
+ while (walker && walker->data) {
+ extcap_info * tool = (extcap_info *)g_hash_table_lookup(tools, walker->data);
+ if (tool) {
+ g_ptr_array_add(tools_array, tool);
+ }
+ walker = g_list_next(walker);
+ }
+ }
+
+ g_ptr_array_sort(tools_array, compare_tools);
+
+ for (guint i = 0; i < tools_array->len; i++) {
+ extcap_info *tool = (extcap_info *)tools_array->pdata[i];
+ callback(tool->basename, tool->version, "extcap", tool->full_path, callback_data);
+ }
+
+ g_ptr_array_free(tools_array, TRUE);
+}
+
+static void
+print_extcap_description(const char *basename, const char *version,
+ const char *description, const char *filename,
+ void *user_data _U_)
+{
+ ws_debug_printf("%-16s\t%s\t%s\t%s\n", basename, version, description, filename);
+}
+
+void
+extcap_dump_all(void)
+{
+ extcap_get_descriptions(print_extcap_description, NULL);
+}
+
/**
* Obtains a list of extcap program paths. Use g_slist_free_full(paths, g_free)
* to destroy the list.
@@ -1937,10 +1985,7 @@ extcap_list_interfaces_cb(thread_pool_t *pool, void *data, char *output)
}
-/* Handles loading of the interfaces.
- *
- * A list of interfaces can be obtained by calling \ref extcap_loaded_interfaces
- */
+/* Handles loading of the interfaces. */
static void
extcap_load_interface_list(void)
{