dm secu
This commit is contained in:
parent
3f0b52a64e
commit
49483c87a9
9 changed files with 628 additions and 0 deletions
34
securite/dm/pcap_analyzer/src/main.rs
Normal file
34
securite/dm/pcap_analyzer/src/main.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
use std::{error::Error, path::PathBuf};
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use pcap::Capture;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let Args { file, cmd } = Args::parse();
|
||||
let pcap = Capture::from_file(file)?;
|
||||
|
||||
match cmd {
|
||||
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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
file: PathBuf,
|
||||
|
||||
#[command(subcommand)]
|
||||
cmd: Cmd,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Cmd {
|
||||
Links,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue