+
+ IFS=$'\n'
+ skipnr=0
+
+ for line in $(${SED} -n -e '/^[^#]/p' ${misdn_init_conf});
+ do
+ var=$(echo "${line}" | ${CUT} -d "=" -f1)
+ val=$(echo "${line}" | ${CUT} -d "=" -f2)
+
+ case "${var}" in
+ card)
+ #echo "processing line: $val"
+ nr=$(echo "${val}" | ${CUT} -d "," -f1)
+ mod=$(echo "${val}" | ${CUT} -d "," -f2)
+ opns=$(echo "${val}" | ${CUT} -d "," -f3-)
+
+ #getting portcount from carddb
+ ports=$(find_carddb_line $nr | ${CUT} -d "," -f2)
+ let "nr = ${nr} + ${skipnr}"
+ #echo "nr $nr ports $ports mod $mod opns: $opns"
+
+ case "${mod}" in
+ 2E1)
+ hfcmulti[${nr}]=1
+ hfcmulti[$((${nr} + 1))]=1
+ let "hfcports = ${hfcports} + ${ports}"
+ IFS=$','
+ for li in ${opns}; do
+ hfcmulti[${nr}]=$(echo "obase=10;2^(${!li}-1)+${hfcmulti[${nr}]}" | ${BC})
+ if [ "${li}" != "pcm_slave" ]; then
+ hfcmulti[$((${nr} + 1))]=$(echo "obase=10;2^(${!li}-1)+${hfcmulti[$((${nr}+1))]}" | ${BC})
+ fi
+ done
+ IFS=$'\n'
+ hfcmulti[$((${nr} + 1))]=$(echo "obase=10;2^(${pcm_slave}-1)+${hfcmulti[$((${nr}+1))]}" | ${BC})
+ let "skipnr = ${skipnr} + 1"
+ ;;
+ 0x*)
+ hfcmulti[${nr}]=$(echo ${mod} | ${SED} -e "s/^0x\([0-9]*\)/\1/")
+ let "hfcports = ${hfcports} + ${ports}"
+ IFS=$','
+ for li in ${opns}; do
+ hfcmulti[${nr}]=$(echo "obase=10;2^(${!li}-1)+${hfcmulti[${nr}]}" | ${BC})
+ done
+ IFS=$'\n'
+ ;;
+ *)
+ other_card[${nr}]=${mod}
+ ;;
+ esac
+ ;;
+ te_ptp)
+ for li in $(expand "${val}"); do
+ layermask[${li}]="0xf"
+ protocol[${li}]=34 # 0x22 == 34
+ done
+ ;;
+ te_ptmp)
+ for li in $(expand "${val}"); do
+ layermask[${li}]="0xf"
+ protocol[${li}]=2 # 0x2 == 2
+ done
+ ;;
+ nt_*)
+ for li in $(expand "${val}"); do
+ layermask[${li}]="0x3"
+ protocol[${li}]=18 # 0x12 == 18
+ done
+ ;;
+ te_capi_ptp)
+ for li in $(expand "${val}"); do
+ layermask[${li}]="0x0"
+ protocol[${li}]=34 # 0x22 == 34
+ done
+
+ export addcapi=1
+ ;;
+ te_capi_ptmp)
+ for li in $(expand "${val}"); do
+ layermask[${li}]="0x0"
+ protocol[${li}]=2 # 0x2 == 2
+ done
+
+ export addcapi=1
+ ;;
+
+ option)
+ port=`echo "${val}" | ${SED} -e "s/^\([0-9]*\),.*/\1/"`
+ opt=`echo "${val}" | ${SED} -e "s/^[0-9]*,\(.*\)/\1/"`
+
+ if [ -z ${protocol[${port}]} ]; then
+ protocol[${port}]="0"
+ fi
+
+ IFS=$','
+ for li in ${opt}; do
+ protocol[${port}]=$(echo "obase=10;2^(${!li}-1)+${protocol[${port}]}" | ${BC})
+ done
+ IFS=$'\n'
+ ;;
+ poll)
+ poll=${val}
+ poll_option=poll=${val}
+ ;;
+ dsp_poll)
+ dsp_poll_option=poll=${val}
+ ;;
+ pcm)
+ pcm=${val}
+ ;;
+ dsp_options)
+ export dsp_options=${val}
+ ;;
+ dtmfthreshold)
+ export dtmfthreshold_option="dtmfthreshold=${val}"
+ ;;
+ debug)
+ debug=${val}
+ ;;
+ timer)
+ timer=${val}
+ ;;
+ *)
+ echo "unknown variable: ${var}"
+ ;;
+ esac
+
+ done
+
+ echo "-----------------------------------------"
+ echo " Loading module(s) for your misdn-cards:"
+ echo "-----------------------------------------"
+
+ card_index=1
+ port_index=1
+ while [ ! -z ${hfcmulti[${card_index}]} ] || [ ! -z ${other_card[${card_index}]} ];
+ do
+ if [ ! -z ${hfcmulti[${card_index}]} ]; then
+ # MODPROBE COMMAND FOR hfcmulti CARD
+ hfcmulti_type="type="
+ hfcmulti_prot="protocol="
+ hfcmulti_layer="layermask="
+ while [ ! -z ${hfcmulti[${card_index}]} ];
+ do
+ hfcmulti_type="${hfcmulti_type}$(echo "obase=16;\"0x\";${hfcmulti[${card_index}]}" | ${BC} ),"
+ let "card_index = ${card_index} + 1"
+ done
+ while [ ${hfcports} -gt 0 ];
+ do
+ if [ ! -z ${protocol[${port_index}]} ]; then
+ hfcmulti_prot="${hfcmulti_prot}$(echo "obase=16;\"0x\";${protocol[${port_index}]}" | ${BC}),"
+ else
+ hfcmulti_prot="${hfcmulti_prot}0x2,"
+ fi
+ if [ ! -z ${layermask[${port_index}]} ]; then
+ hfcmulti_layer="${hfcmulti_layer}${layermask[${port_index}]},"
+ else
+ hfcmulti_layer="${hfcmulti_layer}0xf,"
+ fi
+ let "port_index = ${port_index} + 1"
+ let "hfcports = ${hfcports} - 1"
+ done
+ hfcmulti_type="$(echo ${hfcmulti_type} | ${SED} -e 's/^\(.*\),$/\1/')"
+ hfcmulti_prot="$(echo ${hfcmulti_prot} | ${SED} -e 's/^\(.*\),$/\1/')"
+ hfcmulti_layer="$(echo ${hfcmulti_layer} | ${SED} -e 's/^\(.*\),$/\1/')"
+ hfcmulti_cmd="${MODPROBE} --ignore-install hfcmulti ${hfcmulti_type} ${hfcmulti_prot} ${hfcmulti_layer}"
+ if [ ! -z ${poll} ]; then
+ hfcmulti_cmd="${hfcmulti_cmd} poll=${poll}"
+ fi
+ if [ ! -z ${pcm} ]; then
+ hfcmulti_cmd="${hfcmulti_cmd} pcm=${pcm}"
+ fi
+ if [ ! -z ${debug} ]; then
+ hfcmulti_cmd="${hfcmulti_cmd} debug=${debug}"
+ fi
+
+ if [ ! -z ${timer} ]; then
+ hfcmulti_cmd="${hfcmulti_cmd} timer=${timer}"
+ fi
+
+ if [ -z "$1" ] ; then
+ echo ${hfcmulti_cmd}
+ eval ${hfcmulti_cmd}
+ else
+ if [ "$1" = "hfcmulti" ] ; then
+ echo ${hfcmulti_cmd}
+ eval ${hfcmulti_cmd}
+ fi
+ fi
+ else
+ # MODPROBE COMMAND FOR _NON_ hfcmulti CARD
+ other_mod="${other_card[${card_index}]}"
+ other_cmd="${MODPROBE} --ignore-install ${other_mod}"
+ if [ ! -z ${protocol[${port_index}]} ]; then
+ other_prot="protocol=$(echo "obase=16;\"0x\";${protocol[${port_index}]}" | ${BC}),"
+ else
+ other_prot="protocol=0x2,"
+ fi
+ if [ ! -z ${layermask[${port_index}]} ]; then
+ other_layer="layermask=${layermask[${port_index}]},"
+ else
+ other_layer="layermask=0xf,"
+ fi
+ other_extra=""
+ modinfo $other_mod | egrep -q 'parm: *poll' && other_extra="$other_extra ${poll_option}"
+
+ let "prev = ${card_index}"
+ let "card_index = ${card_index} + 1"
+ let "port_index = ${port_index} + 1"
+ while [ "${other_card[${card_index}]}" == "${other_card[${prev}]}" ];
+ do
+ if [ ! -z ${protocol[${port_index}]} ]; then
+ other_prot="${other_prot}$(echo "obase=16;\"0x\";${protocol[${port_index}]}" | ${BC}),"
+ else
+ other_prot="${other_prot}0x2,"
+ fi
+ if [ ! -z ${layermask[${port_index}]} ]; then
+ other_layer="${other_layer}${layermask[${port_index}]},"
+ else
+ other_layer="${other_layer}0xf,"
+ fi
+ let "prev = ${card_index}"
+ let "card_index = ${card_index} + 1"
+ let "port_index = ${port_index} + 1"
+ done
+
+ other_prot="$(echo ${other_prot} | ${SED} -e 's/^\(.*\),$/\1/')"
+ other_layer="$(echo ${other_layer} | ${SED} -e 's/^\(.*\),$/\1/')"
+ other_cmd="${other_cmd} ${other_prot} ${other_layer} ${other_extra}"
+
+ if [ -z "$1" ] ; then
+ echo "${other_cmd}"
+ eval ${other_cmd}
+ else
+ if [ "$1" = "${other_card[${prev}]}" ] ; then
+ echo ${other_cmd}
+ eval ${other_cmd}
+ fi
+ fi
+
+
+ fi
+ done