Skip to content

Releases: wiresock/ndisapi-rs

0.7.0

Choose a tag to compare

@wiresock wiresock released this 24 Jun 20:02
57c37bb

This release hardens the Win32 / driver FFI boundary, fixing a number of safety, correctness, and resource-management issues surfaced by a security/code review. It contains breaking changes — see below.

⚠️ Breaking changes

  • Ndisapi no longer implements Clone. It owns the driver HANDLE and closes it on Drop, so cloning risked a double-close (or operating on a reused OS handle). Use Arc<Ndisapi> for shared ownership — the async API and the examples already do.
  • Ndisapi::ndis_get_request / ndis_set_request are now unsafe fn. The driver reads/writes the generic T as raw bytes, so T must be plain-old-data. The safe u32 wrappers (get_hw_packet_filter / set_hw_packet_filter) are unchanged.

Memory safety / UB

  • SockAddrStorage: added length-aware from_raw_sockaddr, and adapter enumeration now uses it so IPv6 addresses are no longer truncated to a 16-byte SOCKADDR. All from_sockaddr* constructors zero-initialize storage, eliminating reads of uninitialized memory.
  • Registry getters (get_mtu_decrement, get_adapters_startup_mode, get_pool_size) no longer write through a pointer derived from a shared reference (undefined behavior); they now validate REG_DWORD/size and close the HKEY via an RAII guard.

Concurrency (async)

  • Win32EventStream: fixed a lost-wakeup race (the waker is now registered before the readiness re-check) and a teardown use-after-free / use-after-close (UnregisterWaitEx(.., INVALID_HANDLE_VALUE) waits for in-flight callbacks, and on unregister failure the callback/event are leaked rather than freed).
  • AsyncNdisapiAdapter::new no longer leaks the event handle on partial construction.

Correctness

  • set_friendly_name now writes a proper UTF-16 REG_SZ value (was UTF-8) and updates its cached value only after the registry write succeeds.
  • Centralized IPv4 → IN_ADDR conversion to network byte order (from_ip_string previously reversed IPv4 octets on little-endian Windows); fixed add_ndp_entry_ipv4 to match.
  • IntermediateBuffer::set_length clamps to MAX_ETHER_FRAME and the data accessors clamp defensively, so a bad length can no longer panic.
  • delete_routes, the reset_* helpers, and delete_unicast_address_* now accumulate per-entry failures instead of masking them.
  • get_tcpip_bound_adapters_info clamps the driver-reported adapter count to ADAPTER_LIST_SIZE and uses lossy UTF-8 for adapter names.
  • The async batch-send methods report the number of packets submitted instead of an always-zero success counter.

Pull requests: #39 (safety/correctness hardening), #40 (clippy/CI cleanup for the release).

0.6.6

Choose a tag to compare

@wiresock wiresock released this 01 May 07:02
c234b77

Version 0.6.6 Release Notes

✨ New Features

