asterust-junos 0.5.11

Typed Juniper JunOS config views (interfaces, protocols, routing instances and options, policy options, firewall filters, class of service, system, services) extracted from an asterust config tree.
Documentation
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
//! The statements shared by every level of a DHCP local server: the server itself, `dhcpv6`, a group,
//! an interface and a dual-stack group.
//!
//! # See also
//!
//! - [authentication (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/authentication-edit-system-services.html)
//! - [username-include (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/username-include-edit-system-services.html)
//! - [password (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/password-edit-system-services.html)
//! - [allow-leasequery (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/allow-leasequery-edit-system-services-dhcp-.html)
//! - [allow-bulk-leasequery (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/allow-bulk-leasequery-edit-system-services-dhcp-.html)
//! - [allow-active-leasequery (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/allow-active-leasequery-edit-system-services-dhcp.html)
//! - [active-leasequery (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/dhcp-local-server-active-leasequery.html)
//! - [active-fingerprint-server-group (DHCP Local Server and DHCP Relay Groups)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/active-fingerprint-server-group-edit-system-services-dhcp-local-server-group.html)
//! - [fingerprint-server-group (DHCPv4)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/fingerprint-server-group-edit-system-services-dhcp-local-server.html)
//! - [fingerprint-server-group (DHCPv6)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/fingerprint-server-group-edit-system-services-dhcp-local-server-dhcpv6.html)
//! - [dynamic-profile (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/dynamic-profile-edit-system-services.html)
//! - [service-profile (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/service-profile-edit-system-services.html)
//! - [duplicate-clients (DHCPv6 Local Server and Relay Agent)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/duplicate-clients-edit-dhcp.html)
//! - [duplicate-clients-in-subnet](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/duplicate-clients-in-subnet-edit-forwarding-options.html)
//! - [forward-snooped-clients (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/forward-snooped-clients-edit-system-services.html)
//! - [lease-time-validation](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/lease-time-validation-edit-dhcp.html)
//! - [liveness-detection](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/liveness-detection-edit-dhcp.html)
//! - [bfd (DHCP liveness detection)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/bfd-edit-dhcp-liveness-detection-method.html)
//! - [layer2-liveness-detection (Send)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/layer2-liveness-detection-edit-dhcp.html)
//! - [no-snoop](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/no-snoop-edit-dhcp.html)
//! - [pool-match-order](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/pool-match-order-edit-system-services.html)
//! - [reauthenticate (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-services-dhcp-local-server-reauthenticate.html)
//! - [reconfigure (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/reconfigure-edit-dhcp-local-server.html)
//! - [remote-id-mismatch](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/remote-id-mismatch-edit-dhcp.html)
//! - [requested-ip-network-match (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/requested-ip-network-match-edit-system-services.html)
//! - [route-suppression](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/route-suppression-edit-dhcp.html)
//! - [short-cycle-protection](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/short-cycle-protection-edit-dhcp-local-server-relay-agent.html)
//! - [server-duid-type (DHCP Local Server)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/server-duid-type-edit-system-services.html)
//! - [dynamic-server](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/dynamic-server.html)
//! - [interface-traceoptions (System Services DHCP)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-edit-interface-traceoptions-dhcp-local-server.html)

use super::overrides::{parse_overrides, DhcpOverrides};
use crate::protocols::traceoptions::{parse_named_traceoptions, Traceoptions};
use crate::{
    active_children, arg_of, args_of, child_block, has_leaf, list_values, named_children, secret_value,
    statement_words, statements, value_after, Secret,
};
use asterust::config::ConfigLine;

/// The `username-include` block of a DHCP `authentication`: what is concatenated into the username.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpUsernameInclude {
    pub circuit_type: bool,
    pub client_id: bool,
    pub client_id_exclude_headers: bool,
    pub client_id_use_automatic_ascii_hex_encoding: bool,
    pub delimiter: Option<String>,
    pub domain_name: Option<String>,
    /// `device-interface` or `logical-interface`.
    pub interface_description: Option<String>,
    pub interface_name: bool,
    pub logical_system_name: bool,
    pub mac_address: bool,
    pub option_60: bool,
    pub option_82: bool,
    pub option_82_circuit_id: bool,
    pub option_82_remote_id: bool,
    pub relay_agent_interface_id: bool,
    pub relay_agent_remote_id: bool,
    pub relay_agent_subscriber_id: bool,
    pub routing_instance_name: bool,
    pub user_prefix: Option<String>,
    pub vlan_tags: bool,
}

