This commit is contained in:
JOLIMAITRE Matthieu 2024-06-21 02:23:30 +02:00
parent 3f0b52a64e
commit 49483c87a9
9 changed files with 628 additions and 0 deletions

View 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,
}