]> The Tcpdump Group git mirrors - libpcap/commit
Clean up promiscuous mode, when using SOCK_PACKET, as best we can;
authorguy <guy>
Sat, 16 Dec 2000 10:43:26 +0000 (10:43 +0000)
committerguy <guy>
Sat, 16 Dec 2000 10:43:26 +0000 (10:43 +0000)
commitc9452a76667590c4c8137f2b812ae60ac9be80a9
tree528e9a0cc8142c1122cb234b84dc2c1e68cad2f9
parent84533f55bfd95aa8199ec32c9de6559722122637
Clean up promiscuous mode, when using SOCK_PACKET, as best we can;
remember which pcap_t's were opened (with SOCK_PACKET) in promiscuous
mode on interfaces not already in promiscuous mode, turn promiscuous
mode off when closing such a pcap_t, and arrange that, when the program
exits, all pcap_t's of that sort not already closed have their
interfaces taken out of promiscuous mode.  (It's not sufficient to do
this on exit - applications may close a pcap_t without exiting, e.g.
Ethereal.)

This won't always work right (if somebody else requests promiscuous mode
after it's opened by libpcap, we'll turn promiscuous mode off when we
close the pcap_t, and if the program doesn't exit cleanly, it won't
clean up the interfaces), but neither of those problems are fixable -
the only way to get things to work correctly is to use PF_PACKET
sockets, which requires a 2.2 or later kernel.

On a 2.0[.x] kernel, when doing a "recvfrom()" on a SOCK_PACKET socket
to read a captured packet, don't pass a byte count value based on the
snapshot length - "recvfrom()" won't return the actual packet length if
you do that.  (2.2 and later kernels will return the actual packet
length if MSG_TRUNC is passed in.)
pcap-int.h
pcap-linux.c
pcap.c