Repository navigation
Compile and test the library on native Windows (+CI leg) - #141
Merged
lance0 merged 3 commits intoOct 15, 2026
Merged
Conversation
Owner
|
Hi there thanks for the PR I will take a look as soon as I can. |
The suite did not compile on Windows: probe/trace code was unix-only with no fallback, and the pnet dependency linked libpcap's Packet.lib through pnet_datalink even though only packet parsing is used. - probe/socket.rs: real Windows arms for set_dont_fragment (IP_DONTFRAGMENT/IPV6_DONTFRAG via ws2_32), set_dscp (IP_TOS and IPV6_TCLASS), enable_recv_ttl (best-effort no-op), and recv_icmp_with_ttl (socket2 recv_from with the peer decoded by SocketAddr; the ancillary TTL arrives with the IPHelper backend) - probe/rawip.rs: set_ip_hdrincl and raw-socket creation use ws2_32 IP_HDRINCL on Windows, which supports it natively - probe/interface.rs: datalink enumeration is unix-only (pcap); Windows arms return explicit errors and the datalink tests stay unix-gated - cli.rs: --source-ip zone resolution uses iphlpapi if_nametoindex on Windows instead of refusing the platform - Cargo.toml: pnet split into pnet_base/pnet_packet (parsing only) with pnet_datalink under the unix target - removes the Packet.lib link requirement entirely - ci.yml: build-windows job runs the lib tests and clippy on windows-latest Proof: cargo test --lib on native Windows = 300 passed, 0 failed; the full binary now links (no Packet.lib); the unix legs are unchanged.
- Windows Don't Fragment used IP_HDRINCL's value (2) for IPv4 and 42 for IPv6; both options are 14. Constants now come from windows-sys, with a readback test. - Windows recv mapped timeouts to a string error, so the receiver counted every idle poll as a failure and gave up; io::Error now propagates. - check_permissions refuses on Windows with a pointer to WSL2 instead of falling through to the Linux raw-socket path and setcap advice. - IP_HDRINCL via socket2's set_header_included_v4 on all platforms; IPV6_TCLASS / DF via one windows-sys setsockopt helper (SAFETY noted). - Drop unused pnet_base; consistent cfg(unix)/cfg(windows) gates; drop stubs the shared code already covers; revert unrelated cli.rs changes. - CI: run the full test suite and clippy --all-targets on Windows. - CHANGELOG, README platform table, CONTRIBUTING, ROADMAP.
lance0
force-pushed
the
windows-compile-tests
branch
from
October 15, 2026 15:45
02c5b95 to
5095db8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The library is documented as "Windows (native) | Not supported", and it was:
cargo teston a Windows host failed with 25 compile errors and the test binary never linked (pnet's datalink feature demands libpcap'sPacket.lib).This PR makes the library compile, link, and pass its full lib test suite natively on Windows, without touching any unix behavior.
What actually blocked Windows
pnetumbrella crate — only packet parsing is used, but the crate unconditional re-exportspnet_datalink, which links libpcap on Windows. Fix:pnet_base+pnet_packetas direct deps,pnet_datalinkmoved under[target.'cfg(unix)'.dependencies](interface.rs'sdatalinkusage is unix-gated with explicit-error Windows arms forvalidate_interface/bind_socket_to_interface/get_interface_source_ip).set_dont_fragmenthad linux/netbsd/macos+freebsd arms — Windows supports both options (IP_DONTFRAGMENT/IPV6_DONTFRAG), implemented via ws2_32 (socket2does not expose them yet).set_dscpusedsocket2::set_tclass_v6(unix-only API surface) — Windows arm usesIP_TOS/IPV6_TCLASS.recv_icmp_with_ttl/enable_recv_ttl— cmsg TTL parsing is unix-only; the Windows receive path uses socket2recv_fromwith the peer decoded bySocketAddrand reportsresponse_ttl: Noneuntil the IPHelper backend lands (callers already treat TTL as optional/best-effort).--source-ipzone validation —if_nametoindexexists on Windows too, via iphlpapi.dll; implemented instead of the previous "not supported on this platform" refusal.CI
build-windowsjob: build +cargo test --lib+cargo clippy --lib -D warningson windows-latest.Scope statement
The probe send/receive paths for a native Windows traceroute (IPHelper API instead of raw sockets) are a follow-up, not this PR — this PR is the compile/test/CI foundation that makes that work verifiable.
Proof
cargo test --libon native Windows: 300 passed, 0 failedcargo build(full binary) now links — noPacket.lib