asterust_junos/system/services/
dhcp_local_server.rs1use crate::{args_of, child_block, named_children};
4use asterust::config::ConfigLine;
5
6#[derive(Clone, Debug, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct DhcpLocalServerGroup {
10 pub name: String,
11 pub interfaces: Vec<String>,
13}
14
15#[derive(Clone, Debug, PartialEq, Eq)]
17#[non_exhaustive]
18pub struct DhcpLocalServer {
19 pub groups: Vec<DhcpLocalServerGroup>,
20 pub dhcpv6_groups: Vec<DhcpLocalServerGroup>,
22}
23
24pub(super) fn parse_dhcp_local_server(server: &ConfigLine) -> DhcpLocalServer {
25 let groups = |parent: &ConfigLine| -> Vec<DhcpLocalServerGroup> {
26 named_children(parent, "group")
27 .map(|(name, group)| DhcpLocalServerGroup {
28 name: name.to_string(),
29 interfaces: args_of(group, "interface").into_iter().map(str::to_string).collect(),
30 })
31 .collect()
32 };
33 DhcpLocalServer {
34 groups: groups(server),
35 dhcpv6_groups: child_block(server, "dhcpv6").map(groups).unwrap_or_default(),
36 }
37}