initial commit of the new xml way for card configuration and module loading.

caution: does not support everything misdn-init does, yet.
This commit is contained in:
Nadi Sarrar 2006-12-14 12:51:41 +00:00
parent a48dd57635
commit cacd47333c
8 changed files with 788 additions and 0 deletions

11
config/Makefile Normal file
View File

@ -0,0 +1,11 @@
all:
@echo "Please run 'make install'."
install:
install -D -m755 mISDN $(INSTALL_PREFIX)/usr/sbin/mISDN
for file in $(shell echo *.xsl); do install -D -m644 $${file} $(INSTALL_PREFIX)/usr/lib/mISDN/$${file}; done
if [ -d $(INSTALL_PREFIX)/etc/init.d ]; then \
if [ -e $(INSTALL_PREFIX)/etc/init.d/mISDN ]; then rm -rf $(INSTALL_PREFIX)/etc/init.d/mISDN; fi; \
ln -s $(INSTALL_PREFIX)/usr/sbin/mISDN $(INSTALL_PREFIX)/etc/init.d/mISDN; \
fi

333
config/mISDN Executable file
View File

@ -0,0 +1,333 @@
#!/bin/bash
#----------------------------------------------
#
# CONFIGURATION:
#
MISDN_CONF="/etc/mISDN.conf"
MISDN_CONF_XSL="/usr/lib/mISDN/mISDN.conf.xsl"
#
#----------------------------------------------
SELF="${0}"
USAGE="Usage: ${SELF} start|stop|restart|config|scan|help"
function die {
echo "[!!] ${1}"
exit 1
}
function check_cmd
{
if ! which "${1}" > /dev/null; then
if [ "${2}" = "opt" ]; then
return
fi
if [ "$(id -u)" != "0" ]; then
die "$1 not in path, please install and/or be root."
else
die "$1 not in path, please install."
fi
exit 1
else
local var=$(echo ${1} | tr a-z A-Z)
eval "$var=`which ${1}`"
fi
}
function check_misdn_conf
{
if [ ! -f ${MISDN_CONF} ]; then
die "${MISDN_CONF} not found. Please run: ${SELF} config"
fi
}
check_cmd sed
check_cmd cut
check_cmd cp
check_cmd wc
check_cmd grep
check_cmd xsltproc
check_cmd modprobe
check_cmd sleep
check_cmd lspci
check_cmd lsusb opt
declare -a START_COMMANDS
declare -a STOP_COMMANDS
declare -a HFCMULTI_card
declare -a HFCMULTI_type
declare -a HFCMULTI_protocol
declare -a HFCMULTI_layermask
HFCMULTI_options=''
MISDNDSP_options=''
declare -a SCAN_card
declare -a SCAN_opts
declare -a SCAN_num_ports
declare -a SCAN_port_opts
function parse_config
{
local CONFIG=$(${XSLTPROC} ${MISDN_CONF_XSL} ${MISDN_CONF})
local t p l line i tmpcmd
local IFS=$'\n'
for line in ${CONFIG}; do
case "${line}" in
MODULE:hfcmulti*)
HFCMULTI_options=${line:16}
;;
MODULE:mISDN_dsp*)
MISDNDSP_options=${line:17}
;;
CARD:BN*)
i=${#HFCMULTI_type[@]}
let "t = $(echo $line | ${SED} -n 's/.*type:\([^,]*\).*/\1/p')"
HFCMULTI_type[${i}]=$(printf "0x%x" ${t})
# this is for the BN2E1 card that needs two type numbers
t=$(echo $line | ${SED} -n 's/.*type:[^,]*,\([^ ]*\).*/\1/p')
if [ ! -z "${t}" ]; then
let "t = ${t}"
HFCMULTI_type[${i}]="${HFCMULTI_type[${i}]},$(printf "0x%x" ${t})"
fi
HFCMULTI_card[${i}]=$(echo ${line:5} | ${CUT} -d" " -f1)
;;
PORT*)
let "p = $(echo $line | ${SED} -n 's/.*protocol:\([^ ]*\).*/\1/p')"
HFCMULTI_protocol[${i}]="${HFCMULTI_protocol[${i}]:+"${HFCMULTI_protocol[${i}]},"}$(printf "0x%x" ${p})"
let "l = $(echo $line | ${SED} -n 's/.*layermask:\([^ ]*\).*/\1/p')"
HFCMULTI_layermask[${i}]="${HFCMULTI_layermask[${i}]:+"${HFCMULTI_layermask[${i}]},"}$(printf "0x%x" ${l})"
;;
esac
done
START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install capi"
START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_core debug=0"
START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_l1 debug=0"
START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_l2 debug=0"
START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install l3udss1 debug=0"
START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_capi"
tmpcmd="${MODPROBE} --ignore-install hfcmulti type=${HFCMULTI_type[0]}"
i=1
while [ ! -z "${HFCMULTI_type[${i}]}" ]; do
tmpcmd="${tmpcmd},${HFCMULTI_type[${i}]}"
let "i = ${i} + 1"
done
tmpcmd="${tmpcmd} protocol=${HFCMULTI_protocol[0]}"
i=1
while [ ! -z "${HFCMULTI_protocol[${i}]}" ]; do
tmpcmd="${tmpcmd},${HFCMULTI_protocol[${i}]}"
let "i = ${i} + 1"
done
tmpcmd="${tmpcmd} layermask=${HFCMULTI_layermask[0]}"
i=1
while [ ! -z "${HFCMULTI_layermask[${i}]}" ]; do
tmpcmd="${tmpcmd},${HFCMULTI_layermask[${i}]}"
let "i = ${i} + 1"
done
START_COMMANDS[${#START_COMMANDS[@]}]="${tmpcmd} ${HFCMULTI_options}"
START_COMMANDS[${#START_COMMANDS[@]}]="${MODPROBE} --ignore-install mISDN_dsp ${MISDNDSP_options}"
}
function run_start_commands
{
local i=0
echo "-- Loading mISDN modules --"
while [ ! -z "${START_COMMANDS[${i}]}" ]; do
echo ">> ${START_COMMANDS[${i}]}"
eval "${START_COMMANDS[${i}]}"
let "i = ${i} + 1"
done
}
function run_stop_commands
{
local mod i=0
for mod in $(lsmod | ${SED} -ne '/Module/!{s/\([^ ]*\).*/\1/;p}'); do
case "${mod}" in
mISDN_capi | mISDN_dsp | l3udss1 | mISDN_l2 | mISDN_l1 | mISDN_isac | hfcmulti)
STOP_COMMANDS[0]="${STOP_COMMANDS[0]:-"${MODPROBE} -r --ignore-remove"} ${mod}"
;;
mISDN_core)
STOP_COMMANDS[1]="${MODPROBE} -r --ignore-remove mISDN_core"
;;
esac
done
echo "-- Unloading mISDN modules --"
while [ ! -z "${STOP_COMMANDS[${i}]}" ]; do
echo ">> ${STOP_COMMANDS[${i}]}"
eval "${STOP_COMMANDS[${i}]}"
let "i = ${i} + 1"
done
}
function scan_devices
{
local skipnext=0 IFS=$'\n'
local NL="
"
function addcard {
SCAN_card[${#SCAN_card[@]}]="${1}"
SCAN_opts[${#SCAN_opts[@]}]="${2}"
SCAN_num_ports[${#SCAN_num_ports[@]}]="${3}"
SCAN_port_opts[${#SCAN_port_opts[@]}]="${4}"
}
for line in $(${LSPCI} -n -d 0xd161:b410); do
addcard "BN4S0" "" 4 'mode="te" link="ptmp"'
done
for line in $(${LSPCI} -n | ${SED} -n 's/^\(0000:\|\)\([0-9a-f]\{2\}:[0-9a-f]\{2\}.[0-9a-f]\{1\}\)\( Class \| \)[0-9a-f]\{4\}: 1397:\([0-9a-f]\{4\}\).*$/\4 \2/p'); do
if [ ${skipnext} -eq 1 ]; then
skipnext=0
continue
fi
case "${line}" in
30b1*)
case "${line:5}" in
00*)
addcard "BN1E1" "" 1 'mode="nt" link="ptp"'
;;
*)
if [ $(${LSPCI} -n -s "${line:5:3}" | ${WC} -l) -eq 2 ]; then
addcard "BN2E1" "" 2 'mode="nt" link="ptp"'
skipnext=1
else
addcard "BN1E1" "" 1 'mode="nt" link="ptp"'
fi
;;
esac
;;
16b8*)
addcard "BN8S0" "" 8 'mode="te" link="ptmp"'
;;
08b4*)
if ${LSPCI} -n -v -s "${line:5}" | ${GREP} "Subsystem" | ${GREP} "1397:b567" > /dev/null ; then
addcard "BN1S0" "" 1 'mode="te" link="ptmp"'
elif ${LSPCI} -n -v -s "${line:5}" | ${GREP} "Subsystem" | ${GREP} "1397:b566\|1397:b569" > /dev/null ; then
addcard "BN2S0" "" 2 'mode="te" link="ptmp"'
else
addcard "BN4S0" "" 4 'mode="te" link="ptmp"'
fi
;;
esac
done
for line in $(${LSPCI} -n | ${GREP} "1397:\(2bd\(0\|6\|7\|8\|9\|a\|b\|c\)\|b100\)\|1043:0675\|0871:ffa\(1\|2\)\|1051:0100\|15b0:2bd0\|114f:007\(0\|1\|2\|3\)\|13d1:2bd1\|182d:3069"); do
addcard "hfcpci" "" 1 'mode="te" link="ptmp"'
done
for line in $(${LSPCI} -n | ${GREP} "1244:\(0a00\|0e00\)"); do
addcard "avmfritz" "" 1 'mode="te" link="ptmp"'
done
for line in $(${LSPCI} -n -d 1050:6692); do
addcard "w6692pci" "" 1 'mode="te" link="ptmp"'
done
if [ -e ${LSUSB} ]; then
for line in $(${LSUSB} | ${GREP} "0959:2bd0\|0675:1688\|07b0:0007\|0742:200\(7\|8\|9\|A\)\|08e3:0301\|07fa:084\(7\|8\)\|07ba:0006"); do
addcard "hfcsusb" "" 1 'mode="te" link="ptmp"'
done
fi
}
function write_mISDN_conf
{
local NL="
"
local TAB=" "
local HEADER="<?xml version=\"1.0\"?>
<mISDNconf>
${TAB}<module poll=\"128\" debug=\"0\">hfcmulti</module>
${TAB}<module debug=\"0\" options=\"0\">mISDN_dsp</module>"
local FOOTER="</mISDNconf>"
local i=0 j=0 MAIN=""
echo "Writing ${MISDN_CONF} for ${#SCAN_card[@]} mISDN compatible device(s):"
while [ ! -z "${SCAN_card[${i}]}" ]; do
echo ">> ${SCAN_card[${i}]}"
MAIN="${MAIN}${NL}${TAB}<card type=\"${SCAN_card[${i}]}\"${SCAN_opts[${i}]:+" ${SCAN_opts[${i}]}"}>"
j=1
while [ ${j} -le ${SCAN_num_ports[${i}]} ]; do
MAIN="${MAIN}${NL}${TAB}${TAB}<port${SCAN_port_opts[${i}]:+" ${SCAN_port_opts[${i}]}"}>${j}</port>"
let "j = ${j} + 1"
done
MAIN="${MAIN}${NL}${TAB}</card>"
let "i = ${i} + 1"
done
if [ -f ${MISDN_CONF} ]; then
echo "${MISDN_CONF} already present, saving a backup: ${MISDN_CONF}.bak"
${CP} "${MISDN_CONF}" "${MISDN_CONF}.bak" || die "Could not backup your existing ${MISDN_CONF}!"
fi
echo "${HEADER}${MAIN}${NL}${FOOTER}" > ${MISDN_CONF}
}
function print_scan_results
{
local i=0
echo "${#SCAN_card[@]} mISDN compatible device(s) found:"
while [ ! -z "${SCAN_card[${i}]}" ]; do
echo ">> ${SCAN_card[${i}]}"
let "i = ${i} + 1"
done
}
#
# MAIN
#
case "${1}" in
start|--start)
check_misdn_conf
parse_config
run_start_commands
;;
stop|--stop)
check_misdn_conf
parse_config
run_stop_commands
;;
restart|--restart)
check_misdn_conf
parse_config
run_stop_commands
${SLEEP} 2
run_start_commands
;;
config|--config)
scan_devices
write_mISDN_conf
;;
scan|--scan)
scan_devices
print_scan_results
;;
help|--help)
echo "${USAGE}"
exit 0
;;
*)
echo "${USAGE}"
exit 2
;;
esac

