1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! TUN/TAP device management library.
//!
//! This crate provides a safe, strongly-typed API for creating and managing
//! TUN (network tunnel) and TAP (ethernet tunnel) devices on Linux.
//!
//! # Overview
//!
//! TUN devices operate at Layer 3 (IP) and TAP devices operate at Layer 2
//! (Ethernet). Both are virtual network interfaces that can be used for:
//!
//! - VPN implementations
//! - Network simulation
//! - Container networking
//! - Traffic capture and injection
//!
//! # Example
//!
//! ```no_run
//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use nlink::tuntap::{Mode, TunTap};
//!
//! // Create a persistent TUN device
//! let tun = TunTap::builder()
//! .name("mytun0")
//! .mode(Mode::Tun)
//! .persistent(true)
//! .create()?;
//!
//! println!("Created device: {}", tun.name());
//!
//! // Create a TAP device owned by a specific user
//! let tap = TunTap::builder()
//! .name("mytap0")
//! .mode(Mode::Tap)
//! .owner(1000) // uid
//! .group(1000) // gid
//! .persistent(true)
//! .create()?;
//! # Ok(())
//! # }
//! ```
//!
//! # No async support
//!
//! There is none, and there is no `tuntap-async` feature any more.
//! It was declared in `Cargo.toml`, documented in `lib.rs`, included in
//! `full`, and gated **zero** lines: no `#[cfg(feature = "tuntap-async")]`
//! anywhere in the crate and no `create_async` symbol. The example here
//! demonstrated `create_async().await` and `tun.read(&mut buf).await`
//! against a crate name (`rip_tuntap`) that does not exist. A user who
//! enabled the feature got no async API and no way to tell whether they
//! had mistyped it (#276).
//!
//! [`TunTap`] exposes blocking `read_packet` / `write_packet`. Wrap the
//! fd in `tokio::io::unix::AsyncFd` if you need readiness-driven I/O.
// `list_devices` is the feature's only enumeration API and
// `TunTapInfo` its return type; neither was re-exported, so both
// carried `#[allow(dead_code)]` — the compiler already knew they
// were unreachable (#280).
pub use ;
pub use ;
/// The path to the TUN device.
pub const TUN_DEVICE_PATH: &str = "/dev/net/tun";