aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2018-04-05 10:02:27 +0200
committerRoland Knall <rknall@gmail.com>2018-04-05 08:40:04 +0000
commitc2422d78281e10beb6ce4ebda1d61c9d0ca63a09 (patch)
tree47bf7d32733d50da52e5adab94776c07dc175a06
parent5d8964cd3b6362615571831ef1bbe5c8cc972516 (diff)
extcap: Tell utilities the wireshark version
Add an optional argument to extcap-version, which tells the utilities the wireshark version and therefore allows them to handle different versions differently. If no version is provided, the utility has to assume it is dealing with a Wireshark 2.x version (default behavior). Change-Id: I51658300f28f503ca8050d204b73749f1a54df16 Reviewed-on: https://code.wireshark.org/review/26752 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
-rwxr-xr-xdoc/extcap_example.py8
-rw-r--r--extcap.c25
-rw-r--r--extcap.h1
-rw-r--r--extcap/extcap-base.c2
-rw-r--r--extcap/extcap-base.h2
5 files changed, 37 insertions, 1 deletions
diff --git a/doc/extcap_example.py b/doc/extcap_example.py
index 12ee0cd2aa..568dc1a25b 100755
--- a/doc/extcap_example.py
+++ b/doc/extcap_example.py
@@ -142,6 +142,9 @@ def extcap_config(interface):
print ("value {arg=%d}{value=%s}{display=%s}{default=%s}" % value)
+def extcap_version():
+ print ("extcap {version=1.0}{help=http://www.wireshark.org}{display=Example extcap interface}")
+
def extcap_interfaces():
print ("extcap {version=1.0}{help=http://www.wireshark.org}{display=Example extcap interface}")
print ("interface {value=example1}{display=Example interface 1 for extcap}")
@@ -404,6 +407,7 @@ if __name__ == '__main__':
parser.add_argument("--fifo", help="Use together with capture to provide the fifo to dump data to")
parser.add_argument("--extcap-control-in", help="Used to get control messages from toolbar")
parser.add_argument("--extcap-control-out", help="Used to send control messages to toolbar")
+ parser.add_argument("--extcap-version", help="Shows the version of this utility", action="store_true")
# Interface Arguments
parser.add_argument("--verify", help="Demonstrates a verification bool flag", action="store_true" )
@@ -431,6 +435,10 @@ if __name__ == '__main__':
if ( len(sys.argv) <= 1 ):
parser.exit("No arguments given!")
+ if ( args.extcap_version ):
+ extcap_version()
+ sys.exit(0)
+
if ( args.extcap_interfaces == False and args.extcap_interface == None ):
parser.exit("An interface must be provided or the selection must be displayed")
if ( args.extcap_capture_filter and not args.capture ):
diff --git a/extcap.c b/extcap.c
index 061d4535e2..df5c3a726c 100644
--- a/extcap.c
+++ b/extcap.c
@@ -50,6 +50,8 @@
#include "extcap.h"
#include "extcap_parser.h"
+#include "version_info.h"
+
#ifdef _WIN32
static HANDLE pipe_h = INVALID_HANDLE_VALUE;
#endif
@@ -1676,7 +1678,7 @@ static gboolean cb_load_interfaces(extcap_callback_info_t cb_info)
static void
extcap_load_interface_list(void)
{
- gchar *error;
+ gchar *error = NULL;
if (prefs.capture_no_extcap)
return;
@@ -1699,6 +1701,8 @@ extcap_load_interface_list(void)
if (_loaded_interfaces == NULL)
{
GList * arguments = NULL;
+ int major = 0;
+ int minor = 0;
_loaded_interfaces = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, extcap_free_interface_info);
/* Cleanup lookup table */
@@ -1711,6 +1715,11 @@ extcap_load_interface_list(void)
}
arguments = g_list_append(arguments, g_strdup(EXTCAP_ARGUMENT_LIST_INTERFACES));
+ arguments = g_list_append(arguments, g_strdup(EXTCAP_ARGUMENT_VERSION));
+
+ get_ws_version_number(&major, &minor, NULL);
+
+ arguments = g_list_append(arguments, g_strdup_printf("%d.%d", major, minor));
extcap_callback_info_t cb_info;
cb_info.data = NULL;
@@ -1719,6 +1728,20 @@ extcap_load_interface_list(void)
extcap_foreach(arguments, cb_load_interfaces, cb_info);
+ /* Compatibility mode. Utility did not accept version argument, therefore we just ask for the interfaces
+ * and assume, that the utility will handle compatibility on it's end */
+ if ( ! cb_info.data )
+ {
+ g_free(error);
+ error = NULL;
+
+ g_list_free_full(arguments, g_free);
+ arguments = NULL;
+
+ arguments = g_list_append(arguments, g_strdup(EXTCAP_ARGUMENT_LIST_INTERFACES));
+ extcap_foreach(arguments, cb_load_interfaces, cb_info);
+ }
+
g_list_free_full(arguments, g_free);
}
}
diff --git a/extcap.h b/extcap.h
index d7728006e3..3f1eeed2f5 100644
--- a/extcap.h
+++ b/extcap.h
@@ -35,6 +35,7 @@
#define EXTCAP_ARGUMENT_LIST_INTERFACES "--extcap-interfaces"
#define EXTCAP_ARGUMENT_INTERFACE "--extcap-interface"
#define EXTCAP_ARGUMENT_LIST_DLTS "--extcap-dlts"
+#define EXTCAP_ARGUMENT_VERSION "--extcap-version"
#define EXTCAP_ARGUMENT_RUN_CAPTURE "--capture"
#define EXTCAP_ARGUMENT_CAPTURE_FILTER "--extcap-capture-filter"
diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c
index 6ec654c790..45713adfd6 100644
--- a/extcap/extcap-base.c
+++ b/extcap/extcap-base.c
@@ -171,6 +171,7 @@ uint8_t extcap_base_parse_options(extcap_parameters * extcap, int result, char *
extcap->do_list_interfaces = 1;
break;
case EXTCAP_OPT_VERSION:
+ extcap->ws_version = g_strdup(optargument);
extcap->do_version = 1;
break;
case EXTCAP_OPT_LIST_DLTS:
@@ -297,6 +298,7 @@ void extcap_base_cleanup(extcap_parameters ** extcap)
g_free((*extcap)->version);
g_free((*extcap)->helppage);
g_free((*extcap)->help_header);
+ g_free((*extcap)->ws_version);
g_list_foreach((*extcap)->help_options, (GFunc)extcap_help_option_free, NULL);
g_list_free((*extcap)->help_options);
g_free(*extcap);
diff --git a/extcap/extcap-base.h b/extcap/extcap-base.h
index 264281577c..9413bf931f 100644
--- a/extcap/extcap-base.h
+++ b/extcap/extcap-base.h
@@ -75,6 +75,8 @@ typedef struct _extcap_parameters
uint8_t capture;
uint8_t show_config;
+ char * ws_version;
+
/* private content */
GList * interfaces;
uint8_t do_version;