<model>
    <mount>//OPNsense/Kea/dhcp4</mount>
    <version>1.0.3</version>
    <description>Kea DHCPv4 configuration</description>
    <items>
        <general>
            <enabled type="BooleanField">
                <Default>0</Default>
                <Required>Y</Required>
            </enabled>
            <manual_config type="BooleanField"/>
            <interfaces type="InterfaceField">
                <Multiple>Y</Multiple>
            </interfaces>
            <valid_lifetime type="IntegerField">
                <Default>4000</Default>
                <Required>Y</Required>
            </valid_lifetime>
            <fwrules type="BooleanField">
                <Required>Y</Required>
                <Default>1</Default>
            </fwrules>
            <dhcp_socket_type type="OptionField">
                <Default>raw</Default>
                <Required>Y</Required>
                <OptionValues>
                    <udp>udp</udp>
                    <raw>raw</raw>
                </OptionValues>
            </dhcp_socket_type>
        </general>
        <ha>
            <enabled type="BooleanField">
                <Default>0</Default>
                <Required>Y</Required>
            </enabled>
            <this_server_name type="TextField">
                <Mask>/^([0-9a-zA-Z.\:\-,_]){0,1024}$/u</Mask>
            </this_server_name>
            <max_unacked_clients type="IntegerField">
                <MinimumValue>0</MinimumValue>
                <MaximumValue>65535</MaximumValue>
                <Default>2</Default>
                <Required>Y</Required>
            </max_unacked_clients>
        </ha>
        <subnets>
            <subnet4 type="ArrayField">
                <subnet type="NetworkField">
                    <NetMaskRequired>Y</NetMaskRequired>
                    <AddressFamily>ipv4</AddressFamily>
                    <Required>Y</Required>
                </subnet>
                <next_server type="NetworkField">
                    <NetMaskAllowed>N</NetMaskAllowed>
                    <AddressFamily>ipv4</AddressFamily>
                </next_server>
                <option_data_autocollect type="BooleanField">
                    <Default>1</Default>
                    <Required>Y</Required>
                </option_data_autocollect>
                <option_data>
                    <domain_name_servers type="NetworkField">
                        <NetMaskAllowed>N</NetMaskAllowed>
                        <AddressFamily>ipv4</AddressFamily>
                        <AsList>Y</AsList>
                        <FieldSeparator>,</FieldSeparator>
                    </domain_name_servers>
                    <domain_search type="HostnameField">
                        <IpAllowed>N</IpAllowed>
                        <FieldSeparator>,</FieldSeparator>
                        <AsList>Y</AsList>
                        <ValidationMessage>Please specify a valid list of domains</ValidationMessage>
                    </domain_search>
                    <routers type="NetworkField">
                        <NetMaskAllowed>N</NetMaskAllowed>
                        <AddressFamily>ipv4</AddressFamily>
                        <AsList>Y</AsList>
                        <FieldSeparator>,</FieldSeparator>
                    </routers>
                    <static_routes type="TextField">
                        <!-- Needs a custom validator to validate ip pairs-->
                    </static_routes>
                    <domain_name type="HostnameField">
                        <IpAllowed>N</IpAllowed>
                    </domain_name>
                    <ntp_servers type="NetworkField">
                        <NetMaskAllowed>N</NetMaskAllowed>
                        <AddressFamily>ipv4</AddressFamily>
                        <AsList>Y</AsList>
                        <FieldSeparator>,</FieldSeparator>
                    </ntp_servers>
                    <time_servers type="NetworkField">
                        <NetMaskAllowed>N</NetMaskAllowed>
                        <AddressFamily>ipv4</AddressFamily>
                        <AsList>Y</AsList>
                        <FieldSeparator>,</FieldSeparator>
                    </time_servers>
                    <tftp_server_name type="TextField">
                        <Mask>/^([^\n"])*$/u</Mask>
                    </tftp_server_name>
                    <boot_file_name type="TextField">
                        <Mask>/^([^\n"])*$/u</Mask>
                    </boot_file_name>
                    <v6_only_preferred type="IntegerField">
                        <MinimumValue>300</MinimumValue>
                    </v6_only_preferred>
                </option_data>
                <match-client-id type="BooleanField">
                    <Default>1</Default>
                    <Required>Y</Required>
                </match-client-id>
                <pools type=".\KeaPoolsField">
                </pools>
                <description type="DescriptionField"/>
            </subnet4>
        </subnets>
        <reservations>
            <reservation type="ArrayField">
                <subnet type="ModelRelationField">
                    <Model>
                        <subnets>
                            <source>OPNsense.Kea.KeaDhcpv4</source>
                            <items>subnets.subnet4</items>
                            <display>subnet</display>
                        </subnets>
                    </Model>
                    <ValidationMessage>Related subnet not found</ValidationMessage>
                    <Constraints>
                        <check001>
                            <reference>hw_address.check001</reference>
                        </check001>
                    </Constraints>
                    <Required>Y</Required>
                </subnet>
                <ip_address type="NetworkField">
                    <NetMaskAllowed>N</NetMaskAllowed>
                    <AddressFamily>ipv4</AddressFamily>
                    <Constraints>
                        <check001>
                            <ValidationMessage>Duplicate entry exists</ValidationMessage>
                            <type>UniqueConstraint</type>
                        </check001>
                    </Constraints>
                </ip_address>
                <hw_address type="MacAddressField">
                    <Required>Y</Required>
                    <Constraints>
                        <check001>
                            <ValidationMessage>Duplicate entry exists</ValidationMessage>
                            <type>UniqueConstraint</type>
                            <addFields>
                                <field1>subnet</field1>
                            </addFields>
                        </check001>
                    </Constraints>
                </hw_address>
                <hostname type="HostnameField">
                    <IsDNSName>Y</IsDNSName>
                </hostname>
                <description type="DescriptionField"/>
            </reservation>
        </reservations>
        <ha_peers>
            <peer type="ArrayField">
                <name type="TextField">
                    <Required>Y</Required>
                    <Constraints>
                        <check001>
                            <ValidationMessage>Duplicate entry exists</ValidationMessage>
                            <type>UniqueConstraint</type>
                        </check001>
                    </Constraints>
                </name>
                <role type="OptionField">
                    <Default>primary</Default>
                    <Required>Y</Required>
                    <OptionValues>
                        <primary>primary</primary>
                        <standby>standby</standby>
                    </OptionValues>
                </role>
                <url type="UrlField">
                    <Required>Y</Required>
                    <Constraints>
                        <check001>
                            <ValidationMessage>Duplicate entry exists</ValidationMessage>
                            <type>UniqueConstraint</type>
                        </check001>
                    </Constraints>
                </url>
            </peer>
        </ha_peers>
    </items>
</model>
