22 lines
504 B
Diff
22 lines
504 B
Diff
--- pcap-linux.c
|
|
+++ pcap-linux.c
|
|
@@ -1595,6 +1595,18 @@
|
|
}
|
|
}
|
|
|
|
+ if (to_ms > 0) {
|
|
+ struct timeval timeout;
|
|
+ timeout.tv_sec = to_ms / 1000;
|
|
+ timeout.tv_usec = (to_ms * 1000) % 1000000;
|
|
+ if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO,
|
|
+ &timeout, sizeof(timeout)) == -1) {
|
|
+ snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
|
+ "setsockopt: %s", pcap_strerror(errno));
|
|
+ break;
|
|
+ };
|
|
+ }
|
|
+
|
|
/* Save the socket FD in the pcap structure */
|
|
|
|
handle->fd = sock_fd;
|