asterust_junos/interfaces/unit/pppoe_options.rs
1//! `pppoe-options`
2//! `interfaces { pp0 { unit <n> { pppoe-options { ... } } } }`.
3//!
4//! # See also
5//!
6//! - [pppoe-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/pppoe-options-edit-interfaces.html)
7//! - [pppoe-options (SRX Series)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/pppoe-options-interfaces-security.html)
8//! - [auto-reconnect](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/auto-reconnect-edit-interfaces.html)
9//! - [client](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/client-edit-interfaces.html)
10//! - [server](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/server-edit-interfaces.html)
11//! - [service-name](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/service-name-edit-interfaces.html)
12//! - [underlying-interface](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/underlying-interface-edit-interfaces.html)
13//! - [access-concentrator](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/access-concentrator-edit-interfaces.html)
14
15use crate::{arg_of, has_leaf};
16use asterust::config::ConfigLine;
17
18/// The `pppoe-options` of a `pp0` unit.
19#[derive(Clone, Debug, PartialEq, Eq)]
20#[non_exhaustive]
21pub struct PppoeOptions {
22 pub access_concentrator: Option<String>,
23 /// Seconds.
24 pub auto_reconnect: Option<String>,
25 /// `client` or `server`.
26 pub role: Option<String>,
27 pub ignore_eol_tag: bool,
28 pub service_name: Option<String>,
29 pub underlying_interface: Option<String>,
30 pub ppp_max_payload: Option<String>,
31}
32
33pub(super) fn parse_pppoe_options(options: &ConfigLine) -> PppoeOptions {
34 let value = |keyword| arg_of(options, keyword).map(str::to_string);
35 PppoeOptions {
36 access_concentrator: value("access-concentrator"),
37 auto_reconnect: value("auto-reconnect"),
38 role: ["client", "server"]
39 .into_iter()
40 .find(|role| has_leaf(options, role))
41 .map(str::to_string),
42 ignore_eol_tag: has_leaf(options, "ignore-eol-tag"),
43 service_name: value("service-name"),
44 underlying_interface: value("underlying-interface"),
45 ppp_max_payload: value("ppp-max-payload"),
46 }
47}