rust-pcap / pcap

Rust language pcap library
Apache License 2.0
595 stars 138 forks source link

Setting direction to PCAP_D_OUT is not supported on BPF #267

Closed gruberb closed 1 year ago

gruberb commented 1 year ago

I am trying to capture outbound traffic on my M1 Mac, and setting the direction to out:

cap.direction(Direction::Out).unwrap();

results in an error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: PcapError("Setting direction to PCAP_D_OUT is not supported on BPF")'
Wojtek242 commented 1 year ago

That's an error from the underlying libpcap library. That's what PcapError is indicating.

To resolve the error, please consult the libpcap documentation. However, a brief inspection of the underlying libpcap call reveals the following:

pcap_setdirection() isn't necessarily fully supported on all platforms; some platforms might return an error for all values, and some other platforms might not support PCAP_D_OUT.

It does not appear like we can help here.

Wojtek242 commented 1 year ago

If you show you can achieve this with the tcpdump program though then this would be an issue in the pcap crate and I'll reopen it.