rust-pcap / pcap

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

added npcap instructions for windows #190

Closed mason closed 2 years ago

mason commented 2 years ago

The windows instructions are out of date. winpcap is deprecated and doesn't work with this rust library.

stappersg commented 2 years ago

Here someone complete happy without Microsoft Windows.

Apply the patch, we can't break what is already broken

That less rude

Patch has been noticed and I think it should get accepted.

Because:

Wojtek242 commented 2 years ago

winpcap is deprecated and doesn't work with this rust library

It may be deprecated, but it's what our CI pipeline uses.

I propose one of two options:

  1. Add (rather than replace) npcap instructions. That is, have both instructions for winpcap and npcap and let the user choose which they will follow. And also add a note that CI runs on winpcap.
  2. Update the CI pipeline to use npcap and completely replace winpcap.

Let me know which one you prefer!

mason commented 2 years ago

I'm surprised the build works with 4.1.2. I didn't see 4.1.3 initially but locally I couldn't get either of these to work. https://github.com/ebfull/pcap/blob/11fc67b224e1189bb7557b47f02626fa100aada2/.github/workflows/rust.yml#L53

This build is saying its downloading 4.1.2 but this version is missing some functions.

 note: /home/mason/workspace/rust/d2/target/x86_64-pc-windows-gnu/debug/deps/libpcap-b6fd71997e4486f8.rlib(pcap-b6fd71997e4486f8.pcap.3733c9b3-cgu.0.rcgu.o): In function `pcap::Capture<pcap::Inactive>::tstamp_type':
          /home/mason/.cargo/registry/src/github.com-1ecc6299db9ec823/pcap-0.9.0/src/lib.rs:797: undefined reference to `pcap_set_tstamp_type'
          /home/mason/workspace/rust/d2/target/x86_64-pc-windows-gnu/debug/deps/libpcap-b6fd71997e4486f8.rlib(pcap-b6fd71997e4486f8.pcap.3733c9b3-cgu.0.rcgu.o): In function `pcap::Capture<pcap::Inactive>::immediate_mode':
          /home/mason/.cargo/registry/src/github.com-1ecc6299db9ec823/pcap-0.9.0/src/lib.rs:822: undefined reference to `pcap_set_immediate_mode'
          /home/mason/workspace/rust/d2/target/x86_64-pc-windows-gnu/debug/deps/libpcap-b6fd71997e4486f8.rlib(pcap-b6fd71997e4486f8.pcap.3733c9b3-cgu.0.rcgu.o): In function `pcap::Capture<pcap::Inactive>::precision':
          /home/mason/.cargo/registry/src/github.com-1ecc6299db9ec823/pcap-0.9.0/src/lib.rs:859: undefined reference to `pcap_set_tstamp_precision'
          collect2: error: ld returned 1 exit status
Wojtek242 commented 2 years ago

Sorry for the late reply. It looks like you are cross-compiling which is not tested. I wonder if build.rs is getting confused. Do you have the linux libpcap installed on that computer? If so, could you temporarily remove it and see if you get the same error. If you get a different error that would suggest that there is an error in the build scripts somewhere.

lambdaiv commented 2 years ago

I think this pull request should be denied since we aren't sure on how to handle the updates for windows and I think the documentation needs a little more specificity than install this. You also need to install Npcap with the winpcap compatibility switch for the build to work without needing to change any code. I tried locally and through limited testing was able to build, run, and retrieve a list of adapters.

I'll open a discussion issue so we can discuss it further and contain all the discussion around upgrading to Npcap there.

See: https://github.com/ebfull/pcap/issues/196