Skip to content

Instantly share code, notes, and snippets.

@Gottox
Last active November 8, 2021 12:21
Show Gist options
  • Save Gottox/0fdd1fbb443dc0422464910b5313fd12 to your computer and use it in GitHub Desktop.
Save Gottox/0fdd1fbb443dc0422464910b5313fd12 to your computer and use it in GitHub Desktop.
use neli::{
consts::socket::NlFamily, genl::Genlmsghdr, nl::Nlmsghdr, rtnl::Ifaddrmsg,
socket::NlSocketHandle,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut s = NlSocketHandle::new(NlFamily::Route)?;
s.bind(None, &[0x10])?;
// 0x10 -> RTMGRP_IPV4_IFADDR
// defined in kernel header: uapi/linux/rtnetlink.h
for msg in s.iter(true) {
let header: Nlmsghdr<_, Ifaddrmsg> = msg?;
println!("{:#?}", header);
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment