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>
22 int set_sockopt_hwtimestamp(int sock
, const char *dev
)
25 struct hwtstamp_config hwconfig
;
28 if (!strncmp("any", dev
, strlen("any")))
31 memset(&hwconfig
, 0, sizeof(hwconfig
));
32 hwconfig
.tx_type
= HWTSTAMP_TX_OFF
;
33 hwconfig
.rx_filter
= HWTSTAMP_FILTER_ALL
;
35 memset(&ifr
, 0, sizeof(ifr
));
36 strlcpy(ifr
.ifr_name
, dev
, sizeof(ifr
.ifr_name
));
37 ifr
.ifr_data
= &hwconfig
;
39 ret
= ioctl(sock
, SIOCSHWTSTAMP
, &ifr
);
43 timesource
= SOF_TIMESTAMPING_RAW_HARDWARE
;
45 return setsockopt(sock
, SOL_PACKET
, PACKET_TIMESTAMP
, ×ource
,
49 int set_sockopt_hwtimestamp(int sock
, const char *dev
)