rust-pcap / pcap

Rust language pcap library
Apache License 2.0
620 stars 144 forks source link

generate optimized BPF program by default #163

Closed thegwan closed 3 years ago

thegwan commented 3 years ago

tcpdump by default optimizes the generated bpf program, and I figured this crate should provide similar functionality.

An alternative could be to expose a parameter to the filter() and compile() methods to specify whether you want optimized programs.

Wojtek242 commented 3 years ago

I think it would be better to expose it as an option in my opinion since that's what libpcap does. pcap provides Rust abstractions on top of libpcap, but otherwise should just be the same API.

I'll hopefully fix the build failure tonight so if you update we can merge straight away.

thegwan commented 3 years ago

I'll update the tests too at some point in the near future

thegwan commented 3 years ago

@Wojtek242 any updates on the build failure fixes?

Wojtek242 commented 3 years ago

Yes, the builds are fixed on master. Your latest build fails due to cargo fmt though. You just need to reformat your code to satisfy the formatter.

Wojtek242 commented 3 years ago

This is a curious failure now. Possibly very unlucky and we'll see exactly the same on master on the next scheduled run. I will investigate it.

Wojtek242 commented 3 years ago

Yea, so it looks like you were just unlucky. Rust 1.51 was released that day which came with a new clippy lint. It did show up later in the scheduled runs.

I have now fixed it on master so can you please rebase? If it passes, we can finally merge it : ). Thanks a lot for your patience!