aboutsummaryrefslogtreecommitdiffstats
path: root/src/router/types.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-13 22:26:12 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-10-13 22:26:12 +0200
commita08fd4002bfae92072f64f8d5e0084e6f248f139 (patch)
treea50315318549056627adb05bdd0a4f1a02f8541d /src/router/types.rs
parentPort timer.c from WireGuard (diff)
downloadwireguard-rs-a08fd4002bfae92072f64f8d5e0084e6f248f139.tar.xz
wireguard-rs-a08fd4002bfae92072f64f8d5e0084e6f248f139.zip
Work on Linux platform code
Diffstat (limited to 'src/router/types.rs')
-rw-r--r--src/router/types.rs67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/router/types.rs b/src/router/types.rs
deleted file mode 100644
index 4a72c27..0000000
--- a/src/router/types.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-use std::error::Error;
-use std::fmt;
-
-use super::super::types::Endpoint;
-
-pub trait Opaque: Send + Sync + 'static {}
-
-impl<T> Opaque for T where T: Send + Sync + 'static {}
-
-/// A send/recv callback takes 3 arguments:
-///
-/// * `0`, a reference to the opaque value assigned to the peer
-/// * `1`, a bool indicating whether the message contained data (not just keepalive)
-/// * `2`, a bool indicating whether the message was transmitted (i.e. did the peer have an associated endpoint?)
-pub trait Callback<T>: Fn(&T, usize, bool, bool) -> () + Sync + Send + 'static {}
-
-impl<T, F> Callback<T> for F where F: Fn(&T, usize, bool, bool) -> () + Sync + Send + 'static {}
-
-/// A key callback takes 1 argument
-///
-/// * `0`, a reference to the opaque value assigned to the peer
-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 Callbacks: Send + Sync + 'static {
- type Opaque: Opaque;
- 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);
- fn key_confirmed(opaque: &Self::Opaque);
-}
-
-#[derive(Debug)]
-pub enum RouterError {
- NoCryptKeyRoute,
- MalformedIPHeader,
- MalformedTransportMessage,
- UnknownReceiverId,
- NoEndpoint,
- SendError,
-}
-
-impl fmt::Display for RouterError {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self {
- 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::UnknownReceiverId => {
- write!(f, "No decryption state associated with receiver id")
- }
- RouterError::NoEndpoint => write!(f, "No endpoint for peer"),
- RouterError::SendError => write!(f, "Failed to send packet on bind"),
- }
- }
-}
-
-impl Error for RouterError {
- fn description(&self) -> &str {
- "Generic Handshake Error"
- }
-
- fn source(&self) -> Option<&(dyn Error + 'static)> {
- None
- }
-}