• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use nix::net::if_::*;
2 
3 #[cfg(linux_android)]
4 const LOOPBACK: &[u8] = b"lo";
5 
6 #[cfg(not(any(linux_android, target_os = "haiku")))]
7 const LOOPBACK: &[u8] = b"lo0";
8 
9 #[cfg(target_os = "haiku")]
10 const LOOPBACK: &[u8] = b"loop";
11 
12 #[test]
test_if_nametoindex()13 fn test_if_nametoindex() {
14     if_nametoindex(LOOPBACK).expect("assertion failed");
15 }
16 
17 #[test]
test_if_indextoname()18 fn test_if_indextoname() {
19     let loopback_index = if_nametoindex(LOOPBACK).expect("assertion failed");
20     assert_eq!(
21         if_indextoname(loopback_index)
22             .expect("assertion failed")
23             .as_bytes(),
24         LOOPBACK
25     );
26 }
27