From: Yann Dirson Date: Wed, 22 Nov 2023 16:11:57 +0000 (+0100) Subject: Drop unix_helper X-Git-Tag: 0.3.0~11^2~5 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d1c9c71a0ecd143aeb71db1daf4fef87a87d0632;p=xen-guest-agent.git Drop unix_helper We finally don't have a need for separately querying for an interface name from its index, since we don't need to fetch this information every time a packet arrives, netlink already gives us everything we need. Signed-off-by: Yann Dirson --- diff --git a/src/main.rs b/src/main.rs index 5adf922..58ec866 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ mod datastructs; -#[cfg(unix)] -mod unix_helpers; #[cfg_attr(feature = "xenstore", path = "publisher_xenstore.rs")] mod publisher; diff --git a/src/unix_helpers.rs b/src/unix_helpers.rs deleted file mode 100644 index 4ebe760..0000000 --- a/src/unix_helpers.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::ffi::CStr; - -// just wraps libc's if_indextoname() - likely suboptimal -pub fn interface_name(index: u32) -> String { - let mut c_buf: [libc::c_char; libc::IF_NAMESIZE] = [0; libc::IF_NAMESIZE]; - let ret = unsafe { libc::if_indextoname(index, c_buf.as_mut_ptr()) }; - if ret.is_null() { - return "".to_string(); - } - let c_str: &CStr = unsafe { CStr::from_ptr(c_buf.as_ptr()) }; - - c_str.to_str().unwrap().to_owned() -}