diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2020-03-29 18:21:48 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2020-03-29 18:21:48 +0200 |
commit | 12a7b371d4fed75f3934cf7d3788a6cf51c33c22 (patch) | |
tree | 970fc1287d6cbdbd419ef9151e6e94a077b5a7fd /src/platform/dummy/tun/void.rs | |
parent | Merge branch 'tests' (diff) | |
download | wireguard-rs-12a7b371d4fed75f3934cf7d3788a6cf51c33c22.tar.xz wireguard-rs-12a7b371d4fed75f3934cf7d3788a6cf51c33c22.zip |
Restructuring and dependency version bump.
Diffstat (limited to 'src/platform/dummy/tun/void.rs')
-rw-r--r-- | src/platform/dummy/tun/void.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/platform/dummy/tun/void.rs b/src/platform/dummy/tun/void.rs new file mode 100644 index 0000000..0777541 --- /dev/null +++ b/src/platform/dummy/tun/void.rs @@ -0,0 +1,43 @@ +/* +// This code provides a "void" implementation of the tunnel interface: +// The implementation never reads and immediately discards any write without error +// +// This is used during benchmarking and profiling of the inbound path. + +use super::*; + +pub struct VoidTun {} + +pub struct VoidReader {} + +pub struct VoidWriter {} + +impl Tun for VoidTun { + type Writer = VoidWriter; + type Reader = VoidReader; + type Error = TunError; +} + + +impl Reader for VodReader { + type Error = TunError; + + fn write(&self, src: &[u8]) -> Result<(), Self::Error> { + debug!( + "dummy::TUN({}) : write ({}, {})", + self.id, + src.len(), + hex::encode(src) + ); + if self.store { + let m = src.to_owned(); + match self.tx.lock().unwrap().send(m) { + Ok(_) => Ok(()), + Err(_) => Err(TunError::Disconnected), + } + } else { + Ok(()) + } + } +} +*/ |