<model>
    <mount>//OPNsense/TrafficShaper</mount>
    <description>
        OPNsense traffic shaper
    </description>
    <items>
        <pipes>
            <pipe type="ArrayField">
                <number type="IntegerField">
                    <MinimumValue>1</MinimumValue>
                    <MaximumValue>65535</MaximumValue>
                    <ValidationMessage>Pipe number must be between 1...65535</ValidationMessage>
                    <Required>Y</Required>
                </number>
                <enabled type="BooleanField">
                    <default>1</default>
                    <Required>Y</Required>
                </enabled>
                <bandwidth type="IntegerField">
                    <Required>Y</Required>
                    <MinimumValue>1</MinimumValue>
                    <MaximumValue>899795</MaximumValue>
                    <ValidationMessage>Bandwidth out of range</ValidationMessage>
                </bandwidth>
                <bandwidthMetric type="OptionField">
                    <Required>Y</Required>
                    <default>Kbit</default>
                    <OptionValues>
                        <bit>bit/s</bit>
                        <Kbit>Kbit/s</Kbit>
                        <Mbit>Mbit/s</Mbit>
                    </OptionValues>
                    <ValidationMessage>Bandwidth metric should be one of bit,Kbit,Mbit</ValidationMessage>
                </bandwidthMetric>
                <burst type="IntegerField">
                    <Required>N</Required>
                    <ValidationMessage>The burst value is an integer and represent a number of bytes.</ValidationMessage>
                </burst>
                <queue type="IntegerField">
                    <Required>N</Required>
                    <MinimumValue>2</MinimumValue>
                    <MaximumValue>100</MaximumValue>
                    <ValidationMessage>queue size should be between 2...100</ValidationMessage>
                </queue>
                <mask type="OptionField">
                    <Required>Y</Required>
                    <default>none</default>
                    <OptionValues>
                        <none></none>
                        <src-ip>source</src-ip>
                        <dst-ip>destination</dst-ip>
                    </OptionValues>
                </mask>
                <scheduler type="OptionField">
                  <Required>N</Required>
                  <default></default>
                  <BlankDesc>Weighted Fair Queueing</BlankDesc>
                  <OptionValues>
                      <fifo>FIFO</fifo>
                      <rr>Deficit Round Robin</rr>
                      <qfq>QFQ</qfq>
                      <fq_codel>FlowQueue-CoDel</fq_codel>
                  </OptionValues>
                </scheduler>
                <codel_enable type="BooleanField">
                  <default>0</default>
                  <Required>Y</Required>
                </codel_enable>
                <codel_target type="IntegerField">
                  <Required>N</Required>
                  <MinimumValue>1</MinimumValue>
                  <MaximumValue>10000</MaximumValue>
                </codel_target>
                <codel_interval type="IntegerField">
                  <Required>N</Required>
                  <MinimumValue>1</MinimumValue>
                  <MaximumValue>10000</MaximumValue>
                </codel_interval>
                <codel_ecn_enable type="BooleanField">
                  <default>0</default>
                  <Required>Y</Required>
                </codel_ecn_enable>
                <fqcodel_quantum type="IntegerField">
                  <Required>N</Required>
                  <MinimumValue>1</MinimumValue>
                  <MaximumValue>65535</MaximumValue>
                </fqcodel_quantum>
                <fqcodel_limit type="IntegerField">
                  <Required>N</Required>
                  <MinimumValue>1</MinimumValue>
                  <MaximumValue>65535</MaximumValue>
                </fqcodel_limit>
                <fqcodel_flows type="IntegerField">
                  <Required>N</Required>
                  <MinimumValue>1</MinimumValue>
                  <MaximumValue>65535</MaximumValue>
                </fqcodel_flows>
                <origin type="TextField">
                    <Required>N</Required>
                    <mask>/^([a-z,A-Z,1-9]){0,30}$/</mask>
                    <ValidationMessage>Origin should be regular text of max 30 characters</ValidationMessage>
                </origin>
                <description type="TextField">
                    <Required>Y</Required>
                    <mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){1,255}$/u</mask>
                    <ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
                </description>
            </pipe>
        </pipes>
        <queues>
            <queue type="ArrayField">
                <number type="IntegerField">
                    <MinimumValue>1</MinimumValue>
                    <MaximumValue>65535</MaximumValue>
                    <ValidationMessage>Queue number must be between 1...65535</ValidationMessage>
                    <Required>Y</Required>
                </number>
                <enabled type="BooleanField">
                    <default>1</default>
                    <Required>Y</Required>
                </enabled>
                <pipe type="ModelRelationField">
                    <Model>
                        <pipes>
                            <source>OPNsense.TrafficShaper.TrafficShaper</source>
                            <items>pipes.pipe</items>
                            <display>description</display>
                        </pipes>
                    </Model>
                    <ValidationMessage>Related pipe not found</ValidationMessage>
                    <Required>Y</Required>
                </pipe>
                <weight type="IntegerField">
                    <MinimumValue>1</MinimumValue>
                    <MaximumValue>100</MaximumValue>
                    <Default>100</Default>
                    <Required>Y</Required>
                    <ValidationMessage>Weight must be between 1...100</ValidationMessage>
                </weight>
                <mask type="OptionField">
                    <Required>Y</Required>
                    <default>none</default>
                    <OptionValues>
                        <none></none>
                        <src-ip>source</src-ip>
                        <dst-ip>destination</dst-ip>
                    </OptionValues>
                </mask>
                <codel_enable type="BooleanField">
                  <default>0</default>
                  <Required>Y</Required>
                </codel_enable>
                <codel_target type="IntegerField">
                  <Required>N</Required>
                  <MinimumValue>1</MinimumValue>
                  <MaximumValue>10000</MaximumValue>
                </codel_target>
                <codel_interval type="IntegerField">
                  <Required>N</Required>
                  <MinimumValue>1</MinimumValue>
                  <MaximumValue>10000</MaximumValue>
                </codel_interval>
                <codel_ecn_enable type="BooleanField">
                  <default>0</default>
                  <Required>Y</Required>
                </codel_ecn_enable>
                <description type="TextField">
                    <Required>Y</Required>
                    <mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){1,255}$/u</mask>
                    <ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
                </description>
                <origin type="TextField">
                    <Required>N</Required>
                    <mask>/^([a-z,A-Z,1-9]){0,30}$/</mask>
                    <ValidationMessage>origin should be regular text of max 30 characters</ValidationMessage>
                </origin>
            </queue>
        </queues>
        <rules>
            <rule type="ArrayField">
                <sequence type="IntegerField">
                    <MinimumValue>1</MinimumValue>
                    <MaximumValue>1000000</MaximumValue>
                    <ValidationMessage>provide a valid sequence for sorting</ValidationMessage>
                    <Required>Y</Required>
                    <default>1</default>
                </sequence>
                <interface type="InterfaceField">
                    <Required>Y</Required>
                    <default>wan</default>
                    <filters>
                        <enable>/^(?!0).*$/</enable>
                    </filters>
                </interface>
                <interface2 type="InterfaceField">
                    <Required>N</Required>
                    <default></default>
                    <filters>
                        <enable>/^(?!0).*$/</enable>
                    </filters>
                </interface2>
                <proto type="OptionField">
                    <Required>Y</Required>
                    <default>ip</default>
                    <OptionValues>
                        <ip>ip</ip>
                        <ip4>ipv4</ip4>
                        <ip6>ipv6</ip6>
                        <udp>udp</udp>
                        <tcp>tcp</tcp>
                        <tcp_ack>tcp (ACK packets only)</tcp_ack>
                        <tcp_ack_not>tcp (non-ACK packets)</tcp_ack_not>
                        <icmp>icmp</icmp>
                        <igmp>igmp</igmp>
                        <esp>esp</esp>
                        <ah>ah</ah>
                        <gre>gre</gre>
                    </OptionValues>
                </proto>
                <source type="NetworkField">
                    <Required>Y</Required>
                    <default>any</default>
                </source>
                <src_port type="PortField">
                    <Required>Y</Required>
                    <default>any</default>
                </src_port>
                <destination type="NetworkField">
                    <Required>Y</Required>
                    <default>any</default>
                </destination>
                <dst_port type="PortField">
                    <Required>Y</Required>
                    <default>any</default>
                </dst_port>
                <direction type="OptionField">
                    <Required>N</Required>
                    <default></default>
                    <OptionValues>
                        <__empty__>both</__empty__>
                        <in>in</in>
                        <out>out</out>
                    </OptionValues>
                </direction>
                <target type="ModelRelationField">
                    <Model>
                        <pipes>
                            <source>OPNsense.TrafficShaper.TrafficShaper</source>
                            <items>pipes.pipe</items>
                            <display>description</display>
                            <filters>
                                <description>/(.){1,255}/</description>
                            </filters>
                        </pipes>
                        <queues>
                            <source>OPNsense.TrafficShaper.TrafficShaper</source>
                            <items>queues.queue</items>
                            <display>description</display>
                            <filters>
                                <description>/(.){1,255}/</description>
                            </filters>
                        </queues>
                    </Model>
                    <ValidationMessage>Related pipe or queue not found</ValidationMessage>
                    <Required>Y</Required>
                </target>
                <description type="TextField">
                    <Required>N</Required>
                    <mask>/^([\t\n\v\f\r 0-9a-zA-Z.\-,_\x{00A0}-\x{FFFF}]){0,255}$/u</mask>
                </description>
                <origin type="TextField">
                    <Required>N</Required>
                    <mask>/^([a-z,A-Z,1-9]){0,30}$/</mask>
                    <ValidationMessage>origin should be regular text of max 30 characters</ValidationMessage>
                </origin>
            </rule>
        </rules>
    </items>
</model>
