use super::aggregated_ether_options::{parse_lacp, Lacp};
use super::ether_options::source_address_filter;
use crate::{arg_of, child_block, toggle};
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct RedundantEtherOptions {
pub flow_control: Option<bool>,
pub lacp: Option<Lacp>,
pub link_speed: Option<String>,
pub loopback: Option<bool>,
pub minimum_links: Option<String>,
pub redundancy_group: Option<String>,
pub source_address_filter: Vec<String>,
pub source_filtering: Option<bool>,
}
pub(super) fn parse_redundant_ether_options(options: &ConfigLine) -> RedundantEtherOptions {
RedundantEtherOptions {
flow_control: toggle(options, "flow-control"),
lacp: child_block(options, "lacp").map(parse_lacp),
link_speed: arg_of(options, "link-speed").map(str::to_string),
loopback: toggle(options, "loopback"),
minimum_links: arg_of(options, "minimum-links").map(str::to_string),
redundancy_group: arg_of(options, "redundancy-group").map(str::to_string),
source_address_filter: source_address_filter(options),
source_filtering: toggle(options, "source-filtering"),
}
}