* data/xml/initscripts-get.xsl: produce IPv6 entries in ifcfg- files
* data/xml/initscripts-put.xsl: read IPv6 entries in ifcfg files and
generate XML for them. Uses libexslt.
* src/drv_initscripts.c: register the strings module from libexslt
* configure.ac: use libexslt
---
configure.ac | 3 +-
data/xml/initscripts-get.xsl | 44 ++++++++++++++++++++++++++++++++++++++++++
data/xml/initscripts-put.xsl | 44 +++++++++++++++++++++++++++++++++++++++++-
src/drv_initscripts.c | 3 ++
4 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8775940..acfacbf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,10 +30,11 @@ PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([LIBAUGEAS], [augeas >= 0.5.0])
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
PKG_CHECK_MODULES([LIBXSLT], [libxslt])
+PKG_CHECK_MODULES([LIBEXSLT], [libexslt])
NETCF_CHECK_READLINE
-NETCF_LIBDEPS=$(echo $LIBAUGEAS_LIBS $LIBXSLT_LIBS $LIBXML_LIBS)
+NETCF_LIBDEPS=$(echo $LIBAUGEAS_LIBS $LIBEXSLT_LIBS $LIBXSLT_LIBS $LIBXML_LIBS)
AC_SUBST([NETCF_LIBDEPS])
AC_OUTPUT(Makefile \
diff --git a/data/xml/initscripts-get.xsl b/data/xml/initscripts-get.xsl
index f144092..fab8ecb 100644
--- a/data/xml/initscripts-get.xsl
+++ b/data/xml/initscripts-get.xsl
@@ -176,6 +176,9 @@
<xsl:for-each select="protocol[@family='ipv4']">
<xsl:call-template name="protocol-ipv4"/>
</xsl:for-each>
+ <xsl:for-each select="protocol[@family='ipv6']">
+ <xsl:call-template name="protocol-ipv6"/>
+ </xsl:for-each>
</xsl:template>
<xsl:template name="protocol-ipv4">
@@ -198,4 +201,45 @@
</xsl:when>
</xsl:choose>
</xsl:template>
+
+ <xsl:template name="protocol-ipv6">
+ <node label="IPV6INIT" value="yes"/>
+ <xsl:if test="count(autoconf) > 0">
+ <node label="IPV6_AUTOCONF" value="yes"/>
+ </xsl:if>
+ <xsl:if test="count(autoconf) = 0">
+ <node label="IPV6_AUTOCONF" value="no"/>
+ </xsl:if>
+ <xsl:if test="count(dhcp) > 0">
+ <node label="DHCPV6" value="yes"/>
+ </xsl:if>
+ <xsl:if test="count(dhcp) = 0">
+ <node label="DHCPV6" value="no"/>
+ </xsl:if>
+ <xsl:if test="count(ip) > 0">
+ <node label="IPV6ADDR">
+ <xsl:attribute name="value">
+ <xsl:value-of select="ip[1]/@address"/><xsl:if
test="ip[1]/@prefix">/<xsl:value-of
select="ip[1]/@prefix"/></xsl:if>
+ </xsl:attribute>
+ </node>
+ </xsl:if>
+ <xsl:if test="count(ip) > 1">
+ <node label="IPV6ADDR_SECONDARIES">
+ <xsl:attribute name="value">
+ <xsl:text>'</xsl:text>
+ <xsl:for-each
select="ip[1]/following-sibling::ip[following-sibling::ip]">
+ <xsl:value-of select="@address"/><xsl:if
test="@prefix">/<xsl:value-of
select="@prefix"/></xsl:if><xsl:value-of select="string('
')"/>
+ </xsl:for-each>
+ <xsl:for-each select="ip[last()]">
+ <xsl:value-of select="@address"/><xsl:if
test="@prefix">/<xsl:value-of
select="@prefix"/></xsl:if>
+ </xsl:for-each>
+ <xsl:text>'</xsl:text>
+ </xsl:attribute>
+ </node>
+ </xsl:if>
+ <xsl:if test="route">
+ <node label="IPV6_DEFAULTGW" value="{route/@gateway}"/>
+ </xsl:if>
+ </xsl:template>
+
</xsl:stylesheet>
diff --git a/data/xml/initscripts-put.xsl b/data/xml/initscripts-put.xsl
index 0bd5dbc..ff741d4 100644
--- a/data/xml/initscripts-put.xsl
+++ b/data/xml/initscripts-put.xsl
@@ -2,7 +2,8 @@
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ipcalc = "http://redhat.com/xslt/netcf/ipcalc/1.0"
xmlns:bond = "http://redhat.com/xslt/netcf/bond/1.0"
- extension-element-prefixes="bond ipcalc"
+
xmlns:str="http://exslt.org/strings"
+ extension-element-prefixes="bond ipcalc str"
version="1.0">
<xsl:import href="util-put.xsl"/>
@@ -165,6 +166,7 @@
<xsl:template name="interface-addressing">
<xsl:call-template name="protocol-ipv4"/>
+ <xsl:call-template name="protocol-ipv6"/>
</xsl:template>
<xsl:template name="protocol-ipv4">
@@ -203,6 +205,46 @@
</xsl:if>
</xsl:template>
+ <xsl:template name="protocol-ipv6">
+ <xsl:if test="node[@label = 'IPV6INIT'][@value =
'yes']">
+ <protocol family="ipv6">
+ <xsl:if test="node[@label = 'IPV6_AUTOCONF'][@value =
'yes']">
+ <autoconf/>
+ </xsl:if>
+ <xsl:if test="node[@label = 'DHCPV6'][@value =
'yes']">
+ <dhcp/>
+ </xsl:if>
+ <xsl:if test="node[@label = 'IPV6ADDR']">
+ <xsl:call-template name="ipv6-address">
+ <xsl:with-param name="value"
+ select="node[@label =
'IPV6ADDR']/@value"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="node[@label = 'IPV6ADDR_SECONDARIES']">
+ <xsl:for-each select="str:split(node[@label =
'IPV6ADDR_SECONDARIES']/@value)">
+ <xsl:call-template name="ipv6-address">
+ <xsl:with-param name="value" select="."/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:if>
+ </protocol>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="ipv6-address">
+ <xsl:param name="value"/>
+ <xsl:variable name="address" select="substring-before($value,
'/')"/>
+ <xsl:variable name="prefix" select="substring-after($value,
'/')"/>
+ <ip address="{$address}">
+ <xsl:if test="$prefix != ''">
+ <xsl:attribute name="prefix"><xsl:value-of
select="$prefix"/></xsl:attribute>
+ </xsl:if>
+ </ip>
+ <xsl:if test="node[@label = 'IPV6_DEFAULTGW']">
+ <route gateway="{node[@label =
'IPV6_DEFAULTGW']/@value}"/>
+ </xsl:if>
+ </xsl:template>
+
<xsl:template name="bare-ethernet-interface">
<interface type="ethernet">
<xsl:call-template name="name-attr"/>
diff --git a/src/drv_initscripts.c b/src/drv_initscripts.c
index 02b7e6e..1c0463d 100644
--- a/src/drv_initscripts.c
+++ b/src/drv_initscripts.c
@@ -45,6 +45,8 @@
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
+#include <libexslt/exslt.h>
+
static const char *const network_scripts_path =
"/files/etc/sysconfig/network-scripts";
@@ -479,6 +481,7 @@ int drv_init(struct netcf *ncf) {
// FIXME: Check for errors
xsltInit();
+ exsltStrRegister();
ncf->driver->get = parse_stylesheet(ncf, "initscripts-get.xsl");
ncf->driver->put = parse_stylesheet(ncf, "initscripts-put.xsl");
ncf->driver->rng = rng_parse(ncf, "interface.rng");
--
1.6.2.5