]> The Tcpdump Group git mirrors - libpcap/commit
Clean up the frame processing in memory-mapped captures.
authorGuy Harris <[email protected]>
Thu, 4 Jun 2015 06:14:47 +0000 (23:14 -0700)
committerGuy Harris <[email protected]>
Thu, 4 Jun 2015 06:14:47 +0000 (23:14 -0700)
commitcd03c8fd9fe7a0c42d043f9c6ad7c5dcb6515929
treeb7a205ec1988640640c79dc6b0aba824d0a94485
parent7b72cad4e84ed7652c9e40fa55b0faaf5cc1210e
Clean up the frame processing in memory-mapped captures.

Pull the check for the current ring buffer frame being owned by the
kernel out of pcap_wait_for_frames_mmap() and move it to its callers.

Replace most calls to pcap_get_ring_frame() with the appropriate code
for that particular version of tpacket; in most places, it's already
known what version of tpacket we have.

The one remaining place is the place in the pcap_setfilter() code where
we scan backwards to find out which packet buffers have already been
processed by the old filter; change that one *not* to move the current
pointer backwards and then restore it, but to check arbitrary buffers in
the ring.  Have a pcap_get_ring_frame_status() routine which gets the
status field of a specified buffer.

When checking a buffer's status, check against TP_STATUS_KERNEL; it's
either exactly TP_STATUS_KERNEL, meaning it's owned by the kernel, or
it's TP_STATUS_USER ORed with zero or more flags, meaning it's owned by
userland.

This makes it a bit more obvious, in the pcap_read_linux_mmap_XXX
routines, what's being done.
pcap-linux.c