Add new NDISAPI functions from upstream wiresock/ndisapi (#37)

This release adds Rust bindings for the new IOCTLs — indexes 30–36 — and corresponding API functions introduced in the upstream wiresock/ndisapi C++ project, enabling per-filter mutation and driver-side cache control without rebuilding the entire filter table.

New Ndisapi Methods

Per-filter mutation

  • add_packet_filter_front — push a filter to the front of the table
  • add_packet_filter_back — append a filter to the back of the table
  • insert_packet_filter — insert a filter at a specific position
  • remove_packet_filter — remove a filter by zero-based index

Packet filter cache

  • set_packet_filter_cache_state
  • enable_packet_filter_cache
  • disable_packet_filter_cache

Packet fragment cache

  • set_packet_fragment_cache_state
  • enable_packet_fragment_cache
  • disable_packet_fragment_cache

New IOCTL Constants

Defined in src/driver/ioctl.rs:

  • IOCTL_NDISRD_ADD_PACKET_FILTER_FRONT30
  • IOCTL_NDISRD_ADD_PACKET_FILTER_BACK31
  • IOCTL_NDISRD_REMOVE_FILTER_BY_INDEX32
  • IOCTL_NDISRD_GET_ADP_FILTERS_LIST33; constant only, no wrapper yet, matches upstream
  • IOCTL_NDISRD_INSERT_FILTER_BY_INDEX34
  • IOCTL_NDISRD_SET_FILTER_CACHE_STATE35
  • IOCTL_NDISRD_SET_FRAGMENT_CACHE_STATE36

New Struct

  • StaticFilterWithPosition#[repr(C, packed)] equivalent of _STATIC_FILTER_WITH_POSITION, containing a position: u32 followed by a StaticFilter. Re-exported from the crate root.

🧰 Maintenance

  • Bump crate version to 0.6.6.
  • Update README install snippet.

Example

use ndisapi::{Ndisapi, StaticFilter};

let api = Ndisapi::new("NDISRD")?;

// Add/insert/remove individual filters without rebuilding the whole table
api.add_packet_filter_front(&filter)?;
api.insert_packet_filter(&filter, 2)?;
api.remove_packet_filter(filter_index)?;

// Toggle driver-side caches
api.disable_packet_filter_cache()?;
api.enable_packet_fragment_cache()?;

Compatibility

No breaking changes — all additions are purely additive.

The new per-filter methods use the *_packet_filter_* prefix to stay consistent with the existing get_packet_filter_table / set_packet_filter_table API.

0.6.5

Choose a tag to compare

@wiresock wiresock released this 23 Dec 15:21
7a89e58

Version 0.6.5 Release Notes

🛠 Documentation build fix (docs.rs)

This patch release fixes documentation generation on docs.rs for the Windows-only ndisapi crate.

What changed

  • Configured docs.rs to build documentation using the Windows target (x86_64-pc-windows-msvc)
  • Prevents docs.rs from attempting to build the crate on Linux, which caused failures in Windows-specific dependencies (windows, windows-future, windows-threading)

Impact

  • No code changes
  • No API changes
  • No behavior changes at runtime
  • Documentation now builds reliably and correctly reflects the Windows-only nature of the crate

Who should update

  • Users browsing documentation on docs.rs
  • CI / automation that links to docs.rs pages

0.6.4

Choose a tag to compare

@wiresock wiresock released this 23 Dec 13:11

Version 0.6.4 Release Notes

  • Update ndisapi dependencies and bump version to 0.6.4 @wiresock (#35)

0.6.3

Choose a tag to compare

@wiresock wiresock released this 15 Dec 12:32
87f0798

Version 0.6.3 Release Notes

✨ New Features

Add unicast_address_list_with_prefix method
PR: #30

  • Introduced a new API method to retrieve unicast IP addresses along with their actual prefix lengths directly from the Windows API
  • Leverages MIB_UNICASTIPADDRESS_TABLE to obtain accurate OnLinkPrefixLength values
  • Updated the listadapters example to demonstrate the new functionality

0.6.2

Choose a tag to compare

@wiresock wiresock released this 05 Nov 15:01
a30de7c

Version 0.6.2 Release Notes

🐛 Bug Fixes

  • Fix panic due to Rust bounds checking flexible array members
    This release resolves a runtime panic caused by Rust’s bounds checking behavior when handling flexible array members.
    Thanks to @pierrehugohpe for the fix! (#28)

Full Changelog: 0.6.0...0.6.2

0.6.0

Choose a tag to compare

@wiresock wiresock released this 24 Mar 21:50
a24ce6f

Version 0.6.0 Release Notes

🚀 Enhancements:

  • Refactored packet handling logic.
  • Updated examples and struct definitions.
  • Added a new example: unsorted-packthru.rs.

0.5.6

Choose a tag to compare

@wiresock wiresock released this 12 Mar 11:42
9b428a0

Version 0.5.6 Release Notes

🚀 Compatibility Update:

  • Windows Crate 0.54.0 Migration: ndisapi-rs has been updated to Windows crate version 0.54.0, thanks to the contributions of @dilawar. This ensures alignment with the latest Windows enhancements and provides users with improved compatibility. Upgrade to benefit from the latest features and a seamlessly integrated experience.

A special thanks to @dilawar for their significant contributions, enhancing the ongoing improvement of ndisapi-rs. Your feedback is crucial as we maintain a reliable and up-to-date networking library. Thank you for your continued support! 🚀

0.5.5

Choose a tag to compare

@wiresock wiresock released this 11 Jan 09:31
6181286

Version 0.5.5 Release Notes

🚀 Enhancements:

  • Refined Iteration: We've upgraded the Iterator to impl IntoIterator, enhancing usability and flexibility in iteration patterns. Thanks to @kgv for this improvement! (PR #21)
  • Key Update to ListEntry Structure: A significant update has been made to the ListEntry struct by replacing raw pointers with usize. This change, primarily aimed at enabling the IntermediateBuffer to implement the Send trait, addresses the critical issue highlighted in Issue #20.

These updates are part of our ongoing effort to enhance functionality and ensure robust, safe operations. Your feedback is always welcome! 🚀

0.5.4

Choose a tag to compare

@wiresock wiresock released this 09 Jan 15:05

Version 0.5.4 Release Notes

🚀 Enhancements:

  • Improved Asynchronous Demo Performance: Updated the async-packthru example for better high-load performance. Traffic visualization on the console is now handled by a dedicated task, making it more efficient for high-load performance testing.
  • Structs and Unions Reexport: Reexported key structs and unions in the filters module, enhancing module usability and integration (@kgv, PR #18).
  • StaticFilter Re-exported: Addressed Issue #16 by re-exporting StaticFilter in ndisapi-rs. This update improves functionality and addresses the missing component reported in the issue (@wiresock, PR #17).