Crates.io | utuntap |
lib.rs | utuntap |
version | 0.3.1 |
source | src |
created_at | 2020-03-09 09:07:47.481192 |
updated_at | 2023-04-29 17:34:45.578603 |
description | A low level Rust library for Tun/Tap devices. |
homepage | https://github.com/siegfried/utuntap |
repository | https://github.com/siegfried/utuntap.git |
max_upload_size | |
id | 216805 |
size | 34,952 |
This library aims to provide robust, well-tested, unified APIs to open Tun/Tap devices on different OSes. It is runtime-agnostic so that you can create your cross-platform wrappers for Tokio, async-std and so on.
It simply provides options to open Tun/Tap device files. More options are listed in the documentation.
use utuntap::tun;
let (mut file, filename) = tun::OpenOptions::new()
.packet_info(false) // Only available on Linux
.open(10)
.expect("failed to open device");
OS | CI Status | Comment |
---|---|---|
Linux | musl is also supported. |
|
OpenBSD | According to the manual, each packet read or written is prefixed with a tunnel header consisting of a 4-byte network byte order integer containing the address family. The values are listed here. | |
macOS | TUN-only | A 4-byte address family prefixed is required by read and write: [0u8, 0, 0, 2] for IPv4; [0u8, 0, 0, 10] for IPv6. |