<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2000-2021 Ericsson Telecom AB
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v2.0
 which accompanies this distribution, and is available at
 https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html

 Contributors:
  Balasko, Jeno
  Raduly, Csaba
-->
<xs:schema targetNamespace="http://tail-f.com/ns/confd/1.0"
	   xmlns="http://tail-f.com/ns/confd/1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xml:lang="en">
  <xs:import namespace="http://www.w3.org/2001/XMLSchema"
	     schemaLocation="XMLSchema.xsd"/>
  <xs:annotation>
    <xs:documentation>
      This Schema is documented in the confd_ns(5) manual page.
    </xs:documentation>
  </xs:annotation>

  <xs:simpleType name="inetAddress">
    <xs:union memberTypes="inetAddressIP inetAddressDNS"/>
  </xs:simpleType>

  <xs:simpleType name="inetAddressIP">
    <xs:union memberTypes="inetAddressIPv4 inetAddressIPv6"/>
  </xs:simpleType>

  <xs:simpleType name="inetAddressIPv4">
    <xs:annotation>
      <xs:documentation>
        IPV4 Address: The value space representation is as defined in
        confd_types(3).
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="7"/>
      <xs:maxLength value="15"/>
      <xs:pattern value="(([0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){1,3}([0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>

    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="inetAddressIPv6">
    <xs:annotation>
      <xs:documentation>
        IPV6 Address: The value space representation is as defined in
        confd_types(3).
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="0"/>
      <xs:maxLength value="39"/>
      <!-- Full -->
      <xs:pattern value="(([0-9a-fA-F]{1,4}:){7})([0-9a-fA-F]{1,4})"/>
      <!-- Mixed -->
      <xs:pattern value="(([0-9a-fA-F]{1,4}:){6})(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))"/>
      <!-- Shortened -->
      <xs:pattern value="(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*(::)(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*"/>
      <!-- Shortened mixed -->
      <xs:pattern value="(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*(::)(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="inetAddressDNS">
    <xs:restriction base="xs:string"/>
  </xs:simpleType>
  
  <xs:simpleType name="inetPortNumber">
    <xs:annotation>
      <xs:documentation>
        RFC 4001 (INET-ADDRESS-MIB)
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:unsignedShort"/>
  </xs:simpleType>

  <xs:simpleType name="size">
    <xs:annotation>
      <xs:documentation>
        Number of bytes, e.g. S1G243K4B equals 1GB+243KB+4B.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="S([0-9]+G)?([0-9]+M)?([0-9]+K)?([0-9]+B)?"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="MD5DigestString">
    <xs:restriction base="xs:string"/>
  </xs:simpleType>

  <xs:simpleType name="DES3CBCEncryptedString">
    <xs:restriction base="xs:string"/>
  </xs:simpleType>

  <xs:simpleType name="AESCFB128EncryptedString">
    <xs:restriction base="xs:string"/>
  </xs:simpleType>

  <xs:simpleType name="atom">
    <xs:annotation>
      <xs:documentation xml:lang="en">
	For internal use only.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string"/>
  </xs:simpleType>

  <xs:simpleType name="hexValue">
    <xs:annotation>
      <xs:documentation xml:lang="en">
	For internal use only.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9a-fA-F]*"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="hexList">
    <xs:annotation>
      <xs:documentation>
	Hexadecimal List:
        A list of octets on hexadecimal format separated with colons.
	Example: 00:4F:4C:41 
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="([0-9a-fA-F][0-9a-fA-F]:)*([0-9a-fA-F][0-9a-fA-F])"/>
      <xs:pattern value=""/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="octetList">
    <xs:annotation>
      <xs:documentation>
        Octet List: 
        A list of octets on decimal format separated with dots.
	Example: 192.168.0.1
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="(([0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.)*([0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="oid">
    <xs:annotation>
      <xs:documentation>
        Object Identifier: 
        A list of integers separated with dots.
        Example: 1.3.6.1.6.1.1
	The OIDs are used in SNMP.	
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="(([0-9]?[0-9]*)\.)*([0-9]?[0-9]*)?"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="objectRef">
    <xs:annotation>
      <xs:documentation>
	Object reference:
	An XPath reference to some element.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Counter32">
    <xs:annotation>
      <xs:documentation>
	From RFC 2578 (SMIv2) 7.1.6:

	The Counter32 type represents a non-negative integer which
	monotonically increases until it reaches a maximum value of 2^32-1
	(4294967295 decimal), when it wraps around and starts increasing
	again from zero.

	Counters have no defined "initial" value, and thus, a single value of
	a Counter has (in general) no information content.  Discontinuities
	in the monotonically increasing value normally occur at re-
	initialization of the management system, and at other times as
	specified in the description of an object-type using this type.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:unsignedInt">
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Counter64">
    <xs:annotation>
      <xs:documentation>
	From RFC 2578 (SMIv2) 7.1.10:

	The Counter64 type represents a non-negative integer which
	monotonically increases until it reaches a maximum value of 2^64-1
	(18446744073709551615 decimal), when it wraps around and starts
	increasing again from zero.

	Counters have no defined "initial" value, and thus, a single value of
	a Counter has (in general) no information content.  Discontinuities
	in the monotonically increasing value normally occur at re-
	initialization of the management system, and at other times as
	specified in the description of an object-type using this type.
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:unsignedLong">
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Gauge32">
    <xs:annotation>
      <xs:documentation>
	From RFC 2578 (SMIv2) 7.1.7:

	The Gauge32 type represents a non-negative integer, which may
	increase or decrease, but shall never exceed a maximum value, nor
	fall below a minimum value.  The maximum value can not be greater
	than 2^32-1 (4294967295 decimal), and the minimum value can not be
	smaller than 0.  The value of a Gauge32 has its maximum value
	whenever the information being modeled is greater than or equal to
	its maximum value, and has its minimum value whenever the information
	being modeled is smaller than or equal to its minimum value.  If the
	information being modeled subsequently decreases below (increases
	above) the maximum (minimum) value, the Gauge32 also decreases
	(increases).  (Note that despite of the use of the term "latched" in
	the original definition of this type, it does not become "stuck" at
	its maximum or minimum value.)
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:unsignedInt">
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ipPrefix">
    <xs:annotation>
      <xs:documentation>
        The ipPrefix type represents an IP prefix and
        is IP version neutral. The format of the textual
        representations implies the IP version.
      </xs:documentation>
    </xs:annotation>

    <xs:union>
    <xs:simpleType>
      <xs:restriction base="ipv4Prefix">
      </xs:restriction>
    </xs:simpleType>
    <xs:simpleType>
      <xs:restriction base="ipv6Prefix">
      </xs:restriction>
    </xs:simpleType>
    </xs:union>
  </xs:simpleType>

  <xs:simpleType name="ipv4Prefix">
    <xs:annotation>
      <xs:documentation>
        The ipv4Prefix type represents an IPv4 address prefix.
        The prefix length is given by the number following the
        slash character and must be less than or equal 32. 

        A prefix length value of n corresponds to an IP address
        mask which has n contiguous 1-bits from the most
        significant bit (MSB) and all other bits set to 0.

        The IPv4 address represented in dotted quad notation 
        should have all bits that do not belong to the prefix
        set to zero.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="(([0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])/\p{N}+"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ipv6Prefix">
    <xs:annotation>
      <xs:documentation>
        The ipv6Prefix type represents an IPv6 address prefix.
        The prefix length is given by the number following the
        slash character and must be less than or equal 128. 

        A prefix length value of n corresponds to an IP address
        mask which has n contiguous 1-bits from the most
        significant bit (MSB) and all other bits set to 0.

        The IPv6 address should have all bits that do not belong to
        the prefix set to zero.
      </xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:pattern value="((([0-9a-fA-F]{1,4}:){7})([0-9a-fA-F]{1,4})/\p{N}+)|((([0-9a-fA-F]{1,4}:){6})(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))/\p{N}+)|((([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*(::)(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*/\p{N}+)((([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*(::)(([0-9a-fA-F]{1,4}:)*([0-9a-fA-F]{1,4}))*(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))/\p{N}+)"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:attribute name="default" type="xs:anySimpleType">
    <xs:annotation>
      <xs:documentation xml:lang="en">
        The confdc compiler generates an XML W3C Schema whenever it
        links a number of .xso files into a final .fxs file. This W3C
        XML Schema can be used to describe, using a standard notation,
        what actually goes over the wire, e.g. as a result to a
        get-config operation.

        Whenever an element has a default value the generated schema
        uses this attribute, as a foreign attribute, rather than the
        standard 'xs:default' attribute.

        Consider this example:

        &lt;xs:element name="size" type="xs:long" minOccurs="0"
                    xmlns:confd="http://tail-f.com/ns/confd/1.0" confd:default="42"&gt;

        In an instance document this means:

        o If the size tag is left out; "42" is stored in the
          configuration database. 
        o If the size tag is empty, i.e. &lt;size/&gt;, the empty string is
          stored in the configuration database.
        
        Using the standard attribute this would have happened:

        o If the size tag is left out no value would have been stored
          in the configuration database. 
        o If the size tag is empty "42" would have been stored in the
          configuration database.
      </xs:documentation>
    </xs:annotation>
  </xs:attribute>

  <xs:attribute name="config" type="xs:boolean">
    <xs:annotation>
      <xs:documentation xml:lang="en">
	When the confdc compiler generates an XML W3C Schema, elements
	to be used as operational data, i.e., having config="false",
	are supplied with an xs:appinfo element, with the attribute
	confd:config="false".
      </xs:documentation>
    </xs:annotation>
  </xs:attribute>

  <xs:element name="errorMessage">
    <xs:annotation>
      <xs:documentation xml:lang="en">
	Used to add custom error message to facets used in restritive
	xs:simpleType constructs in confspec files.

        Consider this example:

        &lt;xs:simpleType name="foo"&gt;
          &lt;xs:restriction base="xs:string"&gt;
            &lt;xs:minLength value="7"/&gt;
            &lt;xs:maxLength value="15"/&gt;
            &lt;xs:pattern value="[a-z]*"&gt;
              &lt;confd:error-app-tag&gt;...&lt;/confd:error-app-tag&gt;
              &lt;confd:error-message&gt;...&lt;/confd:error-message&gt;
            &lt;/xs:pattern&gt;
          &lt;/xs:restriction&gt;
        &lt;/xs:simpleType&gt;
      </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string"/>
    </xs:simpleType>
  </xs:element>
  <xs:element name="errorMessage2"><xs:annotation><xs:documentation xml:lang="en">&lt;/xs:simpleType&gt;</xs:documentation></xs:annotation><xs:simpleType><xs:restriction base="xs:string"/></xs:simpleType></xs:element>
</xs:schema>
