diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-09-14 12:43:09 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-09-14 12:43:09 +0200 |
commit | b31becda71feace70f96043cd39bbe022a054225 (patch) | |
tree | a632ea4bee35d70cf21dd2137120402203cf47f3 /src/router/types.rs | |
parent | Test for confirmation of key using staged packet (diff) | |
download | wireguard-rs-b31becda71feace70f96043cd39bbe022a054225.tar.xz wireguard-rs-b31becda71feace70f96043cd39bbe022a054225.zip |
Begin work on the pure Wireguard implemenation
Start joining the handshake device and router device in the top-level Wireguard implemenation.
Diffstat (limited to 'src/router/types.rs')
-rw-r--r-- | src/router/types.rs | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/router/types.rs b/src/router/types.rs index 61f1fe7..f9f867a 100644 --- a/src/router/types.rs +++ b/src/router/types.rs @@ -22,34 +22,11 @@ pub trait KeyCallback<T>: Fn(&T) -> () + Sync + Send + 'static {} impl<T, F> KeyCallback<T> for F where F: Fn(&T) -> () + Sync + Send + 'static {} -pub trait Endpoint: Send + Sync {} - pub trait Callbacks: Send + Sync + 'static { type Opaque: Opaque; - type CallbackRecv: Callback<Self::Opaque>; - type CallbackSend: Callback<Self::Opaque>; - type CallbackKey: KeyCallback<Self::Opaque>; -} - -/* Concrete implementation of "Callbacks", - * used to hide the constituent type parameters. - * - * This type is never instantiated. - */ -pub struct PhantomCallbacks<O: Opaque, R: Callback<O>, S: Callback<O>, K: KeyCallback<O>> { - _phantom_opaque: PhantomData<O>, - _phantom_recv: PhantomData<R>, - _phantom_send: PhantomData<S>, - _phantom_key: PhantomData<K>, -} - -impl<O: Opaque, R: Callback<O>, S: Callback<O>, K: KeyCallback<O>> Callbacks - for PhantomCallbacks<O, R, S, K> -{ - type Opaque = O; - type CallbackRecv = R; - type CallbackSend = S; - type CallbackKey = K; + fn send(_opaque: &Self::Opaque, _size: usize, _data: bool, _sent: bool) {} + fn recv(_opaque: &Self::Opaque, _size: usize, _data: bool, _sent: bool) {} + fn need_key(_opaque: &Self::Opaque) {} } #[derive(Debug)] @@ -57,7 +34,7 @@ pub enum RouterError { NoCryptKeyRoute, MalformedIPHeader, MalformedTransportMessage, - UnkownReceiverId, + UnknownReceiverId, NoEndpoint, SendError, } @@ -68,7 +45,7 @@ impl fmt::Display for RouterError { RouterError::NoCryptKeyRoute => write!(f, "No cryptkey route configured for subnet"), RouterError::MalformedIPHeader => write!(f, "IP header is malformed"), RouterError::MalformedTransportMessage => write!(f, "IP header is malformed"), - RouterError::UnkownReceiverId => { + RouterError::UnknownReceiverId => { write!(f, "No decryption state associated with receiver id") } RouterError::NoEndpoint => write!(f, "No endpoint for peer"), |