blob: 07775416ce37a3b2e44acd6cc8a74728d917f667 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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(())
}
}
}
*/
|