13
config/mISDN.conf Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<mISDNconf>
<card type="BN8S0">
<port mode="nt" link="ptmp">1</port>
<port mode="nt" link="ptmp">2</port>
<port mode="te" link="ptmp">3</port>
<port mode="te" link="ptmp">4</port>
<port mode="nt" link="ptmp">5</port>
<port mode="nt" link="ptmp">6</port>
<port mode="te" link="ptmp">7</port>
<port mode="te" link="ptmp">8</port>
</card>
</mISDNconf>

230
config/mISDN.conf.bnx.xsl Normal file
View File

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<!--
Card Type: BN2S0, BN4S0, BN8S0
Ports: 2, 4, 8
Card Attributes: ulaw=(yes|no), dtmf=(yes|no), pcm_slave=(yes|no), ignore_pcm_frameclock=(yes|no),
rxclock=(yes|no), crystalclock=(yes|no), watchdog=(yes|no)
Port Attributes: mode=(te|nt), link=(ptp|ptmp), master-clock=(yes|no), capi=(yes|no)
-->
<xsl:template name="type-options">
<xsl:param name="force-pcm-slave">no</xsl:param>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@ulaw" />
<xsl:with-param name="val-true">(2**8)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@dtmf" />
<xsl:with-param name="val-true">(2**9)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:choose>
<xsl:when test="$force-pcm-slave='yes'">
<xsl:text>(2**11)</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@pcm_slave" />
<xsl:with-param name="val-true">(2**11)</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@ignore_pcm_frameclock" />
<xsl:with-param name="val-true">(2**12)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@rxclock" />
<xsl:with-param name="val-true">(2**13)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@crystalclock" />
<xsl:with-param name="val-true">(2**18)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@watchdog" />
<xsl:with-param name="val-true">(2**19)</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="BN2S0card">
<xsl:param name="type">4</xsl:param>
<xsl:value-of select="concat(' type:',$type,'+')" />
<xsl:call-template name="type-options" />
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template name="BN2S0port">
<xsl:text> layermask:</xsl:text>
<xsl:choose>
<xsl:when test="@mode='nt'">
<xsl:text>3</xsl:text>
</xsl:when>
<xsl:when test="@capi='yes'">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>15</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> protocol:</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@mode" />
<xsl:with-param name="match-true">te</xsl:with-param>
<xsl:with-param name="match-false">nt</xsl:with-param>
<xsl:with-param name="val-true">34</xsl:with-param>
<xsl:with-param name="val-false">18</xsl:with-param>
<xsl:with-param name="val-default">34</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:if test="@mode!='nt'">
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@link" />
<xsl:with-param name="match-true">ptp</xsl:with-param>
<xsl:with-param name="match-false">ptmp</xsl:with-param>
<xsl:with-param name="val-true">0</xsl:with-param>
<xsl:with-param name="val-false">(-32)</xsl:with-param>
<xsl:with-param name="val-default">(-32)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
</xsl:if>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@master-clock" />
<xsl:with-param name="val-true">(2**16)</xsl:with-param>
</xsl:call-template>
<xsl:text> capi:</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@capi" />
<xsl:with-param name="val-true">yes</xsl:with-param>
<xsl:with-param name="val-false">no</xsl:with-param>
<xsl:with-param name="val-default">no</xsl:with-param>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template name="BN4S0card">
<xsl:call-template name="BN2S0card">
<xsl:with-param name="type">4</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="BN4S0port">
<xsl:call-template name="BN2S0port" />
</xsl:template>
<xsl:template name="BN8S0card">
<xsl:call-template name="BN2S0card">
<xsl:with-param name="type">8</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="BN8S0port">
<xsl:call-template name="BN2S0port" />
</xsl:template>
<!--
Card Type: BN2E1
Ports: 2
Card Attributes: ulaw=(yes|no), dtmf=(yes|no), pcm_slave=(yes|no), ignore_pcm_frameclock=(yes|no),
rxclock=(yes|no), crystalclock=(yes|no), watchdog=(yes|no)
Port Attributes: mode=(te|nt), link=(ptp|ptmp), optical=(yes|no), los=(yes|no), ais=(yes|no),
slip=(yes|no), nocrc4=(yes|no), capi=(yes|no)
-->
<xsl:template name="BN2E1card">
<xsl:text> type:1+</xsl:text>
<xsl:call-template name="type-options" />
<xsl:text>,1+</xsl:text>
<xsl:call-template name="type-options">
<xsl:with-param name="force-pcm-slave">yes</xsl:with-param>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template name="BN2E1port">
<xsl:text> layermask:</xsl:text>
<xsl:choose>
<xsl:when test="@mode='nt'">
<xsl:text>3</xsl:text>
</xsl:when>
<xsl:when test="@capi='yes'">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>15</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> protocol:</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@mode" />
<xsl:with-param name="match-true">te</xsl:with-param>
<xsl:with-param name="match-false">nt</xsl:with-param>
<xsl:with-param name="val-true">34</xsl:with-param>
<xsl:with-param name="val-false">18</xsl:with-param>
<xsl:with-param name="val-default">34</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:if test="@mode!='nt'">
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@link" />
<xsl:with-param name="match-true">ptp</xsl:with-param>
<xsl:with-param name="match-false">ptmp</xsl:with-param>
<xsl:with-param name="val-true">0</xsl:with-param>
<xsl:with-param name="val-false">(-32)</xsl:with-param>
<xsl:with-param name="val-default">(-32)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
</xsl:if>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@optical" />
<xsl:with-param name="val-true">(2**16)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@los" />
<xsl:with-param name="val-true">(2**18)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@ais" />
<xsl:with-param name="val-true">(2**19)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@slip" />
<xsl:with-param name="val-true">(2**21)</xsl:with-param>
</xsl:call-template>
<xsl:text>+</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@nocrc4" />
<xsl:with-param name="val-true">(2**23)</xsl:with-param>
</xsl:call-template>
<xsl:text> capi:</xsl:text>
<xsl:call-template name="if-match">
<xsl:with-param name="val" select="@capi" />
<xsl:with-param name="val-true">yes</xsl:with-param>
<xsl:with-param name="val-false">no</xsl:with-param>
<xsl:with-param name="val-default">no</xsl:with-param>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<!--
Module: hfcmulti
Options: poll=<number>, pcm=<number>, debug=<number>
-->
<xsl:template name="HFCMULTImodule">
<xsl:call-template name="if-set">
<xsl:with-param name="prefix"> poll=</xsl:with-param>
<xsl:with-param name="val" select="@poll" />
<xsl:with-param name="val-default">128</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="if-set">
<xsl:with-param name="prefix"> pcm=</xsl:with-param>
<xsl:with-param name="val" select="@pcm" />
</xsl:call-template>
<xsl:call-template name="if-set">
<xsl:with-param name="prefix"> debug=</xsl:with-param>
<xsl:with-param name="val" select="@debug" />
<xsl:with-param name="val-default">0</xsl:with-param>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

