mod sys;
mod device;
pub use self::device::Device;
use crate::configuration::Configuration;
use crate::error::Result;
#[derive(Copy, Clone, Debug)]
pub struct PlatformConfig {
pub(crate) packet_information: bool,
pub(crate) ensure_root_privileges: bool,
pub(crate) napi: bool,
pub(crate) vnet_hdr: bool,
}
impl Default for PlatformConfig {
fn default() -> Self {
PlatformConfig {
packet_information: false,
ensure_root_privileges: true,
napi: false,
vnet_hdr: false,
}
}
}
impl PlatformConfig {
#[deprecated(
since = "0.7.0",
note = "No effect applies to the packets delivered from/to tun since the packets always contain no header on all platforms."
)]
pub fn packet_information(&mut self, value: bool) -> &mut Self {
self.packet_information = value;
self
}
pub fn ensure_root_privileges(&mut self, value: bool) -> &mut Self {
self.ensure_root_privileges = value;
self
}
pub fn napi(&mut self, value: bool) -> &mut Self {
self.napi = value;
self
}
pub fn vnet_hdr(&mut self, value: bool) -> &mut Self {
self.vnet_hdr = value;
self
}
}
pub fn create(configuration: &Configuration) -> Result<Device> {
Device::new(configuration)
}