afpacket 0.2.3

Bindings for Linux raw packet sockets (AF_PACKET), and an async wrapper
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use afpacket::async_std::RawPacketStream;
use futures_lite::{future, AsyncReadExt};
use nom::HexDisplay;

fn main() {
    future::block_on(async {
        let mut ps = RawPacketStream::new().unwrap();
        loop {
            let mut buf = [0u8; 1500];
            ps.read(&mut buf).await.unwrap();
            println!("{}", buf.to_hex(24));
        }
    })
}