41
config/mISDN.conf.inc.xsl Normal file
View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template name="if-set">
<xsl:param name="prefix"></xsl:param>
<xsl:param name="val"></xsl:param>
<xsl:param name="val-default"></xsl:param>
<xsl:choose>
<xsl:when test="$val!=''">
<xsl:value-of select="concat($prefix,$val)" />
</xsl:when>
<xsl:otherwise>
<xsl:if test="$val-default!=''">
<xsl:value-of select="concat($prefix,$val-default)" />
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="if-match">
<xsl:param name="val">no</xsl:param>
<xsl:param name="val-default">0</xsl:param>
<xsl:param name="val-true">0</xsl:param>
<xsl:param name="val-false">0</xsl:param>
<xsl:param name="match-true">yes</xsl:param>
<xsl:param name="match-false">no</xsl:param>
<xsl:choose>
<xsl:when test="$val=$match-true">
<xsl:value-of select="$val-true" />
</xsl:when>
<xsl:when test="$val=$match-false">
<xsl:value-of select="$val-false" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$val-default" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<!--
Module: mISDN_dsp
Options: debug=<number>, options=<number>, poll=<number>, dtmfthreshold=<number>
-->
<xsl:template name="MISDNDSPmodule">
<xsl:call-template name="if-set">
<xsl:with-param name="prefix"> debug=</xsl:with-param>
<xsl:with-param name="val" select="@debug" />
<xsl:with-param name="val-default">0</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="if-set">
<xsl:with-param name="prefix"> options=</xsl:with-param>
<xsl:with-param name="val" select="@options" />
<xsl:with-param name="val-default">0</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="if-set">
<xsl:with-param name="prefix"> poll=</xsl:with-param>
<xsl:with-param name="val" select="@poll" />
</xsl:call-template>
<xsl:call-template name="if-set">
<xsl:with-param name="prefix"> dtmfthreshold=</xsl:with-param>
<xsl:with-param name="val" select="@dtmfthreshold" />
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

