diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-12-06 23:26:25 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-12-06 23:26:25 -0800 |
commit | 6c98384b5182d97d6effb8044f00cc755e9dcb1a (patch) | |
tree | 27d3f736a653b6afe69db73e0d49dcaee0f33c52 | |
parent | 3b67275e19d04d493bb2dfc4050332fb27217b95 (diff) |
Explicitly warn that negative packet buffer timeouts should not be used.
We won't treat them as errors, because it appears:
https://stackoverflow.com/questions/46569127/what-does-to-ms-1-do-on-winpcap-and-linux-libpcap/47689659#47689659
that some programs set it to -1, probably expecting it to put the pcap_t
in non-blocking mode (as a result of the *internal implementation* of
capture on a regular network interface on *some* platforms). However,
it won't work on all platforms; if you want non-blocking mode, use
pcap_setnonblock().
-rw-r--r-- | pcap.3pcap.in | 2 | ||||
-rw-r--r-- | pcap_open_live.3pcap | 3 | ||||
-rw-r--r-- | pcap_set_timeout.3pcap | 3 |
3 files changed, 6 insertions, 2 deletions
diff --git a/pcap.3pcap.in b/pcap.3pcap.in index 11c44837..4cc0530d 100644 --- a/pcap.3pcap.in +++ b/pcap.3pcap.in @@ -174,6 +174,8 @@ Not all platforms support a packet buffer timeout; on platforms that don't, the packet buffer timeout is ignored. A zero value for the timeout, on platforms that support a packet buffer timeout, will cause a read to wait forever to allow enough packets to arrive, with no timeout. +A negative value is invalid; the result of setting the timeout to a +negative value is unpredictable. .IP .BR NOTE : the packet buffer timeout cannot be used to cause calls that read diff --git a/pcap_open_live.3pcap b/pcap_open_live.3pcap index ce45c284..d9ce8eec 100644 --- a/pcap_open_live.3pcap +++ b/pcap_open_live.3pcap @@ -56,7 +56,8 @@ specifies the snapshot length to be set on the handle. specifies if the interface is to be put into promiscuous mode. .PP .I to_ms -specifies the packet buffer timeout in milliseconds. (See +specifies the packet buffer timeout, as a non-negative value, in +milliseconds. (See .BR pcap (3PCAP) for an explanation of the packet buffer timeout.) .SH RETURN VALUE diff --git a/pcap_set_timeout.3pcap b/pcap_set_timeout.3pcap index f8e696f0..8cb8cb64 100644 --- a/pcap_set_timeout.3pcap +++ b/pcap_set_timeout.3pcap @@ -39,7 +39,8 @@ which is in units of milliseconds. (See .BR pcap (3PCAP) for an explanation of the packet buffer timeout.) .LP -The behavior, if the timeout isn't specified, is undefined. We +The behavior, if the timeout isn't specified, is undefined, as is the +behavior if the timeout is set to zero or to a negative value. We recommend always setting the timeout to a non-zero value unless immediate mode is set, in which case the timeout has no effect. .SH RETURN VALUE |