feat: tested nl-sys, and it links

This commit is contained in:
Andrew Rioux
2025-01-20 14:40:29 -05:00
parent 6b33f1a5ba
commit c2b5ea37d0
25 changed files with 3615 additions and 32 deletions

View File

@@ -2,3 +2,6 @@
name = "sparse-beacon"
version = "0.7.0"
edition = "2021"
[dependencies]
nl-sys = { path = "../nl-sys" }

View File

@@ -1,3 +1,16 @@
use nl_sys::{netlink, route};
fn main() {
println!("hi there");
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()
};
}