network.rng 7.0 KB
Newer Older
1
<!-- A Relax NG schema for the libvirt network XML format -->
2
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
3
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
4 5 6 7
  <start>
    <ref name="network"/>
  </start>

8
  <define name="network">
9

10 11
    <element name="network">
      <interleave>
C
Cole Robinson 已提交
12

13 14 15
        <!-- The name of the network, used to refer to it through the API
             and in virsh -->
        <element name="name">
C
Cole Robinson 已提交
16
          <text/>
17
        </element>
C
Cole Robinson 已提交
18

19 20 21 22
        <!-- <uuid> element -->
        <optional>
          <element name="uuid"><text/></element>
        </optional>
C
Cole Robinson 已提交
23

24 25 26 27 28 29 30 31 32 33
        <!-- <bridge> element -->
        <optional>
          <!-- The name of the network to be set up; this will back
               the network on the host -->
          <element name="bridge">
            <optional>
              <attribute name="name">
                <text/>
              </attribute>
            </optional>
C
Cole Robinson 已提交
34

35 36 37 38 39 40 41 42
            <optional>
              <attribute name="stp">
                <choice>
                  <value>on</value>
                  <value>off</value>
                </choice>
              </attribute>
            </optional>
C
Cole Robinson 已提交
43

44 45 46 47 48
            <optional>
              <attribute name="delay">
                <data type="integer"/>
              </attribute>
            </optional>
C
Cole Robinson 已提交
49

50 51
          </element>
        </optional>
C
Cole Robinson 已提交
52

53 54 55 56 57 58 59 60
        <!-- <mac> element -->
        <optional>
          <element name="mac">
            <attribute name="address"><ref name="mac-addr"/></attribute>
            <empty/>
          </element>
        </optional>

61 62 63 64 65 66 67 68 69 70
        <!-- <forward> element -->
        <optional>
          <!-- The device through which the bridge is connected to the
               rest of the network -->
          <element name="forward">
            <optional>
              <attribute name="dev">
                <text/>
              </attribute>
            </optional>
C
Cole Robinson 已提交
71

72 73 74 75 76 77 78 79
            <optional>
              <attribute name="mode">
                <choice>
                  <value>nat</value>
                  <value>route</value>
                </choice>
              </attribute>
            </optional>
80
          </element>
81 82 83 84 85
        </optional>

        <!-- <domain> element -->
        <optional>
          <element name="domain">
86 87
            <attribute name="name"><text/></attribute>
          </element>
88 89
        </optional>

90 91 92 93 94 95 96 97 98 99 100 101 102
        <!-- Define the DNS related elements like TXT records
             and other features in the <dns> element -->
        <optional>
            <element name="dns">
              <zeroOrMore>
                <element name="txt">
                  <attribute name="name"><ref name="dns-name"/></attribute>
                  <attribute name="value"><text/></attribute>
                </element>
              </zeroOrMore>
            </element>
        </optional>

103
        <!-- <ip> element -->
104
        <zeroOrMore>
105 106 107 108
          <!-- The IP element sets up NAT'ing and an optional DHCP server
               local to the host. -->
          <element name="ip">
            <optional>
109 110 111 112 113 114 115
              <attribute name="address"><ref name="ip-addr"/></attribute>
            </optional>
            <optional>
              <choice>
                <attribute name="netmask"><ref name="ipv4-addr"/></attribute>
                <attribute name="prefix"><ref name="ip-prefix"/></attribute>
              </choice>
116 117
            </optional>
            <optional>
118
              <attribute name="family"><ref name="addr-family"/></attribute>
119
            </optional>
120
            <optional>
121 122 123
              <element name="tftp">
                <attribute name="root"><text/></attribute>
              </element>
124
            </optional>
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
            <optional>
              <!-- Define the range(s) of IP addresses that the DHCP
                   server should hand out -->
              <element name="dhcp">
                <zeroOrMore>
                  <element name="range">
                    <attribute name="start"><ref name="ipv4-addr"/></attribute>
                    <attribute name="end"><ref name="ipv4-addr"/></attribute>
                  </element>
                </zeroOrMore>
                <zeroOrMore>
                  <element name="host">
                    <attribute name="mac"><ref name="mac-addr"/></attribute>
                    <attribute name="name"><text/></attribute>
                    <attribute name="ip"><ref name="ipv4-addr"/></attribute>
                  </element>
                </zeroOrMore>
                <optional>
                  <element name="bootp">
                    <attribute name="file"><text/></attribute>
                    <optional>
                      <attribute name="server"><text/></attribute>
                    </optional>
                  </element>
                </optional>
              </element>
            </optional>
152
          </element>
153
        </zeroOrMore>
154
      </interleave>
155
    </element>
156
  </define>
157 158 159 160 161 162 163 164

  <!-- An ipv4 "dotted quad" address -->
  <define name='ipv4-addr'>
    <data type='string'>
      <param name="pattern">(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))</param>
    </data>
  </define>

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
  <!-- Based on http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6 -->
  <define name='ipv6-addr'>
    <data type='string'>
      <!-- To understand this better, take apart the toplevel '|'s -->
      <param name="pattern">(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(([0-9A-Fa-f]{1,4}:){0,5}:(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(::([0-9A-Fa-f]{1,4}:){0,5}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)</param>
    </data>
  </define>

  <define name='ip-addr'>
    <choice>
      <ref name='ipv4-addr'/>
      <ref name='ipv6-addr'/>
    </choice>
  </define>

  <define name='ip-prefix'>
    <data type='unsignedInt'>
      <param name="maxInclusive">128</param>
    </data>
  </define>

  <define name='addr-family'>
    <data type='string'>
      <param name="pattern">(ipv4)|(ipv6)</param>
    </data>
  </define>

192 193 194 195 196 197 198
  <!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
  <define name='mac-addr'>
    <data type='string'>
      <param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param>
    </data>
  </define>

199 200 201 202 203 204 205
  <!-- a valid DNS name -->
  <define name='dns-name'>
    <data type='string'>
      <param name="pattern">([a-zA-Z\-]+)</param>
    </data>
  </define>

206
</grammar>