Registry / networking / pnet
library0.35.0rscratesunverified

Cross-platform, low-level networking library for Rust that provides packet construction and capture.

# Cargo.toml [dependencies] pnet = "0.35.0"
INSTALL
IMPORT
SIG · PNET
P
pnet
networkingrustv0.35.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EthernetPacket
use pnet::packet::ethernet::EthernetPacket;

Creates an Ethernet packet with broadcast destination and IPv4 ethertype.

use pnet::packet::ethernet::{EthernetPacket, MutableEthernetPacket}; use pnet::packet::Packet; let mut buffer = vec![0u8; 14]; let mut packet = MutableEthernetPacket::new(&mut buffer).unwrap(); packet.set_destination([0xff; 6]); packet.set_source([0x00; 6]); packet.set_ethertype(pnet::packet::ethernet::EtherTypes::Ipv4); println!("Packet: {:?}", packet.to_immutable());
Debug
Known issues
gotchaPacket capture requires root/administrator privileges on most systems.
fix
Run your application with sudo or as administrator, or use a virtual interface for testing.
affects: >=0.30.0
Upgrade
Version history
0.35.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
pnet — cargo add pnet · libregistry