/// The `authentication` block. The `password` is read only with the `secrets` feature.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpAuthentication {
    /// `None` unless the `secrets` feature is enabled.
    pub password: Option<Secret>,
    pub username_include: Option<DhcpUsernameInclude>,
}

/// `allow-active-leasequery`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpActiveLeasequeryLimits {
    pub idle_timeout: Option<String>,
    pub timeout: Option<String>,
}

/// `allow-bulk-leasequery`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpBulkLeasequery {
    pub max_connections: Option<String>,
    pub max_empty_replies: Option<String>,
    pub restricted_requestor: bool,
    pub timeout: Option<String>,
}

/// `active-leasequery`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpActiveLeasequery {
    pub peer_addresses: Vec<String>,
    pub timeout: Option<String>,
    pub idle_timeout: Option<String>,
    pub exclude_interfaces: Vec<String>,
}

/// An `address` of a fingerprint server group.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpFingerprintServer {
    pub address: String,
    pub logical_system: Option<String>,
    pub routing_instance: Option<String>,
}

/// A group of `fingerprint-server-group`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpFingerprintServerGroup {
    pub name: String,
    pub servers: Vec<DhcpFingerprintServer>,
}

/// A `dynamic-profile <name>`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpDynamicProfile {
    pub name: String,
    /// `merge` or `replace`.
    pub aggregate_clients: Option<String>,
    pub use_primary: Option<String>,
}

/// `lease-time-validation`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpLeaseTimeValidation {
    pub lease_time_threshold: Option<String>,
    pub violation_action: Option<String>,
}

/// The `bfd` method of `liveness-detection`.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpBfd {
    /// `0`, `1` or `automatic`.
    pub version: Option<String>,
    pub minimum_interval: Option<String>,
    pub minimum_receive_interval: Option<String>,
    pub multiplier: Option<String>,
    pub no_adaptation: bool,
    pub transmit_interval_minimum_interval: Option<String>,
    pub transmit_interval_threshold: Option<String>,
    pub detection_time_threshold: Option<String>,
    /// `automatic`, `multihop` or `singlehop`.
    pub session_mode: Option<String>,
    pub holddown_interval: Option<String>,
}

/// `liveness-detection`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpLivenessDetection {
    /// `clear-binding`, `clear-binding-if-interface-up` or `log-only`.
    pub failure_action: Option<String>,
    pub bfd: Option<DhcpBfd>,
    /// From `layer2-liveness-detection { max-consecutive-retries }`.
    pub layer2_max_consecutive_retries: Option<String>,
    /// From `layer2-liveness-detection { transmit-interval }`.
    pub layer2_transmit_interval: Option<String>,
    /// `layer2-liveness-detection` is configured.
    pub layer2: bool,
}

/// `reconfigure`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpReconfigure {
    pub attempts: Option<String>,
    pub clear_on_abort: bool,
    pub clear_on_terminate: bool,
    pub strict: bool,
    pub support_option_pd_exclude: bool,
    pub timeout: Option<String>,
    pub token: Option<String>,
    /// `trigger { radius-disconnect; }`.
    pub trigger_radius_disconnect: bool,
}

/// `short-cycle-protection`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpShortCycleProtection {
    pub lockout_min_time: Option<String>,
    pub lockout_max_time: Option<String>,
}

/// An `interface <name>` of a `dynamic-server` group.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpDynamicServerInterface {
    pub name: String,
    pub overrides: Option<DhcpOverrides>,
}

/// A `group <name>` of the DHCPv6 `dynamic-server`.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpDynamicServerGroup {
    pub name: String,
    /// The pool of `neighbor-discovery-router-advertisement`.
    pub ndra_pool: Option<String>,
    pub interfaces: Vec<DhcpDynamicServerInterface>,
}

