linkem 0.2.1

A realistic network emulation library
Documentation
1
2
3
4
5
6
7
8
9
//! Wrappers over [`nix::libc`] functions.

use std::{ffi::c_str, num::NonZeroU32, str::FromStr};

pub fn if_nametoindex(name: &str) -> Option<NonZeroU32> {
    let string = c_str::CString::from_str(name).expect("to convert into c string");
    let index = unsafe { nix::libc::if_nametoindex(string.as_ptr()) };
    NonZeroU32::new(index)
}