aboutsummaryrefslogtreecommitdiffstats
path: root/src/platform/dummy/tun/void.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/platform/dummy/tun/void.rs43
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(())
+ }
+ }
+}
+*/