aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-02-19 22:11:52 -0800
committerGuy Harris <gharris@sonic.net>2022-02-19 22:11:52 -0800
commitbb659a3c9e4b5df6e55bcee859cdb12565b9d2d9 (patch)
treeac7792dfe7ef046569f22599ef8fd0b10e7183a3 /pcap-linux.c
parent7f14beebf2a33c58e6e5dc98258dd81d22485985 (diff)
linux: clean up fetching of time stamp types.
Always define an internal iface_get_ts_info() routine to fetch the time stamp types, even if there's no support for time stamp types - in that case, we simply don't set any time stamp types. This gets rid of an #ifdef in pcap_create_interface(), and avoids some potention "argument not used" warnings.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 13851322..952f5824 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -319,10 +319,8 @@ static int iface_get_arptype(int fd, const char *device, char *ebuf);
static int iface_bind(int fd, int ifindex, char *ebuf, int protocol);
static int enter_rfmon_mode(pcap_t *handle, int sock_fd,
const char *device);
-#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP)
-static int iface_ethtool_get_ts_info(const char *device, pcap_t *handle,
+static int iface_get_ts_info(const char *device, pcap_t *handle,
char *ebuf);
-#endif
static int iface_get_offload(pcap_t *handle);
static int fix_program(pcap_t *handle, struct sock_fprog *fcode);
@@ -349,15 +347,13 @@ pcap_create_interface(const char *device, char *ebuf)
handle->activate_op = pcap_activate_linux;
handle->can_set_rfmon_op = pcap_can_set_rfmon_linux;
-#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP)
/*
* See what time stamp types we support.
*/
- if (iface_ethtool_get_ts_info(device, handle, ebuf) == -1) {
+ if (iface_get_ts_info(device, handle, ebuf) == -1) {
pcap_close(handle);
return NULL;
}
-#endif
/*
* We claim that we support microsecond and nanosecond time
@@ -4785,7 +4781,7 @@ iface_set_all_ts_types(pcap_t *handle, char *ebuf)
* Get a list of time stamping capabilities.
*/
static int
-iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
+iface_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
{
int fd;
struct ifreq ifr;
@@ -4903,7 +4899,7 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
}
#else /* ETHTOOL_GET_TS_INFO */
static int
-iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
+iface_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
{
/*
* This doesn't apply to the "any" device; you can't say "turn on
@@ -4926,7 +4922,15 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
return 0;
}
#endif /* ETHTOOL_GET_TS_INFO */
-
+#else /* defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) */
+static int
+iface_get_ts_info(const char *device _U_, pcap_t *p _U_, char *ebuf _U_)
+{
+ /*
+ * Nothing to fetch, so it always "succeeds".
+ */
+ return 0;
+}
#endif /* defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) */
/*