89
config/mISDN.conf.xsl Normal file
View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:include href='mISDN.conf.inc.xsl' />
<xsl:include href='mISDN.conf.mISDN_dsp.xsl' />
<xsl:include href='mISDN.conf.hfcmulti.xsl' />
<xsl:include href='mISDN.conf.bnx.xsl' />
<!--
Main mISDNconf Template
-->
<xsl:template match="mISDNconf">
<!-- module -->
<xsl:for-each select="module">
<xsl:choose>
<xsl:when test=".='hfcmulti'">
<xsl:value-of select="concat('MODULE:',.)" />
<xsl:call-template name="HFCMULTImodule" />
</xsl:when>
<xsl:when test=".='mISDN_dsp'">
<xsl:value-of select="concat('MODULE:',.)" />
<xsl:call-template name="MISDNDSPmodule" />
</xsl:when>
</xsl:choose>
</xsl:for-each>
<!-- card, port -->
<xsl:for-each select="card">
<xsl:choose>
<xsl:when test="@type='BN2S0'">
<xsl:value-of select="concat('CARD:',@type)" />
<xsl:call-template name="BN2S0card" />
<xsl:for-each select="port">
<xsl:sort data-type="number" />
<xsl:text>PORT:</xsl:text>
<xsl:value-of select="." />
<xsl:call-template name="BN2S0port" />
</xsl:for-each>
</xsl:when>
<xsl:when test="@type='BN4S0'">
<xsl:value-of select="concat('CARD:',@type)" />
<xsl:call-template name="BN4S0card" />
<xsl:for-each select="port">
<xsl:sort data-type="number" />
<xsl:text>PORT:</xsl:text>
<xsl:value-of select="." />
<xsl:call-template name="BN4S0port" />
</xsl:for-each>
</xsl:when>
<xsl:when test="@type='BN8S0'">
<xsl:value-of select="concat('CARD:',@type)" />
<xsl:call-template name="BN8S0card" />
<xsl:for-each select="port">
<xsl:sort data-type="number" />
<xsl:text>PORT:</xsl:text>
<xsl:value-of select="." />
<xsl:call-template name="BN8S0port" />
</xsl:for-each>
</xsl:when>
<xsl:when test="@type='BN2E1'">
<xsl:value-of select="concat('CARD:',@type)" />
<xsl:call-template name="BN2E1card" />
<xsl:for-each select="port">
<xsl:sort data-type="number" />
<xsl:text>PORT:</xsl:text>
<xsl:value-of select="." />
<xsl:call-template name="BN2E1port" />
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>