Crates.io | libpcap |
lib.rs | libpcap |
version | 0.1.7 |
source | src |
created_at | 2022-03-11 02:30:01.969074 |
updated_at | 2022-03-25 08:30:23.179058 |
description | Rust libpcap |
homepage | https://github.com/asmcos/libpcap |
repository | https://github.com/asmcos/libpcap |
max_upload_size | |
id | 547963 |
size | 16,614 |
Rust-wrapped version of C libpcap.
install WinPcap.
install libpcap-dev
libpcap should be installed on Mac OS X by default.
https://github.com/the-tcpdump-group/libpcap
let dev = libpcap::lookup();
println!("Found net device: {}",dev);
let mut Packet = libpcap::open(dev.as_str())?;
while let data = libpcap::next(&mut Packet){
println!("{:?}",Packet);
}
result
Packet { ts: 1647398752.372106, caplen: 74, len: 74 }Data 0x5619ab247d10,Length 74
0xfc, 0x33, 0x42, 0x5e, 0x4a, 0x01, 0x68,..................
Find devices ["en0", "p2p0", "awdl0", "utun0", "utun1", "lo0", "bridge0", "en1", "gif0", "stf0"],
Use default: en0
IP:192.168.1.0
mask:255.255.255.0