curve: free buffers in reverse order to allocation
[netsniff-ng.git] / tstamping.c
blob7c978504e6400d81125081bcc8c7fc9a3c0e2776
1 #include <string.h>
2 #include <sys/ioctl.h>
3 #include <sys/types.h>
4 #include <sys/socket.h>
5 #include <linux/sockios.h>
6 #include <linux/net_tstamp.h>
7 #include <linux/net_tstamp.h>
8 #include <linux/if_packet.h>
9 #include <linux/if.h>
11 #include "str.h"
12 #include "tstamping.h"
14 #ifdef __WITH_HARDWARE_TIMESTAMPING
15 int set_sockopt_hwtimestamp(int sock, const char *dev)
17 int timesource, ret;
18 struct hwtstamp_config hwconfig;
19 struct ifreq ifr;
21 if (!strncmp("any", dev, strlen("any")))
22 return -1;
24 memset(&hwconfig, 0, sizeof(hwconfig));
25 hwconfig.tx_type = HWTSTAMP_TX_OFF;
26 hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
28 memset(&ifr, 0, sizeof(ifr));
29 strlcpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
30 ifr.ifr_data = &hwconfig;
32 ret = ioctl(sock, SIOCSHWTSTAMP, &ifr);
33 if (ret < 0)
34 return -1;
36 timesource = SOF_TIMESTAMPING_RAW_HARDWARE;
38 return setsockopt(sock, SOL_PACKET, PACKET_TIMESTAMP, &timesource,
39 sizeof(timesource));
41 #else
42 int set_sockopt_hwtimestamp(int sock, const char *dev)
44 return -1;
46 #endif