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
//!
//! ```ignore
//! use rip_tuntap::{TunTap, Mode};
//!
//! // 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()?;
//! ```
//!
//! # Async Support
//!
//! Enable the `async` feature for async read/write operations:
//!
//! ```ignore
//! use rip_tuntap::{TunTap, Mode};
//!
//! let mut tun = TunTap::builder()
//! .name("mytun0")
//! .mode(Mode::Tun)
//! .create_async()
//! .await?;
//!
//! // Read packets
//! let mut buf = [0u8; 1500];
//! let n = tun.read(&mut buf).await?;
//!
//! // Write packets
//! tun.write(&packet).await?;
//! ```
pub use ;
pub use ;
/// The path to the TUN device.
pub const TUN_DEVICE_PATH: &str = "/dev/net/tun";