Signed-off-by: Christoph Heiss <[email protected]>
---
 proxmox-sdn-types/src/lib.rs       |  1 +
 proxmox-sdn-types/src/wireguard.rs | 43 ++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 proxmox-sdn-types/src/wireguard.rs

diff --git a/proxmox-sdn-types/src/lib.rs b/proxmox-sdn-types/src/lib.rs
index 1656f1d..3328b45 100644
--- a/proxmox-sdn-types/src/lib.rs
+++ b/proxmox-sdn-types/src/lib.rs
@@ -1,3 +1,4 @@
 pub mod area;
 pub mod net;
 pub mod openfabric;
+pub mod wireguard;
diff --git a/proxmox-sdn-types/src/wireguard.rs 
b/proxmox-sdn-types/src/wireguard.rs
new file mode 100644
index 0000000..4c79b50
--- /dev/null
+++ b/proxmox-sdn-types/src/wireguard.rs
@@ -0,0 +1,43 @@
+//! API types for the WireGuard fabric.
+
+use std::fmt::Display;
+
+use proxmox_schema::{api, UpdaterType};
+use serde::{Deserialize, Serialize};
+
+/// Persistent keep-alive interval. Specifies how often a authenticated, empty
+/// packet will be sent to the peer to keep e.g. stateful firewall open or NAT
+/// mappings.
+///
+/// Interval in seconds, between 1 and 65536 inclusive.
+#[api(
+    type: Integer,
+    minimum: 1,
+)]
+#[derive(Serialize, Deserialize, Hash, Debug, Clone, Copy, PartialEq, Eq, 
PartialOrd, Ord)]
+#[serde(transparent)]
+pub struct PersistentKeepalive(
+    #[serde(deserialize_with = "proxmox_serde::perl::deserialize_u16")] u16,
+);
+
+impl PersistentKeepalive {
+    /// Determines whether the given `PersistentKeepalive` value means that it 
is
+    /// turned off.
+    pub fn is_off(&self) -> bool {
+        self.0 == 0
+    }
+
+    pub fn raw(&self) -> u16 {
+        self.0
+    }
+}
+
+impl UpdaterType for PersistentKeepalive {
+    type Updater = Option<PersistentKeepalive>;
+}
+
+impl Display for PersistentKeepalive {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        self.0.fmt(f)
+    }
+}
-- 
2.52.0



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to