mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-08 14:29:56 +00:00
a950dd2a31
This commit adds support for IPv6 parsing and formatting to the virtual network XML parser, including moving around data definitions to allow for multiple <ip> elements on a single network, but only changes the consumers of this API to accommodate for the changes in API/structure, not to add any actual IPv6 functionality. That will come in a later patch - this patch attempts to maintain the same final functionality in both drivers that use the network XML parser - vbox and "bridge" (the Linux bridge-based driver used by the qemu hypervisor driver). * src/libvirt_private.syms: Add new private API functions. * src/conf/network_conf.[ch]: Change C data structure and parsing/formatting. * src/network/bridge_driver.c: Update to use new parser/formatter. * src/vbox/vbox_tmpl.c: update to use new parser/formatter * docs/schemas/network.rng: changes to the schema - * there can now be more than one <ip> element. * ip address is now an ip-addr (ipv4 or ipv6) rather than ipv4-addr * new optional "prefix" attribute that can be used in place of "netmask" * new optional "family" attribute - "ipv4" or "ipv6" (will default to ipv4) * define data types for the above * tests/networkxml2xml(in|out)/nat-network.xml: add multiple <ip> elements (including IPv6) to a single network definition to verify they are being correctly parsed and formatted.
179 lines
6.2 KiB
Plaintext
179 lines
6.2 KiB
Plaintext
<!-- A Relax NG schema for the libvirt network XML format -->
|
|
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
|
|
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
|
<start>
|
|
<ref name="network"/>
|
|
</start>
|
|
|
|
<define name="network">
|
|
|
|
<element name="network">
|
|
<interleave>
|
|
|
|
<!-- The name of the network, used to refer to it through the API
|
|
and in virsh -->
|
|
<element name="name">
|
|
<text/>
|
|
</element>
|
|
|
|
<!-- <uuid> element -->
|
|
<optional>
|
|
<element name="uuid"><text/></element>
|
|
</optional>
|
|
|
|
<!-- <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>
|
|
|
|
<optional>
|
|
<attribute name="stp">
|
|
<choice>
|
|
<value>on</value>
|
|
<value>off</value>
|
|
</choice>
|
|
</attribute>
|
|
</optional>
|
|
|
|
<optional>
|
|
<attribute name="delay">
|
|
<data type="integer"/>
|
|
</attribute>
|
|
</optional>
|
|
|
|
</element>
|
|
</optional>
|
|
|
|
<!-- <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>
|
|
|
|
<optional>
|
|
<attribute name="mode">
|
|
<choice>
|
|
<value>nat</value>
|
|
<value>route</value>
|
|
</choice>
|
|
</attribute>
|
|
</optional>
|
|
</element>
|
|
</optional>
|
|
|
|
<!-- <domain> element -->
|
|
<optional>
|
|
<element name="domain">
|
|
<attribute name="name"><text/></attribute>
|
|
</element>
|
|
</optional>
|
|
|
|
<!-- <ip> element -->
|
|
<zeroOrMore>
|
|
<!-- The IP element sets up NAT'ing and an optional DHCP server
|
|
local to the host. -->
|
|
<element name="ip">
|
|
<optional>
|
|
<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>
|
|
</optional>
|
|
<optional>
|
|
<attribute name="family"><ref name="addr-family"/></attribute>
|
|
</optional>
|
|
<optional>
|
|
<element name="tftp">
|
|
<attribute name="root"><text/></attribute>
|
|
</element>
|
|
</optional>
|
|
<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>
|
|
</element>
|
|
</zeroOrMore>
|
|
</interleave>
|
|
</element>
|
|
</define>
|
|
|
|
<!-- 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>
|
|
|
|
<!-- 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>
|
|
|
|
<!-- 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>
|
|
|
|
</grammar>
|