feat: finished adding pcap-sys

This commit is contained in:
Andrew Rioux
2025-01-20 14:56:46 -05:00
parent c2b5ea37d0
commit ad8cad56e7
6 changed files with 22 additions and 74 deletions

View File

@@ -4,4 +4,4 @@ version = "0.7.0"
edition = "2021"
[dependencies]
nl-sys = { path = "../nl-sys" }
pcap-sys = { path = "../pcap-sys" }

View File

@@ -1,8 +1,3 @@
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "freebsd" {
let freebsd_libs = std::env::var("FREEBSD_LIBS").unwrap();
println!("cargo:rustc-link-arg=--sysroot={freebsd_libs}");
println!("cargo:rustc-link-arg=-L{freebsd_libs}/lib");
println!("cargo:rustc-link-arg=-L{freebsd_libs}/usr/lib");
}
include!("../build_freebsd.rs");
}

View File

@@ -1,16 +1,6 @@
use nl_sys::{netlink, route};
fn main() {
let ip = std::net::Ipv4Addr::new(192, 168, 3, 10);
let (ifname, _, srcip, src_mac, dst_mac, _) = {
let socket = netlink::Socket::new().unwrap();
let routes = socket.get_routes().unwrap();
let neighs = socket.get_neigh().unwrap();
let links = socket.get_links().unwrap();
let addrs = socket.get_addrs().unwrap();
route::get_macs_and_src_for_ip(&addrs, &routes, &neighs, &links, ip).unwrap()
};
let interfaces = pcap_sys::PcapDevIterator::new().unwrap();
for interface in interfaces {
println!("Found interface: {interface}");
}
}