- const int timestamp_on = 1;
- if (setsockopt(s, SOL_SOCKET, SO_TIMESTAMPNS,
- ×tamp_on, sizeof(timestamp_on)) < 0)
- error(1, errno, "setsockopt SO_TIMESTAMP");
+ // TODO: set HW TSTAMP flags?
+ const int so_timestamping_flags = SOF_TIMESTAMPING_RAW_HARDWARE;
+ if (setsockopt(s, SOL_SOCKET, SO_TIMESTAMPING,
+ &so_timestamping_flags,
+ sizeof(so_timestamping_flags)) < 0)
+ {
+ perror("setsockopt SO_TIMESTAMPING");
+ fprintf(stderr, "Falling back to SW timestamps.\n");
+
+ const int timestamp_on = 1;
+ if (setsockopt(s, SOL_SOCKET, SO_TIMESTAMPNS,
+ ×tamp_on, sizeof(timestamp_on)) < 0)
+ error(1, errno, "setsockopt SO_TIMESTAMPNS");
+ }