Skip to main content

asterust_junos/interfaces/
redundant_ether_options.rs

1//! `redundant-ether-options`
2//! `interfaces { reth<n> { redundant-ether-options { ... } } }`.
3//!
4//! # See also
5//!
6//! - [redundant-ether-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/interfaces-edit-redundant-ether-options.html)
7
8use super::aggregated_ether_options::{parse_lacp, Lacp};
9use super::ether_options::source_address_filter;
10use crate::{arg_of, child_block, toggle};
11use asterust::config::ConfigLine;
12
13/// The `redundant-ether-options` of a redundant Ethernet interface.
14#[derive(Clone, Debug, PartialEq, Eq)]
15#[non_exhaustive]
16pub struct RedundantEtherOptions {
17    /// `Some(true)` for `flow-control`, `Some(false)` for `no-flow-control`.
18    pub flow_control: Option<bool>,
19    pub lacp: Option<Lacp>,
20    pub link_speed: Option<String>,
21    /// `Some(true)` for `loopback`, `Some(false)` for `no-loopback`.
22    pub loopback: Option<bool>,
23    pub minimum_links: Option<String>,
24    pub redundancy_group: Option<String>,
25    /// The MAC addresses of `source-address-filter`.
26    pub source_address_filter: Vec<String>,
27    /// `Some(true)` for `source-filtering`, `Some(false)` for `no-source-filtering`.
28    pub source_filtering: Option<bool>,
29}
30
31pub(super) fn parse_redundant_ether_options(options: &ConfigLine) -> RedundantEtherOptions {
32    RedundantEtherOptions {
33        flow_control: toggle(options, "flow-control"),
34        lacp: child_block(options, "lacp").map(parse_lacp),
35        link_speed: arg_of(options, "link-speed").map(str::to_string),
36        loopback: toggle(options, "loopback"),
37        minimum_links: arg_of(options, "minimum-links").map(str::to_string),
38        redundancy_group: arg_of(options, "redundancy-group").map(str::to_string),
39        source_address_filter: source_address_filter(options),
40        source_filtering: toggle(options, "source-filtering"),
41    }
42}