aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/README.extcap4
-rwxr-xr-xdoc/extcap_example.py2
-rw-r--r--extcap.c30
-rw-r--r--extcap.h4
-rw-r--r--extcap_parser.c13
-rw-r--r--extcap_parser.h16
-rw-r--r--ui/qt/extcap_options_dialog.cpp19
7 files changed, 59 insertions, 29 deletions
diff --git a/doc/README.extcap b/doc/README.extcap
index 6a4f33f44d..fb901a73ea 100644
--- a/doc/README.extcap
+++ b/doc/README.extcap
@@ -44,7 +44,7 @@ in the doc/extcap.4 generated man page (in the build dir).
Example:
$ extcapbin --extcap-interfaces
-extcap {version=1.0}
+extcap {version=1.0}{help=Some help url}
interface {value=example1}{display=Example interface 1 for extcap}
interface {value=example2}{display=Example interface 2 for extcap}
@@ -55,6 +55,8 @@ interface in the about dialog of Wireshark (Qt only).
The value for each interface will be used in subsequent calls as the interface
name IFACE.
+Using the help argument, an interface may provide a generic help url for the extcap utility.
+
STEP2: the extcap is queried for valid DLTs (Data Link Types) for all the
interfaces returned by the step 1.
diff --git a/doc/extcap_example.py b/doc/extcap_example.py
index 9007e26bba..02a3f2b8c5 100755
--- a/doc/extcap_example.py
+++ b/doc/extcap_example.py
@@ -123,7 +123,7 @@ def extcap_config(interface):
def extcap_interfaces():
- print ("extcap {version=1.0}")
+ print ("extcap {version=1.0}{help=http://www.wireshark.org}")
print ("interface {value=example1}{display=Example interface usage for extcap}")
def extcap_dlts(interface):
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 )
diff --git a/extcap.h b/extcap.h
index 254bd9fa3a..5a78d214d8 100644
--- a/extcap.h
+++ b/extcap.h
@@ -75,6 +75,10 @@ extcap_get_if_dlts(const gchar * ifname, char ** err_str);
GList *
append_extcap_interface_list(GList *list, char **err_str);
+/* return the help page or NULL for the given ifname */
+gchar *
+extcap_get_help_for_ifname(const char *ifname);
+
/* get a list of all available extcap tools */
GHashTable *
extcap_tools_list(void);
diff --git a/extcap_parser.c b/extcap_parser.c
index f2271399d9..f9e2c856ea 100644
--- a/extcap_parser.c
+++ b/extcap_parser.c
@@ -188,6 +188,8 @@ static extcap_token_sentence *extcap_tokenize_sentence(const gchar *s) {
param_type = EXTCAP_PARAM_VALIDATION;
} else if (g_ascii_strcasecmp(arg, "version") == 0) {
param_type = EXTCAP_PARAM_VERSION;
+ } else if (g_ascii_strcasecmp(arg, "help") == 0) {
+ param_type = EXTCAP_PARAM_HELP;
} else {
param_type = EXTCAP_PARAM_UNKNOWN;
}
@@ -550,11 +552,7 @@ static extcap_interface * extcap_parse_interface_sentence(extcap_token_sentence
if (sent == EXTCAP_SENTENCE_UNKNOWN)
return NULL;
- ri = g_new(extcap_interface, 1);
-
- ri->call = NULL;
- ri->display = NULL;
- ri->version = NULL;
+ ri = g_new0(extcap_interface, 1);
ri->if_type = sent;
@@ -580,6 +578,11 @@ static extcap_interface * extcap_parse_interface_sentence(extcap_token_sentence
ri->version = g_strdup(param_value);
}
+ if ((param_value = (gchar *)g_hash_table_lookup(s->param_list, ENUM_KEY(EXTCAP_PARAM_HELP)))
+ != NULL) {
+ ri->help = g_strdup(param_value);
+ }
+
return ri;
}
diff --git a/extcap_parser.h b/extcap_parser.h
index 298fbd7558..5f12037014 100644
--- a/extcap_parser.h
+++ b/extcap_parser.h
@@ -75,7 +75,8 @@ typedef enum {
EXTCAP_PARAM_REQUIRED,
EXTCAP_PARAM_SAVE,
EXTCAP_PARAM_VALIDATION,
- EXTCAP_PARAM_VERSION
+ EXTCAP_PARAM_VERSION,
+ EXTCAP_PARAM_HELP
} extcap_param_type;
#define ENUM_KEY(s) GUINT_TO_POINTER((guint)s)
@@ -127,15 +128,12 @@ typedef struct _extcap_arg {
GList * values;
} extcap_arg;
-typedef struct _extcap_if {
- gchar * extcap_path;
- GList * interfaces;
-} extcap_if;
-
typedef struct _extcap_interface {
- gchar *call;
- gchar *display;
- gchar *version;
+ gchar * call;
+ gchar * display;
+ gchar * version;
+ gchar * help;
+ gchar * extcap_path;
extcap_sentence_type if_type;
} extcap_interface;
diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp
index cd728d8d91..0c1e8bae9d 100644
--- a/ui/qt/extcap_options_dialog.cpp
+++ b/ui/qt/extcap_options_dialog.cpp
@@ -34,6 +34,8 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
+#include <QUrl>
+#include <QDesktopServices>
#include "ringbuffer.h"
#include "ui/capture_ui_utils.h"
@@ -304,8 +306,21 @@ void ExtcapOptionsDialog::on_buttonBox_rejected()
void ExtcapOptionsDialog::on_buttonBox_helpRequested()
{
- // Probably the wrong URL.
- wsApp->helpTopicAction(HELP_EXTCAP_OPTIONS_DIALOG);
+ interface_t device;
+ gchar * interface_help = NULL;
+
+ device = g_array_index(global_capture_opts.all_ifaces, interface_t, device_idx);
+ interface_help = extcap_get_help_for_ifname(device.name);
+
+ if (interface_help)
+ {
+ QUrl help_url = QString(interface_help);
+ QDesktopServices::openUrl(help_url);
+ }
+ else
+ {
+ wsApp->helpTopicAction(HELP_EXTCAP_OPTIONS_DIALOG);
+ }
}
bool ExtcapOptionsDialog::saveOptionToCaptureInfo()