Skip to main content

asterust_junos/interfaces/
keepalives.rs

1//! `keepalives`
2//! `interfaces { <name> { keepalives interval <s> down-count <n> up-count <n>; } }`.
3//!
4//! # See also
5//!
6//! - [keepalives](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/keepalives-edit-interfaces.html)
7//! - [no-keepalives](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/no-keepalives-edit-interfaces.html)
8
9use crate::{statement_words, value_after};
10use asterust::config::ConfigLine;
11
12/// The `keepalives` settings of an interface; `no-keepalives` is a separate flag.
13#[derive(Clone, Debug, PartialEq, Eq)]
14#[non_exhaustive]
15pub struct Keepalives {
16    /// Seconds.
17    pub interval: Option<String>,
18    pub down_count: Option<String>,
19    pub up_count: Option<String>,
20}
21
22pub(super) fn parse_keepalives(interface: &ConfigLine) -> Option<Keepalives> {
23    let words = statement_words(interface, "keepalives")?;
24    Some(Keepalives {
25        interval: value_after(&words, "interval"),
26        down_count: value_after(&words, "down-count"),
27        up_count: value_after(&words, "up-count"),
28    })
29}