/// The statements shared by every level of a DHCP local server. The ones a level does not allow are
/// unset.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct DhcpOptions {
    pub active_fingerprint_server_group: Option<String>,
    pub active_leasequery: Option<DhcpActiveLeasequery>,
    pub allow_active_leasequery: Option<DhcpActiveLeasequeryLimits>,
    pub allow_bulk_leasequery: Option<DhcpBulkLeasequery>,
    /// `allow-leasequery`: whether it is configured.
    pub allow_leasequery: bool,
    /// `allow-leasequery { restricted-requestor; }`.
    pub allow_leasequery_restricted_requestor: bool,
    pub authentication: Option<DhcpAuthentication>,
    pub dynamic_profiles: Vec<DhcpDynamicProfile>,
    /// DHCPv6 `duplicate-clients incoming-interface`.
    pub duplicate_clients: Option<String>,
    /// `incoming-interface` or `option-82`.
    pub duplicate_clients_in_subnet: Option<String>,
    pub dynamic_server: Vec<DhcpDynamicServerGroup>,
    pub fingerprint_server_groups: Vec<DhcpFingerprintServerGroup>,
    /// `all-interfaces`, `configured-interfaces` or `non-configured-interfaces`.
    pub forward_snooped_clients: Option<String>,
    pub interface_traceoptions: Option<Traceoptions>,
    pub lease_time_validation: Option<DhcpLeaseTimeValidation>,
    pub liveness_detection: Option<DhcpLivenessDetection>,
    pub no_snoop: bool,
    pub overrides: Option<DhcpOverrides>,
    /// e.g. `ip-address-first`, `option-82`, `external-authority`.
    pub pool_match_order: Vec<String>,
    /// e.g. `lease-renewal`, `remote-id-mismatch`, `actual-data-rate-change`.
    pub reauthenticate: Vec<String>,
    pub reconfigure: Option<DhcpReconfigure>,
    /// `remote-id-mismatch disconnect`.
    pub remote_id_mismatch_disconnect: bool,
    pub requested_ip_network_match: Option<String>,
    /// `access`, `access-internal` or `destination`.
    pub route_suppression: Option<String>,
    pub server_duid_type: Option<String>,
    pub service_profile: Option<String>,
    pub short_cycle_protection: Option<DhcpShortCycleProtection>,
}

fn flag(block: &ConfigLine, name: &str) -> bool {
    has_leaf(block, name)
}

fn parse_username_include(include: &ConfigLine) -> DhcpUsernameInclude {
    let client_id = statement_words(include, "client-id");
    let option_82 = statement_words(include, "option-82");
    let option_82_flag = |name: &str| option_82.as_ref().is_some_and(|words| words.contains(&name));
    let field = |keyword: &str| arg_of(include, keyword).map(str::to_string);
    // `client-id` and `option-82` carry options on the line or in a block.
    DhcpUsernameInclude {
        circuit_type: flag(include, "circuit-type"),
        client_id: client_id.is_some(),
        client_id_exclude_headers: client_id.as_ref().is_some_and(|w| w.contains(&"exclude-headers")),
        client_id_use_automatic_ascii_hex_encoding: client_id
            .as_ref()
            .is_some_and(|w| w.contains(&"use-automatic-ascii-hex-encoding")),
        delimiter: field("delimiter"),
        domain_name: field("domain-name"),
        interface_description: field("interface-description").or_else(|| field("interfaces-description")),
        interface_name: flag(include, "interface-name"),
        logical_system_name: flag(include, "logical-system-name"),
        mac_address: flag(include, "mac-address"),
        option_60: flag(include, "option-60"),
        option_82: option_82.is_some(),
        option_82_circuit_id: option_82_flag("circuit-id"),
        option_82_remote_id: option_82_flag("remote-id"),
        relay_agent_interface_id: flag(include, "relay-agent-interface-id"),
        relay_agent_remote_id: flag(include, "relay-agent-remote-id"),
        relay_agent_subscriber_id: flag(include, "relay-agent-subscriber-id"),
        routing_instance_name: flag(include, "routing-instance-name"),
        user_prefix: field("user-prefix"),
        vlan_tags: flag(include, "vlan-tags"),
    }
}

