1 use smoltcp::phy::wait as phy_wait;
2 use smoltcp::phy::{Device, RawSocket, RxToken};
3 use smoltcp::time::Instant;
4 use smoltcp::wire::{EthernetFrame, PrettyPrinter};
5 use std::env;
6 use std::os::unix::io::AsRawFd;
7 
main()8 fn main() {
9     let ifname = env::args().nth(1).unwrap();
10     let mut socket = RawSocket::new(ifname.as_ref(), smoltcp::phy::Medium::Ethernet).unwrap();
11     loop {
12         phy_wait(socket.as_raw_fd(), None).unwrap();
13         let (rx_token, _) = socket.receive(Instant::now()).unwrap();
14         rx_token.consume(|buffer| {
15             println!(
16                 "{}",
17                 PrettyPrinter::<EthernetFrame<&[u8]>>::new("", &buffer)
18             );
19         })
20     }
21 }
22