Blame pcap_get_required_select_timeout.3pcap

Packit 209cc3
.\" Copyright (c) 1994, 1996, 1997
Packit 209cc3
.\"	The Regents of the University of California.  All rights reserved.
Packit 209cc3
.\"
Packit 209cc3
.\" Redistribution and use in source and binary forms, with or without
Packit 209cc3
.\" modification, are permitted provided that: (1) source code distributions
Packit 209cc3
.\" retain the above copyright notice and this paragraph in its entirety, (2)
Packit 209cc3
.\" distributions including binary code include the above copyright notice and
Packit 209cc3
.\" this paragraph in its entirety in the documentation or other materials
Packit 209cc3
.\" provided with the distribution, and (3) all advertising materials mentioning
Packit 209cc3
.\" features or use of this software display the following acknowledgement:
Packit 209cc3
.\" ``This product includes software developed by the University of California,
Packit 209cc3
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
Packit 209cc3
.\" the University nor the names of its contributors may be used to endorse
Packit 209cc3
.\" or promote products derived from this software without specific prior
Packit 209cc3
.\" written permission.
Packit 209cc3
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
Packit 209cc3
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
Packit 209cc3
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit 209cc3
.\"
Packit 209cc3
.TH PCAP_GET_REQUIRED_SELECT_TIMEOUT 3PCAP "25 July 2018"
Packit 209cc3
.SH NAME
Packit 209cc3
pcap_get_required_select_timeout \- get a file descriptor on which a
Packit 209cc3
select() can be done for a live capture
Packit 209cc3
.SH SYNOPSIS
Packit 209cc3
.nf
Packit 209cc3
.ft B
Packit 209cc3
#include <pcap/pcap.h>
Packit 209cc3
.ft
Packit 209cc3
.LP
Packit 209cc3
.ft B
Packit 209cc3
struct timeval *pcap_get_required_select_timeout(pcap_t *p);
Packit 209cc3
.ft
Packit 209cc3
.fi
Packit 209cc3
.SH DESCRIPTION
Packit 209cc3
.B pcap_get_required_select_timeout()
Packit 209cc3
returns, on UNIX, a pointer to a
Packit 209cc3
.B struct timeval
Packit 209cc3
containing a value that must be used as the minimum timeout in
Packit 209cc3
.BR select(2) ,
Packit 209cc3
.BR poll(2) ,
Packit 209cc3
.BR epoll_wait(2) ,
Packit 209cc3
and
Packit 209cc3
.B kevent()
Packit 209cc3
calls if
Packit 209cc3
.B pcap_get_selectable_fd(3PCAP)
Packit 209cc3
returns
Packit 209cc3
.BR PCAP_ERROR .
Packit 209cc3
.PP
Packit 209cc3
The timeout that should be used in those calls must be no larger than
Packit 209cc3
the smallest of all timeouts returned by
Packit 209cc3
.B \%pcap_get_required_select_timeout()
Packit 209cc3
for devices from which packets will be captured.
Packit 209cc3
.PP
Packit 209cc3
The device for which
Packit 209cc3
.B pcap_get_selectable_fd()
Packit 209cc3
returned
Packit 209cc3
.B PCAP_ERROR
Packit 209cc3
must be put in non-blocking mode with
Packit 209cc3
.BR pcap_setnonblock(3PCAP) ,
Packit 209cc3
and an attempt must always be made to read packets from the device
Packit 209cc3
when the
Packit 209cc3
.BR select() ,
Packit 209cc3
.BR poll() ,
Packit 209cc3
.BR epoll_wait() ,
Packit 209cc3
or
Packit 209cc3
.B kevent()
Packit 209cc3
call returns.
Packit 209cc3
.PP
Packit 209cc3
Note that a device on which a read can be done without blocking may,
Packit 209cc3
on some platforms, not have any packets to read if the packet buffer
Packit 209cc3
timeout has expired.  A call to
Packit 209cc3
.B pcap_dispatch(3PCAP)
Packit 209cc3
or
Packit 209cc3
.B pcap_next_ex(3PCAP)
Packit 209cc3
will return 0 in this case, but will not block.
Packit 209cc3
.PP
Packit 209cc3
.B pcap_get_required_select_timeout()
Packit 209cc3
is not available on Windows.
Packit 209cc3
.SH RETURN VALUE
Packit 209cc3
A pointer to a
Packit 209cc3
.B struct timeval
Packit 209cc3
is returned if the timeout is required; otherwise
Packit 209cc3
.B NULL
Packit 209cc3
is returned.
Packit 209cc3
.SH BACKWARD COMPATIBILITY
Packit 209cc3
This function became available in libpcap release 1.9.0.  In previous
Packit 209cc3
releases,
Packit 209cc3
.BR select() ,
Packit 209cc3
.BR poll() ,
Packit 209cc3
.BR epoll_wait() ,
Packit 209cc3
and
Packit 209cc3
.B kevent()
Packit 209cc3
cannot be used on any capture source for which
Packit 209cc3
.B pcap_get_selectable_fd
Packit 209cc3
returns \-1.
Packit 209cc3
.SH SEE ALSO
Packit 209cc3
pcap(3PCAP), pcap_get_selectable_fd(3PCAP), select(2), poll(2),
Packit 209cc3
epoll_wait(2), kqueue(2)