From 0b7ca6aa381e9e24bc4f19e04bbbfcd8682baa51 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 15 Mar 2023 13:21:49 +0100 Subject: [PATCH] Implement VIF detection for FreeBSD --- src/main.rs | 1 + src/vif_detect_freebsd.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/vif_detect_freebsd.rs diff --git a/src/main.rs b/src/main.rs index 45901f9..0a53ff3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ mod collector_net; mod collector_memory; #[cfg_attr(target_os = "linux", path = "vif_detect_linux.rs")] +#[cfg_attr(target_os = "freebsd", path = "vif_detect_freebsd.rs")] mod vif_detect; use crate::datastructs::KernelInfo; diff --git a/src/vif_detect_freebsd.rs b/src/vif_detect_freebsd.rs new file mode 100644 index 0000000..0b03c89 --- /dev/null +++ b/src/vif_detect_freebsd.rs @@ -0,0 +1,11 @@ +use crate::datastructs::{NetEvent, ToolstackNetInterface}; + +// identifies a VIF as named "xn%ID" + +pub fn add_vif_info(event: &mut NetEvent) -> () { + const PREFIX: &str = "xn"; + if ! event.iface.name.starts_with(PREFIX) { return; } + if let Ok(index) = event.iface.name[PREFIX.len()..].parse() { + event.iface.toolstack_iface = ToolstackNetInterface::VIF(index); + } +} -- 2.39.5