2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
7 extern int set_sockopt_hwtimestamp(int sock
, const char *dev
);
9 #ifdef __WITH_HARDWARE_TIMESTAMPING
11 #include <sys/ioctl.h>
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <linux/sockios.h>
15 #include <linux/net_tstamp.h>
16 #include <linux/net_tstamp.h>
17 #include <linux/if_packet.h>
23 int set_sockopt_hwtimestamp(int sock
, const char *dev
)
26 struct hwtstamp_config hwconfig
;
29 if (!strncmp("any", dev
, strlen("any")))
32 memset(&hwconfig
, 0, sizeof(hwconfig
));
33 hwconfig
.tx_type
= HWTSTAMP_TX_OFF
;
34 hwconfig
.rx_filter
= HWTSTAMP_FILTER_ALL
;
36 memset(&ifr
, 0, sizeof(ifr
));
37 strlcpy(ifr
.ifr_name
, dev
, sizeof(ifr
.ifr_name
));
38 ifr
.ifr_data
= &hwconfig
;
40 ret
= ioctl(sock
, SIOCSHWTSTAMP
, &ifr
);
44 timesource
= SOF_TIMESTAMPING_RAW_HARDWARE
;
46 return setsockopt(sock
, SOL_PACKET
, PACKET_TIMESTAMP
, ×ource
,
50 int set_sockopt_hwtimestamp(int sock
, const char *dev
)