fn parse_bfd(bfd: &ConfigLine) -> DhcpBfd {
    let field = |keyword: &str| arg_of(bfd, keyword).map(str::to_string);
    let transmit = child_block(bfd, "transmit-interval");
    DhcpBfd {
        version: field("version"),
        minimum_interval: field("minimum-interval"),
        minimum_receive_interval: field("minimum-receive-interval"),
        multiplier: field("multiplier"),
        no_adaptation: flag(bfd, "no-adaptation"),
        transmit_interval_minimum_interval: transmit.and_then(|t| arg_of(t, "minimum-interval")).map(str::to_string),
        transmit_interval_threshold: transmit.and_then(|t| arg_of(t, "threshold")).map(str::to_string),
        detection_time_threshold: child_block(bfd, "detection-time")
            .and_then(|d| arg_of(d, "threshold"))
            .map(str::to_string),
        session_mode: field("session-mode"),
        holddown_interval: field("holddown-interval"),
    }
}

fn parse_liveness(liveness: &ConfigLine) -> DhcpLivenessDetection {
    let method = child_block(liveness, "method");
    let layer2 = method.and_then(|m| child_block(m, "layer2-liveness-detection"));
    DhcpLivenessDetection {
        failure_action: arg_of(liveness, "failure-action").map(str::to_string),
        bfd: method.and_then(|m| child_block(m, "bfd")).map(parse_bfd),
        layer2_max_consecutive_retries: layer2
            .and_then(|l| arg_of(l, "max-consecutive-retries"))
            .map(str::to_string),
        layer2_transmit_interval: layer2.and_then(|l| arg_of(l, "transmit-interval")).map(str::to_string),
        layer2: layer2.is_some(),
    }
}

fn parse_dynamic_profiles(parent: &ConfigLine) -> Vec<DhcpDynamicProfile> {
    named_children(parent, "dynamic-profile")
        .map(|(name, profile)| DhcpDynamicProfile {
            name: name.to_string(),
            aggregate_clients: arg_of(profile, "aggregate-clients").map(str::to_string),
            use_primary: arg_of(profile, "use-primary").map(str::to_string),
        })
        .collect()
}

fn parse_fingerprint_groups(parent: &ConfigLine) -> Vec<DhcpFingerprintServerGroup> {
    let Some(outer) = child_block(parent, "fingerprint-server-group") else {
        return Vec::new();
    };
    named_children(outer, "fingerprint-server-group")
        .map(|(name, group)| DhcpFingerprintServerGroup {
            name: name.to_string(),
            servers: named_children(group, "address")
                .map(|(address, server)| DhcpFingerprintServer {
                    address: address.to_string(),
                    logical_system: arg_of(server, "logical-system").map(str::to_string),
                    routing_instance: arg_of(server, "routing-instance").map(str::to_string),
                })
                .collect(),
        })
        .collect()
}

fn parse_dynamic_server(parent: &ConfigLine) -> Vec<DhcpDynamicServerGroup> {
    let Some(server) = child_block(parent, "dynamic-server") else {
        return Vec::new();
    };
    named_children(server, "group")
        .map(|(name, group)| DhcpDynamicServerGroup {
            name: name.to_string(),
            ndra_pool: arg_of(group, "neighbor-discovery-router-advertisement").map(str::to_string),
            interfaces: named_children(group, "interface")
                .map(|(name, interface)| DhcpDynamicServerInterface {
                    name: name.to_string(),
                    overrides: child_block(interface, "overrides").map(parse_overrides),
                })
                .collect(),
        })
        .collect()
}

