Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/00-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: './.github/workflows/01-build-and-test-unix.yml'
with:
os: 'ubuntu-latest'
toolchain: '1.64'
toolchain: '1.85'
msrv: true

linux-coverage-stable:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/00-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: './.github/workflows/01-build-and-test-unix.yml'
with:
os: 'macos-latest'
toolchain: '1.64'
toolchain: '1.85'
msrv: true

macos-coverage-stable:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/00-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: './.github/workflows/01-build-and-test-windows.yml'
with:
os: 'windows-latest'
toolchain: '1.64'
toolchain: '1.85'
msrv: true
secrets:
NPCAP_OEM_PASSWORD: ${{ secrets.NPCAP_OEM_PASSWORD }}
Expand Down
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,51 @@

## [Unreleased]

### Added

- Bindings for `pcap_dump_ftell64` and `pcap_dump_ftell` added. They can be accessed via the
`offset` call on `Savefile`, which reports how many bytes have been written to the file so far.
`pcap_dump_ftell64` is used where it is available, that is from libpcap 1.9.0 on; before that
the offset comes back as a `long` and the call fails once the file has grown past 2 GB on the
platforms where that is a 32-bit type.
- Binding for `pcap_dump_file` added. It can be accessed via the `file` call on `Savefile` and
returns the `FILE *` the savefile is being written to. Not available on Windows, where wpcap
may be linked against a different C runtime than its caller.
- Binding for `pcap_snapshot` added. It can be accessed via the `snaplen` call on activated
captures and reports the snapshot length in effect, which the `snaplen` call on
`Capture<Inactive>` could previously only set. For a `Capture<Offline>` this reports the length
the savefile was recorded with.
- Binding for `pcap_init` added. It can be accessed via the `init` call and selects the character
encoding libpcap uses for strings. Requires libpcap 1.10.0.

### Changed

- Rust Edition is now `2024`.
- MSRV is now `1.85`.
- `bitflags` updated from 1.3 to 2.13. `IfFlags` is generated by `bitflags`, so it changes along
with it; in particular its `Debug` output is now `IfFlags(LOOPBACK | UP)` instead of
`LOOPBACK | UP`.
- `errno` updated from 0.2 to 0.3. `Error::ErrnoError` carries an `errno::Errno`, so crates that
construct or match on it have to move to 0.3 as well.
- `Error` has a new `InvalidPath` variant on Windows, which exhaustive matches have to cover.
- `windows-sys` updated from 0.36 to 0.61. `HANDLE` is a raw pointer there rather than an `isize`,
which changes the signature of `Capture::get_event` on Windows. A raw pointer is not `Send`, so
a type of your own that stores the returned `HANDLE` no longer derives `Send` and can no longer
be moved to another thread without a wrapper of its own. `PacketStream` is unaffected.

### Removed

- `IfFlags::from_bits_unchecked`, which `bitflags` 1 generated. `bitflags` 2 provides
`IfFlags::from_bits_retain` instead.

### Fixed

- `Capture::from_file`, `Capture::from_file_with_precision`, `Capture::savefile` and
`Capture::savefile_append` no longer convert the path with `Path::to_str`. On UN*X the path is
handed to libpcap as bytes, so file names that are not valid UTF-8 now work. On Windows such a
path returns the new `Error::InvalidPath`, where `savefile` used to panic and `from_file` used
to report that a null pointer had been supplied as the file name.

## [2.5.0] - 2026-08-15

### Added
Expand Down
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "pcap"
version = "2.5.0"
version = "3.0.0"
authors = ["Sean Bowe <ewillbefull@gmail.com>", "Wojciech Kozlowski <wk@wojciechkozlowski.eu>", "Hideki Sekine"]
edition = "2021"
rust-version = "1.64"
edition = "2024"
rust-version = "1.85"
description = "A packet capture API around pcap/wpcap"
keywords = ["pcap", "packet", "sniffing"]
readme = "README.md"
Expand All @@ -14,25 +14,25 @@ license = "MIT OR Apache-2.0"
build = "build.rs"

[dependencies]
bitflags = "1.3"
bitflags = "2.13"
libc = "0.2"
errno = "0.2"
errno = "0.3"
tokio = { version = "1.0", features = ["net", "rt", "macros", "rt-multi-thread"], optional = true }
futures = { version = "0.3", optional = true }
gat-std = { version = "0.1.1", optional = true }

[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.36.1", features = ["Win32_Foundation", "Win32_Networking_WinSock"] }
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Networking_WinSock"] }

[dev-dependencies]
etherparse = "0.13.0"
etherparse = "0.21.0"
once_cell = "1.14.0"
mockall = "0.11.4"
mockall = "0.15.0"
tempfile = "3.10"

[target.'cfg(target_os = "windows")'.dev-dependencies]
eui48 = { version = "1.1", default-features = false }
windows-sys = { version = "0.36.1", features = ["Win32_System_Threading"] }
windows-sys = { version = "0.61", features = ["Win32_System_Threading"] }

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
tun-tap = "0.1.3"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Use the `lending-iter` feature to enable the lending packet iterator. See `lendi

## Minimum Supported Rust Version (MSRV)

This crate uses Rust 2021 and requires a compiler version >= 1.64.
This crate uses Rust 2024 and requires a compiler version >= 1.85.

The feature `capture-stream` depends on `tokio = "1.0"`. Therefore, when `capture-stream` is enabled, this crate requires a compiler version new enough to compile the `tokio` crate.

Expand Down
15 changes: 5 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,11 @@ fn get_libpcap_version(libdirpath: Option<PathBuf>) -> Result<Version, Box<dyn s
libfile = libdir.join(libfile);
}

let lib = if let Ok(lib) = unsafe {
// Loading a shared library is unsafe in the general case since initialization and
// termination routines could have arbitrary behavior. This is sound as long as the shared
// library is "well-behaved." See https://github.com/nagisa/rust_libloading/issues/86 and
// https://github.com/nagisa/rust_libloading/blob/0.8.3/src/changelog.rs#L96-L151 for
// details.
libloading::Library::new(libfile)
} {
lib
} else {
// Loading a shared library is unsafe in the general case since initialization and termination
// routines could have arbitrary behavior. This is sound as long as the shared library is
// "well-behaved." See https://github.com/nagisa/rust_libloading/issues/86 and
// https://github.com/nagisa/rust_libloading/blob/0.8.3/src/changelog.rs#L96-L151 for details.
let Ok(lib) = (unsafe { libloading::Library::new(libfile) }) else {
return Ok(Version::max());
};

Expand Down
4 changes: 2 additions & 2 deletions examples/winevt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ mod windowsonly {
use bitflags::bitflags;
use std::{
sync::{
atomic::{AtomicU32, Ordering},
Arc,
atomic::{AtomicU32, Ordering},
},
thread::{sleep, spawn, JoinHandle},
thread::{JoinHandle, sleep, spawn},
time::Duration,
};
use windows_sys::Win32::{Foundation::HANDLE, System::Threading::SetEvent};
Expand Down
Loading
Loading