asterust_junos/interfaces/ether_options/
ieee_802_3ad.rs1use crate::{active_children, arg_of, child_block, statement_words, value_after};
11use asterust::config::ConfigLine;
12
13#[derive(Clone, Debug, PartialEq, Eq)]
15#[non_exhaustive]
16pub struct Ieee8023ad {
17 pub aggregated_interface: Option<String>,
19 pub role: Option<String>,
21 pub link_index: Option<String>,
22 pub distribution_list: Option<String>,
23 pub lacp_port_priority: Option<String>,
25 pub link_protection_sub_group: Option<String>,
26}
27
28pub(super) fn parse_ieee_802_3ad(options: &ConfigLine) -> Option<Ieee8023ad> {
31 let statement = active_children(options).find(|c| c.text == "802.3ad" || c.arg("802.3ad").is_some())?;
32 let words = statement_words(options, "802.3ad")?;
33 Some(Ieee8023ad {
34 aggregated_interface: words.iter().find(|w| w.starts_with("ae")).map(|w| w.to_string()),
35 role: words
36 .iter()
37 .find(|w| matches!(**w, "primary" | "backup"))
38 .map(|w| w.to_string()),
39 link_protection_sub_group: value_after(&words, "link-protection-sub-group"),
40 link_index: value_after(&words, "link-index"),
41 distribution_list: value_after(&words, "distribution-list"),
42 lacp_port_priority: child_block(statement, "lacp")
43 .and_then(|lacp| arg_of(lacp, "port-priority"))
44 .map(str::to_string),
45 })
46}