dm secu
This commit is contained in:
parent
303c31a179
commit
e5959fe81f
1 changed files with 12 additions and 5 deletions
|
@ -12,23 +12,30 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
Cmd::Links => {
|
||||
for record in pcap.list_datalinks()? {
|
||||
let name = record.get_name().unwrap_or_else(|_| "<unnamed>".into());
|
||||
let description = record.get_description().unwrap_or_default();
|
||||
println!("link {name} {description}")
|
||||
let desc = record.get_description().unwrap_or_default();
|
||||
println!("link {name} {desc}")
|
||||
}
|
||||
}
|
||||
|
||||
Cmd::Stats => {
|
||||
let mut total_ipv4 = 0;
|
||||
let mut total = 0;
|
||||
let mut total_ipv4 = 0;
|
||||
let mut errs = 0;
|
||||
while let Ok(packet) = pcap.next_packet() {
|
||||
let packet = SlicedPacket::from_ethernet(packet.data)?;
|
||||
total += 1;
|
||||
|
||||
let Ok(packet) = SlicedPacket::from_ethernet(packet.data) else {
|
||||
errs += 1;
|
||||
continue;
|
||||
};
|
||||
|
||||
if let Some(NetSlice::Ipv4(_)) = packet.net {
|
||||
total_ipv4 += 1;
|
||||
}
|
||||
total += 1;
|
||||
}
|
||||
println!("Count: {total: >9}");
|
||||
println!("Count IPv4: {total_ipv4: >9}");
|
||||
println!("Errors: {errs: >9}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue