asterust_junos/protocols/bgp/
neighbor.rs1use super::peer_options::{parse_peer_options, BgpPeerOptions};
9use crate::{arg_of, first_word};
10use asterust::config::ConfigLine;
11
12#[derive(Clone, Debug, PartialEq, Eq)]
14#[non_exhaustive]
15pub struct BgpNeighbor {
16 pub address: String,
17 pub description: Option<String>,
18 pub peer_as: Option<String>,
19 pub local_address: Option<String>,
20 pub options: BgpPeerOptions,
21}
22
23pub(super) fn parse_neighbor(address: &str, neighbor: &ConfigLine) -> BgpNeighbor {
24 BgpNeighbor {
25 address: address.to_string(),
26 description: arg_of(neighbor, "description").map(str::to_string),
27 peer_as: arg_of(neighbor, "peer-as").and_then(first_word).map(str::to_string),
28 local_address: arg_of(neighbor, "local-address").map(str::to_string),
29 options: parse_peer_options(neighbor),
30 }
31}