The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that: (1) source code distributions
retain the above copyright notice and this paragraph in its entirety, (2)
distributions including binary code include the above copyright notice and
this paragraph in its entirety in the documentation or other materials
provided with the distribution, and (3) all advertising materials mentioning
features or use of this software display the following acknowledgement:
``This product includes software developed by the University of California,
Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
the University nor the names of its contributors may be used to endorse
or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include <pcap/pcap.h>const struct timeval *pcap_get_required_select_timeout(pcap_t *p);
For kevent (), one EVFILT_TIMER filter per selectable descriptor can be used, rather than using the timeout argument to kevent (); if the EVFILT_TIMER event for a particular selectable descriptor signals an event, pcap_dispatch (3PCAP) should be called for the corresponding pcap_t .
On Linux systems with timerfd_create (2), one timer object created by timerfd_create () per selectable descriptor can be used, rather than using the timeout argument to epoll_wait (); if the timer object for a particular selectable descriptor signals an event, pcap_dispatch (3PCAP) should be called for the corresponding pcap_t .
Otherwise, a timeout value no larger than the smallest of all timeouts returned by \%pcap_get_required_select_timeout () for devices from which packets will be captured and any other timeouts to be used in the call should be used as the timeout for the call, and, when the call returns, pcap_dispatch (3PCAP) should be called for all pcap_t s for which a non- NULL timeout was returned, regardless of whether it's indicated as having anything to read from it or not.
All devices with a non- NULL timeout must be put in non-blocking mode with pcap_setnonblock (3PCAP).
Note that a device on which a read can be done without blocking may, on some platforms, not have any packets to read if the packet buffer timeout has expired. A call to pcap_dispatch () or pcap_next_ex (3PCAP) will return 0 in this case, but will not block.
pcap_get_required_select_timeout () is not available on Windows.
In libpcap release 1.10.0 and later, the timeout value can change from call to call, so pcap_get_required_select_timeout () must be called before each call to select (), poll (), epoll_wait (), or kevent (), and the new value must be used to calculate timeouts for the call. Code that does that will also work with libpcap 1.9.x releases, so code using pcap_get_required_select_timeout () should be changed to call it for each call to select (), poll (), epoll_wait (), or kevent () even if the code must also work with libpcap 1.9.x.