aboutsummaryrefslogtreecommitdiffstats
path: root/capchild/capture_ifinfo.c
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 /capchild/capture_ifinfo.c
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 'capchild/capture_ifinfo.c')
-rw-r--r--capchild/capture_ifinfo.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/capchild/capture_ifinfo.c b/capchild/capture_ifinfo.c
index e3773f512b..d158cabe81 100644
--- a/capchild/capture_ifinfo.c
+++ b/capchild/capture_ifinfo.c
@@ -228,11 +228,10 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
char **err_str, void (*update_cb)(void))
{
if_capabilities_t *caps;
- GList *linktype_list = NULL;
+ GList *linktype_list = NULL, *timestamp_list = NULL;
int err, i;
gchar *data, *primary_msg, *secondary_msg;
- gchar **raw_list, **lt_parts;
- data_link_info_t *data_link_info;
+ gchar **raw_list;
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface Capabilities ...");
@@ -309,11 +308,12 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
}
/*
- * The rest are link-layer types.
+ * The following are link-layer types.
*/
- for (i = 1; raw_list[i] != NULL; i++) {
+ for (i = 1; raw_list[i] != NULL && *raw_list[i] != '\0'; i++) {
+ data_link_info_t *data_link_info;
/* ...and what if the interface name has a tab in it, Mr. Clever Programmer? */
- lt_parts = g_strsplit(raw_list[i], "\t", 3);
+ char **lt_parts = g_strsplit(raw_list[i], "\t", 3);
if (lt_parts[0] == NULL || lt_parts[1] == NULL || lt_parts[2] == NULL) {
g_strfreev(lt_parts);
continue;
@@ -330,6 +330,25 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
linktype_list = g_list_append(linktype_list, data_link_info);
}
+
+ if (raw_list[i]) { /* Oh, timestamp types! */
+ for (i++; raw_list[i] != NULL && *raw_list[i] != '\0'; i++) {
+ timestamp_info_t *timestamp_info;
+ char **tt_parts = g_strsplit(raw_list[i], "\t", 2);
+ if (tt_parts[0] == NULL || tt_parts[1] == NULL) {
+ g_strfreev(tt_parts);
+ continue;
+ }
+
+ timestamp_info = g_new(timestamp_info_t,1);
+ timestamp_info->name = g_strdup(tt_parts[0]);
+ timestamp_info->description = g_strdup(tt_parts[1]);
+ g_strfreev(tt_parts);
+
+ timestamp_list = g_list_append(timestamp_list, timestamp_info);
+ }
+ }
+
g_strfreev(raw_list);
/* Check to see if we built a list */
@@ -340,7 +359,11 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
g_free(caps);
return NULL;
}
+
caps->data_link_types = linktype_list;
+ /* Might be NULL. Not all systems report timestamp types */
+ caps->timestamp_types = timestamp_list;
+
return caps;
}