tun_sync/platform/linux/
mod.rs

1//            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2//                    Version 2, December 2004
3//
4// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
5//
6// Everyone is permitted to copy and distribute verbatim or modified
7// copies of this license document, and changing it is allowed as long
8// as the name is changed.
9//
10//            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11//   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12//
13//  0. You just DO WHAT THE FUCK YOU WANT TO.
14
15//! Linux specific functionality.
16
17pub mod sys;
18
19mod device;
20pub use self::device::{Device, Queue};
21
22use crate::configuration::Configuration as C;
23use crate::error::*;
24
25/// Linux-only interface configuration.
26#[derive(Copy, Clone, Default, Debug)]
27pub struct Configuration {
28    pub(crate) packet_information: bool,
29}
30
31impl Configuration {
32    /// Enable or disable packet information, when enabled the first 4 bytes of
33    /// each packet is a header with flags and protocol type.
34    pub fn packet_information(&mut self, value: bool) -> &mut Self {
35        self.packet_information = value;
36        self
37    }
38}
39
40/// Create a TUN device with the given name.
41pub fn create(configuration: &C) -> Result<Device> {
42    Device::new(configuration)
43}