summaryrefslogtreecommitdiff
path: root/extcap.c
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2016-09-05 07:54:47 +0200
committerRoland Knall <rknall@gmail.com>2016-09-07 09:09:30 +0000
commitee1a4109cfc8fb314d151f59859a348765ba9dbf (patch)
tree36f0efeb8e85e339824ce3d63841f87385ab971b /extcap.c
parent859cf86c8d25b7ead113821ece4e9dec853e70d6 (diff)
downloadwireshark-ee1a4109cfc8fb314d151f59859a348765ba9dbf.tar.gz
extcap: Add tool-specified helppage
Allow the tool to provide a link to a helppage, displayed by clicking on help in the configuration dialog. The URL will be opened using an URL based service, therefore local as well as remote URLs are possible. Change-Id: I58b30244e97919d5cf6892faf96536ddc30fb5a7 Reviewed-on: https://code.wireshark.org/review/17549 Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/extcap.c b/extcap.c
index 2cdbf44051..cc76dff2dd 100644
--- a/extcap.c
+++ b/extcap.c
@@ -105,9 +105,9 @@ extcap_if_exists(const gchar *ifname)
static gboolean
extcap_if_exists_for_extcap(const gchar *ifname, const gchar *extcap)
{
- gchar *entry = (gchar *)g_hash_table_lookup(ifaces, ifname);
+ extcap_interface * entry = (extcap_interface *)g_hash_table_lookup(ifaces, ifname);
- if ( entry && strcmp(entry, extcap) == 0 )
+ if ( entry && strcmp(entry->extcap_path, extcap) == 0 )
return TRUE;
return FALSE;
@@ -116,14 +116,15 @@ extcap_if_exists_for_extcap(const gchar *ifname, const gchar *extcap)
static gchar *
extcap_if_executable(const gchar *ifname)
{
- return (gchar *)g_hash_table_lookup(ifaces, ifname);
+ extcap_interface * interface = (extcap_interface *)g_hash_table_lookup(ifaces, ifname);
+ return interface != NULL ? interface->extcap_path : NULL;
}
static void
-extcap_if_add(const gchar *ifname, const gchar *extcap)
+extcap_if_add(extcap_interface * interface)
{
- if ( !g_hash_table_lookup(ifaces, ifname) )
- g_hash_table_insert(ifaces, g_strdup(ifname), g_strdup(extcap));
+ if (!g_hash_table_lookup(ifaces, interface->call))
+ g_hash_table_insert(ifaces, g_strdup(interface->call), interface);
}
static void
@@ -282,7 +283,7 @@ extcap_get_if_dlts(const gchar *ifname, char **err_str) {
return caps;
}
-static void extcap_free_interface(gpointer i, gpointer user_data _U_) {
+static void extcap_free_interface(gpointer i) {
extcap_interface * interface = (extcap_interface *)i;
@@ -292,6 +293,7 @@ static void extcap_free_interface(gpointer i, gpointer user_data _U_) {
g_free(interface->call);
g_free(interface->display);
g_free(interface->version);
+ g_free(interface->help);
}
static gboolean interfaces_cb(const gchar *extcap, const gchar *ifname _U_, gchar *output, void *data,
@@ -334,7 +336,8 @@ static gboolean interfaces_cb(const gchar *extcap, const gchar *ifname _U_, gcha
*il = g_list_append(*il, if_info);
}
- extcap_if_add(int_iter->call, extcap);
+ int_iter->extcap_path = g_strdup(extcap);
+ extcap_if_add(int_iter);
}
/* Call for interfaces and tools alike. Multiple calls (because a tool has multiple
@@ -344,8 +347,6 @@ static gboolean interfaces_cb(const gchar *extcap, const gchar *ifname _U_, gcha
walker = g_list_next(walker);
}
- g_list_foreach(interfaces, extcap_free_interface, NULL);
-
return TRUE;
}
@@ -372,7 +373,7 @@ extcap_reload_interface_list(GList **retp, char **err_str) {
/* ifaces is used as cache, do not destroy its contents when
* returning or no extcap interfaces can be queried for options */
if (ifaces == NULL)
- ifaces = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ ifaces = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, extcap_free_interface);
else
g_hash_table_remove_all(ifaces);
@@ -388,6 +389,13 @@ extcap_reload_interface_list(GList **retp, char **err_str) {
g_free(argv);
}
+gchar *
+extcap_get_help_for_ifname(const char *ifname)
+{
+ extcap_interface * interface = (extcap_interface *)g_hash_table_lookup(ifaces, ifname);
+ return interface != NULL ? interface->help : NULL;
+}
+
GHashTable *
extcap_tools_list(void) {
if ( tools == NULL || g_hash_table_size(tools) == 0 )