Skip to main content

asterust_junos/protocols/bgp/peer_options/
remove_private.rs

1//! `remove-private`
2//! `protocols { bgp { group <name> { remove-private [all] [replace] [nearest] [no-peer-loop-check]; } } }`.
3//!
4//! # See also
5//!
6//! - [remove-private](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/remove-private-edit-protocols-bgp.html)
7
8use crate::statement_words;
9use asterust::config::ConfigLine;
10
11/// The `remove-private` statement, which strips private AS numbers from advertised AS paths.
12#[derive(Clone, Debug, Default, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct RemovePrivate {
15    pub all: bool,
16    pub replace: bool,
17    pub nearest: bool,
18    pub no_peer_loop_check: bool,
19}
20
21/// Reads a bare `remove-private;`, inline words or a block.
22pub(super) fn parse_remove_private(line: &ConfigLine) -> Option<RemovePrivate> {
23    let words = statement_words(line, "remove-private")?;
24    Some(RemovePrivate {
25        all: words.contains(&"all"),
26        replace: words.contains(&"replace"),
27        nearest: words.contains(&"nearest"),
28        no_peer_loop_check: words.contains(&"no-peer-loop-check"),
29    })
30}