aboutsummaryrefslogtreecommitdiff
path: root/pcap_get_selectable_fd.3pcap
Commit message (Collapse)AuthorAgeFilesLines
* Show correct last modified date in all man pages.Denis Ovsienko2020-02-161-1/+1
| | | | | | | | | For clarity, as before, the last modified date stands for changes more substantial than trivial editorial and formatting fixups. That, for example, would be at least a change of the described behaviour, return value, semantics or backward compatibility. [skip ci]
* On Linux, return error on interface going away, not just going down.Guy Harris2020-01-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a pain to detect, because the PF_PACKET socket code appears to get separate "interface went down" and "interface went away" notifications in my "unplug a USB Wi-Fi adapter" tests on my VMware Fusion Ubuntu 18.04 virtual machine (5.3.0 kernel), and the first notification delivers a wakeup and returns ENETDOWN while the second notificaiton delivers *no* wakeup and sets the ifindex member of the struct packet_sock for the socket, so there's nothing we can test after the wakeup that's guaranteed to indicate that the interface has disappeared. So what we have to do is remember the ENETDOWN but not return it as an error, and then arrange to periodically check whether the interface is still there; if it isn't, we *then* return the "interface went away" error, and, if we see traffic or see that the interface is up, we clear the remembered ENETDOWN and stop doing the periodic checks. This is tricky, because it needs to work not only for blocking pcap_t's, where we're in a loop doing poll() calls, so we can keep checking within the loop, but also for non-blocking pcap_t's on which the caller is doing select()/poll()/epoll_wait(). In order to make *that* work, we need to tweak the semantics of pcap_get_required_select_timeout() so that it's not guaranteed that it will always return the same value, so that it should be called within event loops rather than called once outside the event loop. Normally, there is no timeout required for Linux PF_PACKET sockets, but when we're doing the periodic tests, the timeout is required. While we're doing that, we make the return value of pcap_get_required_select_timeout() a const pointer - there was no good reason for the caller to modify it (it doesn't belong to the caller). If poll() returns POLLERR, use getsockopt(SO_ERROR) to get the socket error, rather than a read(). Update the documentation to reflect this, and make various other cleanups (including documenting the error return value for pcap_get_selectable_fd() to -1 rather than PCAP_ERROR - it's not an error code, it's just a specific error value). Also note that, for kqueues on *BSD/macOS and for select/poll on Linux, the timeout needn't be used as a timeout for the call - you can have a timer, so that when that *particular* timer fires, you try calling pcap_dispatch() on the pcap_t to which it corresponds. Update selpolltest to add more capabilities needed when testing this on Linux. This should address GitHub issue #859 and pull request #858.
* Style cleanup.Guy Harris2019-11-231-21/+21
| | | | | | | | Use the BSD house style, in which, in foobar() returns 17 on success and 137 on failure. "foobar" is boldfaced but "()" isn't.
* More formatting fixes.Guy Harris2019-11-021-3/+3
|
* Fix manpage reference formatting to be consistent.Daniel Miller2018-08-241-9/+10
| | | | | | | All manpage references such as pcap_create(3PCAP) will now be formatted with the identifier (e.g. "pcap_create") in **bold** and the section name (e.g. "(3PCAP)") in roman (default) face. This is how most manpages seem to be formatted and makes things more consistent.
* Spell PCAP_ERROR and PCAP_ERROR_BREAK in the man pages.Denis Ovsienko2018-07-251-7/+14
| | | | [skip ci]
* Refine references in some man pages, round 2.Denis Ovsienko2018-07-171-12/+11
| | | | [skip ci]
* Update the timestamp in some man pages.Denis Ovsienko2018-07-111-1/+1
| | | | | | | | In the man pages that since the previous timestamp had meaningful (i.e. not typos or whitespace fixups) changes set the timestamp to the date of such last meaningful change. [skip ci]
* Use the right name for calls to wait for events.Guy Harris2018-01-201-2/+2
| | | | | | For the epoll mechanism, the call to wait for events is epoll_wait() (and epoll_pwait()); for the kqueue mechanism, the call to wait for events is kevent() (and additional calls in Darwin-based systems).
* Add a new API to handle some non-select()able devices.Guy Harris2018-01-191-38/+50
| | | | | | | | | | | DAG adapters don't support blocking until packets arrive; a program using select()/poll()/epoll()/kqueue-based event loop must periodically poll DAG pcap_t's to see if they have packets available. Add pcap_get_required_select_timeout(), which returns a pointer to a struct timeval containing the appropriate timeout interval if polling is required and NULL if polling isn't required or isn't supported. Clean up the pcap_get_selectable_fd() documentation while we're at it.
* Call the timeout the "packet buffer timeout" rather than the "read timeout".Guy Harris2017-01-201-5/+5
| | | | | | | | | That should make it clearer that the timeout does *not* guarantee that a call that reads packets will return within N milliseconds even if no packets arrive. In the pcap_open_live() and pcap_set_timeout() calls, point to the detailed description of the packet buffer timeout in pcap(3PCAP).
* update last modified date in man page(s)Denis Ovsienko2015-12-181-1/+1
|
* Be more emphatic that a read timeout may cause no packets to be read.Guy Harris2014-10-181-3/+9
| | | | | | | | | | | | | | | | | | Note, in more places, that if you call pcap_dispatch() on a pcap_t for which there's a read timeout, it might return 0 if the read timeout expires and there are no packets to be read - but that this behavior is not guaranteed (so write your code to be able to handle it if it does happen but not to depend on it happening). Note also that a select()/poll()/etc. on the selectable descriptor for the pcap_t might report the descriptor as readable if the read timeout expires, even if there are no packets available to read - but that it might not (so write your code to be able to handle it if it does happen but not to depend on it happening). Also, note that pcap_t's start out blocking, so they don't think that a 0 return from pcap_dispatch() means it's non-blocking and that they need to call pcap_setnonblock() to put it in blocking mode.
* refresh last midification dates for some man pagesDenis Ovsienko2014-04-071-1/+1
| | | | | This change reflects only meaningful (i.e. not purely editorial) changes in the text.
* remove libpcap's own CVS keywordsDenis Ovsienko2014-01-031-2/+0
| | | | | | This change removes CVS keywords that express that the file belongs to libpcap repository. All such keywords represented the revision and timestamp by the end of 2008 or even older.
* Improve the description of the BPF select() issue.Guy Harris2011-07-221-4/+14
| | | | | | | | Indicate what releases of FreeBSD, NetBSD, OpenBSD, and Mac OS X first fixed select() to handle the timeout on BPF devices. (DragonFly BSD was forked from FreeBSD after the fix, so it always had the fix.) More precisely describe what the problem is.
* Give N. Leiten credit for the poll() exceptional condition checks inGuy Harris2009-10-121-26/+1
| | | | | | | | pcap-linux.c memory-mapped mode. Always doing a poll() if there are no packets available allows us to catch disappearing interfaces in memory-mapped mode, so remove the caveats about Linux.
* Snow Leopard fixes poll() and kqueues to work on BPF devices (and ttys).Guy Harris2009-10-111-1/+31
| | | | | Describe what happens with select() and poll() on Linux if the device on which you're capturing goes away.
* Document the new API's, move a bunch of information about libpcapguy2008-04-061-9/+11
| | | | | | concepts to the pcap(3PCAP) man page, refer people to the pcap(3PCAP) man page from the man pages for libpcap functions, and clean up some errors.
* Include <pcap/pcap.h> in the SUMMARY sections - as long as we're goingguy2008-04-051-2/+2
| | | | | | | to 1.0, might as well go with the place where Red Hat stuck the header at one point and where the header "officially" resides. (We should put a "backwards compatibility" note into pcap.3pcap.)
* Split the pcap(3) man page into a bunch of individual man pages forguy2008-04-051-0/+112
functions plus an overall man page for libpcap, and put them all into section 3PCAP. That means you can actually do "man pcap_open_live" and get something meaningful, rather than having to do "man pcap" and then scroll through all the other stuff in the man page.