AF_PACKET equivalent under Mac OS X (Darwin)
I am trying to compile a C program on Mac OS X that us开发者_运维技巧es AF_PACKET sockets and libpcap, what is the equivalent in OS X?
The closest equivalent to AF_PACKET sockets in Mac OS X (and in other BSD-flavored OSes, such as FreeBSD, NetBSD, OpenBSD, Dragonfly BSD, and so on) is BPF, but it doesn't work very much like AF_PACKET sockets; see "man bpf".
The exact equivalent to libpcap in Mac OS X (and in other BSD-flavored UN*Xes) is, well, libpcap. (libpcap is also the exact equivalent to libpcap in many other UN*Xes, but it doesn't ship as a standard part of all of those UN*Xes, whereas it does ship as a standard part of Mac OS X and the other BSD-flavored UN*Xes.)
精彩评论