Search code examples
packet-capturepacket-snifferslibpcap

Does libpcap get a copy of the packet?


Does libpcap get a copy of the packet or the actual packet?

By copy, I mean: the application using libpcap gets packet A, and the kernel also gets packet A.

By actual, I mean: only the application using libpcap gets packet A, but the kernel didn't get it.


Solution

  • libpcap will not allow you to do what you want. The goal of pcap is to transparently receive a copy of every packet in the system.

    You should investigate how to inter-operate with the existing firewall in your system, or how to add your own filters to the netfilter system (on Linux)