Commit a20f85ef authored by Joanne Hugé's avatar Joanne Hugé

Add socket option for timestamps

parent 3d857a59
...@@ -54,7 +54,7 @@ static size_t tx_buffer_len = sizeof(tx_buffer); ...@@ -54,7 +54,7 @@ static size_t tx_buffer_len = sizeof(tx_buffer);
static int fd; static int fd;
static int so_timestamping_flags = static int so_timestamping_flags =
SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_TX_SOFTWARE; SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_RAW_HARDWARE;
// Sets the interface // Sets the interface
static int set_if(char *network_if) { static int set_if(char *network_if) {
...@@ -165,6 +165,8 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime, ...@@ -165,6 +165,8 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
if (sendmsgerr < 0) if (sendmsgerr < 0)
error(EXIT_FAILURE, errno, "sendmsg failed, ret value: %d\n", sendmsgerr); error(EXIT_FAILURE, errno, "sendmsg failed, ret value: %d\n", sendmsgerr);
for(int i = 0; i < (use_timestamps + 1); i++) {
printf("Polling...\n");
pollerr = poll(&poll_fd, 1, 0); pollerr = poll(&poll_fd, 1, 0);
// If the poll revents containts a POLLERR flag // If the poll revents containts a POLLERR flag
if (pollerr == 1 && (poll_fd.revents & POLLERR)) { if (pollerr == 1 && (poll_fd.revents & POLLERR)) {
...@@ -172,6 +174,7 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime, ...@@ -172,6 +174,7 @@ void send_udp_packet(int use_etf, int use_timestamps, uint64_t txtime,
} else if(use_timestamps) { } else if(use_timestamps) {
process_timestamps(fd); process_timestamps(fd);
} }
}
} }
static void process_timestamps(int sock) { static void process_timestamps(int sock) {
...@@ -192,11 +195,12 @@ static void process_timestamps(int sock) { ...@@ -192,11 +195,12 @@ static void process_timestamps(int sock) {
msg.msg_control = &control; msg.msg_control = &control;
msg.msg_controllen = sizeof(control); msg.msg_controllen = sizeof(control);
if (recvmsg(sock, &msg, 0) == -1) { if (recvmsg(sock, &msg, MSG_DONTWAIT) == -1) {
fprintf(stderr, "recvmsg failed"); fprintf(stderr, "recvmsg failed");
exit(EXIT_FAILURE);
} }
else {
print_timestamps(&msg); print_timestamps(&msg);
}
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment