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