11

I am trying to compile a C program on Mac OS X that uses AF_PACKET sockets and libpcap, what is the equivalent in OS X?

Nemo
  • 70,042
  • 10
  • 116
  • 153
  • [Related](http://lists.apple.com/archives/darwin-development/2003/Jun/msg00235.html) – Nemo Sep 02 '11 at 15:15

1 Answers1

9

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.)