<?xml version="1.0"?>
<!-- DHCP server configuration -->
<interfaceDefinition>
  <node name="service">
    <children>
      <node name="dhcp-server" owner="${vyos_conf_scripts_dir}/service_dhcp-server.py">
        <properties>
          <help>Dynamic Host Configuration Protocol (DHCP) for DHCP server</help>
          <priority>911</priority>
        </properties>
        <children>
          #include <include/generic-disable-node.xml.i>
          <leafNode name="dynamic-dns-update">
            <properties>
              <help>Dynamically update Domain Name System (RFC4702)</help>
              <valueless/>
            </properties>
          </leafNode>
          <node name="failover">
            <properties>
              <help>DHCP failover configuration</help>
            </properties>
            <children>
              #include <include/source-address-ipv4.xml.i>
              <leafNode name="remote">
                <properties>
                  <help>IPv4 remote address used for connectio</help>
                  <valueHelp>
                    <format>ipv4</format>
                    <description>IPv4 address of failover peer</description>
                  </valueHelp>
                  <constraint>
                    <validator name="ipv4-address"/>
                  </constraint>
                </properties>
              </leafNode>
              <leafNode name="name">
                <properties>
                  <help>Peer name used to identify connection</help>
                  <constraint>
                    #include <include/constraint/alpha-numeric-hyphen-underscore-dot.xml.i>
                  </constraint>
                  <constraintErrorMessage>Invalid failover peer name. May only contain letters, numbers and .-_</constraintErrorMessage>
                </properties>
              </leafNode>
              <leafNode name="status">
                <properties>
                  <help>Failover hierarchy</help>
                  <completionHelp>
                    <list>primary secondary</list>
                  </completionHelp>
                  <valueHelp>
                    <format>primary</format>
                    <description>Configure this server to be the primary node</description>
                  </valueHelp>
                  <valueHelp>
                    <format>secondary</format>
                    <description>Configure this server to be the secondary node</description>
                  </valueHelp>
                  <constraint>
                    <regex>(primary|secondary)</regex>
                  </constraint>
                  <constraintErrorMessage>Invalid DHCP failover peer status</constraintErrorMessage>
                </properties>
              </leafNode>
              #include <include/pki/ca-certificate.xml.i>
              #include <include/pki/certificate.xml.i>
            </children>
          </node>
          <leafNode name="hostfile-update">
            <properties>
              <help>Updating /etc/hosts file (per client lease)</help>
              <valueless/>
            </properties>
          </leafNode>
          #include <include/listen-address-ipv4.xml.i>
          #include <include/listen-interface-multi-broadcast.xml.i>
          <tagNode name="shared-network-name">
            <properties>
              <help>Name of DHCP shared network</help>
              <constraint>
                #include <include/constraint/alpha-numeric-hyphen-underscore-dot.xml.i>
              </constraint>
              <constraintErrorMessage>Invalid shared network name. May only contain letters, numbers and .-_</constraintErrorMessage>
            </properties>
            <children>
              <leafNode name="authoritative">
                <properties>
                  <help>Option to make DHCP server authoritative for this physical network</help>
                  <valueless/>
                </properties>
              </leafNode>
              #include <include/dhcp/option-v4.xml.i>
              #include <include/generic-description.xml.i>
              #include <include/generic-disable-node.xml.i>
              <tagNode name="subnet">
                <properties>
                  <help>DHCP subnet for shared network</help>
                  <valueHelp>
                    <format>ipv4net</format>
                    <description>IPv4 address and prefix length</description>
                  </valueHelp>
                  <constraint>
                    <validator name="ipv4-prefix"/>
                  </constraint>
                  <constraintErrorMessage>Invalid IPv4 subnet definition</constraintErrorMessage>
                </properties>
                <children>
                  #include <include/dhcp/option-v4.xml.i>
                  #include <include/generic-description.xml.i>
                  #include <include/generic-disable-node.xml.i>
                  <leafNode name="exclude">
                    <properties>
                      <help>IP address to exclude from DHCP lease range</help>
                      <valueHelp>
                        <format>ipv4</format>
                        <description>IPv4 address to exclude from lease range</description>
                      </valueHelp>
                      <constraint>
                        <validator name="ipv4-address"/>
                      </constraint>
                      <multi/>
                    </properties>
                  </leafNode>
                  <leafNode name="lease">
                    <properties>
                      <help>Lease timeout in seconds</help>
                      <valueHelp>
                        <format>u32</format>
                        <description>DHCP lease time in seconds</description>
                      </valueHelp>
                      <constraint>
                        <validator name="numeric" argument="--range 0-4294967295"/>
                      </constraint>
                      <constraintErrorMessage>DHCP lease time must be between 0 and 4294967295 (49 days)</constraintErrorMessage>
                    </properties>
                    <defaultValue>86400</defaultValue>
                  </leafNode>
                  <tagNode name="range">
                    <properties>
                      <help>DHCP lease range</help>
                      <constraint>
                        #include <include/constraint/alpha-numeric-hyphen-underscore-dot.xml.i>
                      </constraint>
                      <constraintErrorMessage>Invalid range name, may only be alphanumeric, dot and hyphen</constraintErrorMessage>
                    </properties>
                    <children>
                      #include <include/dhcp/option-v4.xml.i>
                      <leafNode name="start">
                        <properties>
                          <help>First IP address for DHCP lease range</help>
                          <valueHelp>
                            <format>ipv4</format>
                            <description>IPv4 start address of pool</description>
                          </valueHelp>
                          <constraint>
                            <validator name="ipv4-address"/>
                          </constraint>
                        </properties>
                      </leafNode>
                      <leafNode name="stop">
                        <properties>
                          <help>Last IP address for DHCP lease range</help>
                          <valueHelp>
                            <format>ipv4</format>
                            <description>IPv4 end address of pool</description>
                          </valueHelp>
                          <constraint>
                            <validator name="ipv4-address"/>
                          </constraint>
                        </properties>
                      </leafNode>
                    </children>
                  </tagNode>
                  <tagNode name="static-mapping">
                    <properties>
                      <help>Hostname for static mapping reservation</help>
                      <constraint>
                        <validator name="fqdn"/>
                      </constraint>
                      <constraintErrorMessage>Invalid static mapping hostname</constraintErrorMessage>
                    </properties>
                    <children>
                      #include <include/dhcp/option-v4.xml.i>
                      #include <include/generic-description.xml.i>
                      #include <include/generic-disable-node.xml.i>
                      <leafNode name="ip-address">
                        <properties>
                          <help>Fixed IP address of static mapping</help>
                          <valueHelp>
                            <format>ipv4</format>
                            <description>IPv4 address used in static mapping</description>
                          </valueHelp>
                          <constraint>
                            <validator name="ipv4-address"/>
                          </constraint>
                        </properties>
                      </leafNode>
                      #include <include/interface/mac.xml.i>
                      #include <include/interface/duid.xml.i>
                    </children>
                  </tagNode>
                  <leafNode name="subnet-id">
                    <properties>
                      <help>Unique ID mapped to leases in the lease file</help>
                      <valueHelp>
                        <format>u32</format>
                        <description>Unique subnet ID</description>
                      </valueHelp>
                      <constraint>
                        <validator name="numeric" argument="--range 1-4294967295"/>
                      </constraint>
                    </properties>
                  </leafNode>
                </children>
              </tagNode>
            </children>
          </tagNode>
        </children>
      </node>
    </children>
  </node>
</interfaceDefinition>