/// The statements of `parent` that every DHCP local server level shares.
pub(super) fn parse_options(parent: &ConfigLine) -> DhcpOptions {
    let field = |keyword: &str| arg_of(parent, keyword).map(str::to_string);
    let first = |keyword: &str| statements(parent, keyword).first().map(|s| s.to_string());
    let leasequery = child_block(parent, "allow-leasequery");
    let reauthenticate = statement_words(parent, "reauthenticate");
    DhcpOptions {
        active_fingerprint_server_group: field("active-fingerprint-server-group"),
        active_leasequery: child_block(parent, "active-leasequery").map(|query| DhcpActiveLeasequery {
            peer_addresses: child_block(query, "peer-address")
                .map(|peers| active_children(peers).map(|a| a.text.clone()).collect())
                .unwrap_or_default(),
            timeout: arg_of(query, "timeout").map(str::to_string),
            idle_timeout: arg_of(query, "idle-timeout").map(str::to_string),
            exclude_interfaces: args_of(query, "exclude-interface")
                .into_iter()
                .flat_map(list_values)
                .collect(),
        }),
        allow_active_leasequery: child_block(parent, "allow-active-leasequery").map(|query| {
            DhcpActiveLeasequeryLimits {
                idle_timeout: arg_of(query, "idle-timeout").map(str::to_string),
                timeout: arg_of(query, "timeout").map(str::to_string),
            }
        }),
        allow_bulk_leasequery: child_block(parent, "allow-bulk-leasequery").map(|query| DhcpBulkLeasequery {
            max_connections: arg_of(query, "max-connections").map(str::to_string),
            max_empty_replies: arg_of(query, "max-empty-replies").map(str::to_string),
            restricted_requestor: flag(query, "restricted-requestor"),
            timeout: arg_of(query, "timeout").map(str::to_string),
        }),
        allow_leasequery: leasequery.is_some(),
        allow_leasequery_restricted_requestor: leasequery.is_some_and(|q| flag(q, "restricted-requestor")),
        authentication: child_block(parent, "authentication").map(|auth| DhcpAuthentication {
            password: secret_value(arg_of(auth, "password")),
            username_include: child_block(auth, "username-include").map(parse_username_include),
        }),
        dynamic_profiles: parse_dynamic_profiles(parent),
        duplicate_clients: field("duplicate-clients"),
        duplicate_clients_in_subnet: field("duplicate-clients-in-subnet"),
        dynamic_server: parse_dynamic_server(parent),
        fingerprint_server_groups: parse_fingerprint_groups(parent),
        forward_snooped_clients: field("forward-snooped-clients"),
        interface_traceoptions: parse_named_traceoptions(parent, "interface-traceoptions"),
        lease_time_validation: child_block(parent, "lease-time-validation").map(|validation| DhcpLeaseTimeValidation {
            lease_time_threshold: arg_of(validation, "lease-time-threshold").map(str::to_string),
            violation_action: arg_of(validation, "violation-action").map(str::to_string),
        }),
        liveness_detection: child_block(parent, "liveness-detection").map(parse_liveness),
        no_snoop: flag(parent, "no-snoop"),
        overrides: child_block(parent, "overrides").map(parse_overrides),
        pool_match_order: child_block(parent, "pool-match-order")
            .map(|order| active_children(order).map(|c| c.text.clone()).collect())
            .unwrap_or_default(),
        reauthenticate: reauthenticate
            .map(|words| words.into_iter().map(str::to_string).collect())
            .unwrap_or_default(),
        reconfigure: child_block(parent, "reconfigure").map(|reconfigure| DhcpReconfigure {
            attempts: arg_of(reconfigure, "attempts").map(str::to_string),
            clear_on_abort: flag(reconfigure, "clear-on-abort"),
            clear_on_terminate: flag(reconfigure, "clear-on-terminate"),
            strict: flag(reconfigure, "strict"),
            support_option_pd_exclude: flag(reconfigure, "support-option-pd-exclude"),
            timeout: arg_of(reconfigure, "timeout").map(str::to_string),
            token: arg_of(reconfigure, "token").map(str::to_string),
            trigger_radius_disconnect: child_block(reconfigure, "trigger")
                .is_some_and(|trigger| flag(trigger, "radius-disconnect")),
        }),
        remote_id_mismatch_disconnect: first("remote-id-mismatch").as_deref() == Some("disconnect"),
        requested_ip_network_match: field("requested-ip-network-match"),
        route_suppression: field("route-suppression"),
        server_duid_type: field("server-duid-type"),
        service_profile: field("service-profile"),
        short_cycle_protection: statement_words(parent, "short-cycle-protection").map(|words| {
            DhcpShortCycleProtection {
                lockout_min_time: value_after(&words, "lockout-min-time"),
                lockout_max_time: value_after(&words, "lockout-max-time"),
            }
        }),
    }
}