Skip to content

[3.0.0 prep] Windows runtime dynamic loading - #416

Merged
Wojtek242 merged 3 commits into
rust-pcap:mainfrom
cicku:wpcap-runtime
Oct 5, 2026
Merged

Wojtek242 merged 3 commits into
rust-pcap:mainfrom
cicku:wpcap-runtime

Conversation

@cicku

@cicku cicku commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

This PR removes the SDK dependency on Windows, which unlocks cross build and fixes several other issues (#408 will be rebased onto this PR once merged).

Tested with winpcap 4.1.3, npcap 1.00~1.89.

UN*X behavior remains unchanged, tested with libpcap 1.10.7 and 1.11.0.


Fixes #246, #396.

@cicku
cicku marked this pull request as ready for review September 15, 2026 02:59
@cicku
cicku marked this pull request as draft September 15, 2026 03:00
@cicku
cicku marked this pull request as ready for review September 17, 2026 16:35
@cicku

cicku commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@Wojtek242 let me know your thoughts on this one.

@Wojtek242 Wojtek242 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay.

Looks good, but I am confused by the requires_library method. I understand why you would want to build pcap without build-time linking, but isn't a library required at runtime anyway making a requires_library call sprinkled throughout the call a bit redundant?

What I'm worried about is that as you seem to have implemented it adding a requires_library call requires a good understanding of where to place it making it vulnerable to future mistakes. Is it possible to either not have it or centralise it in one place so that it's called once and that's it.

@cicku

cicku commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

I am trying to allow a binary built against the crate now starts on a machine with no Npcap installed, and Error::LibraryNotFound is how it finds out then. In another word, this is not a redundant work. #396 links several external issues, so does cross compiling.


Is it possible to either not have it or centralise it in one place so that it's called once and that's it.

The easiest is to shrink the surface by routing Capture::dead and dead_with_precision through a shared private open_dead, the three Linktype lookups through a shared private lookup, and write the rule down once above require_library instead of leaving it implied.

Or, I can split the FFI declarations into two groups and give the handle-free group a leading &Library parameter. Personally I do not see a single call being feasible.

Feel free to decide and I can adjust then.

@Wojtek242

Copy link
Copy Markdown
Collaborator

Or, I can split the FFI declarations into two groups and give the handle-free group a leading &Library parameter. Personally I do not see a single call being feasible.

I like this option. It makes the assumptions clear to the next programmer.

But if it starts getting too clunky/ugly feel free to push back and try the other option you suggested as well.

@cicku

cicku commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

I made some changes, let me know if this is fine or not.

@Wojtek242

Copy link
Copy Markdown
Collaborator

Thanks for the update. LGTM

@Wojtek242
Wojtek242 merged commit 7f4cc36 into rust-pcap:main Oct 5, 2026
15 checks passed
@cicku
cicku deleted the wpcap-runtime branch October 6, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can it build on Linux to windows

2 participants