nmstate 2.2.60

Library for networking management in a declarative manner
Documentation
// SPDX-License-Identifier: Apache-2.0

use std::str::FromStr;

use crate::{BaseInterface, VxlanConfig, VxlanInterface};

pub(crate) fn np_vxlan_to_nmstate(
    np_iface: &nispor::Iface,
    base_iface: BaseInterface,
) -> VxlanInterface {
    let vxlan_conf = np_iface.vxlan.as_ref().map(|np_vxlan_info| VxlanConfig {
        id: np_vxlan_info.vxlan_id,
        base_iface: np_vxlan_info.base_iface.clone(),
        learning: Some(np_vxlan_info.learning),
        local: std::net::IpAddr::from_str(np_vxlan_info.local.as_str()).ok(),
        remote: std::net::IpAddr::from_str(np_vxlan_info.remote.as_str()).ok(),
        dst_port: Some(np_vxlan_info.dst_port),
    });

    VxlanInterface {
        base: base_iface,
        vxlan: vxlan_conf,
    }
}