tcpdump mailing list archives

Re: pcap_get_selectable_fd q


From: Guy Harris <guy () alum mit edu>
Date: Tue, 24 Aug 2010 10:01:35 -0700


On Aug 24, 2010, at 5:11 AM, Tim mizas wrote:

What kind of FD does pcap_get_selectable_fd return?

It returns either

        1) the same FD that pcap_fileno() returns, if select() is supported on it

or

        2) -1, if select() is *not* supported on it (which is the case in, for example, FreeBSD 4.3 and 4.4, as well as 
for the DAG cards).

I thought it was a socket's,

There is no guarantee whatsoever that the value returned by pcap_fileno() or pcap_get_selectable_fd() is a socket.

but when I tried to do a recv on it,

If it *were* a socket, and you did a recv() on it, unless you used MSG_PEEK you would remove the packet from the socket 
queue, so libpcap wouldn't see that packet.

I'm also not sure what would happen if it were a socket on Linux where memory-mapped capturing is being done.

(I.e., don't do a recv() on it unless you fully understand what libpcap is doing.)
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: