diff --git a/Makefile.am b/Makefile.am index 9f6ab76916..1e6d72f0c7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -147,7 +147,16 @@ libfreeswitch_la_LDFLAGS += $(ODBC_LIB_FLAGS) endif if ENABLE_ZRTP -libfreeswitch_la_LDFLAGS += -lzrtp -lbn +CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bgaes +CORE_CFLAGS += -I$(switch_srcdir)/libs/libzrtp/third_party/bnlib +CORE_CFLAGS += -isystem $(switch_srcdir)/libs/libzrtp/include +ZRTP_LDFLAGS = -Llibs/libzrtp/third_party/bnlib +ZRTP_LDFLAGS += -Llibs/libzrtp/projects/gnu/build +ZRTP_LIBS = -lbn -lzrtp +libfreeswitch_la_LDFLAGS += $(ZRTP_LDFLAGS) +libfreeswitch_la_LIBADD += $(ZRTP_LIBS) +CORE_LIBS += libs/libzrtp/projects/gnu/build/libzrtp.a +LIBS += libs/libzrtp/third_party/bnlib/libbn.a endif library_includedir = $(includedir) @@ -429,6 +438,9 @@ src/include/switch_version.h: src/include/switch_version.h.in .version $(libfree libs/libedit/src/.libs/libedit.a: cd libs/libedit && $(MAKE) +libs/libzrtp/projects/gnu/build/libzrtp.a: + cd libs/libzrtp/projects/gnu && $(MAKE) + libs/curl/Makefile: cd libs/curl && sh ./configure.gnu --prefix=$(prefix) @@ -460,7 +472,6 @@ libs/srtp/libsrtp.la: libs/srtp libs/srtp/.update @cd libs/srtp && $(MAKE) @$(TOUCH_TARGET) - ## ## helper targets ## diff --git a/bootstrap.sh b/bootstrap.sh index ff1f4550d0..17c52f386d 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,300 +1,340 @@ #!/bin/sh +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- +##### bootstrap FreeSWITCH and FreeSWITCH libraries + echo "bootstrap: checking installation..." BGJOB=false -while getopts jh arg -do - case $arg in +VERBOSE=false +BASEDIR=`pwd`; +LIBDIR=${BASEDIR}/libs; +SUBDIRS="apr \ + libzrtp ilbc curl iksemel js js/nsprpub ldns libdingaling libedit libsndfile pcre sofia-sip \ + speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-3.8.2 broadvoice silk libcodec2 \ + fs"; + +while getopts 'jhd:v' o; do + case "$o" in j) BGJOB=true;; + d) SUBDIRS="$OPTARG";; + v) VERBOSE=true;; h) echo "Usage: $0 " - echo " Options:" - echo " -j => Run Jobs in Background" - exit;; + echo " Options:" + echo " -d 'library1 library2'" + echo " => Bootstrap only specified subdirectories" + echo " -j => Run Jobs in Background" + exit;; esac done -BASEDIR=`pwd`; -LIBDIR=${BASEDIR}/libs; -SUBDIRS="ilbc curl iksemel js js/nsprpub ldns libdingaling libedit libsndfile pcre sofia-sip \ - speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-3.8.2 broadvoice silk libcodec2"; +ex() { + test $VERBOSE && echo "bootstrap: $@" >&2 + $@ +} -if [ ! -f modules.conf ]; then +setup_modules() { + if [ ! -f modules.conf ]; then cp build/modules.conf.in modules.conf -fi + fi +} -# keep automake from making us magically GPL, and to stop complaining about missing files. -cp -f docs/COPYING . -cp -f docs/AUTHORS . -cp -f docs/ChangeLog . -touch NEWS -touch README +setup_gnu() { + # keep automake from making us magically GPL, and to stop + # complaining about missing files. + cp -f docs/COPYING . + cp -f docs/AUTHORS . + cp -f docs/ChangeLog . + touch NEWS + touch README +} -# autoconf 2.59 or newer -ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` -if test -z "$ac_version"; then -echo "bootstrap: autoconf not found." -echo " You need autoconf version 2.59 or newer installed" -echo " to build FreeSWITCH from source." -exit 1 -fi +check_ac_ver() { + # autoconf 2.59 or newer + ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` + if test -z "$ac_version"; then + echo "bootstrap: autoconf not found." + echo " You need autoconf version 2.59 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + fi + if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then + echo "Autoconf 2.62 is broken on OpenBSD, please try another version" + exit 1 + fi + IFS=_; set $ac_version; IFS=' ' + ac_version=$1 + IFS=.; set $ac_version; IFS=' ' + if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then + echo "bootstrap: autoconf version $ac_version found." + echo " You need autoconf version 2.59 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + else + echo "bootstrap: autoconf version $ac_version (ok)" + fi +} -if test `uname -s` = "OpenBSD" && test "$ac_version" = "2.62"; then -echo "Autoconf 2.62 is broken on OpenBSD, please try another version" -exit 1 -fi +check_am_ver() { + # automake 1.7 or newer + am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` + if test -z "$am_version"; then + echo "bootstrap: automake not found." + echo " You need automake version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + fi + IFS=_; set $am_version; IFS=' ' + am_version=$1 + IFS=.; set $am_version; IFS=' ' + if test "$1" = "1" -a "$2" -lt "7"; then + echo "bootstrap: automake version $am_version found." + echo " You need automake version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + else + echo "bootstrap: automake version $am_version (ok)" + fi +} -IFS=_; set $ac_version; IFS=' ' -ac_version=$1 -IFS=.; set $ac_version; IFS=' ' -if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then -echo "bootstrap: autoconf version $ac_version found." -echo " You need autoconf version 2.59 or newer installed" -echo " to build FreeSWITCH from source." -exit 1 -else -echo "bootstrap: autoconf version $ac_version (ok)" -fi +check_acl_ver() { + # aclocal 1.7 or newer + acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` + if test -z "$acl_version"; then + echo "bootstrap: aclocal not found." + echo " You need aclocal version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + fi + IFS=_; set $acl_version; IFS=' ' + acl_version=$1 + IFS=.; set $acl_version; IFS=' ' + if test "$1" = "1" -a "$2" -lt "7"; then + echo "bootstrap: aclocal version $acl_version found." + echo " You need aclocal version 1.7 or newer installed" + echo " to build FreeSWITCH from source." + exit 1 + else + echo "bootstrap: aclocal version $acl_version (ok)" + fi +} +check_lt_ver() { + # Sample libtool --version outputs: + # ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11) + # ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a + # output is multiline from 1.5 onwards -# automake 1.7 or newer + # Require libtool 1.4 or newer + libtool=${LIBTOOL:-`${LIBDIR}/apr/build/PrintPath glibtool libtool libtool22 libtool15 libtool14`} + lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` + if test -z "$lt_pversion"; then + echo "bootstrap: libtool not found." + echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." + exit 1 + fi + lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'` + IFS=.; set $lt_version; IFS=' ' + lt_status="good" -am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` -if test -z "$am_version"; then -echo "bootstrap: automake not found." -echo " You need automake version 1.7 or newer installed" -echo " to build FreeSWITCH from source." -exit 1 -fi -IFS=_; set $am_version; IFS=' ' -am_version=$1 -IFS=.; set $am_version; IFS=' ' -if test "$1" = "1" -a "$2" -lt "7"; then -echo "bootstrap: automake version $am_version found." -echo " You need automake version 1.7 or newer installed" -echo " to build FreeSWITCH from source." -exit 1 -else -echo "bootstrap: automake version $am_version (ok)" -fi + if test -z "$1"; then a=0 ; else a=$1;fi + if test -z "$2"; then b=0 ; else b=$2;fi + if test -z "$3"; then c=0 ; else c=$3;fi + lt_major=$a -# aclocal 1.7 or newer - -acl_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;s/[- ].*//g;q'` -if test -z "$acl_version"; then -echo "bootstrap: aclocal not found." -echo " You need aclocal version 1.7 or newer installed" -echo " to build FreeSWITCH from source." -exit 1 -fi -IFS=_; set $acl_version; IFS=' ' -acl_version=$1 -IFS=.; set $acl_version; IFS=' ' -if test "$1" = "1" -a "$2" -lt "7"; then -echo "bootstrap: aclocal version $acl_version found." -echo " You need aclocal version 1.7 or newer installed" -echo " to build FreeSWITCH from source." -exit 1 -else -echo "bootstrap: aclocal version $acl_version (ok)" -fi - -# Sample libtool --version outputs: -# ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11) -# ltmain.sh (GNU libtool 1.1361 2004/01/02 23:10:52) 1.5a -# output is multiline from 1.5 onwards - -# Require libtool 1.4 or newer -libtool=${LIBTOOL:-`${LIBDIR}/apr/build/PrintPath glibtool libtool libtool22 libtool15 libtool14`} -lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` -if test -z "$lt_pversion"; then - echo "bootstrap: libtool not found." - echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." - exit 1 -fi -lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'` -IFS=.; set $lt_version; IFS=' ' -lt_status="good" - -if test -z "$1"; then a=0 ; else a=$1;fi -if test -z "$2"; then b=0 ; else b=$2;fi -if test -z "$3"; then c=0 ; else c=$3;fi -lt_major=$a - -if test "$a" -eq "2"; then - lt_status="good" -elif test "$a" -lt "2"; then - if test "$b" -lt "5" -o "$b" = "5" -a "$c" -lt "14" ; then + if test "$a" -eq "2"; then + lt_status="good" + elif test "$a" -lt "2"; then + if test "$b" -lt "5" -o "$b" = "5" -a "$c" -lt "14" ; then lt_status="bad" - fi -else + fi + else lt_status="bad" -fi -if test $lt_status = "good"; then - echo "bootstrap: libtool version $lt_pversion (ok)" -else - echo "bootstrap: libtool version $lt_pversion found." - echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." - exit 1 -fi + fi + if test $lt_status = "good"; then + echo "bootstrap: libtool version $lt_pversion (ok)" + else + echo "bootstrap: libtool version $lt_pversion found." + echo " You need libtool version 1.5.14 or newer to build FreeSWITCH from source." + exit 1 + fi +} -# check libtoolize availability -if [ -n "${LIBTOOL}" ]; then +check_libtoolize() { + # check libtoolize availability + if [ -n "${LIBTOOL}" ]; then libtoolize=${LIBTOOLIZE:-`dirname "${libtool}"`/libtoolize} -else + else libtoolize=${LIBTOOLIZE:-`${LIBDIR}/apr/build/PrintPath glibtoolize libtoolize libtoolize22 libtoolize15 libtoolize14`} -fi -if [ "x$libtoolize" = "x" ]; then + fi + if [ "x$libtoolize" = "x" ]; then echo "libtoolize not found in path" exit 1 -fi -if [ ! -x "$libtoolize" ]; then + fi + if [ ! -x "$libtoolize" ]; then echo "$libtoolize does not exist or is not executable" exit 1 -fi - -# compare libtool and libtoolize version -ltl_pversion=`$libtoolize --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` -ltl_version=`echo $ltl_pversion|sed -e 's/\([a-z]*\)$/.\1/'` -IFS=.; set $ltl_version; IFS=' ' - -if [ "x${lt_version}" != "x${ltl_version}" ]; then - echo "$libtool and $libtoolize have different versions" - exit 1 -fi - - -# -# Info output -# -echo "Bootstrapping using:" -echo " autoconf : ${AUTOCONF:-`which autoconf`}" -echo " automake : ${AUTOMAKE:-`which automake`}" -echo " aclocal : ${ACLOCAL:-`which aclocal`}" -echo " libtool : ${libtool} (${lt_version})" -echo " libtoolize: ${libtoolize}" -echo - -echo "Entering directory ${LIBDIR}/apr" -cd ${LIBDIR}/apr - -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -# bootstrap: Build the support scripts needed to compile from a -# checked-out version of the source code. - -# Create the libtool helper files -# -# Note: we copy (rather than link) them to simplify distribution. -# Note: APR supplies its own config.guess and config.sub -- we do not -# rely on libtool's versions -# -echo "Copying libtool helper files ..." - -# Remove any libtool files so one can switch between libtool 1.3 -# and libtool 1.4 by simply rerunning the bootstrap script. -(cd build ; rm -f ltconfig ltmain.sh libtool.m4) - -if ${libtoolize} -n --install >/dev/null 2>&1 ; then - $libtoolize --force --copy --install -else - $libtoolize --force --copy -fi - -if [ -f libtool.m4 ]; then - ltfile=`pwd`/libtool.m4 -else - if [ $lt_major -eq 2 ]; then - ltfindcmd="`sed -n \"/aclocaldir=/{s/.*=/echo /p;q;}\" < $libtoolize`" - ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`/libtool.m4} - else - ltfindcmd="`sed -n \"/=[^\\\`]/p;/libtool_m4=/{s/.*=/echo /p;q;}\" \ - < $libtoolize`" - ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`} - fi - # Expecting the code above to be very portable, but just in case... - if [ -z "$ltfile" -o ! -f "$ltfile" ]; then - ltpath=`dirname $libtoolize` - ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4 - fi -fi - -if [ ! -f $ltfile ]; then - echo "$ltfile not found" - exit 1 -fi - -echo "bootstrap: Using libtool.m4 at ${ltfile}." - -cat $ltfile | sed -e 's/LIBTOOL=\(.*\)top_build/LIBTOOL=\1apr_build/' > build/libtool.m4 - -# libtool.m4 from 1.6 requires ltsugar.m4 -if [ -f ltsugar.m4 ]; then - rm -f build/ltsugar.m4 - mv ltsugar.m4 build/ltsugar.m4 -fi - -# Clean up any leftovers -rm -f aclocal.m4 libtool.m4 - -# fix for FreeBSD (at least): -# libtool.m4 is in share/aclocal, while e.g. aclocal19 only looks in share/aclocal19 -# get aclocal's default directory and include the libtool.m4 directory via -I if -# it's in a different location - -aclocal_dir="`${ACLOCAL:-aclocal} --print-ac-dir`" - -if [ -n "${aclocal_dir}" -a -n "${ltfile}" -a "`dirname ${ltfile}`" != "${aclocal_dir}" ] ; then - ACLOCAL_OPTS="-I `dirname ${ltfile}`" -fi - -### run aclocal -echo "Re-creating aclocal.m4 ..." -${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} - -### do some work to toss config.cache? -echo "Creating configure ..." -${AUTOCONF:-autoconf} - -# -# Generate the autoconf header -# -echo "Creating include/arch/unix/apr_private.h.in ..." -${AUTOHEADER:-autoheader} - -# Libs automake automation function -libbootstrap() -{ - i=$1 - if [ -d ${LIBDIR}/${i} ] ; then - echo "Entering directory ${LIBDIR}/${i}" - cd ${LIBDIR}/${i} - rm -f aclocal.m4 - CFFILE= - if [ -f ${LIBDIR}/${i}/configure.in ] ; then - CFFILE="${LIBDIR}/${i}/configure.in" - else - if [ -f ${LIBDIR}/${i}/configure.ac ] ; then - CFFILE="${LIBDIR}/${i}/configure.ac" - fi fi - if [ ! -z ${CFFILE} ] ; then + # compare libtool and libtoolize version + ltl_pversion=`$libtoolize --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'` + ltl_version=`echo $ltl_pversion|sed -e 's/\([a-z]*\)$/.\1/'` + IFS=.; set $ltl_version; IFS=' ' + if [ "x${lt_version}" != "x${ltl_version}" ]; then + echo "$libtool and $libtoolize have different versions" + exit 1 + fi +} + +print_autotools_vers() { + # + # Info output + # + echo "Bootstrapping using:" + echo " autoconf : ${AUTOCONF:-`which autoconf`}" + echo " automake : ${AUTOMAKE:-`which automake`}" + echo " aclocal : ${ACLOCAL:-`which aclocal`}" + echo " libtool : ${libtool} (${lt_version})" + echo " libtoolize: ${libtoolize}" + echo +} + +bootstrap_apr() { + echo "Entering directory ${LIBDIR}/apr" + cd ${LIBDIR}/apr + + # Licensed to the Apache Software Foundation (ASF) under one or more + # contributor license agreements. See the NOTICE file distributed with + # this work for additional information regarding copyright ownership. + # The ASF licenses this file to You under the Apache License, Version 2.0 + # (the "License"); you may not use this file except in compliance with + # the License. You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # + # + + # bootstrap: Build the support scripts needed to compile from a + # checked-out version of the source code. + + # Create the libtool helper files + # + # Note: we copy (rather than link) them to simplify distribution. + # Note: APR supplies its own config.guess and config.sub -- we do not + # rely on libtool's versions + # + echo "Copying libtool helper files ..." + + # Remove any libtool files so one can switch between libtool 1.3 + # and libtool 1.4 by simply rerunning the bootstrap script. + (cd build ; rm -f ltconfig ltmain.sh libtool.m4) + + if ${libtoolize} -n --install >/dev/null 2>&1 ; then + $libtoolize --force --copy --install + else + $libtoolize --force --copy + fi + + if [ -f libtool.m4 ]; then + ltfile=`pwd`/libtool.m4 + else + if [ $lt_major -eq 2 ]; then + ltfindcmd="`sed -n \"/aclocaldir=/{s/.*=/echo /p;q;}\" < $libtoolize`" + ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`/libtool.m4} + else + ltfindcmd="`sed -n \"/=[^\\\`]/p;/libtool_m4=/{s/.*=/echo /p;q;}\" \ + < $libtoolize`" + ltfile=${LIBTOOL_M4-`eval "$ltfindcmd"`} + fi + # Expecting the code above to be very portable, but just in case... + if [ -z "$ltfile" -o ! -f "$ltfile" ]; then + ltpath=`dirname $libtoolize` + ltfile=`cd $ltpath/../share/aclocal ; pwd`/libtool.m4 + fi + fi + + if [ ! -f $ltfile ]; then + echo "$ltfile not found" + exit 1 + fi + + echo "bootstrap: Using libtool.m4 at ${ltfile}." + + cat $ltfile | sed -e 's/LIBTOOL=\(.*\)top_build/LIBTOOL=\1apr_build/' > build/libtool.m4 + + # libtool.m4 from 1.6 requires ltsugar.m4 + if [ -f ltsugar.m4 ]; then + rm -f build/ltsugar.m4 + mv ltsugar.m4 build/ltsugar.m4 + fi + + # Clean up any leftovers + rm -f aclocal.m4 libtool.m4 + + # fix for FreeBSD (at least): + # libtool.m4 is in share/aclocal, while e.g. aclocal19 only looks in share/aclocal19 + # get aclocal's default directory and include the libtool.m4 directory via -I if + # it's in a different location + + aclocal_dir="`${ACLOCAL:-aclocal} --print-ac-dir`" + + if [ -n "${aclocal_dir}" -a -n "${ltfile}" -a "`dirname ${ltfile}`" != "${aclocal_dir}" ] ; then + ACLOCAL_OPTS="-I `dirname ${ltfile}`" + fi + + ### run aclocal + echo "Re-creating aclocal.m4 ..." + ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} + + ### do some work to toss config.cache? + echo "Creating configure ..." + ${AUTOCONF:-autoconf} + + # + # Generate the autoconf header + # + echo "Creating include/arch/unix/apr_private.h.in ..." + ${AUTOHEADER:-autoheader} + + # Remove autoconf 2.5x's cache directory + rm -rf autom4te*.cache + + echo "Entering directory ${LIBDIR}/apr-util" + cd ${LIBDIR}/apr-util + if ! ${BGJOB}; then + ./buildconf + else + ./buildconf & + fi +} + +bootstrap_libzrtp() { + (cd ${LIBDIR}/libzrtp/projects/gnu && ./bootstrap.sh) +} + +# Libs automake automation function +libbootstrap() { + i=$1 + if [ -d ${LIBDIR}/${i} ]; then + echo "Entering directory ${LIBDIR}/${i}" + ex cd ${LIBDIR}/${i} + ex rm -f aclocal.m4 + CFFILE= + if [ -f ${LIBDIR}/${i}/configure.in ]; then + CFFILE="${LIBDIR}/${i}/configure.in" + else + if [ -f ${LIBDIR}/${i}/configure.ac ]; then + CFFILE="${LIBDIR}/${i}/configure.ac" + fi + fi + + if [ ! -z ${CFFILE} ]; then LTTEST=`grep "AC_PROG_LIBTOOL" ${CFFILE}` LTTEST2=`grep "AM_PROG_LIBTOOL" ${CFFILE}` AMTEST=`grep "AM_INIT_AUTOMAKE" ${CFFILE}` @@ -303,71 +343,98 @@ libbootstrap() AXTEST=`grep "ACX_LIBTOOL_C_ONLY" ${CFFILE}` echo "Creating aclocal.m4" - ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} ${ACLOCAL_FLAGS} + ex ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} ${ACLOCAL_FLAGS} -#only run if AC_PROG_LIBTOOL is in configure.in/configure.ac - if [ ! -z "${LTTEST}" -o "${LTTEST2}" -o "${AXTEST}" ] ; then - echo "Running libtoolize..." - if ${libtoolize} -n --install >/dev/null 2>&1 ; then - $libtoolize --force --copy --install - else - $libtoolize --force --copy - fi + # only run if AC_PROG_LIBTOOL is in configure.in/configure.ac + if [ ! -z "${LTTEST}" -o "${LTTEST2}" -o "${AXTEST}" ]; then + echo "Running libtoolize..." + if ${libtoolize} -n --install >/dev/null 2>&1; then + ex $libtoolize --force --copy --install + else + ex $libtoolize --force --copy + fi fi echo "Creating configure" - ${AUTOCONF:-autoconf} + ex ${AUTOCONF:-autoconf} -#only run if AC_CONFIG_HEADERS is found in configure.in/configure.ac - if [ ! -z "${AHTEST}" ] ; then - echo "Running autoheader..." - ${AUTOHEADER:-autoheader} ; + # only run if AC_CONFIG_HEADERS is found in configure.in/configure.ac + if [ ! -z "${AHTEST}" ]; then + echo "Running autoheader..." + ex ${AUTOHEADER:-autoheader}; fi -#run if AM_INIT_AUTOMAKE / AC_PROG_INSTALL is in configure.in/configure.ac - if [ ! -z "${AMTEST}" -o "${AMTEST2}" ] ; then - echo "Creating Makefile.in" - ${AUTOMAKE:-automake} --no-force --add-missing --copy ; + # run if AM_INIT_AUTOMAKE / AC_PROG_INSTALL is in configure.in/configure.ac + if [ ! -z "${AMTEST}" -o "${AMTEST2}" ]; then + echo "Creating Makefile.in" + ex ${AUTOMAKE:-automake} --no-force --add-missing --copy; fi - rm -rf autom4te*.cache - fi + ex rm -rf autom4te*.cache + fi else - echo "Skipping directory ${LIBDIR}/${i}" + echo "Skipping directory ${LIBDIR}/${i}" fi } +bootstrap_fs() { + cd ${BASEDIR} + rm -f aclocal.m4 + ${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} + $libtoolize --copy --automake + ${AUTOCONF:-autoconf} + ${AUTOHEADER:-autoheader} + ${AUTOMAKE:-automake} --no-force --add-missing --copy + rm -rf autom4te*.cache +} -# Remove autoconf 2.5x's cache directory -rm -rf autom4te*.cache +bootstrap_libs_pre() { + case "$1" in + ldns) + # This file shouldn't even be in the tree as it's autogenerated + # during bootstrap, but some people report it breaks the build + # if it's not there. Let's prevent it from getting accidentally + # updated. + (cd $BASEDIR/libs/ldns && cp -a install-sh install-sh~) ;; + esac +} -echo "Entering directory ${LIBDIR}/apr-util" -cd ${LIBDIR}/apr-util -if [ "${BGJOB}" = "false" ] ; then - ./buildconf -else - ./buildconf & -fi +bootstrap_libs_post() { + case "$1" in + ldns) (cd $BASEDIR/libs/ldns && mv install-sh~ install-sh) ;; + esac +} +bootstrap_libs() { + for i in ${SUBDIRS}; do + case "$i" in + apr|fs|libzrtp) + ${BGJOB} && wait + bootstrap_$i + continue + ;; + esac + bootstrap_libs_pre ${i} + if ! ${BGJOB}; then + libbootstrap ${i} ; bootstrap_libs_post ${i} + else + ((libbootstrap ${i} ; bootstrap_libs_post ${i}) &) + fi + done +} -for i in ${SUBDIRS} -do - if [ "${BGJOB}" = "false" ] ; then - libbootstrap ${i} - else - libbootstrap ${i} & - fi -done +run() { + setup_modules + setup_gnu + check_ac_ver + check_am_ver + check_acl_ver + check_lt_ver + check_libtoolize + print_autotools_vers + bootstrap_libs + ${BGJOB} && wait + return 0 +} -if [ "${BGJOB}" = "true" ] ; then - wait -fi -cd ${BASEDIR} - -rm -f aclocal.m4 -${ACLOCAL:-aclocal} ${ACLOCAL_OPTS} -$libtoolize --copy --automake -${AUTOCONF:-autoconf} -${AUTOHEADER:-autoheader} -${AUTOMAKE:-automake} --no-force --add-missing --copy -rm -rf autom4te*.cache +run diff --git a/build/modules.conf.in b/build/modules.conf.in index a9993c1e87..18babbfec9 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -1,131 +1,132 @@ -loggers/mod_console -loggers/mod_logfile -loggers/mod_syslog -#applications/mod_cidlookup +#applications/mod_abstraction +#applications/mod_avmd #applications/mod_blacklist +#applications/mod_callcenter +#applications/mod_cidlookup +applications/mod_cluechoo applications/mod_commands applications/mod_conference -applications/mod_dptools -applications/mod_enum -#applications/mod_osp -applications/mod_fifo #applications/mod_curl applications/mod_db -applications/mod_hash -#applications/mod_http_cache -#applications/mod_redis -applications/mod_voicemail -#applications/mod_voicemail_ivr #applications/mod_directory -#applications/mod_lcr -applications/mod_expr -applications/mod_esf -#applications/mod_easyroute -applications/mod_fsv -#applications/mod_nibblebill -#applications/mod_soundtouch -#applications/mod_rss -applications/mod_spandsp -#applications/mod_snom -#applications/mod_vmd -#applications/mod_avmd -#applications/mod_memcache -#applications/mod_spy -applications/mod_cluechoo -applications/mod_valet_parking #applications/mod_distributor -#applications/mod_stress +applications/mod_dptools +#applications/mod_easyroute +applications/mod_enum +applications/mod_esf +#applications/mod_esl +applications/mod_expr +applications/mod_fifo +#applications/mod_fsk +applications/mod_fsv +applications/mod_hash +applications/mod_httapi +#applications/mod_http_cache +#applications/mod_ladspa +#applications/mod_lcr +#applications/mod_memcache +#applications/mod_mongo +#applications/mod_nibblebill +#applications/mod_osp +#applications/mod_redis +#applications/mod_rss +applications/mod_sms #applications/mod_snapshot #applications/mod_snipe_hunt -#applications/mod_callcenter -#applications/mod_fsk -#applications/mod_ladspa -#applications/mod_mongo -#applications/mod_abstraction -#applications/mod_esl -applications/mod_sms -applications/mod_httapi -codecs/mod_g723_1 -codecs/mod_amr -#codecs/mod_amrwb -#codecs/mod_silk -#codecs/mod_codec2 -codecs/mod_g729 -#codecs/mod_com_g729 -codecs/mod_h26x -codecs/mod_bv -codecs/mod_ilbc -codecs/mod_speex -codecs/mod_siren -#codecs/mod_celt -#codecs/mod_opus -#codecs/mod_sangoma_codec -#codecs/mod_dahdi_codec -#codecs/mod_isac -#dialplans/mod_dialplan_directory -dialplans/mod_dialplan_xml -dialplans/mod_dialplan_asterisk -#directories/mod_ldap -#endpoints/mod_dingaling -#endpoints/mod_portaudio -endpoints/mod_sofia -endpoints/mod_loopback -#endpoints/mod_alsa -#endpoints/mod_opal -#endpoints/mod_skinny -#endpoints/mod_skypopen -#endpoints/mod_h323 -#endpoints/mod_khomp -#endpoints/mod_rtmp -#../../libs/openzap/mod_openzap -#../../libs/freetdm/mod_freetdm -#asr_tts/mod_unimrcp +#applications/mod_snom +#applications/mod_soundtouch +applications/mod_spandsp +#applications/mod_spy +#applications/mod_stress +applications/mod_valet_parking +#applications/mod_vmd +applications/mod_voicemail +#applications/mod_voicemail_ivr +#asr_tts/mod_cepstral #asr_tts/mod_flite #asr_tts/mod_pocketsphinx -#asr_tts/mod_cepstral #asr_tts/mod_tts_commandline +#asr_tts/mod_unimrcp +codecs/mod_amr +#codecs/mod_amrwb +codecs/mod_bv +#codecs/mod_celt +#codecs/mod_codec2 +#codecs/mod_com_g729 +#codecs/mod_dahdi_codec +codecs/mod_g723_1 +codecs/mod_g729 +codecs/mod_h26x +codecs/mod_ilbc +#codecs/mod_isac +#codecs/mod_opus +#codecs/mod_sangoma_codec +#codecs/mod_silk +codecs/mod_siren +codecs/mod_speex +dialplans/mod_dialplan_asterisk +#dialplans/mod_dialplan_directory +dialplans/mod_dialplan_xml +#directories/mod_ldap +#endpoints/mod_alsa +#endpoints/mod_dingaling +#endpoints/mod_h323 +#endpoints/mod_khomp +endpoints/mod_loopback +#endpoints/mod_opal +#endpoints/mod_portaudio +#endpoints/mod_rtmp +#endpoints/mod_skinny +#endpoints/mod_skypopen +endpoints/mod_sofia +event_handlers/mod_cdr_csv +#event_handlers/mod_cdr_mongodb +#event_handlers/mod_cdr_pg_csv +event_handlers/mod_cdr_sqlite +#event_handlers/mod_erlang_event #event_handlers/mod_event_multicast event_handlers/mod_event_socket #event_handlers/mod_event_zmq -event_handlers/mod_cdr_csv -event_handlers/mod_cdr_sqlite -#event_handlers/mod_cdr_mongodb -#event_handlers/mod_cdr_pg_csv #event_handlers/mod_radius_cdr -#event_handlers/mod_erlang_event #event_handlers/mod_snmp -formats/mod_native_file -formats/mod_sndfile -#formats/mod_shout formats/mod_local_stream -formats/mod_tone_stream +formats/mod_native_file #formats/mod_portaudio_stream #formats/mod_shell_stream +#formats/mod_shout +formats/mod_sndfile +formats/mod_tone_stream +#languages/mod_java +languages/mod_lua +#languages/mod_managed +#languages/mod_perl #languages/mod_python languages/mod_spidermonkey -languages/mod_lua -#languages/mod_perl #languages/mod_yaml -#languages/mod_java -#languages/mod_managed -xml_int/mod_xml_rpc -#xml_int/mod_xml_curl -xml_int/mod_xml_cdr -#xml_int/mod_xml_ldap -say/mod_say_en +loggers/mod_console +loggers/mod_logfile +loggers/mod_syslog #say/mod_say_de +say/mod_say_en #say/mod_say_es #say/mod_say_fr +#say/mod_say_he +#say/mod_say_hu #say/mod_say_it #say/mod_say_nl #say/mod_say_pt #say/mod_say_ru -#say/mod_say_zh -#say/mod_say_hu #say/mod_say_th -#say/mod_say_he -#timers/mod_timerfd +#say/mod_say_zh #timers/mod_posix_timer +#timers/mod_timerfd +xml_int/mod_xml_cdr +#xml_int/mod_xml_curl +#xml_int/mod_xml_ldap +xml_int/mod_xml_rpc + +#../../libs/freetdm/mod_freetdm +#../../libs/openzap/mod_openzap ## Experimental Modules (don't cry if they're broken) #../../contrib/mod/xml_int/mod_xml_odbc diff --git a/conf/vanilla/autoload_configs/httapi.conf.xml b/conf/vanilla/autoload_configs/httapi.conf.xml index c2fe584a02..50bbe78f40 100644 --- a/conf/vanilla/autoload_configs/httapi.conf.xml +++ b/conf/vanilla/autoload_configs/httapi.conf.xml @@ -119,7 +119,7 @@ - + diff --git a/configure.in b/configure.in index d362db9dd0..3df878551d 100644 --- a/configure.in +++ b/configure.in @@ -363,13 +363,7 @@ AM_CONDITIONAL([ENABLE_SRTP],[test "${enable_srtp}" = "yes"]) AC_ARG_ENABLE(zrtp, [AS_HELP_STRING([--enable-zrtp], [Compile with zrtp Support])],,[enable_zrtp="no"]) if test "x$enable_zrtp" = "xyes" ; then - saved_LIBS="$LIBS" - LIBS="$saved_LIBS -L/usr/local/lib -lbn -lpthread" - AC_CHECK_LIB(zrtp, zrtp_init, [has_zrtp="yes"], [has_zrtp="no"]) - LIBS="$saved_LIBS" - if test "x$has_zrtp" = "xno"; then - AC_ERROR([Cannot locate zrtp libraries]) - fi + LIBS="-lpthread $LIBS" APR_ADDTO(SWITCH_AM_CFLAGS, -DENABLE_ZRTP) fi @@ -1090,6 +1084,9 @@ AC_CONFIG_SUBDIRS([libs/broadvoice]) AC_CONFIG_SUBDIRS([libs/libg722_1]) AC_CONFIG_SUBDIRS([libs/silk]) AC_CONFIG_SUBDIRS([libs/libcodec2]) +if test "x${enable_zrtp}" = "xyes"; then + AC_CONFIG_SUBDIRS([libs/libzrtp/projects/gnu]) +fi case $host in *-openbsd*) diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c index 36651e49d8..875b359ec3 100644 --- a/libs/esl/fs_cli.c +++ b/libs/esl/fs_cli.c @@ -747,6 +747,8 @@ static const char *cli_usage = static int process_command(esl_handle_t *handle, const char *cmd) { while (*cmd == ' ') cmd++; + + if ((*cmd == '/' && cmd++) || !strncasecmp(cmd, "...", 3)) { if (!strcasecmp(cmd, "help")) { output_printf("%s", cli_usage); @@ -793,6 +795,13 @@ static int process_command(esl_handle_t *handle, const char *cmd) } else { char cmd_str[1024] = ""; const char *err = NULL; + + if (!strncasecmp(cmd, "console loglevel ", 17)) { + snprintf(cmd_str, sizeof(cmd_str), "log %s", cmd + 17); + esl_send_recv(handle, cmd_str); + printf("%s\n", handle->last_sr_reply); + } + snprintf(cmd_str, sizeof(cmd_str), "api %s\nconsole_execute: true\n\n", cmd); if (esl_send_recv(handle, cmd_str)) { output_printf("Socket interrupted, bye!\n"); diff --git a/libs/esl/src/esl.c b/libs/esl/src/esl.c index 02ab7ef271..719912b1e8 100644 --- a/libs/esl/src/esl.c +++ b/libs/esl/src/esl.c @@ -51,7 +51,7 @@ #include #ifndef WIN32 -#define closesocket(x) close(x) +#define closesocket(x) shutdown(x, 2); close(x) #include #include #else diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 1c41ed3b74..9b6641d7b0 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -4834,11 +4834,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load) ftdm_global_set_config_directory(SWITCH_GLOBAL_dirs.conf_dir); if (ftdm_global_init() != FTDM_SUCCESS) { + ftdm_global_destroy(); ftdm_log(FTDM_LOG_ERROR, "Error loading FreeTDM\n"); return SWITCH_STATUS_TERM; } if (ftdm_global_configuration() != FTDM_SUCCESS) { + ftdm_global_destroy(); ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM\n"); return SWITCH_STATUS_TERM; } diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index fa62f5b425..caab35143a 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -5829,6 +5829,8 @@ FT_DECLARE(ftdm_status_t) ftdm_global_destroy(void) /* destroy signaling and io modules */ ftdm_unload_modules(); + ftdm_global_set_logger( NULL ); + /* finally destroy the globals */ ftdm_mutex_lock(globals.mutex); ftdm_sched_destroy(&globals.timingsched); diff --git a/libs/freetdm/src/ftdm_sched.c b/libs/freetdm/src/ftdm_sched.c index c48c3e9433..e644067aad 100644 --- a/libs/freetdm/src/ftdm_sched.c +++ b/libs/freetdm/src/ftdm_sched.c @@ -119,10 +119,15 @@ static void *run_main_schedule(ftdm_thread_t *thread, void *data) /* there are no free runs, wait a bit and check again (FIXME: use ftdm_interrupt_t for this) */ ftdm_mutex_unlock(sched_globals.mutex); - ftdm_sleep(sleepms); + if (ftdm_running()) { + ftdm_sleep(sleepms); + } } for (current = sched_globals.freeruns; current; current = current->next) { + if (!ftdm_running()) { + break; + } /* first run the schedule */ ftdm_sched_run(current); @@ -142,7 +147,9 @@ static void *run_main_schedule(ftdm_thread_t *thread, void *data) ftdm_mutex_unlock(sched_globals.mutex); - ftdm_sleep(sleepms); + if (ftdm_running()) { + ftdm_sleep(sleepms); + } } ftdm_log(FTDM_LOG_NOTICE, "Main scheduling thread going out ...\n"); sched_globals.running = 0; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index e6740c2ddd..e3af9d9b98 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -682,16 +682,26 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm break; case FTDM_CHANNEL_STATE_DIALING: /* outgoing call request */ { - if (FTDM_SPAN_IS_BRI(ftdmchan->span) && - ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM) && - ftdm_test_flag(ftdmchan->span, FTDM_SPAN_PWR_SAVING)) { - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Requesting Line activation\n"); - sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); - ftdm_sangoma_isdn_wakeup_phy(ftdmchan); - ftdm_sched_timer(signal_data->sched, "timer_t3", signal_data->timer_t3*1000, sngisdn_t3_timeout, (void*) sngisdn_info, NULL); + if (FTDM_SPAN_IS_BRI(ftdmchan->span) && ftdm_test_flag(ftdmchan->span, FTDM_SPAN_PWR_SAVING)) { + ftdm_signaling_status_t sigstatus; + ftdm_span_get_sig_status(ftdmchan->span, &sigstatus); + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM)) { + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; + + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Requesting Physical Line activation\n"); + sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); + ftdm_sangoma_isdn_wakeup_phy(ftdmchan); + ftdm_sched_timer(signal_data->sched, "timer_t3", signal_data->timer_t3*1000, sngisdn_t3_timeout, (void*) sngisdn_info, NULL); + } else if (sigstatus == FTDM_SIG_STATE_DOWN) { + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; + + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Requesting Q.921 Line activation\n"); + sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); + sngisdn_snd_info_req(ftdmchan); + ftdm_sched_timer(signal_data->sched, "timer_t3", signal_data->timer_t3*1000, sngisdn_t3_timeout, (void*) sngisdn_info, NULL); + } else { + sngisdn_snd_setup(ftdmchan); + } } else { sngisdn_snd_setup(ftdmchan); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c index 668b63006c..15def40218 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cntrl.c @@ -49,6 +49,16 @@ void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; sig.ev_data.sigstatus.status = status; ftdm_span_send_signal(ftdmchan->span, &sig); + + if (FTDM_SPAN_IS_BRI(ftdmchan->span)) { + sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)ftdmchan->span->signal_data; + if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)) { + ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); + + ftdm_sched_timer(signal_data->sched, "delayed_setup", 1000, sngisdn_delayed_setup, (void*) sngisdn_info, NULL); + } + } return; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c index 2a22514019..55a156c562 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c @@ -972,8 +972,19 @@ ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) cfg.t.cfg.s.inLCe.sapId = signal_data->dchan_id; cfg.t.cfg.s.inLCe.lnkUpDwnInd = TRUE; - cfg.t.cfg.s.inLCe.tCon.enb = TRUE; - cfg.t.cfg.s.inLCe.tCon.val = 35; + + if (FTDM_SPAN_IS_BRI(span)) { + /* tCon Timer causes unwanted hangup on BRI links + where the Q.921 link goes into disconnected + state when idle. */ + + cfg.t.cfg.s.inLCe.tCon.enb = FALSE; + cfg.t.cfg.s.inLCe.tCon.val = 0; + } else { + cfg.t.cfg.s.inLCe.tCon.enb = TRUE; + cfg.t.cfg.s.inLCe.tCon.val = 35; + } + cfg.t.cfg.s.inLCe.tDisc.enb = TRUE; cfg.t.cfg.s.inLCe.tDisc.val = 35; cfg.t.cfg.s.inLCe.t314.enb = FALSE; /* if segmentation enabled, set to TRUE */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 76641f3893..0a34068359 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -1169,12 +1169,13 @@ static ftdm_status_t sngisdn_bring_down(ftdm_channel_t *ftdmchan) void sngisdn_process_rst_cfm (sngisdn_event_data_t *sngisdn_event) { + ftdm_signaling_status_t sigstatus; int16_t suId = sngisdn_event->suId; int16_t dChan = sngisdn_event->dChan; uint8_t ces = sngisdn_event->ces; uint8_t evntType = sngisdn_event->evntType; uint8_t chan_no = 0; - Rst *rstEvnt = &sngisdn_event->event.rstEvnt; + Rst *rstEvnt = &sngisdn_event->event.rstEvnt; sngisdn_span_data_t *signal_data = g_sngisdn_data.dchans[dChan].spans[1]; if (!signal_data) { @@ -1213,23 +1214,26 @@ void sngisdn_process_rst_cfm (sngisdn_event_data_t *sngisdn_event) return; } } + + ftdm_span_get_sig_status(signal_data->ftdm_span, &sigstatus); + if (sigstatus == FTDM_SIG_STATE_DOWN) { + if (chan_no) { /* For a single channel */ + if (chan_no > ftdm_span_get_chan_count(signal_data->ftdm_span)) { + ftdm_log(FTDM_LOG_CRIT, "Received RESTART on invalid channel:%d\n", chan_no); + } else { + ftdm_channel_t *ftdmchan = ftdm_span_get_channel(signal_data->ftdm_span, chan_no); + sngisdn_bring_down(ftdmchan); + } + } else { /* for all channels */ + ftdm_iterator_t *chaniter = NULL; + ftdm_iterator_t *curr = NULL; - if (chan_no) { /* For a single channel */ - if (chan_no > ftdm_span_get_chan_count(signal_data->ftdm_span)) { - ftdm_log(FTDM_LOG_CRIT, "Received RESTART on invalid channel:%d\n", chan_no); - } else { - ftdm_channel_t *ftdmchan = ftdm_span_get_channel(signal_data->ftdm_span, chan_no); - sngisdn_bring_down(ftdmchan); + chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); + for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { + sngisdn_bring_down((ftdm_channel_t*)ftdm_iterator_current(curr)); + } + ftdm_iterator_free(chaniter); } - } else { /* for all channels */ - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - - chaniter = ftdm_span_get_chan_iterator(signal_data->ftdm_span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - sngisdn_bring_down((ftdm_channel_t*)ftdm_iterator_current(curr)); - } - ftdm_iterator_free(chaniter); } ftdm_log(FTDM_LOG_DEBUG, "Processing RESTART CFM (suId:%u dChan:%d ces:%d type:%d)\n", suId, dChan, ces, evntType); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 076cb54a61..f528333634 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -305,6 +305,7 @@ void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan) return; } +/* This is used to request Q.921 to initiate link establishment */ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan) { CnStEvnt cnStEvnt; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index 72b6def4ae..c45bbf0874 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -689,6 +689,17 @@ void sngisdn_rcv_q921_ind(BdMngmt *status) DECODE_LCM_CATEGORY(status->t.usta.alarm.category), DECODE_LLD_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event, DECODE_LLD_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); + + if (FTDM_SPAN_IS_BRI(ftdmspan) && (status->t.usta.alarm.event == PROT_ST_DN)) { + /* Q.921 link is down - This is a line where the Q.921 stops transmitting + after the line goes idle. + + Do not drop current calls, but set sigstatus do down so that we + can try to re-initialize link before trying new outbound calls */ + + sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN); + sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING); + } break; default: ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q921] %s: %s: %s(%d): %s(%d)\n", diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index db1a8d3a0d..254b3abbfb 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -595,6 +595,11 @@ ftdm_status_t set_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb) if (!len) { return FTDM_SUCCESS; } + + if (!strncasecmp(caller_data->cid_num.digits, "0000000000", strlen("0000000000"))) { + return FTDM_SUCCESS; + } + cgPtyNmb->eh.pres = PRSNT_NODEF; cgPtyNmb->screenInd.pres = PRSNT_NODEF; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c index 52c4f4d321..56797fbf9c 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c @@ -112,7 +112,7 @@ uint8_t get_bits(uint8_t octet, uint8_t bitLo, uint8_t bitHi) void sngisdn_trace_interpreted_q921(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t dir, uint8_t *data, uint32_t data_len) { - char *data_str = ftdm_calloc(1,200); /* TODO Find a proper size */ + char *data_str = ftdm_calloc(1,500); /* TODO Find a proper size */ sngisdn_decode_q921(data_str, data, data_len); ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN Q921] %s FRAME %s:\n%s\n", signal_data->ftdm_span->name, ftdm_trace_dir2str(dir), data_str); ftdm_safe_free(data_str); diff --git a/libs/ldns/install-sh b/libs/ldns/install-sh index 6781b987bd..a9244eb078 100755 --- a/libs/ldns/install-sh +++ b/libs/ldns/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2009-04-28.21; # UTC +scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -156,6 +156,10 @@ while test $# -ne 0; do -s) stripcmd=$stripprog;; -t) dst_arg=$2 + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac shift;; -T) no_target_directory=true;; @@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg + # Protect names problematic for `test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac done fi @@ -200,7 +208,11 @@ if test $# -eq 0; then fi if test -z "$dir_arg"; then - trap '(exit $?); exit' 1 2 13 15 + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -228,9 +240,9 @@ fi for src do - # Protect names starting with `-'. + # Protect names problematic for `test' and other utilities. case $src in - -*) src=./$src;; + -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then @@ -252,12 +264,7 @@ do echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # Protect names starting with `-'. - case $dst in - -*) dst=./$dst;; - esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. @@ -385,7 +392,7 @@ do case $dstdir in /*) prefix='/';; - -*) prefix='./';; + [-=\(\)!]*) prefix='./';; *) prefix='';; esac @@ -403,7 +410,7 @@ do for d do - test -z "$d" && continue + test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then diff --git a/libs/libnatpmp/natpmp.c b/libs/libnatpmp/natpmp.c index d4b9dcbe31..c79e92bdfd 100644 --- a/libs/libnatpmp/natpmp.c +++ b/libs/libnatpmp/natpmp.c @@ -165,15 +165,22 @@ int sendnewportmappingrequest(natpmp_t * p, int protocol, uint16_t privateport, uint16_t publicport, uint32_t lifetime) { + uint16_t *n; + uint32_t *m; + if(!p || (protocol!=NATPMP_PROTOCOL_TCP && protocol!=NATPMP_PROTOCOL_UDP)) return NATPMP_ERR_INVALIDARGS; p->pending_request[0] = 0; p->pending_request[1] = (char)protocol; p->pending_request[2] = 0; p->pending_request[3] = 0; - *((uint16_t *)(intptr_t)(p->pending_request + 4)) = htons(privateport); - *((uint16_t *)(intptr_t)(p->pending_request + 6)) = htons(publicport); - *((uint32_t *)(intptr_t)(p->pending_request + 8)) = htonl(lifetime); + n = (uint16_t *)(p->pending_request + 4); *n = htons(privateport); + n = (uint16_t *)(p->pending_request + 6); *n = htons(publicport); + m = (uint32_t *)(p->pending_request + 8); *m = htonl(lifetime); + + //*((uint16_t *)(p->pending_request + 4)) = htons(privateport); + //*((uint16_t *)(p->pending_request + 6)) = htons(publicport); + //*((uint32_t *)(p->pending_request + 8)) = htonl(lifetime); p->pending_request_len = 12; return sendnatpmprequest(p); } diff --git a/libs/libzrtp/.gitignore b/libs/libzrtp/.gitignore new file mode 100644 index 0000000000..4bb1123214 --- /dev/null +++ b/libs/libzrtp/.gitignore @@ -0,0 +1,2 @@ +# -*- mode:conf -*- +/include/zrtp_config_unix.h diff --git a/libs/libzrtp/projects/gnu/.gitignore b/libs/libzrtp/projects/gnu/.gitignore new file mode 100644 index 0000000000..0920c730f6 --- /dev/null +++ b/libs/libzrtp/projects/gnu/.gitignore @@ -0,0 +1,10 @@ +# -*- mode:conf -*- +/Makefile +/Makefile.in +/_configs.sed +/build/Makefile +/build/Makefile.in +/build/test/Makefile +/build/test/Makefile.in +/config/config.h +/config/stamp-h1 diff --git a/libs/libzrtp/projects/gnu/acinclude.m4 b/libs/libzrtp/projects/gnu/acinclude.m4 new file mode 100644 index 0000000000..f5879955c2 --- /dev/null +++ b/libs/libzrtp/projects/gnu/acinclude.m4 @@ -0,0 +1,94 @@ +AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl +AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl +AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl +AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl +AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl +AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl +AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl +AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl +AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl +m4_pushdef([_script],[conftest.prefix])dnl +m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl +_OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)` +_DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` +_PKG=`echo ifelse($2, , $PACKAGE, $2)` +_LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` +_UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` +_INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'` +if test ".$_INP" = "."; then + for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue + case "$ac_file" in + *.h) _INP=$ac_file ;; + *) + esac + test ".$_INP" != "." && break + done +fi +if test ".$_INP" = "."; then + case "$_OUT" in + */*) _INP=`basename "$_OUT"` + ;; + *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` + ;; + *) _INP=config.h + ;; + esac +fi +if test -z "$_PKG" ; then + AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) +else + if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then + _INP="$srcdir/$_INP" + fi fi + AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) + if test -f $_INP ; then + echo "s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/" > _script + echo "s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/" >> _script + echo "s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1 \\" >> _script + echo "@%:@def[]ine $_UPP""_\\1 \\2 \\" >> _script + echo "@%:@endif/" >>_script + echo "s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1 \\" >> _script + echo "@%:@define $_LOW""_\\1 \\2 \\" >> _script + echo "@%:@endif/" >> _script + # now executing _script on _DEF input to create _OUT output file + echo "@%:@ifndef $_DEF" >$tmp/pconfig.h + echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h + echo ' ' >>$tmp/pconfig.h + echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h + + sed -f _script $_INP >>$tmp/pconfig.h + echo ' ' >>$tmp/pconfig.h + echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h + echo "@%:@endif" >>$tmp/pconfig.h + if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then + AC_MSG_NOTICE([$_OUT is unchanged]) + else + ac_dir=`AS_DIRNAME(["$_OUT"])` + AS_MKDIR_P(["$ac_dir"]) + rm -f "$_OUT" + mv $tmp/pconfig.h "$_OUT" + fi + cp _script _configs.sed + else + AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT]) + fi + rm -f conftest.* +fi +m4_popdef([_symbol])dnl +m4_popdef([_script])dnl +AS_VAR_POPDEF([_INP])dnl +AS_VAR_POPDEF([_UPP])dnl +AS_VAR_POPDEF([_LOW])dnl +AS_VAR_POPDEF([_PKG])dnl +AS_VAR_POPDEF([_DEF])dnl +AS_VAR_POPDEF([_OUT])dnl +],[PACKAGE="$PACKAGE"])]) + +dnl implementation note: a bug report (31.5.2005) from Marten Svantesson points +dnl out a problem where `echo "\1"` results in a Control-A. The unix standard +dnl http://www.opengroup.org/onlinepubs/000095399/utilities/echo.html +dnl defines all backslash-sequences to be inherently non-portable asking +dnl for replacement mit printf. Some old systems had problems with that +dnl one either. However, the latest libtool (!) release does export an $ECHO +dnl (and $echo) that does the right thing - just one question is left: what +dnl was the first version to have it? Is it greater 2.58 ? diff --git a/libs/libzrtp/projects/gnu/autoreconf.sh b/libs/libzrtp/projects/gnu/autoreconf.sh deleted file mode 100755 index fb8e583f63..0000000000 --- a/libs/libzrtp/projects/gnu/autoreconf.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -aclocal -I ./config/ -autoheader -autoconf -automake diff --git a/libs/libzrtp/projects/gnu/bootstrap.sh b/libs/libzrtp/projects/gnu/bootstrap.sh new file mode 100755 index 0000000000..abc867ebf8 --- /dev/null +++ b/libs/libzrtp/projects/gnu/bootstrap.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +reconf () { + aclocal + mkdir -p config + libtoolize --copy --automake + autoconf + autoheader + automake --no-force --add-missing --copy +} + +(cd ../../third_party/bnlib && reconf) +reconf + diff --git a/libs/libzrtp/projects/gnu/cfg b/libs/libzrtp/projects/gnu/cfg deleted file mode 100755 index 8f19122fb7..0000000000 --- a/libs/libzrtp/projects/gnu/cfg +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./configure --enable-enterprise \ No newline at end of file diff --git a/libs/libzrtp/third_party/bnlib/.gitignore b/libs/libzrtp/third_party/bnlib/.gitignore new file mode 100644 index 0000000000..93a51e214c --- /dev/null +++ b/libs/libzrtp/third_party/bnlib/.gitignore @@ -0,0 +1,3 @@ +# -*- mode:conf -*- +/Makefile +/bnconfig.h diff --git a/libs/libzrtp/third_party/bnlib/Makefile b/libs/libzrtp/third_party/bnlib/Makefile deleted file mode 100644 index 9d0890ce82..0000000000 --- a/libs/libzrtp/third_party/bnlib/Makefile +++ /dev/null @@ -1,182 +0,0 @@ -# -# This code is pretty well tested, but not optimizing it will have -# a *major* effect on speed, so its optimzation flags are separate -# from the rest of the release. -# -# For the SPARC v8, at least, gcc produces a *much* faster library than -# the SunPro C compiler. On a 50 MHz TI TMS390Z50 SuperSPARC: -# 14.5 vs. 47.2 ms per 256-bit modular exponentiation. -# 77.4 vs. 317.8 ms per 512-bit modular exponentiation. -# 249.0 vs. 1031.5 ms per 1024-bit modular exponentiation -# -CC=gcc -# for libzrtp support -CFLAGS= -Wno-unused-parameter -fno-strict-aliasing -fPIC -DZRTP_AUTOMAKE=1 -DHAVE_CONFIG_H $(DEFINE) -I../../include -I../../include/enterprise -I../../projects/gnu/config -I../../third_party/bgaes -srcdir=. - - -# Extra object files (e.g. lbnalpha.o for Alpha assembly routines) -AUXOBJS= -# Extra definitions (e.g. -DBNINCLUDE=lbnalpha.h) -DEFINE= - -SHELL = /bin/sh -.SUFFIXES: -.SUFFIXES: .c .h .o .s - -LD =$(CC) -LDFLAGS = -LIBS= -RANLIB=ranlib - -# If you have a machine-specific assembly file, add it to AUXOBJS. -OBJS = bn00.o lbn00.o bn.o lbnmem.o sieve.o prime.o \ - bnprint.o jacobi.o germain.o $(AUXOBJS) - -BNLIB = libbn.a - -# for libzrtp support -all: $(BNLIB) bntest32.c bntest64.c -# bntest germtest - -# for libzrtp support -install: all - test -d /usr/local/include/libzrtp || mkdir /usr/local/include/libzrtp - cp *.h /usr/local/include/libzrtp - cp 'libbn.a' '/usr/local/lib/libbn.a' - chmod 644 /usr/local/lib/libbn.a - chown 0:0 /usr/local/lib/libbn.a - $(RANLIB) '/usr/local/lib/libbn.a' - -# for libzrtp support -#check: bntest -# ./bntest -check: - -bntest: bntest00.o $(BNLIB) - $(LD) $(LDFLAGS) -o $@ bntest00.o $(BNLIB) $(LIBS) - -germtest: germtest.o $(BNLIB) - $(LD) $(LDFLAGS) -o $@ germtest.o $(BNLIB) $(LIBS) - -$(BNLIB): $(OBJS) - $(AR) r $@ $? - $(RANLIB) $@ - -# Here we get tricky... if we're compiling with GCC, then GCCMAGIC1 and -# GCCMAGIC2 are set so that we actually do a link, but with the -r flag -# (produce relocatable output) and with -lgcc *only*. This is so that -# the result can be linked cleanly with code compiled with another cc, -# which doesn't know about -lgcc. Presumably the lbnXX.o file, which -# has by far the most math in it, will have a call to every interesting -# support-library function. - -lbn00.o: $(srcdir)/lbn00.c $(HDRS) bnconfig.h - $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ -Wl,-r -nostdlib lbn00.c -lgcc - -lbn16.o: $(srcdir)/lbn16.c $(HDRS) bnconfig.h - $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ -Wl,-r -nostdlib lbn16.c -lgcc - -lbn32.o: $(srcdir)/lbn32.c $(HDRS) bnconfig.h - $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ -Wl,-r -nostdlib lbn32.c -lgcc - -lbn64.o: $(srcdir)/lbn64.c $(HDRS) bnconfig.h - $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ -Wl,-r -nostdlib lbn64.c -lgcc - -# The default .o rule. -.c.o: bnconfig.h - $(CC) $(CPPFLAGS) $(CFLAGS) -I. -I$(srcdir) -o $@ -c $< - -# Extra, non-obvious dependencies. Bnlib can be compiled in three -# word sizes, and the *00.c files #include the right .c files based -# on , which means that a single compilation will only use a -# subset of these files. Duplicated here in case someone regenerates -# dependencies with cc -M and they get lost. - -lbn00.o: lbn16.c lbn32.c lbn64.c lbn16.h lbn32.h lbn64.h -bn00.o: bn16.c bn32.c bn64.c bn16.h bn32.h bn64.h \ - bninit16.c bninit32.c bninit64.c -bntest00.o: bntest16.c bntest32.c bntest64.c lbn16.h lbn32.h lbn64.h - -# Actual build commented out to prevent confusion by people without autoconf. -# Do it manually for now. -configure: configure.in - @echo "configure script is out of date; run autoconf" -# autoconf - -clean: - $(RM) -f *.o *32.[ch] *64.[ch] - -distclean: clean - -rm -f Makefile - -BNSOURCES = lbn32.c lbn32.h bn32.c bn32.h bninit32.c bntest32.c \ - lbn64.c lbn64.h bn64.c bn64.h bninit64.c bntest64.c - -# An explicit target that can be made before distribution for -# machines that don't have sed. -bnsources: $(BNSOURCES) - -# The 16-bit versions of the code are the master versions; all else is -# generated from them. This fiddling about makes them unwriteable -# to discourage improper edits. - -# (You didn't know that suffixes for suffix rules didn't have to begin -# with a period, did you?) -.SUFFIXES: 16.c 16.h 32.c 32.h 64.c 64.h -16.c32.c: - @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@ - sed -e s/32/64/g -e s/16/32/g $< > $@ - @chmod a-w $@ - -16.h32.h: - @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@ - sed -e s/32/64/g -e s/16/32/g $< > $@ - @chmod a-w $@ - -16.c64.c: - @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@ - sed -e s/32/128/g -e s/16/64/g $< > $@ - @chmod a-w $@ - -16.h64.h: - @test ! -f $@ -o -w $@ || chmod u+w $@ && test -w $@ || rm -f $@ - sed -e s/32/128/g -e s/16/64/g $< > $@ - @chmod a-w $@ - -### Dependencies -bn.o: bn.c bn.h -bn00.o: bn00.c bnsize00.h lbn.h bn16.c bn32.c bn64.c lbn16.c lbn32.h \ - lbn64.h lbnmem.h bn16.h bn32.h bn64.h bn.h kludge.h bninit16.c \ - bninit32.c bninit64.c -bn16.o: bn16.c lbn.h lbn16.h lbnmem.h bn16.h bn.h kludge.h -bn32.o: bn32.c lbn.h lbn32.h lbnmem.h bn32.h bn.h kludge.h -bn64.o: bn64.c lbn.h lbn64.h lbnmem.h bn64.h bn.h kludge.h -bn68000.o: bn68000.c lbn.h lbn68000.h bn16.h bn32.h -bn8086.o: bn8086.c lbn.h bn64.h lbn8086.h bn32.h -bninit16.o: bninit16.c bn.h bn16.h -bninit32.o: bninit32.c bn.h bn32.h -bninit64.o: bninit64.c bn.h bn64.h -bnprint.o: bnprint.c bn.h bnprint.h kludge.h -bntest00.o: bntest00.c bnsize00.h lbn.h bntest16.c bntest32.c \ - bntest64.c cputime.h lbn16.h lbn32.h lbn64.h kludge.h -bntest16.o: bntest16.c cputime.h lbn16.h lbn.h kludge.h -bntest32.o: bntest32.c cputime.h lbn32.h lbn.h kludge.h -bntest64.o: bntest64.c cputime.h lbn64.h lbn.h kludge.h -germain.o: germain.c bn.h germain.h jacobi.h lbnmem.h sieve.h kludge.h -germtest.o: germtest.c bn.h germain.h sieve.h cputime.h bnprint.h -jacobi.o: jacobi.c bn.h jacobi.h -lbn00.o: lbn00.c bnsize00.h lbn.h lbn16.c lbn16.h lbn32.c lbn32.h \ - lbn64.c lbn64.h lbnmem.h kludge.h -lbn16.o: lbn16.c lbn.h lbn16.h lbnmem.h kludge.h -lbn32.o: lbn32.c lbn.h lbn32.h lbnmem.h kludge.h -lbn64.o: lbn64.c lbn.h lbn64.h lbnmem.h kludge.h -lbn68000.o: lbn68000.c lbn.h lbn68000.h -lbn68020.o: lbn68020.c lbn.h lbn68020.h -lbnmem.o: lbnmem.c lbn.h lbnmem.h kludge.h -lbnppc.o: lbnppc.c lbnppc.h ppcasm.h -prime.o: prime.c bn.h lbnmem.h prime.h sieve.h kludge.h -sieve.o: sieve.c bn.h sieve.h kludge.h -sizetest.c: bnsize00.h - -distdir: diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index c35540c4f5..4c9b84cadf 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Thu Mar 1 10:03:45 CST 2012 +Wed Apr 4 16:17:37 CDT 2012 diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c b/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c index 523599c7a7..c1c4fd23df 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su_localinfo.c @@ -409,8 +409,10 @@ static int li_scope6(struct in6_addr const *ip6) { if (IN6_IS_ADDR_V4MAPPED(ip6) || IN6_IS_ADDR_V4COMPAT(ip6)) { - uint32_t ip4 = *(uint32_t *)(ip6->s6_addr + 12); - return li_scope4(ip4); + uint32_t *u = (uint32_t *)(ip6->s6_addr + 12); + + uint32_t ip4 = *u; + return li_scope4(ip4); } else if (IN6_IS_ADDR_LOOPBACK(ip6)) return LI_SCOPE_HOST; diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 87577caae1..185fdb64af 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -314,7 +314,8 @@ typedef enum { SCF_CLEAR_SQL = (1 << 17), SCF_THREADED_SYSTEM_EXEC = (1 << 18), SCF_SYNC_CLOCK_REQUESTED = (1 << 19), - SCF_CORE_ODBC_REQ = (1 << 20) + SCF_CORE_ODBC_REQ = (1 << 20), + SCF_DEBUG_SQL = (1 << 21) } switch_core_flag_enum_t; typedef uint32_t switch_core_flag_t; @@ -1743,7 +1744,8 @@ typedef enum { SCSC_PAUSE_CHECK, SCSC_READY_CHECK, SCSC_THREADED_SYSTEM_EXEC, - SCSC_SYNC_CLOCK_WHEN_IDLE + SCSC_SYNC_CLOCK_WHEN_IDLE, + SCSC_DEBUG_SQL, } switch_session_ctl_t; typedef enum { diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index 0d436fac2f..558b8522f4 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -214,7 +214,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_get(_In_ switch_xml_t xml,...); ///\param prn_header add header too ///\return the xml text string SWITCH_DECLARE(char *) switch_xml_toxml(_In_ switch_xml_t xml, _In_ switch_bool_t prn_header); - +SWITCH_DECLARE(char *) switch_xml_toxml_nolock(switch_xml_t xml, _In_ switch_bool_t prn_header); ///\brief Converts an switch_xml structure back to xml using the buffer passed in the parameters. ///\param xml the xml node ///\param buf buffer to use diff --git a/src/mod/.gitignore b/src/mod/.gitignore index f7a1c41eea..064b64c73d 100644 --- a/src/mod/.gitignore +++ b/src/mod/.gitignore @@ -14,6 +14,7 @@ /applications/mod_fax/mod_fax.log /applications/mod_fifo/Makefile /applications/mod_fsv/Makefile +/applications/mod_httapi/Makefile /applications/mod_limit/Makefile /applications/mod_sms/Makefile /applications/mod_spandsp/Makefile diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 287afa6d95..d82d5eb2d2 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1908,6 +1908,12 @@ SWITCH_STANDARD_API(ctl_function) } switch_core_session_ctl(command, &arg); stream->write_function(stream, "+OK\n"); + + } else if (!strcasecmp(argv[0], "debug_sql")) { + int x = 0; + switch_core_session_ctl(SCSC_DEBUG_SQL, &x); + stream->write_function(stream, "+OK SQL DEBUG [%s]\n", x ? "on" : "off"); + } else if (!strcasecmp(argv[0], "reclaim_mem")) { switch_core_session_ctl(SCSC_RECLAIM, &arg); stream->write_function(stream, "+OK\n"); @@ -5461,6 +5467,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add complete del"); switch_console_set_complete("add db_cache status"); switch_console_set_complete("add fsctl debug_level"); + switch_console_set_complete("add fsctl debug_sql"); switch_console_set_complete("add fsctl last_sps"); switch_console_set_complete("add fsctl default_dtmf_duration"); switch_console_set_complete("add fsctl hupall"); diff --git a/src/mod/applications/mod_esf/mod_esf.c b/src/mod/applications/mod_esf/mod_esf.c index 39952f2a8c..5dd4782519 100644 --- a/src/mod/applications/mod_esf/mod_esf.c +++ b/src/mod/applications/mod_esf/mod_esf.c @@ -226,7 +226,7 @@ SWITCH_STANDARD_APP(bcast_function) bytes = 16; switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes); - for (;;) { + while (switch_channel_ready(channel)) { status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); diff --git a/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt b/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt index 8690a62fc8..99970d88c9 100644 --- a/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt +++ b/src/mod/applications/mod_httapi/docs/mod_httapi_doc.txt @@ -319,7 +319,7 @@ user-agent : mod_httapi/1.0 User Agent header value. : * = default - + *set-params : tag can be parsed for session params. set-vars : tag can be parsed to set channel vars. diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index fba7736363..2c93cf02bd 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -1498,7 +1498,7 @@ static switch_status_t httapi_sync(client_t *client) switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); - if (method != NULL && strcasecmp(method, "get") && strcasecmp(method, "post")) { + if (!zstr(method)) { switch_curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, method); } diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index bedafc2e5e..6a6e8294ed 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -87,8 +87,8 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]) { -#if 0 - if (status >= 300 && sip && !sip->sip_retry_after && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) { + + if (status == 481 && sip && !sip->sip_retry_after && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) { char *sql; sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", sip->sip_call_id->i_id); @@ -96,7 +96,7 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status, sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); nua_handle_destroy(nh); } -#endif + } #define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri", #varprefix "_params") @@ -8282,8 +8282,10 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number); } } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Setting NAT mode based on %s\n", is_nat); + + if (is_nat) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Setting NAT mode based on %s\n", is_nat); + } if (app && data && !strcasecmp(app, "conference")) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 72267d7ea4..5786ec8f14 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -2439,11 +2439,22 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) switch (cid_type) { case CID_TYPE_PID: if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) { - tech_pvt->asserted_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"", use_name, use_number, rpid_domain); + if (zstr(tech_pvt->caller_profile->caller_id_name) || !strcasecmp(tech_pvt->caller_profile->caller_id_name, "_undef_")) { + tech_pvt->asserted_id = switch_core_session_sprintf(tech_pvt->session, "", + use_number, rpid_domain); + } else { + tech_pvt->asserted_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"", + use_name, use_number, rpid_domain); + } } else { - tech_pvt->preferred_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"", - tech_pvt->caller_profile->caller_id_name, - tech_pvt->caller_profile->caller_id_number, rpid_domain); + if (zstr(tech_pvt->caller_profile->caller_id_name) || !strcasecmp(tech_pvt->caller_profile->caller_id_name, "_undef_")) { + tech_pvt->preferred_id = switch_core_session_sprintf(tech_pvt->session, "", + tech_pvt->caller_profile->caller_id_number, rpid_domain); + } else { + tech_pvt->preferred_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"", + tech_pvt->caller_profile->caller_id_name, + tech_pvt->caller_profile->caller_id_number, rpid_domain); + } } if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) { @@ -2604,8 +2615,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)), TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)), TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)), - TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_IF(!zstr(recover_via), SIPTAG_VIA_STR(recover_via)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_IF(!zstr(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)), TAG_IF(!zstr(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)), TAG_IF(!zstr(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)), @@ -2638,8 +2649,8 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)), TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)), TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)), - TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_IF(!zstr(recover_via), SIPTAG_VIA_STR(recover_via)), + TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_IF(!zstr(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)), TAG_IF(!zstr(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)), TAG_IF(!zstr(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)), @@ -3881,13 +3892,25 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha if (zstr(attr->a_name)) { continue; } - if (!strcasecmp(attr->a_name, "ptime")) { dptime = atoi(attr->a_value); break; } } + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Looking for zrtp-hash to set sdp_zrtp_hash_string\n"); + for (m = sdp->sdp_media; m; m = m->m_next) { + for (attr = m->m_attributes; attr; attr = attr->a_next) { + if (zstr(attr->a_name)) continue; + if (!strcasecmp(attr->a_name, "zrtp-hash") && attr->a_value) { + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Found zrtp-hash, setting sdp_zrtp_hash_string=%s\n", attr->a_value); + switch_channel_set_variable(channel, "sdp_zrtp_hash_string", attr->a_value); + switch_channel_set_flag(channel, CF_ZRTP_HASH); + break; + } + } + } + for (m = sdp->sdp_media; m; m = m->m_next) { ptime = dptime; if (m->m_type == sdp_media_image && m->m_port) { @@ -5948,7 +5971,7 @@ void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *sess } if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { - xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE); + xml_cdr_text = switch_xml_toxml_nolock(cdr, SWITCH_FALSE); switch_xml_free(cdr); } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 56f7ef7b00..7b85161da3 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -2101,7 +2101,8 @@ void sofia_reg_handle_sip_r_challenge(int status, } else if (gateway) { switch_snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->auth_username, gateway->register_password); } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot locate any authentication credentials to complete an authentication request for realm '%s'\n", realm); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, + "Cannot locate any authentication credentials to complete an authentication request for realm '%s'\n", realm); goto cancel; } @@ -2114,7 +2115,9 @@ void sofia_reg_handle_sip_r_challenge(int status, tl_gets(tags, NUTAG_CALLSTATE_REF(ss_state), SIPTAG_WWW_AUTHENTICATE_REF(authenticate), TAG_END()); - nua_authenticate(nh, SIPTAG_EXPIRES_STR(gateway ? gateway->expires_str : "3600"), NUTAG_AUTH(authentication), TAG_END()); + nua_authenticate(nh, + TAG_IF(sofia_private && sofia_private->gateway, SIPTAG_EXPIRES_STR(gateway ? gateway->expires_str : "3600")), + NUTAG_AUTH(authentication), TAG_END()); goto end; diff --git a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c index aad224655c..4370ee7f91 100644 --- a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c +++ b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c @@ -181,60 +181,61 @@ static switch_status_t set_json_cdr_log_dirs() return status; } +#define json_object_safe_new_string(str) json_object_new_string(str ? str : "") #define JSON_ENSURE_SUCCESS(obj) if (is_error(obj)) { return; } static void set_json_profile_data(struct json_object *json, switch_caller_profile_t *caller_profile) { struct json_object *param = NULL; - param = json_object_new_string((char *)caller_profile->username); + param = json_object_safe_new_string((char *)caller_profile->username); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "username", param); - param = json_object_new_string((char *)caller_profile->dialplan); + param = json_object_safe_new_string((char *)caller_profile->dialplan); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "dialplan", param); - param = json_object_new_string((char *)caller_profile->caller_id_name); + param = json_object_safe_new_string((char *)caller_profile->caller_id_name); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "caller_id_name", param); - param = json_object_new_string((char *)caller_profile->ani); + param = json_object_safe_new_string((char *)caller_profile->ani); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "ani", param); - param = json_object_new_string((char *)caller_profile->aniii); + param = json_object_safe_new_string((char *)caller_profile->aniii); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "aniii", param); - param = json_object_new_string((char *)caller_profile->caller_id_number); + param = json_object_safe_new_string((char *)caller_profile->caller_id_number); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "caller_id_number", param); - param = json_object_new_string((char *)caller_profile->network_addr); + param = json_object_safe_new_string((char *)caller_profile->network_addr); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "network_addr", param); - param = json_object_new_string((char *)caller_profile->rdnis); + param = json_object_safe_new_string((char *)caller_profile->rdnis); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "rdnis", param); - param = json_object_new_string(caller_profile->destination_number); + param = json_object_safe_new_string(caller_profile->destination_number); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "destination_number", param); - param = json_object_new_string(caller_profile->uuid); + param = json_object_safe_new_string(caller_profile->uuid); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "uuid", param); - param = json_object_new_string((char *)caller_profile->source); + param = json_object_safe_new_string((char *)caller_profile->source); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "source", param); - param = json_object_new_string((char *)caller_profile->context); + param = json_object_safe_new_string((char *)caller_profile->context); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "context", param); - param = json_object_new_string(caller_profile->chan_name); + param = json_object_safe_new_string(caller_profile->chan_name); JSON_ENSURE_SUCCESS(param); json_object_object_add(json, "chan_name", param); @@ -260,7 +261,7 @@ static void set_json_chan_vars(struct json_object *json, switch_channel_t *chann } } - variable = json_object_new_string(data); + variable = json_object_safe_new_string(data); if (!is_error(variable)) { json_object_object_add(json, hi->name, variable); } @@ -297,10 +298,10 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct json_object_object_add(cdr, "channel_data", j_channel_data); - j_field = json_object_new_string((char *) switch_channel_state_name(switch_channel_get_state(channel))); + j_field = json_object_safe_new_string((char *) switch_channel_state_name(switch_channel_get_state(channel))); json_object_object_add(j_channel_data, "state", j_field); - j_field = json_object_new_string(switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound"); + j_field = json_object_safe_new_string(switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound"); json_object_object_add(j_channel_data, "direction", j_field); @@ -311,13 +312,13 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct if ((f = switch_channel_get_flag_string(channel))) { - j_field = json_object_new_string((char *) f); + j_field = json_object_safe_new_string((char *) f); json_object_object_add(j_channel_data, "flags", j_field); free(f); } if ((f = switch_channel_get_cap_string(channel))) { - j_field = json_object_new_string((char *) f); + j_field = json_object_safe_new_string((char *) f); json_object_object_add(j_channel_data, "caps", j_field); free(f); } @@ -351,8 +352,8 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct goto error; } - json_object_object_add(j_application, "app_name", json_object_new_string(ap->app)); - json_object_object_add(j_application, "app_data", json_object_new_string(ap->arg ? ap->arg : "")); + json_object_object_add(j_application, "app_name", json_object_safe_new_string(ap->app)); + json_object_object_add(j_application, "app_data", json_object_safe_new_string(ap->arg)); json_object_object_add(j_apps, "application", j_application); } @@ -372,11 +373,11 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct json_object_object_add(cdr, "callflow", j_callflow); if (!zstr(caller_profile->dialplan)) { - json_object_object_add(j_callflow, "dialplan", json_object_new_string((char *)caller_profile->dialplan)); + json_object_object_add(j_callflow, "dialplan", json_object_safe_new_string((char *)caller_profile->dialplan)); } if (!zstr(caller_profile->profile_index)) { - json_object_object_add(j_callflow, "profile_index", json_object_new_string((char *)caller_profile->profile_index)); + json_object_object_add(j_callflow, "profile_index", json_object_safe_new_string((char *)caller_profile->profile_index)); } if (caller_profile->caller_extension) { @@ -390,11 +391,11 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct json_object_object_add(j_callflow, "extension", j_caller_extension); - json_object_object_add(j_caller_extension, "name", json_object_new_string(caller_profile->caller_extension->extension_name)); - json_object_object_add(j_caller_extension, "number", json_object_new_string(caller_profile->caller_extension->extension_number)); + json_object_object_add(j_caller_extension, "name", json_object_safe_new_string(caller_profile->caller_extension->extension_name)); + json_object_object_add(j_caller_extension, "number", json_object_safe_new_string(caller_profile->caller_extension->extension_number)); if (caller_profile->caller_extension->current_application) { - json_object_object_add(j_caller_extension, "current_app", json_object_new_string(caller_profile->caller_extension->current_application->application_name)); + json_object_object_add(j_caller_extension, "current_app", json_object_safe_new_string(caller_profile->caller_extension->current_application->application_name)); } for (ap = caller_profile->caller_extension->applications; ap; ap = ap->next) { @@ -410,8 +411,8 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct if (ap == caller_profile->caller_extension->current_application) { json_object_object_add(j_application, "last_executed", json_object_new_string("true")); } - json_object_object_add(j_application, "app_name", json_object_new_string(ap->application_name)); - json_object_object_add(j_application, "app_data", json_object_new_string(switch_str_nil(ap->application_data))); + json_object_object_add(j_application, "app_name", json_object_safe_new_string(ap->application_name)); + json_object_object_add(j_application, "app_data", json_object_safe_new_string(switch_str_nil(ap->application_data))); } if (caller_profile->caller_extension->children) { @@ -437,13 +438,13 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct json_object_object_add(j_inner_extension, "extension", j_caller_extension); - json_object_object_add(j_caller_extension, "name", json_object_new_string(cp->caller_extension->extension_name)); - json_object_object_add(j_caller_extension, "number", json_object_new_string(cp->caller_extension->extension_number)); + json_object_object_add(j_caller_extension, "name", json_object_safe_new_string(cp->caller_extension->extension_name)); + json_object_object_add(j_caller_extension, "number", json_object_safe_new_string(cp->caller_extension->extension_number)); - json_object_object_add(j_caller_extension, "dialplan", json_object_new_string((char *)cp->dialplan)); + json_object_object_add(j_caller_extension, "dialplan", json_object_safe_new_string((char *)cp->dialplan)); if (cp->caller_extension->current_application) { - json_object_object_add(j_caller_extension, "current_app", json_object_new_string(cp->caller_extension->current_application->application_name)); + json_object_object_add(j_caller_extension, "current_app", json_object_safe_new_string(cp->caller_extension->current_application->application_name)); } for (ap = cp->caller_extension->applications; ap; ap = ap->next) { @@ -457,8 +458,8 @@ static switch_status_t generate_json_cdr(switch_core_session_t *session, struct if (ap == cp->caller_extension->current_application) { json_object_object_add(j_application, "last_executed", json_object_new_string("true")); } - json_object_object_add(j_application, "app_name", json_object_new_string(ap->application_name)); - json_object_object_add(j_application, "app_data", json_object_new_string(switch_str_nil(ap->application_data))); + json_object_object_add(j_application, "app_name", json_object_safe_new_string(ap->application_name)); + json_object_object_add(j_application, "app_data", json_object_safe_new_string(switch_str_nil(ap->application_data))); } } } diff --git a/src/mod/timers/mod_posix_timer/test/Makefile b/src/mod/timers/mod_posix_timer/test/Makefile new file mode 100644 index 0000000000..856345298b --- /dev/null +++ b/src/mod/timers/mod_posix_timer/test/Makefile @@ -0,0 +1,6 @@ +all: + gcc ../mod_posix_timer.c main.c switch.c -I. -o timer_test -lpthread -lrt -g -DLOG_LEVEL=-1 + +clean: + -rm timer_test + diff --git a/src/mod/timers/mod_posix_timer/test/README b/src/mod/timers/mod_posix_timer/test/README new file mode 100644 index 0000000000..f47c511272 --- /dev/null +++ b/src/mod/timers/mod_posix_timer/test/README @@ -0,0 +1,2 @@ +Stress test for mod_posix_timer. Runs without FreeSWITCH. + diff --git a/src/mod/timers/mod_posix_timer/test/main.c b/src/mod/timers/mod_posix_timer/test/main.c new file mode 100644 index 0000000000..1df054566d --- /dev/null +++ b/src/mod/timers/mod_posix_timer/test/main.c @@ -0,0 +1,44 @@ + +#include +#include + +extern SWITCH_MODULE_LOAD_FUNCTION(mod_posix_timer_load); +extern SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_posix_timer_shutdown); + +switch_loadable_module_interface_t *mod = NULL; +switch_memory_pool_t pool = { 0 }; + +int main (int argc, char **argv) +{ + int i; + switch_timer_interface_t *timer_if; + switch_timer_t *timer[1000]; + + mod_posix_timer_load(&mod, &pool); + timer_if = mod->timer; + + + // TODO create multi-threaded test + + // create 10 ms timers + for (i = 0; i < 1000; i++) { + timer[i] = malloc(sizeof(switch_timer_t)); + memset(timer[i], 0, sizeof(switch_timer_t)); + timer[i]->interval = 1; + timer[i]->samples = 8; + timer_if->timer_init(timer[i]); + } + + for (i = 0; i < 50000; i++) { + timer_if->timer_next(timer[0]); + } + + // destroy timers + for (i = 0; i < 1000; i++) { + timer_if->timer_destroy(timer[i]); + free(timer[i]); + } + + mod_posix_timer_shutdown(); + return 0; +} diff --git a/src/mod/timers/mod_posix_timer/test/switch.c b/src/mod/timers/mod_posix_timer/test/switch.c new file mode 100644 index 0000000000..7ac7a3a97c --- /dev/null +++ b/src/mod/timers/mod_posix_timer/test/switch.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include + + +switch_loadable_module_interface_t * switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name) +{ + return malloc(sizeof(switch_loadable_module_interface_t)); +} + +void * switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, int iname) +{ + mod->timer = malloc(sizeof(switch_timer_interface_t)); + return mod->timer; +} + +switch_status_t switch_mutex_lock(switch_mutex_t *mutex) +{ + return pthread_mutex_lock(mutex); +} + +switch_status_t switch_mutex_unlock(switch_mutex_t *mutex) +{ + return pthread_mutex_unlock(mutex); +} + +switch_status_t switch_mutex_init(switch_mutex_t **mutex, int flags, switch_memory_pool_t *pool) +{ + pthread_mutexattr_t atts = { 0 }; + pthread_mutexattr_init(&atts); + if (flags == SWITCH_MUTEX_NESTED) { + pthread_mutexattr_settype(&atts, PTHREAD_MUTEX_RECURSIVE_NP); + } + *mutex = malloc(sizeof(switch_mutex_t)); + return pthread_mutex_init(*mutex, &atts); +} + +switch_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool) +{ + *cond = malloc(sizeof(switch_thread_cond_t)); + return pthread_cond_init(*cond, NULL); +} + +switch_status_t switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex, int wait) +{ + struct timespec dur = { 0, 0 }; + clock_gettime(CLOCK_REALTIME, &dur); + dur.tv_sec = wait / 1000000000; + dur.tv_nsec = wait % 1000000000; + return pthread_cond_timedwait(cond, mutex, &dur); +} + +switch_status_t switch_thread_cond_broadcast(switch_thread_cond_t *cond) +{ + return pthread_cond_broadcast(cond); +} + +void switch_log_printf(int dummy, int level, char *format, ...) +{ + va_list vl; + va_start(vl, format); + if (level > LOG_LEVEL) { + vprintf(format, vl); + } + va_end(vl); +} + + diff --git a/src/mod/timers/mod_posix_timer/test/switch.h b/src/mod/timers/mod_posix_timer/test/switch.h new file mode 100644 index 0000000000..25391943fb --- /dev/null +++ b/src/mod/timers/mod_posix_timer/test/switch.h @@ -0,0 +1,122 @@ +#ifndef SWITCH_H +#define SWITCH_H + +#include +#include +#include +#include + +#define SWITCH_STATUS_SUCCESS 0 +#define SWITCH_STATUS_GENERR 1 +#define SWITCH_STATUS_FALSE 2 + +#define SWITCH_MUTEX_NESTED 1 + +#define SWITCH_CHANNEL_LOG 0 + +#define SWITCH_LOG_INFO 0 + +typedef int switch_status_t; +typedef size_t switch_size_t; +typedef pthread_mutex_t switch_mutex_t; +typedef pthread_cond_t switch_thread_cond_t; +typedef int switch_memory_pool_t; +typedef int switch_bool_t; + +#define SWITCH_TIMER_INTERFACE 0 + +typedef struct switch_loadable_module_interface switch_loadable_module_interface_t; +typedef struct switch_timer_interface switch_timer_interface_t; + +typedef int switch_module_flag_t; +#define SWITCH_API_VERSION 0 +#define SWITCH_MOD_DECLARE_DATA +#define SMODF_NONE 0 +#define SWITCH_MODULE_LOAD_ARGS (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) +#define SWITCH_MODULE_RUNTIME_ARGS (void) +#define SWITCH_MODULE_SHUTDOWN_ARGS (void) +typedef switch_status_t (*switch_module_load_t) SWITCH_MODULE_LOAD_ARGS; +typedef switch_status_t (*switch_module_runtime_t) SWITCH_MODULE_RUNTIME_ARGS; +typedef switch_status_t (*switch_module_shutdown_t) SWITCH_MODULE_SHUTDOWN_ARGS; +#define SWITCH_MODULE_LOAD_FUNCTION(name) switch_status_t name SWITCH_MODULE_LOAD_ARGS +#define SWITCH_MODULE_RUNTIME_FUNCTION(name) switch_status_t name SWITCH_MODULE_RUNTIME_ARGS +#define SWITCH_MODULE_SHUTDOWN_FUNCTION(name) switch_status_t name SWITCH_MODULE_SHUTDOWN_ARGS +typedef struct switch_loadable_module_function_table { + int switch_api_version; + switch_module_load_t load; + switch_module_shutdown_t shutdown; + switch_module_runtime_t runtime; + switch_module_flag_t flags; +} switch_loadable_module_function_table_t; + +#define SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, flags) \ +static const char modname[] = #name ; \ +SWITCH_MOD_DECLARE_DATA switch_loadable_module_function_table_t name##_module_interface = { \ + SWITCH_API_VERSION, \ + load, \ + shutdown, \ + runtime, \ + flags \ +} + +#define SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime) \ + SWITCH_MODULE_DEFINITION_EX(name, load, shutdown, runtime, SMODF_NONE) + + + +switch_loadable_module_interface_t * switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name); + +typedef struct { + int id; + int interval; + int tick; + int samplecount; + int samples; + int diff; + void *private_info; +} switch_timer_t; + + +/*! \brief A table of functions that a timer module implements */ +struct switch_timer_interface { + /*! the name of the interface */ + const char *interface_name; + /*! function to allocate the timer */ + switch_status_t (*timer_init) (switch_timer_t *); + /*! function to wait for one cycle to pass */ + switch_status_t (*timer_next) (switch_timer_t *); + /*! function to step the timer one step */ + switch_status_t (*timer_step) (switch_timer_t *); + /*! function to reset the timer */ + switch_status_t (*timer_sync) (switch_timer_t *); + /*! function to check if the current step has expired */ + switch_status_t (*timer_check) (switch_timer_t *, switch_bool_t); + /*! function to deallocate the timer */ + switch_status_t (*timer_destroy) (switch_timer_t *); + int refs; + switch_mutex_t *reflock; + switch_loadable_module_interface_t *parent; + struct switch_timer_interface *next; +}; + +struct switch_loadable_module_interface { + switch_timer_interface_t *timer; +}; + +void * switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, int iname); + +switch_status_t switch_mutex_lock(switch_mutex_t *mutex); + +switch_status_t switch_mutex_unlock(switch_mutex_t *mutex); + +switch_status_t switch_mutex_init(switch_mutex_t **mutex, int flags, switch_memory_pool_t *pool); + +switch_status_t switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool); + +switch_status_t switch_thread_cond_timedwait(switch_thread_cond_t *cond, switch_mutex_t *mutex, int wait); + +switch_status_t switch_thread_cond_broadcast(switch_thread_cond_t *cond); + +void switch_log_printf(int dummy, int level, char *format, ...); + +#endif diff --git a/src/switch_channel.c b/src/switch_channel.c index c3970ea8e2..b15b0948a7 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1380,7 +1380,7 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw for (;;) { if ((channel->state < CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) || - (other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down_nosig(channel)) { + (other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down(channel)) { break; } switch_yield(20000); @@ -1399,6 +1399,8 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *cha break; } + switch_channel_check_signal(channel, SWITCH_TRUE); + switch_cond_next(); if (++count >= timeout) { @@ -1866,12 +1868,11 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state( switch_channel_clear_flag(channel, CF_TAGGED); - - switch_mutex_lock(channel->state_mutex); - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n", channel->name, state_names[state]); + switch_mutex_lock(channel->state_mutex); + channel->running_state = state; if (state == CS_ROUTING || state == CS_HANGUP) { diff --git a/src/switch_core.c b/src/switch_core.c index 19de186fc7..4eeb02e447 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1875,6 +1875,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t runtime.runlevel++; switch_core_set_signal_handlers(); + switch_load_network_lists(SWITCH_FALSE); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bringing up environment.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Loading Modules.\n"); @@ -1884,7 +1885,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t return SWITCH_STATUS_GENERR; } - switch_load_network_lists(SWITCH_FALSE); + switch_load_core_config("post_load_switch.conf"); @@ -2014,6 +2015,17 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, void * } switch (cmd) { + case SCSC_DEBUG_SQL: + { + if (switch_test_flag((&runtime), SCF_DEBUG_SQL)) { + switch_clear_flag((&runtime), SCF_DEBUG_SQL); + newintval = 0; + } else { + switch_set_flag((&runtime), SCF_DEBUG_SQL); + newintval = 1; + } + } + break; case SCSC_VERBOSE_EVENTS: if (intval) { if (oldintval > -1) { diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 8b147327a2..952b345e67 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -41,7 +41,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor switch_io_event_hook_video_write_frame_t *ptr; switch_status_t status = SWITCH_STATUS_FALSE; - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -65,7 +65,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core switch_assert(session != NULL); - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -153,7 +153,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi } } - if (switch_channel_down_nosig(session->channel) || !switch_core_codec_ready(session->read_codec)) { + if (switch_channel_down(session->channel) || !switch_core_codec_ready(session->read_codec)) { *frame = NULL; status = SWITCH_STATUS_FALSE; goto even_more_done; @@ -1114,7 +1114,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess while (switch_buffer_inuse(session->raw_write_buffer) >= session->write_impl.decoded_bytes_per_packet) { int rate; - if (switch_channel_down_nosig(session->channel) || !session->raw_write_buffer) { + if (switch_channel_down(session->channel) || !session->raw_write_buffer) { goto error; } if ((session->raw_write_frame.datalen = (uint32_t) @@ -1296,7 +1296,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(switch_core_sessio switch_dtmf_t new_dtmf; int fed = 0; - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -1339,7 +1339,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(switch_core_sessio switch_status_t status = SWITCH_STATUS_FALSE; switch_dtmf_t new_dtmf; - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } @@ -1418,7 +1418,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core dtmf.flags = 0; } - if (switch_channel_down_nosig(session->channel)) { + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; } diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 0082b7b4ef..fa4c9cf3a4 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -34,7 +34,7 @@ #include #include "private/switch_core_pvt.h" -//#define DEBUG_SQL 1 + #define SWITCH_SQL_QUEUE_LEN 100000 #define SWITCH_SQL_QUEUE_PAUSE_LEN 90000 @@ -1019,11 +1019,11 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, if (new_mlen < runtime.max_sql_buffer_len) { sql_len = new_mlen; -#ifdef DEBUG_SQL - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "REALLOC %ld %d %d\n", (long int)sql_len, switch_queue_size(sql_manager.sql_queue[0]), - switch_queue_size(sql_manager.sql_queue[1])); -#endif + if (switch_test_flag((&runtime), SCF_DEBUG_SQL)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "REALLOC %ld %d %d\n", (long int)sql_len, switch_queue_size(sql_manager.sql_queue[0]), + switch_queue_size(sql_manager.sql_queue[1])); + } if (!(tmp = realloc(sqlbuf, sql_len))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread ending on mem err\n"); abort(); @@ -1031,10 +1031,10 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, } sqlbuf = tmp; } else { -#ifdef DEBUG_SQL - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "SAVE %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1])); -#endif + if (switch_test_flag((&runtime), SCF_DEBUG_SQL)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "SAVE %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1])); + } save_sql = sql; sql = NULL; lc = 0; @@ -1077,16 +1077,16 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, wrote = 0; if (trans && iterations && (iterations > target || !lc)) { -#ifdef DEBUG_SQL - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "RUN %d %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1]), iterations); -#endif + if (switch_test_flag((&runtime), SCF_DEBUG_SQL)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "RUN %d %d %d\n", switch_queue_size(sql_manager.sql_queue[0]), switch_queue_size(sql_manager.sql_queue[1]), iterations); + } if (switch_cache_db_persistant_execute_trans(sql_manager.event_db, sqlbuf, 1) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread unable to commit transaction, records lost!\n"); } -#ifdef DEBUG_SQL - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DONE\n"); -#endif + if (switch_test_flag((&runtime), SCF_DEBUG_SQL)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DONE\n"); + } iterations = 0; @@ -1628,10 +1628,7 @@ static char create_channels_sql[] = " call_uuid VARCHAR(256),\n" " sent_callee_name VARCHAR(1024),\n" " sent_callee_num VARCHAR(256)\n" - ");\n" - "create index chidx1 on channels (hostname);\n" - "create index uuindex on channels (uuid);\n" - "create index uuindex2 on channels (call_uuid);\n"; + ");\n"; static char create_calls_sql[] = "CREATE TABLE calls (\n" @@ -1641,11 +1638,7 @@ static char create_calls_sql[] = " caller_uuid VARCHAR(256),\n" " callee_uuid VARCHAR(256),\n" " hostname VARCHAR(256)\n" - ");\n" - "create index callsidx1 on calls (hostname);\n" - "create index eruuindex on calls (caller_uuid);\n" - "create index eeuuindex on calls (callee_uuid);\n" - "create index eeuuindex2 on calls (call_uuid);\n"; + ");\n"; static char create_interfaces_sql[] = "CREATE TABLE interfaces (\n" @@ -1688,8 +1681,8 @@ static char create_registrations_sql[] = " network_port VARCHAR(256),\n" " network_proto VARCHAR(256),\n" " hostname VARCHAR(256)\n" - ");\n" - "create index regindex1 on registrations (reg_user,realm,hostname);\n"; + ");\n"; + @@ -2051,6 +2044,15 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_ switch_cache_db_execute_sql(dbh, "create index nat_map_port_proto on nat (port,proto,hostname)", NULL); switch_cache_db_execute_sql(dbh, "create index channels1 on channels(hostname)", NULL); switch_cache_db_execute_sql(dbh, "create index calls1 on calls(hostname)", NULL); + switch_cache_db_execute_sql(dbh, "create index chidx1 on channels (hostname)", NULL); + switch_cache_db_execute_sql(dbh, "create index uuindex on channels (uuid)", NULL); + switch_cache_db_execute_sql(dbh, "create index uuindex2 on channels (call_uuid)", NULL); + switch_cache_db_execute_sql(dbh, "create index callsidx1 on calls (hostname)", NULL); + switch_cache_db_execute_sql(dbh, "create index eruuindex on calls (caller_uuid)", NULL); + switch_cache_db_execute_sql(dbh, "create index eeuuindex on calls (callee_uuid)", NULL); + switch_cache_db_execute_sql(dbh, "create index eeuuindex2 on calls (call_uuid)", NULL); + switch_cache_db_execute_sql(dbh, "create index regindex1 on registrations (reg_user,realm,hostname)", NULL); + skip: diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 955f7b50d6..1814fb70e4 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1556,7 +1556,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi } switch_core_session_receive_message(other_session, &msg); switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL); - switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL); + //switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL); switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL); } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 06dc31e1cb..b75549c417 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -776,7 +776,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio state = switch_channel_get_state(other_channel); running_state = switch_channel_get_running_state(other_channel); - if (switch_channel_down_nosig(other_channel) || switch_channel_down_nosig(channel)) { + if (switch_channel_down_nosig(other_channel) || switch_channel_down(channel)) { break; } diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index b4178e9e85..a29f4c6f22 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -2181,6 +2181,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session } } + switch_channel_audio_sync(channel); + ilen = len; for (;;) { switch_event_t *event; @@ -2346,7 +2348,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session } } } - } done: @@ -2377,8 +2378,12 @@ SWITCH_DECLARE(void) switch_ivr_clear_speech_cache(switch_core_session_t *sessio if (cache_obj->timer.interval) { switch_core_timer_destroy(&cache_obj->timer); } - switch_core_speech_close(&cache_obj->sh, &flags); - switch_core_codec_destroy(&cache_obj->codec); + if (&cache_obj->sh && cache_obj->sh.speech_interface) { + switch_core_speech_close(&cache_obj->sh, &flags); + } + if (&cache_obj->codec) { + switch_core_codec_destroy(&cache_obj->codec); + } switch_channel_set_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME, NULL); } } @@ -2412,7 +2417,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses timer = <imer; if ((var = switch_channel_get_variable(channel, SWITCH_CACHE_SPEECH_HANDLES_VARIABLE)) && switch_true(var)) { - if ((cache_obj = switch_channel_get_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME))) { + if ((cache_obj = (cached_speech_handle_t *) switch_channel_get_private(channel, SWITCH_CACHE_SPEECH_HANDLES_OBJ_NAME))) { need_create = 0; if (!strcasecmp(cache_obj->tts_name, tts_name)) { need_alloc = 0; @@ -2422,7 +2427,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses } if (!cache_obj) { - cache_obj = switch_core_session_alloc(session, sizeof(*cache_obj)); + cache_obj = (cached_speech_handle_t *) switch_core_session_alloc(session, sizeof(*cache_obj)); } if (need_alloc) { switch_copy_string(cache_obj->tts_name, tts_name, sizeof(cache_obj->tts_name)); diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 5e741c4eb7..932485eae7 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -71,7 +71,7 @@ static switch_mutex_t *port_lock = NULL; typedef srtp_hdr_t rtp_hdr_t; #ifdef ENABLE_ZRTP -#include +#include "zrtp.h" static zrtp_global_t *zrtp_global; static zrtp_zid_t zid = { "FreeSWITCH01" }; static int zrtp_on = 0; diff --git a/src/switch_xml.c b/src/switch_xml.c index 2c687839c8..ce85efad4c 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -2451,12 +2451,22 @@ static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, } } +SWITCH_DECLARE(char *) switch_xml_toxml_nolock(switch_xml_t xml, switch_bool_t prn_header) +{ + char *s = (char *) malloc(SWITCH_XML_BUFSIZE); + switch_assert(s); + return switch_xml_toxml_buf(xml, s, SWITCH_XML_BUFSIZE, 0, prn_header); +} + + SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml, switch_bool_t prn_header) { char *r, *s; - switch_mutex_lock(XML_GEN_LOCK); + s = (char *) malloc(SWITCH_XML_BUFSIZE); switch_assert(s); + + switch_mutex_lock(XML_GEN_LOCK); r = switch_xml_toxml_buf(xml, s, SWITCH_XML_BUFSIZE, 0, prn_header); switch_mutex_unlock(XML_GEN_LOCK); return r;