1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! `arp`
//! `system { arp { ... } }`.
//!
//! # See also
//!
//! - [purging](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/purging-edit-system-arp.html)
//! - [non-subscriber-no-reply](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/non-subscriber-no-reply-edit-system-arp.html)
//! - [proactive-arp-detection](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-arp-proactive-arp-detection.html)
use crate::has_leaf;
use asterust::config::ConfigLine;
/// The `system arp` options.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct Arp {
/// Purge obsolete ARP entries when an interface or link goes offline.
pub purging: bool,
/// Drop ARP requests from non-subscribers when a user route is added for a subscriber.
pub non_subscriber_no_reply: bool,
pub proactive_arp_detection: bool,
}
pub(super) fn parse_arp(arp: &ConfigLine) -> Arp {
Arp {
purging: has_leaf(arp, "purging"),
non_subscriber_no_reply: has_leaf(arp, "non-subscriber-no-reply"),
proactive_arp_detection: has_leaf(arp, "proactive-arp-detection"),
}
}
#[cfg(test)]
mod tests {
use crate::system::system;
use asterust::config::juniper;
// Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
#[test]
fn extracts_arp_options() {
let arp = system(&juniper::parse_braces(
"system {\n arp {\n purging;\n non-subscriber-no-reply;\n proactive-arp-detection;\n }\n}\n",
))
.unwrap()
.arp
.unwrap();
assert!(arp.purging);
assert!(arp.non_subscriber_no_reply);
assert!(arp.proactive_arp_detection);
}
#[test]
fn arp_options_default_to_off() {
let arp = system(&juniper::parse_braces(
"system {\n arp {\n purging;\n }\n}\n",
))
.unwrap()
.arp
.unwrap();
assert!(!arp.non_subscriber_no_reply);
assert!(!arp.proactive_arp_detection);
}
#[test]
fn no_arp_is_none() {
let system = system(&juniper::parse_braces("system {\n host-name pe1;\n}\n")).unwrap();
assert!(system.arp.is_none());
}
}