aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad.fatoum@siemens.com>2017-08-07 16:38:52 +0200
committerAnders Broman <a.broman58@gmail.com>2017-08-22 07:55:26 +0000
commitaca55a29f7b982e7a0bd9911d1d176561c8d7a84 (patch)
tree35b4f2b92ba79f49d26ebb06ae805e9eb6f4e4ac /ui
parent2845f6be8db0b1720e23db0877ec837f00967bdc (diff)
Add hardware timestamping support
pcap provides a pcap_set_tstamp_type function, which can be used to request hardware timestamps from a supporting kernel. This patch adds support for aforementioned function as well as two new command line options to dumpcap, wireshark and tshark: --list-time-stamp-types List time stamp types supported for the interface --time-stamp-type <type> Change the interface's timestamp method Name choice mimics those used by tcpdump(1), which already supports this feature. However, unlike tcpdump, we provide both options unconditionally. If Wireshark was configured without pcap_set_tstamp_type being available, --list-time-stamp-types reports an empty list. Change-Id: I418a4b2b84cb01949cd262aad0ad8427f5ac0652 Signed-off-by: Ahmad Fatoum <ahmad.fatoum@siemens.com> Reviewed-on: https://code.wireshark.org/review/23113 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/commandline.c23
-rw-r--r--ui/commandline.h1
-rw-r--r--ui/gtk/main.c20
3 files changed, 33 insertions, 11 deletions
diff --git a/ui/commandline.c b/ui/commandline.c
index dc20e1505b..e692a5e57d 100644
--- a/ui/commandline.c
+++ b/ui/commandline.c
@@ -109,8 +109,10 @@ commandline_print_usage(gboolean for_help_option) {
fprintf(output, " -B <buffer size> size of kernel buffer (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
#endif
fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
+ fprintf(output, " --time-stamp-type <type> timestamp method for interface\n");
fprintf(output, " -D print list of interfaces and exit\n");
fprintf(output, " -L print list of link-layer types of iface and exit\n");
+ fprintf(output, " --list-time-stamp-types print list of timestamp types for iface and exit\n");
fprintf(output, "\n");
fprintf(output, "Capture stop conditions:\n");
fprintf(output, " -c <packet count> stop after n packets (def: infinite)\n");
@@ -352,6 +354,7 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
{
int opt;
gboolean arg_error = FALSE;
+ const char *list_option_supplied = NULL;
#ifdef HAVE_LIBPCAP
int status;
#else
@@ -405,6 +408,7 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
#ifdef HAVE_LIBPCAP
global_commandline_info.start_capture = FALSE;
global_commandline_info.list_link_layer_types = FALSE;
+ global_commandline_info.list_timestamp_types = FALSE;
global_commandline_info.quit_after_cap = getenv("WIRESHARK_QUIT_AFTER_CAPTURE") ? TRUE : FALSE;
#endif
global_commandline_info.full_screen = FALSE;
@@ -420,6 +424,7 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
case 'H': /* Hide capture info dialog box */
case 'p': /* Don't capture in promiscuous mode */
case 'i': /* Use interface x */
+ case LONGOPT_SET_TSTAMP_TYPE: /* Set capture timestamp type */
#ifdef HAVE_PCAP_CREATE
case 'I': /* Capture in monitor mode, if available */
#endif
@@ -469,6 +474,16 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
case 'L': /* Print list of link-layer types and exit */
#ifdef HAVE_LIBPCAP
global_commandline_info.list_link_layer_types = TRUE;
+ list_option_supplied = "-L";
+#else
+ capture_option_specified = TRUE;
+ arg_error = TRUE;
+#endif
+ break;
+ case LONGOPT_LIST_TSTAMP_TYPES:
+#ifdef HAVE_LIBPCAP
+ global_commandline_info.list_timestamp_types = TRUE;
+ list_option_supplied = "--list-time-stamp-types";
#else
capture_option_specified = TRUE;
arg_error = TRUE;
@@ -631,18 +646,18 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
}
#ifdef HAVE_LIBPCAP
- if (global_commandline_info.start_capture && global_commandline_info.list_link_layer_types) {
+ if (global_commandline_info.start_capture && list_option_supplied) {
/* Specifying *both* is bogus. */
- cmdarg_err("You can't specify both -L and a live capture.");
+ cmdarg_err("You can't specify both %s and a live capture.", list_option_supplied);
exit(1);
}
- if (global_commandline_info.list_link_layer_types) {
+ if (list_option_supplied) {
/* We're supposed to list the link-layer types for an interface;
did the user also specify a capture file to be read? */
if (global_commandline_info.cf_name) {
/* Yes - that's bogus. */
- cmdarg_err("You can't specify -L and a capture file to be read.");
+ cmdarg_err("You can't specify %s and a capture file to be read.", list_option_supplied);
exit(1);
}
/* No - did they specify a ring buffer option? */
diff --git a/ui/commandline.h b/ui/commandline.h
index 85ba97c0c5..344805f1e1 100644
--- a/ui/commandline.h
+++ b/ui/commandline.h
@@ -37,6 +37,7 @@ typedef struct commandline_param_info
{
#ifdef HAVE_LIBPCAP
gboolean list_link_layer_types;
+ gboolean list_timestamp_types;
gboolean start_capture;
gboolean quit_after_cap;
#endif
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index b9b4292cc4..8214139455 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -1996,6 +1996,7 @@ main(int argc, char *argv[])
#endif
#endif
#endif
+ int caps_queries = 0;
gint pl_size = 280, tv_size = 95, bv_size = 75;
gchar *rc_file;
dfilter_t *rfcode = NULL;
@@ -2294,8 +2295,13 @@ main(int argc, char *argv[])
fill_in_local_interfaces(main_window_update);
- if (global_commandline_info.start_capture || global_commandline_info.list_link_layer_types) {
- /* We're supposed to do a live capture or get a list of link-layer
+ if (global_commandline_info.list_link_layer_types)
+ caps_queries |= CAPS_QUERY_LINK_TYPES;
+ if (global_commandline_info.list_timestamp_types)
+ caps_queries |= CAPS_QUERY_TIMESTAMP_TYPES;
+
+ if (global_commandline_info.start_capture || caps_queries) {
+ /* We're supposed to do a live capture or get a list of link-layer/timestamp
types for a live capture device; if the user didn't specify an
interface to use, pick a default. */
ret = capture_opts_default_iface_if_necessary(&global_capture_opts,
@@ -2305,13 +2311,13 @@ main(int argc, char *argv[])
}
}
- if (global_commandline_info.list_link_layer_types) {
+ if (caps_queries) {
/* Get the list of link-layer types for the capture devices. */
if_capabilities_t *caps;
guint i;
interface_t device;
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
-
+ int if_caps_queries = caps_queries;
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (device.selected) {
gchar* auth_str = NULL;
@@ -2342,10 +2348,10 @@ main(int argc, char *argv[])
create_console();
#endif /* _WIN32 */
#if defined(HAVE_PCAP_CREATE)
- capture_opts_print_if_capabilities(caps, device.name, device.monitor_mode_supported);
-#else
- capture_opts_print_if_capabilities(caps, device.name, FALSE);
+ if (device.monitor_mode_supported)
+ if_caps_queries |= CAPS_MONITOR_MODE;
#endif
+ capture_opts_print_if_capabilities(caps, device.name, if_caps_queries);
#ifdef _WIN32
destroy_console();
#endif /* _WIN32 */