aboutsummaryrefslogtreecommitdiffstats
path: root/src/router/types.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-09-01 17:16:01 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-09-01 17:16:01 +0200
commit929eadb651ba41bb72ba8f85a0d68c0cbad18661 (patch)
tree98fec908179a23a90205463773eebc6b9377f82c /src/router/types.rs
parentAdded Bind trait to router (diff)
downloadwireguard-rs-929eadb651ba41bb72ba8f85a0d68c0cbad18661.tar.xz
wireguard-rs-929eadb651ba41bb72ba8f85a0d68c0cbad18661.zip
Outbound cryptkey routing
Diffstat (limited to 'src/router/types.rs')
-rw-r--r--src/router/types.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/router/types.rs b/src/router/types.rs
index 82dcd09..5077686 100644
--- a/src/router/types.rs
+++ b/src/router/types.rs
@@ -1,4 +1,6 @@
+use std::fmt;
use std::marker::PhantomData;
+use std::error::Error;
pub trait Opaque: Send + Sync + 'static {}
@@ -49,3 +51,30 @@ impl<O: Opaque, R: Callback<O>, S: Callback<O>, K: KeyCallback<O>> Callbacks
type CallbackSend = S;
type CallbackKey = K;
}
+
+
+
+#[derive(Debug)]
+pub enum RouterError {
+ NoCryptKeyRoute,
+ MalformedIPHeader,
+}
+
+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")
+ }
+ }
+}
+
+impl Error for RouterError {
+ fn description(&self) -> &str {
+ "Generic Handshake Error"
+ }
+
+ fn source(&self) -> Option<&(dyn Error + 'static)> {
+ None
+ }
+} \ No newline at end of file