diff options
author | 2019-10-23 10:32:18 +0200 | |
---|---|---|
committer | 2019-10-23 10:32:18 +0200 | |
commit | 3fa928b3158ce33a57e9ba2c1913485eb409ff4b (patch) | |
tree | 87562a6c84bf421a19d01ef153927f3f8315cf98 /src/platform/mod.rs | |
parent | Work on porting timer semantics and linux platform (diff) | |
download | wireguard-rs-3fa928b3158ce33a57e9ba2c1913485eb409ff4b.tar.xz wireguard-rs-3fa928b3158ce33a57e9ba2c1913485eb409ff4b.zip |
Work on platform specific code (Linux)
Diffstat (limited to 'src/platform/mod.rs')
-rw-r--r-- | src/platform/mod.rs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/platform/mod.rs b/src/platform/mod.rs index de33714..a0bbc13 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -2,21 +2,32 @@ use std::error::Error; use super::wireguard::bind::Bind; use super::wireguard::tun::Tun; +use super::wireguard::Endpoint; + +#[cfg(test)] +mod dummy; #[cfg(target_os = "linux")] mod linux; #[cfg(target_os = "linux")] -pub use linux::PlatformTun; +pub use linux::LinuxTun as TunInstance; + +pub trait BindOwner: Send { + type Error: Error; + + fn set_fwmark(&self, value: Option<u32>) -> Option<Self::Error>; +} -pub trait UDPBind: Bind { - type Closer; +pub trait PlatformBind: Bind { + type Owner: BindOwner; /// Bind to a new port, returning the reader/writer and - /// an associated instance of the Closer type, which closes the UDP socket upon "drop". - fn bind(port: u16) -> Result<(Self::Reader, Self::Writer, Self::Closer), Self::Error>; + /// an associated instance of the owner type, which closes the UDP socket upon "drop" + /// and enables configuration of the fwmark value. + fn bind(port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error>; } -pub trait TunBind: Tun { +pub trait PlatformTun: Tun { fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::MTU), Self::Error>; } |