Closed spacemeowx2 closed 4 years ago
@spacemeowx2 Hi! Thank you for the report. I have already fixed it in the newest version. But I have problems with testing because I work on PC. I have Linux and Windows but not Apple machine. Automatic tests on Travis are possible but they allow only unit tests, sending and receiving packets is not possible (or at least I don't know how to setup the environment). Could you please test my change and let me know if it works? I'll be very grateful.
Regards, Szymon
Thank you for the fix. This fix has compile time error:
error[E0063]: missing field `comment` in initializer of `pcap_common::structs::PCapPacketHeader`
--> src/wpcap/interface.rs:69:22
|
69 | let header = PCapPacketHeader {
| ^^^^^^^^^^^^^^^^ missing `comment`
error[E0277]: `[i8; 256]` doesn't implement `std::fmt::Debug`
--> src/pcap_common/structs.rs:65:5
|
65 | pub comment: [c_char; 256]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `[i8; 256]` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
|
= help: the trait `std::fmt::Debug` is not implemented for `[i8; 256]`
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&[i8; 256]`
= note: required for the cast to the object type `dyn std::fmt::Debug`
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0063, E0277.
For more information about an error, try `rustc --explain E0063`.
error: Could not compile `rawsock`.
To learn more, run the command again with --verbose.
You can see how did I fix these issues, but it breaks Windows compile because wpcap builds on both macOS and Windows. I think wpcap is only available on Windows so could you make wpcap only build on Windows?
https://github.com/spacemeowx2/rust-rawsock/commit/7f0d42526d3061e1d2ad7eb270fca1e4a1864d8e
https://github.com/spacemeowx2/rust-rawsock/commit/b38742ad127426d6f8d57242ac5f70b7b44c6ac6
I tried to disable wpcap on non-Windows OS. Not sure am I doing right thing. I'm new to rust.
@spacemeowx2 You are right - my fix broke the build on MacOS. It was more tricky than I thought. But now Travis shows correct build, I think it should be OK now, you can try it.
Your approach with disabling wpcap on MacOS is very problematic. Writing multiplatform code is super hard if some symbols are available on one platform but not on the other. This is the purpose of rawsock - to cover all platforms with just a single API, so that nobody has problems writing multiplatform code. This is why wpcap is available on all platforms but loading the library will always fail except on Windows. In similar way pfring library is only available on Linux but the module compiles on all platforms.
Travis shows that the build works now on all platforms. Should be OK.
Command:
cargo run --example dynamic
I think uncomment this two line should work.
https://github.com/szymonwieloch/rust-rawsock/blob/b55d6b2d5d35f9eda9961b9716a66a8c1d8a5798/src/pcap_common.rs#L63-L64
pcap.h