From 5837e0678aa2024935550ad1df35c1d106d410fd Mon Sep 17 00:00:00 2001 From: canep Date: Tue, 30 Aug 2022 16:14:33 +0200 Subject: [PATCH] pcap last version, added description on device list --- Cargo.toml | 2 +- src/main.rs | 6 +++--- src/thread_parse_packets_functions.rs | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ac56817e..d85c27a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -pcap = "0.9.2" +pcap = "0.10.1" etherparse = "0.12.0" clap = { version = "3.2.6", features = ["derive"] } chrono = "0.4.20" diff --git a/src/main.rs b/src/main.rs index 75f80532..680fcaaf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -160,8 +160,8 @@ fn main() { fn print_device_list() { println!("\r"); for dev in Device::list().expect("Error retrieving device list\r\n") { - print!("{}{}{}", "\r\tDevice: ".cyan(), dev.name.cyan(), - "\r\n\t\tAddresses: ".cyan()); + print!("{}{} ({}){}", "\r\tDevice: "/*.cyan()*/, dev.name.cyan(), dev.desc.unwrap().cyan(), + "\r\n\t\tAddresses: "/*.cyan()*/); if dev.addresses.len() == 0 { println!("\r"); } @@ -185,7 +185,7 @@ fn print_device_list() { fn retrieve_device(adapter: &mut String) -> Option { let mut found_device = None; if (*adapter).eq(&"default".to_string()) { - *adapter = Device::lookup().expect("Error retrieving default network adapter\r\n").name; + *adapter = Device::lookup().expect("Error retrieving default network adapter\r\n").expect("Error: no suitable devices\r\n").name; } let dev_list = Device::list().expect("Unable to retrieve network adapters list\r\n"); for device in dev_list { diff --git a/src/thread_parse_packets_functions.rs b/src/thread_parse_packets_functions.rs index dfe59143..f772827d 100644 --- a/src/thread_parse_packets_functions.rs +++ b/src/thread_parse_packets_functions.rs @@ -60,8 +60,9 @@ pub fn parse_packets_loop(device: Device, lowest_port: u16, highest_port: u16, if *status == Status::Running { drop(status); - match cap.next() { - Err(_) => { + match cap.next_packet() { + Err(e) => { + println!("ERROR: {:?}", e); // Debug continue; } Ok(packet) => {