tun_rs/platform/unix/
mod.rs1mod sockaddr;
2#[cfg(any(
3 all(target_os = "linux", not(target_env = "ohos")),
4 target_os = "freebsd",
5 target_os = "openbsd",
6 target_os = "netbsd",
7 target_os = "macos"
8))]
9pub(crate) use sockaddr::sockaddr_union;
10
11#[cfg(any(
12 all(target_os = "linux", not(target_env = "ohos")),
13 target_os = "macos",
14 target_os = "freebsd",
15 target_os = "openbsd",
16 target_os = "netbsd",
17))]
18#[allow(unused_imports)]
19pub(crate) use sockaddr::ipaddr_to_sockaddr;
20
21mod fd;
22pub(crate) use self::fd::Fd;
23#[cfg(feature = "interruptible")]
24mod interrupt;
25#[cfg(feature = "interruptible")]
26pub use interrupt::InterruptEvent;
27mod tun;
28pub(crate) use self::tun::Tun;
29
30pub(crate) mod device;
31
32#[cfg(all(
33 unix,
34 not(any(
35 target_os = "windows",
36 target_os = "macos",
37 all(target_os = "linux", not(target_env = "ohos")),
38 target_os = "freebsd",
39 target_os = "openbsd",
40 target_os = "netbsd",
41 ))
42))]
43pub struct DeviceImpl {
45 pub(crate) tun: Tun,
46 #[allow(dead_code)]
47 pub(crate) op_lock: std::sync::Mutex<()>,
48}
49#[cfg(all(
50 unix,
51 not(any(
52 target_os = "windows",
53 target_os = "macos",
54 all(target_os = "linux", not(target_env = "ohos")),
55 target_os = "freebsd",
56 target_os = "openbsd",
57 target_os = "netbsd",
58 ))
59))]
60impl DeviceImpl {
61 pub(crate) fn from_tun(tun: Tun) -> std::io::Result<Self> {
62 Ok(Self {
63 tun,
64 op_lock: std::sync::Mutex::new(()),
65 })
66 }
67}