Add conversion helpers for FRR interfaces. We can't put these in eg. `TryInto` implementations, as we need a tupel and tupels are foreign types. Create a simple conversion function that converts the OpenFabric and OSPF interfaces to FRR interfaces.
Signed-off-by: Gabriel Goller <g.gol...@proxmox.com> --- .../src/sdn/fabric/openfabric/frr.rs | 24 +++++++++++++++ proxmox-ve-config/src/sdn/fabric/ospf/frr.rs | 29 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 proxmox-ve-config/src/sdn/fabric/openfabric/frr.rs create mode 100644 proxmox-ve-config/src/sdn/fabric/ospf/frr.rs diff --git a/proxmox-ve-config/src/sdn/fabric/openfabric/frr.rs b/proxmox-ve-config/src/sdn/fabric/openfabric/frr.rs new file mode 100644 index 000000000000..682fe62ab72f --- /dev/null +++ b/proxmox-ve-config/src/sdn/fabric/openfabric/frr.rs @@ -0,0 +1,24 @@ +use proxmox_frr::{ + openfabric::{OpenFabricInterface, OpenFabricInterfaceError}, + FrrWord, +}; + +use super::{FabricId, InterfaceProperties}; + +impl InterfaceProperties { + pub fn to_frr_interface( + &self, + fabric_id: &FabricId, + is_ipv6: bool, + ) -> Result<OpenFabricInterface, OpenFabricInterfaceError> { + let frr_word = FrrWord::new(fabric_id.to_string())?; + Ok(OpenFabricInterface { + fabric_id: frr_word.into(), + passive: self.passive(), + hello_interval: self.hello_interval, + csnp_interval: self.csnp_interval, + hello_multiplier: self.hello_multiplier, + is_ipv6, + }) + } +} diff --git a/proxmox-ve-config/src/sdn/fabric/ospf/frr.rs b/proxmox-ve-config/src/sdn/fabric/ospf/frr.rs new file mode 100644 index 000000000000..9d493b60efd5 --- /dev/null +++ b/proxmox-ve-config/src/sdn/fabric/ospf/frr.rs @@ -0,0 +1,29 @@ +use proxmox_frr::{ + ospf::{NetworkType, OspfInterface, OspfInterfaceError, OspfRouter}, + FrrWord, +}; + +use super::{Area, InterfaceProperties, NodeSection}; + +impl From<NodeSection> for OspfRouter { + fn from(val: NodeSection) -> Self { + OspfRouter { + router_id: val.router_id, + } + } +} + +impl InterfaceProperties { + pub fn to_frr_interface(&self, area: &Area) -> Result<OspfInterface, OspfInterfaceError> { + let frr_word = FrrWord::new(area.to_string())?; + Ok(OspfInterface { + area: frr_word.try_into()?, + passive: self.passive, + network_type: if let Some(true) = self.unnumbered { + Some(NetworkType::PointToPoint) + } else { + None + }, + }) + } +} -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel