Merge branch 'master' into smgmaster
This commit is contained in:
commit
c58a3db915
|
@ -11,10 +11,6 @@
|
|||
.deps
|
||||
.\#*
|
||||
\#*
|
||||
/Debug/
|
||||
/Release/
|
||||
/All/
|
||||
/bin/
|
||||
*.user
|
||||
*.suo
|
||||
*.ncb
|
||||
|
@ -39,105 +35,115 @@
|
|||
*.xz
|
||||
*.bz2
|
||||
*.tbz2
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.cache
|
||||
configure.lineno
|
||||
config.log
|
||||
config.status
|
||||
core.*
|
||||
/Path
|
||||
|
||||
/w32/Library/lastversion
|
||||
/w32/Library/tmpVersion.Bat
|
||||
!/w32/Console/FreeSwitchConsole.vcproj.user
|
||||
!/w32/Setup/inno_setup/vcredist_x64.exe
|
||||
!/w32/Setup/inno_setup/vcredist_x86.exe
|
||||
.version
|
||||
AUTHORS
|
||||
COPYING
|
||||
ChangeLog
|
||||
Makefile
|
||||
Makefile.in
|
||||
NEWS
|
||||
README
|
||||
TAGS
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
build/Makefile
|
||||
build/Makefile.in
|
||||
build/config/compile
|
||||
build/config/config.guess
|
||||
build/config/depcomp
|
||||
build/config/install-sh
|
||||
build/config/ltmain.sh
|
||||
build/config/missing
|
||||
build/freeswitch.pc
|
||||
build/getlib.sh
|
||||
build/getsounds.sh
|
||||
build/modmake.rules
|
||||
build/getg729.sh
|
||||
config.cache
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
configure.lineno
|
||||
freeswitch
|
||||
fs_cli
|
||||
fs_encode
|
||||
fs_ivrd
|
||||
libtool
|
||||
noreg
|
||||
modules.conf
|
||||
quiet_libtool
|
||||
tone2wav
|
||||
scripts/fsxs
|
||||
scripts/gentls_cert
|
||||
a.out.dSYM
|
||||
src/mod/applications/mod_easyroute/Makefile
|
||||
src/mod/applications/mod_lcr/Makefile
|
||||
src/mod/applications/mod_nibblebill/Makefile
|
||||
src/mod/applications/mod_rss/Makefile
|
||||
src/mod/applications/mod_snipe_hunt/Makefile
|
||||
src/mod/codecs/mod_dahdi_codec/Makefile
|
||||
src/mod/dialplans/mod_dialplan_directory/Makefile
|
||||
src/mod/formats/mod_shell_stream/Makefile
|
||||
src/mod/say/mod_say_de/Makefile
|
||||
src/mod/say/mod_say_es/Makefile
|
||||
src/mod/say/mod_say_fr/Makefile
|
||||
src/mod/say/mod_say_it/Makefile
|
||||
src/mod/say/mod_say_nl/Makefile
|
||||
src/mod/say/mod_say_th/Makefile
|
||||
src/mod/say/mod_say_zh/Makefile
|
||||
libs/curl/lib/ca-bundle.h
|
||||
libs/g729/
|
||||
libs/fsg729-*-installer
|
||||
src/mod/codecs/mod_com_g729/
|
||||
src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig
|
||||
src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig
|
||||
src/mod/languages/mod_python/mod_python_wrap.cpp.orig
|
||||
libs/freetdm/detect_dtmf
|
||||
libs/freetdm/detect_tones
|
||||
libs/freetdm/testanalog
|
||||
libs/freetdm/testapp
|
||||
libs/freetdm/testcid
|
||||
libs/freetdm/testpri
|
||||
libs/freetdm/testr2
|
||||
libs/freetdm/testsangomaboost
|
||||
libs/freetdm/testtones
|
||||
libs/esl/fs_cli
|
||||
libs/esl/ivrd
|
||||
libs/esl/testserver
|
||||
libs/esl/testclient
|
||||
libs/libcodec2/Makefile
|
||||
libs/libcodec2/Makefile.in
|
||||
libs/libcodec2/config.guess
|
||||
libs/libcodec2/config.sub
|
||||
libs/libcodec2/configure
|
||||
libs/libcodec2/depcomp
|
||||
libs/libcodec2/install-sh
|
||||
libs/libcodec2/libtool
|
||||
libs/libcodec2/ltmain.sh
|
||||
libs/libcodec2/missing
|
||||
libs/libcodec2/src/Makefile
|
||||
libs/libcodec2/src/Makefile.in
|
||||
libs/libcodec2/unittest/Makefile
|
||||
libs/libcodec2/unittest/Makefile.in
|
||||
src/mod/applications/mod_osp/Makefile
|
||||
src/mod/applications/mod_osp/Makefile.in
|
||||
src/mod/applications/mod_hash/Makefile
|
||||
src/mod/applications/mod_hash/Makefile.in
|
||||
src/mod/applications/mod_hash/mod_hash.log
|
||||
|
||||
/.version
|
||||
/a.out.dSYM
|
||||
/AUTHORS
|
||||
/ChangeLog
|
||||
/configure
|
||||
/COPYING
|
||||
/freeswitch
|
||||
/fs_cli
|
||||
/fs_encode
|
||||
/fs_ivrd
|
||||
/libtool
|
||||
/Makefile
|
||||
/Makefile.in
|
||||
/modules.conf
|
||||
/NEWS
|
||||
/Path
|
||||
/quiet_libtool
|
||||
/README
|
||||
/TAGS
|
||||
/tone2wav
|
||||
|
||||
/All/
|
||||
/Debug/
|
||||
/bin/
|
||||
/Release/
|
||||
|
||||
/build/config/compile
|
||||
/build/config/config.guess
|
||||
/build/config/depcomp
|
||||
/build/config/install-sh
|
||||
/build/config/ltmain.sh
|
||||
/build/config/missing
|
||||
/build/freeswitch.pc
|
||||
/build/getlib.sh
|
||||
/build/getsounds.sh
|
||||
/build/Makefile
|
||||
/build/Makefile.in
|
||||
/build/modmake.rules
|
||||
|
||||
/libs/curl/lib/ca-bundle.h
|
||||
/libs/esl/fs_cli
|
||||
/libs/esl/ivrd
|
||||
/libs/esl/testclient
|
||||
/libs/esl/testserver
|
||||
/libs/freetdm/detect_dtmf
|
||||
/libs/freetdm/detect_tones
|
||||
/libs/freetdm/testanalog
|
||||
/libs/freetdm/testapp
|
||||
/libs/freetdm/testcid
|
||||
/libs/freetdm/testpri
|
||||
/libs/freetdm/testr2
|
||||
/libs/freetdm/testsangomaboost
|
||||
/libs/freetdm/testtones
|
||||
/libs/fsg729-*-installer
|
||||
/libs/g729/
|
||||
/libs/libcodec2/config.guess
|
||||
/libs/libcodec2/config.sub
|
||||
/libs/libcodec2/configure
|
||||
/libs/libcodec2/depcomp
|
||||
/libs/libcodec2/install-sh
|
||||
/libs/libcodec2/libtool
|
||||
/libs/libcodec2/ltmain.sh
|
||||
/libs/libcodec2/Makefile
|
||||
/libs/libcodec2/Makefile.in
|
||||
/libs/libcodec2/missing
|
||||
/libs/libcodec2/src/Makefile
|
||||
/libs/libcodec2/src/Makefile.in
|
||||
/libs/libcodec2/unittest/Makefile
|
||||
/libs/libcodec2/unittest/Makefile.in
|
||||
|
||||
/scripts/fsxs
|
||||
/scripts/gentls_cert
|
||||
|
||||
/src/mod/applications/mod_easyroute/Makefile
|
||||
/src/mod/applications/mod_hash/Makefile
|
||||
/src/mod/applications/mod_hash/Makefile.in
|
||||
/src/mod/applications/mod_hash/mod_hash.log
|
||||
/src/mod/applications/mod_lcr/Makefile
|
||||
/src/mod/applications/mod_nibblebill/Makefile
|
||||
/src/mod/applications/mod_osp/Makefile
|
||||
/src/mod/applications/mod_osp/Makefile.in
|
||||
/src/mod/applications/mod_rss/Makefile
|
||||
/src/mod/applications/mod_snipe_hunt/Makefile
|
||||
/src/mod/codecs/mod_com_g729/
|
||||
/src/mod/codecs/mod_dahdi_codec/Makefile
|
||||
/src/mod/dialplans/mod_dialplan_directory/Makefile
|
||||
/src/mod/formats/mod_shell_stream/Makefile
|
||||
/src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig
|
||||
/src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig
|
||||
/src/mod/languages/mod_python/mod_python_wrap.cpp.orig
|
||||
/src/mod/say/mod_say_de/Makefile
|
||||
/src/mod/say/mod_say_es/Makefile
|
||||
/src/mod/say/mod_say_fr/Makefile
|
||||
/src/mod/say/mod_say_it/Makefile
|
||||
/src/mod/say/mod_say_nl/Makefile
|
||||
/src/mod/say/mod_say_th/Makefile
|
||||
/src/mod/say/mod_say_zh/Makefile
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ scripts/fsxs: scripts/fsxs.in
|
|||
## misc
|
||||
##
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfigdir = @pkgconfigdir@
|
||||
pkgconfig_DATA = build/freeswitch.pc
|
||||
|
||||
$(switch_builddir)/modules.conf:
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
bz="false"
|
||||
|
||||
BUNZIP=/usr/bin/bunzip2
|
||||
TAR=@TAR@
|
||||
ZCAT=@ZCAT@
|
||||
WGET=@WGET@
|
||||
|
@ -17,14 +20,26 @@ base=http://files.freeswitch.org/downloads/libs/
|
|||
tarfile=$1
|
||||
url=`echo $tarfile | grep "://"`
|
||||
|
||||
if [ `echo $tarfile | grep bz2` ] ; then
|
||||
bz="true"
|
||||
UNZIPPER=$BUNZIP
|
||||
else
|
||||
UNZIPPER=$ZCAT
|
||||
fi
|
||||
|
||||
if [ ! -z $url ] ; then
|
||||
base=$tarfile/
|
||||
tarfile=$2
|
||||
fi
|
||||
|
||||
if [ ! -d $tarfile ] ; then
|
||||
uncompressed=`echo $tarfile | sed "s/\.tar\.gz//g"`
|
||||
uncompressed=`echo $uncompressed | sed "s/\.tgz//g"`
|
||||
|
||||
if [ $bz = "true" ] ; then
|
||||
uncompressed=`echo $tarfile | sed "s/\.tar\.bz2//g"`
|
||||
else
|
||||
uncompressed=`echo $tarfile | sed "s/\.tar\.gz//g"`
|
||||
uncompressed=`echo $uncompressed | sed "s/\.tgz//g"`
|
||||
fi
|
||||
|
||||
if [ ! -f $tarfile ] ; then
|
||||
rm -fr $uncompressed
|
||||
|
@ -35,7 +50,7 @@ if [ ! -d $tarfile ] ; then
|
|||
fi
|
||||
fi
|
||||
if [ ! -d $uncompressed ] ; then
|
||||
$ZCAT -c -d $tarfile | $TAR xf -
|
||||
$UNZIPPER -c -d $tarfile | $TAR xf -
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -52,8 +52,9 @@
|
|||
|
||||
<!-- If TTS is enabled all audio-file params beginning with -->
|
||||
<!-- 'say:' will be considered text to say with TTS -->
|
||||
<!-- Set a default path here so you can use relative paths in the other sound params-->
|
||||
<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>
|
||||
<!-- Override the default path here, after which you use relative paths in the other sound params -->
|
||||
<!-- Note: The default path is the conference's first caller's sound_prefix -->
|
||||
<!--<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>-->
|
||||
<!-- File to play to acknowledge succees -->
|
||||
<!--<param name="ack-sound" value="beep.wav"/>-->
|
||||
<!-- File to play to acknowledge failure -->
|
||||
|
@ -106,7 +107,7 @@
|
|||
<param name="rate" value="16000"/>
|
||||
<param name="interval" value="20"/>
|
||||
<param name="energy-level" value="300"/>
|
||||
<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>
|
||||
<!--<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>-->
|
||||
<param name="muted-sound" value="conference/conf-muted.wav"/>
|
||||
<param name="unmuted-sound" value="conference/conf-unmuted.wav"/>
|
||||
<param name="alone-sound" value="conference/conf-alone.wav"/>
|
||||
|
@ -131,7 +132,7 @@
|
|||
<param name="rate" value="32000"/>
|
||||
<param name="interval" value="20"/>
|
||||
<param name="energy-level" value="300"/>
|
||||
<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>
|
||||
<!--<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>-->
|
||||
<param name="muted-sound" value="conference/conf-muted.wav"/>
|
||||
<param name="unmuted-sound" value="conference/conf-unmuted.wav"/>
|
||||
<param name="alone-sound" value="conference/conf-alone.wav"/>
|
||||
|
@ -156,7 +157,7 @@
|
|||
<param name="rate" value="48000"/>
|
||||
<param name="interval" value="10"/>
|
||||
<param name="energy-level" value="300"/>
|
||||
<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>
|
||||
<!--<param name="sound-prefix" value="$${sounds_dir}/en/us/callie"/>-->
|
||||
<param name="muted-sound" value="conference/conf-muted.wav"/>
|
||||
<param name="unmuted-sound" value="conference/conf-unmuted.wav"/>
|
||||
<param name="alone-sound" value="conference/conf-alone.wav"/>
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
<!--Colorize the Console -->
|
||||
<param name="colorize-console" value="true"/>
|
||||
|
||||
<!-- maximum number of simo db handles open -->
|
||||
<param name="max-db-handles" value="50"/>
|
||||
<!-- maximum number of seconds to wait for a new db handle before failing -->
|
||||
<param name="db-handle-timeout" value="10"/>
|
||||
|
||||
<!-- minimum idle CPU before refusing calls -->
|
||||
<!--<param name="min-idle-cpu" value="25"/>-->
|
||||
|
||||
|
|
|
@ -16,12 +16,16 @@
|
|||
<soft-key-set-sets>
|
||||
<soft-key-set-set name="default">
|
||||
<soft-key-set name="KeySetOnHook" value="SoftkeyNewcall,SoftkeyRedial"/>
|
||||
<soft-key-set name="KeySetOffHook" value=",SoftkeyRedial,SoftkeyEndcall"/>
|
||||
<soft-key-set name="KeySetDigitsAfterDialingFirstDigit" value="SoftkeyBackspace,,SoftkeyEndcall"/>
|
||||
<soft-key-set name="KeySetConnected" value="SoftkeyEndcall,SoftkeyHold,SoftkeyNewcall,SoftkeyTransfer"/>
|
||||
<soft-key-set name="KeySetRingIn" value="SoftkeyAnswer,SoftkeyEndcall,SoftkeyNewcall"/>
|
||||
<soft-key-set name="KeySetOnHold" value="SoftkeyNewcall,SoftkeyResume,SoftkeyEndcall"/>
|
||||
<soft-key-set name="KeySetRingIn" value="SoftkeyAnswer,SoftkeyEndcall,SoftkeyNewcall"/>
|
||||
<soft-key-set name="KeySetOffHook" value=",SoftkeyRedial,SoftkeyEndcall"/>
|
||||
<soft-key-set name="KeySetConnectedWithTransfer" value="SoftkeyEndcall,SoftkeyHold,SoftkeyNewcall,SoftkeyTransfer"/>
|
||||
<soft-key-set name="KeySetDigitsAfterDialingFirstDigit" value="SoftkeyBackspace,,SoftkeyEndcall"/>
|
||||
<!-- <soft-key-set name="KeySetConnectedWithConference" value=""/> -->
|
||||
<soft-key-set name="KeySetRingOut" value=",,SoftkeyEndcall,SoftkeyTransfer"/>
|
||||
<soft-key-set name="KeySetOffHookWithFeatures" value=",SoftkeyRedial,SoftkeyEndcall"/>
|
||||
<soft-key-set name="KeySetInUseHint" value="SoftkeyNewcall,SoftkeyRedial"/>
|
||||
</soft-key-set-set>
|
||||
</soft-key-set-sets>
|
||||
<device-types>
|
||||
|
|
|
@ -207,6 +207,7 @@
|
|||
<X-PRE-PROCESS cmd="set" data="de-ring=%(1000,4000,425,0)"/>
|
||||
<X-PRE-PROCESS cmd="set" data="dz-ring=%(1500,3500,425.0,0.0)"/>
|
||||
<X-PRE-PROCESS cmd="set" data="pl-ring=%(1000,4000,425,0)"/>
|
||||
<X-PRE-PROCESS cmd="set" data="il-ring=%(1000,2000,425.0,0)"/>
|
||||
<X-PRE-PROCESS cmd="set" data="bong-ring=v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1400,0,350,440)"/>
|
||||
<X-PRE-PROCESS cmd="set" data="sit=%(274,0,913.8);%(274,0,1370.6);%(380,0,1776.7)"/>
|
||||
<!--
|
||||
|
|
11
configure.in
11
configure.in
|
@ -93,6 +93,17 @@ AC_SUBST(libdir)
|
|||
AC_SUBST(bindir)
|
||||
AC_SUBST(includedir)
|
||||
|
||||
AC_ARG_WITH([pkgconfigdir],
|
||||
[AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])],
|
||||
[case "${withval}" in
|
||||
yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;;
|
||||
*) pkgconfigdir="${withval}" ;;
|
||||
esac
|
||||
],
|
||||
[pkgconfigdir="${libdir}/pkgconfig"]
|
||||
)
|
||||
AC_SUBST([pkgconfigdir])
|
||||
|
||||
#Set default language
|
||||
AC_LANG_C
|
||||
# Checks for programs.
|
||||
|
|
|
@ -54,6 +54,7 @@ static unsigned char esl_console_complete(const char *buffer, const char *cursor
|
|||
#endif
|
||||
|
||||
static char prompt_str[512] = "";
|
||||
static int CONNECTED = 0;
|
||||
|
||||
typedef struct {
|
||||
char name[128];
|
||||
|
@ -538,6 +539,11 @@ static void handle_SIGINT(int sig)
|
|||
{
|
||||
if (sig);
|
||||
|
||||
if (!CONNECTED) {
|
||||
fprintf(stdout, "Interrupted.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
WARN_STOP = 1;
|
||||
|
||||
signal(SIGINT, handle_SIGINT);
|
||||
|
@ -572,6 +578,7 @@ static int usage(char *name){
|
|||
printf(" -P, --port=port Port to connect (1 - 65535)\n");
|
||||
printf(" -u, --user=user@domain user@domain\n");
|
||||
printf(" -p, --password=password Password\n");
|
||||
printf(" -i, --interrupt Allow Control-c to interrupt");
|
||||
printf(" -x, --execute=command Execute Command and Exit\n");
|
||||
printf(" -l, --loglevel=command Log Level\n");
|
||||
printf(" -q, --quiet Disable logging\n");
|
||||
|
@ -1017,6 +1024,7 @@ int main(int argc, char *argv[])
|
|||
{"loglevel", 1, 0, 'l'},
|
||||
{"quiet", 0, 0, 'q'},
|
||||
{"retry", 0, 0, 'r'},
|
||||
{"interrupt", 0, 0, 'i'},
|
||||
{"reconnect", 0, 0, 'R'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
@ -1032,6 +1040,7 @@ int main(int argc, char *argv[])
|
|||
int temp_log = -1;
|
||||
int argv_error = 0;
|
||||
int argv_exec = 0;
|
||||
int ctl_c = 0;
|
||||
char argv_command[1024] = "";
|
||||
char argv_loglevel[128] = "";
|
||||
int argv_quiet = 0;
|
||||
|
@ -1060,7 +1069,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
for(;;) {
|
||||
int option_index = 0;
|
||||
opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:qrRh?", options, &option_index);
|
||||
opt = getopt_long(argc, argv, "H:U:P:S:u:p:d:x:l:qrRhi?", options, &option_index);
|
||||
if (opt == -1) break;
|
||||
switch (opt)
|
||||
{
|
||||
|
@ -1104,6 +1113,9 @@ int main(int argc, char *argv[])
|
|||
case 'q':
|
||||
argv_quiet = 1;
|
||||
break;
|
||||
case 'i':
|
||||
ctl_c = 1;
|
||||
break;
|
||||
case 'r':
|
||||
loops += 120;
|
||||
break;
|
||||
|
@ -1229,6 +1241,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
connect:
|
||||
|
||||
CONNECTED = 0;
|
||||
|
||||
while (--loops > 0) {
|
||||
memset(&handle, 0, sizeof(handle));
|
||||
if (esl_connect(&handle, profile->host, profile->port, profile->user, profile->pass)) {
|
||||
|
@ -1246,6 +1260,10 @@ int main(int argc, char *argv[])
|
|||
esl_log(ESL_LOG_INFO, "Retrying\n");
|
||||
}
|
||||
} else {
|
||||
if (!ctl_c) {
|
||||
CONNECTED = 1;
|
||||
}
|
||||
|
||||
if (temp_log < 0 ) {
|
||||
esl_global_set_default_logger(profile->debug);
|
||||
} else {
|
||||
|
|
|
@ -790,11 +790,12 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1api(JNIEn
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1bgapi(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
|
||||
SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1bgapi(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4) {
|
||||
jlong jresult = 0 ;
|
||||
ESLconnection *arg1 = (ESLconnection *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
char *arg4 = (char *) NULL ;
|
||||
ESLevent *result = 0 ;
|
||||
|
||||
(void)jenv;
|
||||
|
@ -811,10 +812,16 @@ SWIGEXPORT jlong JNICALL Java_org_freeswitch_esl_eslJNI_ESLconnection_1bgapi(JNI
|
|||
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
|
||||
if (!arg3) return 0;
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3);
|
||||
arg4 = 0;
|
||||
if (jarg4) {
|
||||
arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0);
|
||||
if (!arg4) return 0;
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4);
|
||||
*(ESLevent **)&jresult = result;
|
||||
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
|
||||
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
|
||||
if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4);
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ public class ESLconnection {
|
|||
return (cPtr == 0) ? null : new ESLevent(cPtr, true);
|
||||
}
|
||||
|
||||
public ESLevent bgapi(String cmd, String arg) {
|
||||
long cPtr = eslJNI.ESLconnection_bgapi(swigCPtr, this, cmd, arg);
|
||||
public ESLevent bgapi(String cmd, String arg, String job_uuid) {
|
||||
long cPtr = eslJNI.ESLconnection_bgapi(swigCPtr, this, cmd, arg, job_uuid);
|
||||
return (cPtr == 0) ? null : new ESLevent(cPtr, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class eslJNI {
|
|||
public final static native int ESLconnection_send(long jarg1, ESLconnection jarg1_, String jarg2);
|
||||
public final static native long ESLconnection_sendRecv(long jarg1, ESLconnection jarg1_, String jarg2);
|
||||
public final static native long ESLconnection_api(long jarg1, ESLconnection jarg1_, String jarg2, String jarg3);
|
||||
public final static native long ESLconnection_bgapi(long jarg1, ESLconnection jarg1_, String jarg2, String jarg3);
|
||||
public final static native long ESLconnection_bgapi(long jarg1, ESLconnection jarg1_, String jarg2, String jarg3, String jarg4);
|
||||
public final static native long ESLconnection_sendEvent(long jarg1, ESLconnection jarg1_, long jarg2, ESLevent jarg2_);
|
||||
public final static native long ESLconnection_recvEvent(long jarg1, ESLconnection jarg1_);
|
||||
public final static native long ESLconnection_recvEventTimed(long jarg1, ESLconnection jarg1_, int jarg2);
|
||||
|
|
|
@ -2498,12 +2498,14 @@ static int _wrap_ESLconnection_bgapi(lua_State* L) {
|
|||
ESLconnection *arg1 = (ESLconnection *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
char *arg4 = (char *) NULL ;
|
||||
ESLevent *result = 0 ;
|
||||
|
||||
SWIG_check_num_args("bgapi",2,3)
|
||||
SWIG_check_num_args("bgapi",2,4)
|
||||
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("bgapi",1,"ESLconnection *");
|
||||
if(!lua_isstring(L,2)) SWIG_fail_arg("bgapi",2,"char const *");
|
||||
if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("bgapi",3,"char const *");
|
||||
if(lua_gettop(L)>=4 && !lua_isstring(L,4)) SWIG_fail_arg("bgapi",4,"char const *");
|
||||
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_ESLconnection,0))){
|
||||
SWIG_fail_ptr("ESLconnection_bgapi",1,SWIGTYPE_p_ESLconnection);
|
||||
|
@ -2513,7 +2515,10 @@ static int _wrap_ESLconnection_bgapi(lua_State* L) {
|
|||
if(lua_gettop(L)>=3){
|
||||
arg3 = (char *)lua_tostring(L, 3);
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3);
|
||||
if(lua_gettop(L)>=4){
|
||||
arg4 = (char *)lua_tostring(L, 4);
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4);
|
||||
SWIG_arg=0;
|
||||
SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLevent,1); SWIG_arg++;
|
||||
return SWIG_arg;
|
||||
|
|
|
@ -275,7 +275,7 @@ class ESLPINVOKE {
|
|||
public static extern IntPtr ESLconnection_Api(HandleRef jarg1, string jarg2, string jarg3);
|
||||
|
||||
[DllImport("ESL", EntryPoint="CSharp_ESLconnection_Bgapi")]
|
||||
public static extern IntPtr ESLconnection_Bgapi(HandleRef jarg1, string jarg2, string jarg3);
|
||||
public static extern IntPtr ESLconnection_Bgapi(HandleRef jarg1, string jarg2, string jarg3, string jarg4);
|
||||
|
||||
[DllImport("ESL", EntryPoint="CSharp_ESLconnection_SendEvent")]
|
||||
public static extern IntPtr ESLconnection_SendEvent(HandleRef jarg1, HandleRef jarg2);
|
||||
|
|
|
@ -80,8 +80,8 @@ public class ESLconnection : IDisposable {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public ESLevent Bgapi(string cmd, string arg) {
|
||||
IntPtr cPtr = ESLPINVOKE.ESLconnection_Bgapi(swigCPtr, cmd, arg);
|
||||
public ESLevent Bgapi(string cmd, string arg, string job_uuid) {
|
||||
IntPtr cPtr = ESLPINVOKE.ESLconnection_Bgapi(swigCPtr, cmd, arg, job_uuid);
|
||||
ESLevent ret = (cPtr == IntPtr.Zero) ? null : new ESLevent(cPtr, true);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -677,17 +677,19 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Api(void * jarg1, char * jarg
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Bgapi(void * jarg1, char * jarg2, char * jarg3) {
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_ESLconnection_Bgapi(void * jarg1, char * jarg2, char * jarg3, char * jarg4) {
|
||||
void * jresult ;
|
||||
ESLconnection *arg1 = (ESLconnection *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
char *arg4 = (char *) NULL ;
|
||||
ESLevent *result = 0 ;
|
||||
|
||||
arg1 = (ESLconnection *)jarg1;
|
||||
arg2 = (char *)jarg2;
|
||||
arg3 = (char *)jarg3;
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3);
|
||||
arg4 = (char *)jarg4;
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4);
|
||||
jresult = (void *)result;
|
||||
return jresult;
|
||||
}
|
||||
|
|
|
@ -3072,6 +3072,7 @@ XS(_wrap_ESLconnection_bgapi) {
|
|||
ESLconnection *arg1 = (ESLconnection *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
char *arg4 = (char *) NULL ;
|
||||
ESLevent *result = 0 ;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
|
@ -3081,11 +3082,14 @@ XS(_wrap_ESLconnection_bgapi) {
|
|||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
int res4 ;
|
||||
char *buf4 = 0 ;
|
||||
int alloc4 = 0 ;
|
||||
int argvi = 0;
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 2) || (items > 3)) {
|
||||
SWIG_croak("Usage: ESLconnection_bgapi(self,cmd,arg);");
|
||||
if ((items < 2) || (items > 4)) {
|
||||
SWIG_croak("Usage: ESLconnection_bgapi(self,cmd,arg,job_uuid);");
|
||||
}
|
||||
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
|
@ -3104,16 +3108,25 @@ XS(_wrap_ESLconnection_bgapi) {
|
|||
}
|
||||
arg3 = reinterpret_cast< char * >(buf3);
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3);
|
||||
if (items > 3) {
|
||||
res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4);
|
||||
if (!SWIG_IsOK(res4)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_bgapi" "', argument " "4"" of type '" "char const *""'");
|
||||
}
|
||||
arg4 = reinterpret_cast< char * >(buf4);
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4);
|
||||
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
|
||||
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
|
||||
XSRETURN(argvi);
|
||||
fail:
|
||||
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
|
||||
SWIG_croak_null();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,10 +152,11 @@ class ESLconnection {
|
|||
return is_resource($r) ? new ESLevent($r) : $r;
|
||||
}
|
||||
|
||||
function bgapi($cmd,$arg=null) {
|
||||
function bgapi($cmd,$arg=null,$job_uuid=null) {
|
||||
switch (func_num_args()) {
|
||||
case 1: $r=ESLconnection_bgapi($this->_cPtr,$cmd); break;
|
||||
default: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg);
|
||||
case 2: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg); break;
|
||||
default: $r=ESLconnection_bgapi($this->_cPtr,$cmd,$arg,$job_uuid);
|
||||
}
|
||||
return is_resource($r) ? new ESLevent($r) : $r;
|
||||
}
|
||||
|
|
|
@ -2075,13 +2075,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) {
|
|||
ESLconnection *arg1 = (ESLconnection *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
char *arg4 = (char *) NULL ;
|
||||
ESLevent *result = 0 ;
|
||||
zval **args[3];
|
||||
zval **args[4];
|
||||
int arg_count;
|
||||
|
||||
SWIG_ResetError();
|
||||
arg_count = ZEND_NUM_ARGS();
|
||||
if(arg_count<2 || arg_count>3 ||
|
||||
if(arg_count<2 || arg_count>4 ||
|
||||
zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)
|
||||
WRONG_PARAM_COUNT;
|
||||
|
||||
|
@ -2104,7 +2105,14 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_bgapi) {
|
|||
/*@SWIG@*/;
|
||||
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3);
|
||||
if(arg_count > 3) {
|
||||
/*@SWIG:/usr/local/share/swig/1.3.35/php4/utils.i,26,CONVERT_STRING_IN@*/
|
||||
convert_to_string_ex(args[3]);
|
||||
arg4 = (char *) Z_STRVAL_PP(args[3]);
|
||||
/*@SWIG@*/;
|
||||
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4);
|
||||
{
|
||||
SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0);
|
||||
}
|
||||
|
|
|
@ -4151,6 +4151,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P
|
|||
ESLconnection *arg1 = (ESLconnection *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
char *arg4 = (char *) NULL ;
|
||||
ESLevent *result = 0 ;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
|
@ -4160,12 +4161,16 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P
|
|||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
int res4 ;
|
||||
char *buf4 = 0 ;
|
||||
int alloc4 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
PyObject * obj1 = 0 ;
|
||||
PyObject * obj2 = 0 ;
|
||||
PyObject * obj3 = 0 ;
|
||||
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
if (!PyArg_ParseTuple(args,(char *)"OO|O:ESLconnection_bgapi",&obj0,&obj1,&obj2)) SWIG_fail;
|
||||
if (!PyArg_ParseTuple(args,(char *)"OO|OO:ESLconnection_bgapi",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
|
||||
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 );
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ESLconnection_bgapi" "', argument " "1"" of type '" "ESLconnection *""'");
|
||||
|
@ -4183,19 +4188,28 @@ SWIGINTERN PyObject *_wrap_ESLconnection_bgapi(PyObject *SWIGUNUSEDPARM(self), P
|
|||
}
|
||||
arg3 = reinterpret_cast< char * >(buf3);
|
||||
}
|
||||
if (obj3) {
|
||||
res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
|
||||
if (!SWIG_IsOK(res4)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ESLconnection_bgapi" "', argument " "4"" of type '" "char const *""'");
|
||||
}
|
||||
arg4 = reinterpret_cast< char * >(buf4);
|
||||
}
|
||||
{
|
||||
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3);
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4);
|
||||
SWIG_PYTHON_THREAD_END_ALLOW;
|
||||
}
|
||||
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 );
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return resultobj;
|
||||
fail:
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -3055,6 +3055,7 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) {
|
|||
ESLconnection *arg1 = (ESLconnection *) 0 ;
|
||||
char *arg2 = (char *) 0 ;
|
||||
char *arg3 = (char *) NULL ;
|
||||
char *arg4 = (char *) NULL ;
|
||||
ESLevent *result = 0 ;
|
||||
void *argp1 = 0 ;
|
||||
int res1 = 0 ;
|
||||
|
@ -3064,9 +3065,12 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) {
|
|||
int res3 ;
|
||||
char *buf3 = 0 ;
|
||||
int alloc3 = 0 ;
|
||||
int res4 ;
|
||||
char *buf4 = 0 ;
|
||||
int alloc4 = 0 ;
|
||||
VALUE vresult = Qnil;
|
||||
|
||||
if ((argc < 1) || (argc > 2)) {
|
||||
if ((argc < 1) || (argc > 3)) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
|
||||
}
|
||||
res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_ESLconnection, 0 | 0 );
|
||||
|
@ -3086,14 +3090,23 @@ _wrap_ESLconnection_bgapi(int argc, VALUE *argv, VALUE self) {
|
|||
}
|
||||
arg3 = reinterpret_cast< char * >(buf3);
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3);
|
||||
if (argc > 2) {
|
||||
res4 = SWIG_AsCharPtrAndSize(argv[2], &buf4, NULL, &alloc4);
|
||||
if (!SWIG_IsOK(res4)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char const *","bgapi", 4, argv[2] ));
|
||||
}
|
||||
arg4 = reinterpret_cast< char * >(buf4);
|
||||
}
|
||||
result = (ESLevent *)(arg1)->bgapi((char const *)arg2,(char const *)arg3,(char const *)arg4);
|
||||
vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, SWIG_POINTER_OWN | 0 );
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
|
||||
return vresult;
|
||||
fail:
|
||||
if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
|
||||
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
|
||||
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
|
|
@ -949,15 +949,18 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
|
|||
while(!revent && handle->connected) {
|
||||
esl_size_t len1;
|
||||
|
||||
if ((len1 = esl_buffer_read_packet(handle->packet_buf, handle->socket_buf, sizeof(handle->socket_buf)))) {
|
||||
if ((len1 = esl_buffer_read_packet(handle->packet_buf, handle->socket_buf, sizeof(handle->socket_buf) - 1))) {
|
||||
char *data = (char *) handle->socket_buf;
|
||||
char *p, *e;
|
||||
|
||||
*(data + len1) = '\0';
|
||||
|
||||
esl_event_create(&revent, ESL_EVENT_CLONE);
|
||||
revent->event_id = ESL_EVENT_SOCKET_DATA;
|
||||
esl_event_add_header_string(revent, ESL_STACK_BOTTOM, "Event-Name", "SOCKET_DATA");
|
||||
|
||||
hname = p = data;
|
||||
|
||||
while(p) {
|
||||
hname = p;
|
||||
p = NULL;
|
||||
|
@ -984,7 +987,8 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
|
|||
break;
|
||||
}
|
||||
|
||||
rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf));
|
||||
rrval = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1);
|
||||
*((char *)handle->socket_buf + rrval) = '\0';
|
||||
|
||||
if (rrval == 0) {
|
||||
if (++zc >= 100) {
|
||||
|
@ -1020,7 +1024,8 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
|
|||
if (s >= len) {
|
||||
sofar = esl_buffer_read(handle->packet_buf, body, len);
|
||||
} else {
|
||||
r = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf));
|
||||
r = handle_recv(handle, handle->socket_buf, sizeof(handle->socket_buf) - 1);
|
||||
*((char *)handle->socket_buf + r) = '\0';
|
||||
|
||||
if (r < 0) {
|
||||
strerror_r(handle->errnum, handle->err, sizeof(handle->err));
|
||||
|
@ -1061,7 +1066,10 @@ ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, int check_q, esl_
|
|||
hval = esl_event_get_header(revent, "content-type");
|
||||
|
||||
if (!esl_safe_strcasecmp(hval, "text/disconnect-notice") && revent->body) {
|
||||
goto fail;
|
||||
const char *dval = esl_event_get_header(revent, "content-disposition");
|
||||
if (esl_strlen_zero(dval) || strcasecmp(dval, "linger")) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (revent->body) {
|
||||
|
|
|
@ -131,6 +131,8 @@ static const char *EVENT_NAMES[] = {
|
|||
"NAT",
|
||||
"RECORD_START",
|
||||
"RECORD_STOP",
|
||||
"PLAYBACK_START",
|
||||
"PLAYBACK_STOP",
|
||||
"CALL_UPDATE",
|
||||
"FAILURE",
|
||||
"SOCKET_DATA",
|
||||
|
|
|
@ -105,7 +105,7 @@ ESLevent *ESLconnection::api(const char *cmd, const char *arg)
|
|||
return event;
|
||||
}
|
||||
|
||||
ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg)
|
||||
ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg, const char *job_uuid)
|
||||
{
|
||||
size_t len;
|
||||
char *cmd_buf;
|
||||
|
@ -115,12 +115,17 @@ ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10;
|
||||
len = strlen(cmd) + (arg ? strlen(arg) : 0) + (job_uuid ? strlen(job_uuid) + 12 : 0) + 10;
|
||||
|
||||
cmd_buf = (char *) malloc(len + 1);
|
||||
assert(cmd_buf);
|
||||
|
||||
if (job_uuid) {
|
||||
snprintf(cmd_buf, len, "bgapi %s%s%s\nJob-UUID: %s", cmd, arg ? " " : "", arg ? arg : "", job_uuid);
|
||||
} else {
|
||||
snprintf(cmd_buf, len, "bgapi %s%s%s", cmd, arg ? " " : "", arg ? arg : "");
|
||||
}
|
||||
|
||||
snprintf(cmd_buf, len, "bgapi %s %s", cmd, arg ? arg : "");
|
||||
*(cmd_buf + (len)) = '\0';
|
||||
|
||||
event = sendRecv(cmd_buf);
|
||||
|
|
|
@ -119,6 +119,8 @@ typedef enum {
|
|||
ESL_EVENT_NAT,
|
||||
ESL_EVENT_RECORD_START,
|
||||
ESL_EVENT_RECORD_STOP,
|
||||
ESL_EVENT_PLAYBACK_START,
|
||||
ESL_EVENT_PLAYBACK_STOP,
|
||||
ESL_EVENT_CALL_UPDATE,
|
||||
ESL_EVENT_FAILURE,
|
||||
ESL_EVENT_SOCKET_DATA,
|
||||
|
|
|
@ -82,7 +82,7 @@ class ESLconnection {
|
|||
int send(const char *cmd);
|
||||
ESLevent *sendRecv(const char *cmd);
|
||||
ESLevent *api(const char *cmd, const char *arg = NULL);
|
||||
ESLevent *bgapi(const char *cmd, const char *arg = NULL);
|
||||
ESLevent *bgapi(const char *cmd, const char *arg = NULL, const char *job_uuid = NULL);
|
||||
ESLevent *sendEvent(ESLevent *send_me);
|
||||
ESLevent *recvEvent();
|
||||
ESLevent *recvEventTimed(int ms);
|
||||
|
|
|
@ -61,7 +61,7 @@ LINK = $(LIBTOOL) --mode=link --tag=CC $(CC) $(FTDM_CFLAGS) $(LDFLAGS) -o $
|
|||
#
|
||||
EXTRA_DIST = freetdm.pc.in
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfigdir = @pkgconfigdir@
|
||||
pkgconfig_DATA = freetdm.pc
|
||||
|
||||
|
||||
|
@ -76,6 +76,7 @@ libfreetdm_la_SOURCES = \
|
|||
$(SRC)/ftdm_queue.c \
|
||||
$(SRC)/ftdm_sched.c \
|
||||
$(SRC)/ftdm_call_utils.c \
|
||||
$(SRC)/ftdm_variables.c \
|
||||
$(SRC)/ftdm_config.c \
|
||||
$(SRC)/ftdm_callerid.c \
|
||||
$(SRC)/fsk.c \
|
||||
|
@ -248,7 +249,7 @@ endif
|
|||
|
||||
if HAVE_OPENR2
|
||||
mod_LTLIBRARIES += ftmod_r2.la
|
||||
ftmod_r2_la_SOURCES = $(SRC)/ftmod/ftmod_r2/ftmod_r2.c
|
||||
ftmod_r2_la_SOURCES = $(SRC)/ftmod/ftmod_r2/ftmod_r2.c $(SRC)/ftmod/ftmod_r2/ftmod_r2_io_mf_lib.c
|
||||
ftmod_r2_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
|
||||
ftmod_r2_la_LDFLAGS = -shared -module -avoid-version -lopenr2
|
||||
ftmod_r2_la_LIBADD = libfreetdm.la
|
||||
|
|
|
@ -54,6 +54,9 @@ with the signaling protocols that you can run on top of your I/O interfaces.
|
|||
<!-- whether you want to wait for caller id -->
|
||||
<param name="enable-callerid" value="true"/>
|
||||
|
||||
<!-- How much to wait for dial tone (0 if you just want to dial out immediately without waiting for dial tone) -->
|
||||
<!--<param name="wait-dialtone-timeout" value="5000"/>-->
|
||||
|
||||
<!-- whether you want to enable callwaiting feature -->
|
||||
<!--<param name="callwaiting" value="true"/>-->
|
||||
|
||||
|
|
|
@ -65,6 +65,18 @@ AC_ARG_WITH([modinstdir],
|
|||
)
|
||||
AC_SUBST([modinstdir])
|
||||
|
||||
# freetdm.pc pkgconfig file
|
||||
AC_ARG_WITH([pkgconfigdir],
|
||||
[AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])],
|
||||
[case "${withval}" in
|
||||
yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;;
|
||||
*) pkgconfigdir="${withval}" ;;
|
||||
esac
|
||||
],
|
||||
[pkgconfigdir="${libdir}/pkgconfig"]
|
||||
)
|
||||
AC_SUBST([pkgconfigdir])
|
||||
|
||||
AC_ARG_ENABLE([enable_64],
|
||||
[AS_HELP_STRING([--enable-64], [Enable 64bit compilation])],
|
||||
[enable_64="${enableval}"],
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,118 @@
|
|||
Using FreeTDM Variables
|
||||
|
||||
1. User application sending variables or raw buffer to FreeTDM
|
||||
==============================================================
|
||||
|
||||
The User can include a ftdm_usrmsg_t before sending an event to freetdm.
|
||||
|
||||
example #1a - Making an outbound call:
|
||||
--------------------------------------
|
||||
|
||||
To make an outbound call:
|
||||
ftdm_usrmsg_t usrmsg;
|
||||
|
||||
/* Attach variable to usrmsg */
|
||||
ftdm_usrmsg_add_var(&usrmsg, "isdn.prog_ind.descr", "inband-info-available");
|
||||
|
||||
ftdm_channel_call_place_ex(ftdmchan, &usrmsg);
|
||||
|
||||
example #1b - Adding a variable:
|
||||
--------------------------------
|
||||
When using ftmod_sangoma_isdn, user want to specify progress indicator inside PROCEED message.
|
||||
|
||||
|
||||
ftdm_usrmsg_t usrmsg;
|
||||
|
||||
/* Attach variable to usrmsg */
|
||||
ftdm_usrmsg_add_var(&usrmsg, "isdn.prog_ind.descr", "inband-info-available");
|
||||
|
||||
/* Request FreeTDM to send a PROCEED msg */
|
||||
ftdm_channel_call_indicate_ex(ftdmchan, FTDM_CHANNEL_INDICATE_PROCEED, &usrmsg);
|
||||
|
||||
|
||||
example #2 - Setting raw data:
|
||||
--------------------------------------------------------
|
||||
|
||||
When using ftmod_sangoma_isdn, user wants to transmit a custom Facility IE, inside a FACILITY message.
|
||||
|
||||
ftdm_usrmsg_t usrmsg;
|
||||
|
||||
uint8_t *my_facility_ie = ftdm_calloc(1, 200); /*memory has to be allocated using ftdm_calloc !! */
|
||||
unsigned my_facility_ie_len = 0;
|
||||
|
||||
/* Fill my_facility_ie with custom data here */
|
||||
my_facility_ie[my_facility_ie_len++] = 0x1C; /* Q.931 Facility IE ID */
|
||||
my_facility_ie[my_facility_ie_len++] = 0x03; /* Length of facility IE */
|
||||
my_facility_ie[my_facility_ie_len++] = 0x01;
|
||||
my_facility_ie[my_facility_ie_len++] = 0x02;
|
||||
my_facility_ie[my_facility_ie_len++] = 0x03;
|
||||
|
||||
ftdm_usrmsg_set_raw_data(&usrmsg, my_facility_ie, my_facility_ie_len);
|
||||
|
||||
ftdm_channel_call_indicate(ftdmchan, FTDM_CHANNEL_INDICATE_FACILITY, &usrmsg);
|
||||
|
||||
/* FreeTDM will automatically free my_facility_ie */
|
||||
|
||||
|
||||
2. User application receiving variables and raw buffer from FreeTDM
|
||||
==================================================================
|
||||
|
||||
example #1 - print all variables received from FreeTDM
|
||||
------------------------------------------------------
|
||||
|
||||
/* Inside event call-back function */
|
||||
ftdm_iterator_t *iter = NULL;
|
||||
ftdm_iterator_t *curr = NULL;
|
||||
const char *var_name = NULL;
|
||||
const char *var_value = NULL;
|
||||
|
||||
/* Read all variables attached to this event */
|
||||
iter = ftdm_sigmsg_get_var_iterator(sigmsg, iter);
|
||||
for (curr = iter ; curr; curr = ftdm_iterator_next(curr)) {
|
||||
ftdm_get_current_var(curr, &var_name, &var_value);
|
||||
fprintf("Call Variable: %s=%s\n", var_name, var_value);
|
||||
}
|
||||
ftdm_iterator_free(iter);
|
||||
|
||||
|
||||
example #2 - accessing a specific variable
|
||||
------------------------------------------
|
||||
|
||||
/* Inside event call-back function */
|
||||
char *string = NULL;
|
||||
string = ftdm_sigmsg_get_var(sigmsg, "isdn.prog_ind.descr");
|
||||
if (string && *string) {
|
||||
fprintf("Progress indicator:%s\n", string);
|
||||
}
|
||||
|
||||
|
||||
example #3a - accessing raw data
|
||||
-------------------------------
|
||||
|
||||
/* Inside event call-back function */
|
||||
ftdm_size_t len;
|
||||
uint8_t *mydata;
|
||||
if (ftdm_sigmsg_get_raw_data(sigmsg, (void**)&mydata, &len) == FTDM_SUCCESS) {
|
||||
/* raw data is available, do something with mydata here */
|
||||
}
|
||||
/* Once this function returns, raw data will be free'd inside FreeTDM */
|
||||
|
||||
|
||||
example #3b - accessing raw data
|
||||
-------------------------------
|
||||
|
||||
/* Inside event call-back function */
|
||||
ftdm_size_t len;
|
||||
uint8_t *mydata;
|
||||
if (ftdm_sigmsg_get_raw_data_detached(sigmsg, (void**)&mydata, &len) == FTDM_SUCCESS) {
|
||||
/* raw data is available, do something with mydata here */
|
||||
|
||||
}
|
||||
|
||||
:
|
||||
:
|
||||
:
|
||||
|
||||
/* User owns raw data and is responsible for free'ing it*/
|
||||
ftdm_safe_free(mydata);
|
||||
|
|
@ -43,21 +43,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\
|
|||
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_boost", "src\ftmod\ftmod_sangoma_boost\ftmod_sangoma_boost.2008.vcproj", "{D021EF2A-460D-4827-A0F7-41FDECF46F1B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testboost", "msvc\testboost\testboost.2008.vcproj", "{2B1BAF36-0241-43E7-B865-A8338AD48E2E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsangomaboost", "msvc\testboost\testsangomaboost.2008.vcproj", "{0DA69C18-4FA1-4E8C-89CE-12498637C5BE}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2008.vcproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D}
|
||||
|
|
|
@ -19,12 +19,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_pika", "src\ftmod\ftm
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_wanpipe", "src\ftmod\ftmod_wanpipe\ftmod_wanpipe.2010.vcxproj", "{1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_boost", "src\ftmod\ftmod_sangoma_boost\ftmod_sangoma_boost.2010.vcxproj", "{D021EF2A-460D-4827-A0F7-41FDECF46F1B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testboost", "msvc\testboost\testboost.2010.vcxproj", "{2B1BAF36-0241-43E7-B865-A8338AD48E2E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsangomaboost", "msvc\testboost\testsangomaboost.2010.vcxproj", "{0DA69C18-4FA1-4E8C-89CE-12498637C5BE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_sangoma_isdn", "src\ftmod\ftmod_sangoma_isdn\ftmod_sangoma_isdn.2010.vcxproj", "{B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftmod_r2", "src\ftmod\ftmod_r2\ftmod_r2.2010.vcxproj", "{08C3EA27-A51D-47F8-B47D-B189C649CF30}"
|
||||
|
|
|
@ -29,36 +29,116 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
arch=$(uname -m)
|
||||
|
||||
# defs
|
||||
LIBSNG_ISDN_URL=ftp://ftp.sangoma.com/linux/libsng_isdn
|
||||
LIBSNG_ISDN_NAME=libsng_isdn-7-current
|
||||
LIBSNG_SS7_URL=ftp://ftp.sangoma.com/linux/libsng_ss7
|
||||
LIBSNG_SS7_NAME=libsng_ss7-3-current
|
||||
LIBSNG_ISDN_DIR="$LIBSNG_ISDN_NAME.$arch"
|
||||
LIBSNG_SS7_DIR="$LIBSNG_SS7_NAME.$arch"
|
||||
|
||||
# download and decompress a tarball
|
||||
# $1 = prefix_url, such as ftp://ftp.sangoma.com/foo/bar
|
||||
# $2 = package name, such as libsng_isdn-7.0.0.x86_64
|
||||
function download() {
|
||||
wget $1/$2.tgz
|
||||
if [ $? = 0 ]
|
||||
then
|
||||
tardir=$(tar -tf $2.tgz | head -n1 | sed 's,\/,,g')
|
||||
tar -xvzf $2.tgz || echo "FAILED to decompress $2.tgz"
|
||||
if [ "$tardir" != "$2" ]
|
||||
then
|
||||
mv $tardir $2 || echo "FAILED to move $tardir to $2"
|
||||
fi
|
||||
echo "SUCCESSFULLY downloaded $2"
|
||||
else
|
||||
echo "FAILED to download $1/$2.tgz"
|
||||
fi
|
||||
}
|
||||
|
||||
# download and build libsng-ss7
|
||||
fullname="$LIBSNG_ISDN_NAME.$arch"
|
||||
if [ -d $fullname ]
|
||||
then
|
||||
echo "skipping isdn download since $fullname directory already exists ... remove if you want this step to be performed"
|
||||
else
|
||||
download $LIBSNG_ISDN_URL $fullname
|
||||
fi
|
||||
|
||||
cd $LIBSNG_ISDN_DIR
|
||||
make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-isdn"
|
||||
cd ..
|
||||
|
||||
# download and build libsng-ss7
|
||||
fullname="$LIBSNG_SS7_NAME.$arch"
|
||||
if [ -d $fullname ]
|
||||
then
|
||||
echo "skipping ss7 download since $fullname directory already exists ... remove if you want this step to be performed"
|
||||
else
|
||||
download $LIBSNG_SS7_URL $fullname
|
||||
fi
|
||||
|
||||
cd $LIBSNG_SS7_DIR
|
||||
make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-ss7"
|
||||
cd ..
|
||||
|
||||
if [ ! -d $INSTALLPREFIX ]
|
||||
then
|
||||
mkdir -p $INSTALLPREFIX || exit 1
|
||||
fi
|
||||
|
||||
make clean
|
||||
make mod_freetdm-clean
|
||||
if [ $NODOCS = "NO" ]
|
||||
if [ ! -d $INSTALLPREFIX/bin-releases ]
|
||||
then
|
||||
make dox || exit 1
|
||||
mkdir -p $INSTALLPREFIX/bin-releases || exit 1
|
||||
fi
|
||||
|
||||
# attempt to compile freetdm
|
||||
echo "Build freetdm and mod_freetdm now..."
|
||||
make all mod_freetdm || exit 1
|
||||
echo "freetdm built OK"
|
||||
|
||||
major=$(echo "$VERSION" | cut -d. -f1)
|
||||
minor=$(echo "$VERSION" | cut -d. -f2)
|
||||
micro=$(echo "$VERSION" | cut -d. -f3)
|
||||
release="freetdm-$VERSION"
|
||||
|
||||
echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... press any key to continue"
|
||||
read
|
||||
# ABI compatibility check
|
||||
if [ -x /usr/local/bin/ftdm_abi_check.py ]; then
|
||||
/usr/local/bin/ftdm_abi_check.py --release_path=$(pwd) --archive_path=$INSTALLPREFIX/bin-releases --version=$VERSION
|
||||
|
||||
mkdir -p $INSTALLPREFIX/$release
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ABI compabitility test failed, not creating release. Either increment the major version number or fix the interface."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -ne "\n\nWARNING: /usr/local/bin/ftdm_abi_check.py not found, skipping ABI compatibility test\n\n"
|
||||
fi
|
||||
|
||||
if [ $NODOCS = "NO" ]
|
||||
then
|
||||
make dox || exit 1
|
||||
fi
|
||||
|
||||
echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... "
|
||||
|
||||
mkdir -p $INSTALLPREFIX/$release $INSTALLPREFIX/bin-releases/$major/$release
|
||||
|
||||
cp -r ./* $INSTALLPREFIX/bin-releases/$major/$release
|
||||
cp -r ./.libs $INSTALLPREFIX/bin-releases/$major/$release
|
||||
|
||||
make clean
|
||||
make mod_freetdm-clean
|
||||
|
||||
cp -r ./* $INSTALLPREFIX/$release
|
||||
|
||||
find $INSTALLPREFIX/ -name .libs -exec rm -rf {} \;
|
||||
find $INSTALLPREFIX/ -name .deps -exec rm -rf {} \;
|
||||
find $INSTALLPREFIX/ -name *.so -exec rm -rf {} \;
|
||||
find $INSTALLPREFIX/ -name *.lo -exec rm -rf {} \;
|
||||
# copy ABI compatibility reports to release
|
||||
if [ -d compat_reports ]; then
|
||||
mv ./compat_reports $INSTALLPREFIX/$release
|
||||
fi
|
||||
|
||||
rm -rf $INSTALLPREFIX/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz}
|
||||
rm -rf $INSTALLPREFIX/bin-releases/$major/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz}
|
||||
|
||||
tar -C $INSTALLPREFIX -czf $INSTALLPREFIX/$release.tar.gz $release/
|
||||
|
||||
|
||||
|
|
|
@ -408,8 +408,6 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
|||
globals.calls++;
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
ftdm_channel_init(tech_pvt->ftdmchan);
|
||||
|
||||
//switch_channel_set_flag(channel, CF_ACCEPT_CNG);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
@ -495,7 +493,6 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||
switch (chantype) {
|
||||
case FTDM_CHAN_TYPE_FXO:
|
||||
case FTDM_CHAN_TYPE_EM:
|
||||
case FTDM_CHAN_TYPE_CAS:
|
||||
{
|
||||
ftdm_channel_call_hangup(tech_pvt->ftdmchan);
|
||||
}
|
||||
|
@ -512,6 +509,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case FTDM_CHAN_TYPE_CAS:
|
||||
case FTDM_CHAN_TYPE_B:
|
||||
{
|
||||
ftdm_call_cause_t hcause = switch_channel_get_cause_q850(channel);
|
||||
|
@ -523,8 +521,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
|
|||
break;
|
||||
default:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unhandled channel type %d for channel %s\n", chantype,
|
||||
switch_channel_get_name(channel));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unhandled channel type %d for channel %s\n", chantype, switch_channel_get_name(channel));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -874,7 +871,7 @@ static switch_status_t channel_receive_message_b(switch_core_session_t *session,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1153,6 +1150,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
const char *var;
|
||||
const char *dest_num = NULL, *callerid_num = NULL;
|
||||
ftdm_hunting_scheme_t hunting;
|
||||
ftdm_usrmsg_t usrmsg;
|
||||
|
||||
memset(&usrmsg, 0, sizeof(ftdm_usrmsg_t));
|
||||
|
||||
if (!outbound_profile) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing caller profile\n");
|
||||
|
@ -1343,11 +1343,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
if ((var = channel_get_variable(session, var_event, "freetdm_calling_party_category"))) {
|
||||
ftdm_set_calling_party_category(var, (uint8_t *)&caller_data.cpc);
|
||||
}
|
||||
|
||||
if ((var = channel_get_variable(session, var_event, "freetdm_custom_call_data"))) {
|
||||
ftdm_set_string(caller_data.raw_data, var);
|
||||
caller_data.raw_data_len = (uint32_t)strlen(var);
|
||||
}
|
||||
|
||||
if (!zstr(dest)) {
|
||||
ftdm_set_string(caller_data.dnis.digits, dest);
|
||||
|
@ -1386,7 +1381,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
char *v = h->name + FREETDM_VAR_PREFIX_LEN;
|
||||
if (!zstr(v)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding outbound freetdm variable %s=%s to channel %d:%d\n", v, h->value, span_id, chan_id);
|
||||
ftdm_call_add_var(&caller_data, v, h->value);
|
||||
ftdm_usrmsg_add_var(&usrmsg, v, h->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1414,7 +1409,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
hunt_data.tech_pvt = tech_pvt;
|
||||
caller_data.priv = &hunt_data;
|
||||
|
||||
if ((status = ftdm_call_place(&caller_data, &hunting)) != FTDM_SUCCESS) {
|
||||
if ((status = ftdm_call_place_ex(&caller_data, &hunting, &usrmsg)) != FTDM_SUCCESS) {
|
||||
if (tech_pvt->read_codec.implementation) {
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
}
|
||||
|
@ -1431,8 +1426,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
goto fail;
|
||||
}
|
||||
|
||||
ftdm_channel_init(caller_data.fchan);
|
||||
|
||||
return SWITCH_CAUSE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1552,8 +1545,8 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
|
|||
switch_channel_set_variable_printf(channel, "freetdm_chan_number", "%d", chanid);
|
||||
switch_channel_set_variable_printf(channel, "freetdm_bearer_capability", "%d", channel_caller_data->bearer_capability);
|
||||
switch_channel_set_variable_printf(channel, "freetdm_bearer_layer1", "%d", channel_caller_data->bearer_layer1);
|
||||
switch_channel_set_variable_printf(channel, "freetdm_screening_ind", ftdm_screening2str(channel_caller_data->screen));
|
||||
switch_channel_set_variable_printf(channel, "freetdm_presentation_ind", ftdm_presentation2str(channel_caller_data->pres));
|
||||
switch_channel_set_variable_printf(channel, "screening_ind", ftdm_screening2str(channel_caller_data->screen));
|
||||
switch_channel_set_variable_printf(channel, "presentation_ind", ftdm_presentation2str(channel_caller_data->pres));
|
||||
|
||||
if (globals.sip_headers) {
|
||||
switch_channel_set_variable(channel, "sip_h_X-FreeTDM-SpanName", ftdm_channel_get_span_name(sigmsg->channel));
|
||||
|
@ -1579,20 +1572,17 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
|
|||
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Screen", "%d", channel_caller_data->screen);
|
||||
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Presentation", "%d", channel_caller_data->pres);
|
||||
}
|
||||
if (channel_caller_data->raw_data_len) {
|
||||
switch_channel_set_variable_printf(channel, "freetdm_custom_call_data", "%s", channel_caller_data->raw_data);
|
||||
}
|
||||
|
||||
/* Add any call variable to the dial plan */
|
||||
iter = ftdm_call_get_var_iterator(channel_caller_data, iter);
|
||||
iter = ftdm_sigmsg_get_var_iterator(sigmsg, iter);
|
||||
for (curr = iter ; curr; curr = ftdm_iterator_next(curr)) {
|
||||
ftdm_call_get_current_var(curr, &var_name, &var_value);
|
||||
ftdm_get_current_var(curr, &var_name, &var_value);
|
||||
snprintf(name, sizeof(name), FREETDM_VAR_PREFIX "%s", var_name);
|
||||
switch_channel_set_variable_printf(channel, name, "%s", var_value);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Variable: %s = %s\n", name, var_value);
|
||||
}
|
||||
ftdm_iterator_free(iter);
|
||||
|
||||
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
|
||||
|
@ -2790,6 +2780,7 @@ static switch_status_t load_config(void)
|
|||
const char *hangup_polarity = "false";
|
||||
int polarity_delay = 600;
|
||||
int callwaiting = 1;
|
||||
int dialtone_timeout = 5000;
|
||||
|
||||
uint32_t span_id = 0, to = 0, max = 0;
|
||||
ftdm_span_t *span = NULL;
|
||||
|
@ -2830,6 +2821,8 @@ static switch_status_t load_config(void)
|
|||
tonegroup = val;
|
||||
} else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) {
|
||||
digit_timeout = val;
|
||||
} else if (!strcasecmp(var, "wait-dialtone-timeout")) {
|
||||
dialtone_timeout = atoi(val);
|
||||
} else if (!strcasecmp(var, "context")) {
|
||||
context = val;
|
||||
} else if (!strcasecmp(var, "dialplan")) {
|
||||
|
@ -2930,6 +2923,7 @@ static switch_status_t load_config(void)
|
|||
"hangup_polarity_reverse", hangup_polarity,
|
||||
"polarity_delay", &polarity_delay,
|
||||
"callwaiting", &callwaiting,
|
||||
"wait_dialtone_timeout", &dialtone_timeout,
|
||||
FTDM_TAG_END) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM analog span %s\n", ftdm_span_get_name(span));
|
||||
continue;
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../src/include;../src/include/private;../src/isdn/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0501"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
@ -122,7 +122,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../src/include;../src/include/private;../src/isdn/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0501"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
@ -198,7 +198,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../src/include;../src/include/private;../src/isdn/include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0501"
|
||||
RuntimeLibrary="2"
|
||||
DisableLanguageExtensions="false"
|
||||
RuntimeTypeInfo="false"
|
||||
|
@ -271,7 +271,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../src/include;../src/include/private;../src/isdn/include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0501"
|
||||
RuntimeLibrary="2"
|
||||
DisableLanguageExtensions="false"
|
||||
RuntimeTypeInfo="false"
|
||||
|
@ -428,6 +428,10 @@
|
|||
RelativePath="..\src\ftdm_call_utils.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_variables.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ftdm_callerid.c"
|
||||
>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -112,7 +112,7 @@
|
|||
</BuildLog>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
|
@ -134,7 +134,7 @@
|
|||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -161,7 +161,7 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../src/include;../src/include/private;../src/isdn/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FREETDM_EXPORTS;TELETONE_EXPORTS;_WIN32_WINNT=0x0502;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
|
@ -203,6 +203,7 @@
|
|||
<ClCompile Include="..\src\fsk.c" />
|
||||
<ClCompile Include="..\src\ftdm_buffer.c" />
|
||||
<ClCompile Include="..\src\ftdm_call_utils.c" />
|
||||
<ClCompile Include="..\src\ftdm_variables.c" />
|
||||
<ClCompile Include="..\src\ftdm_callerid.c" />
|
||||
<ClCompile Include="..\src\ftdm_config.c" />
|
||||
<ClCompile Include="..\src\ftdm_cpu_monitor.c" />
|
||||
|
@ -222,4 +223,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
<ClCompile Include="..\src\ftdm_call_utils.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\ftdm_variables.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\ftdm_callerid.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -131,4 +134,4 @@
|
|||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -146,8 +146,9 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="..\..\debug\freetdm.lib"
|
||||
AdditionalDependencies="freetdm.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""$(OutDir)";"C:\Program Files\Sangoma\api\lib\x64""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
|
@ -300,7 +301,9 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="freetdm.lib"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(OutDir)";"C:\Program Files\Sangoma\api\lib\x64""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
WarnAsError="true"
|
||||
WarnAsError="false"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4100"
|
||||
/>
|
||||
|
@ -146,8 +146,9 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="..\..\debug\freetdm.lib"
|
||||
AdditionalDependencies="freetdm.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""$(OutDir)";"C:\Program Files\Sangoma\api\lib\x64""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
|
@ -300,7 +301,9 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="freetdm.lib"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(OutDir)";"C:\Program Files\Sangoma\api\lib\x64""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
|
|
|
@ -4,5 +4,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
PROJECT(sample)
|
||||
|
||||
ADD_SUBDIRECTORY(boost)
|
||||
#ADD_SUBDIRECTORY(sched) FIXME: this code doesnt compile
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#
|
||||
# Arnaldo M Pereira <arnaldo@sangoma.com>
|
||||
#
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
PROJECT(boost)
|
||||
|
||||
IF(NOT DEFINED WIN32)
|
||||
INCLUDE_DIRECTORIES(/usr/local/freeswitch/include)
|
||||
ADD_DEFINITIONS(-Wall)
|
||||
ADD_EXECUTABLE(ftdmstart ftdmstart.c)
|
||||
TARGET_LINK_LIBRARIES(ftdmstart freetdm)
|
||||
ENDIF(NOT DEFINED WIN32)
|
|
@ -1,10 +0,0 @@
|
|||
CC=gcc
|
||||
CFLAGS=-Wall -I/usr/local/freeswitch/include
|
||||
LDFLAGS=-L/usr/local/freeswitch/lib -lfreetdm
|
||||
|
||||
ftdmstart: ftdmstart.o
|
||||
|
||||
clean:
|
||||
rm -rf ftdmstart.o
|
||||
|
||||
|
|
@ -1,469 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Sangoma Technologies
|
||||
* Moises Silva <moy@sangoma.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of the original author; nor the names of any contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sample program for the boost signaling absraction.
|
||||
* Usage: testboostalone <spanno-1> <spanno-2> ... -d [number-to-dial-if-any]
|
||||
* compile this program linking to the freetdm library (ie -lfreetdm)
|
||||
**/
|
||||
|
||||
#ifndef __linux__
|
||||
#define _CRT_SECURE_NO_WARNINGS 1
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "freetdm.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/* arbitrary limit for max calls in this sample program */
|
||||
#define MAX_CALLS 255
|
||||
|
||||
/* some timers (in seconds) to fake responses in incoming calls */
|
||||
#define PROGRESS_TIMER 1
|
||||
#define ANSWER_TIMER 5
|
||||
#define HANGUP_TIMER 15
|
||||
|
||||
/* simple variable used to stop the application */
|
||||
static int app_running = 0;
|
||||
|
||||
typedef void (*expired_function_t)(ftdm_channel_t *channel);
|
||||
typedef struct dummy_timer_s {
|
||||
int time;
|
||||
ftdm_channel_t *channel;
|
||||
expired_function_t expired;
|
||||
} dummy_timer_t;
|
||||
|
||||
/* dummy second resolution timers */
|
||||
static dummy_timer_t g_timers[MAX_CALLS];
|
||||
|
||||
/* mutex to protect the timers (both, the test thread and the signaling thread may modify them) */
|
||||
static ftdm_mutex_t *g_schedule_mutex;
|
||||
|
||||
/* unique outgoing channel */
|
||||
static ftdm_channel_t *g_outgoing_channel = NULL;
|
||||
|
||||
static void interrupt_requested(int signal)
|
||||
{
|
||||
app_running = 0;
|
||||
}
|
||||
|
||||
static void schedule_timer(ftdm_channel_t *channel, int sec, expired_function_t expired)
|
||||
{
|
||||
int i;
|
||||
ftdm_mutex_lock(g_schedule_mutex);
|
||||
for (i = 0; i < sizeof(g_timers)/sizeof(g_timers[0]); i++) {
|
||||
/* check the timer slot is free to use */
|
||||
if (!g_timers[i].time) {
|
||||
g_timers[i].time = sec;
|
||||
g_timers[i].channel = channel;
|
||||
g_timers[i].expired = expired;
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to schedule timer\n");
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
}
|
||||
|
||||
static void run_timers(void)
|
||||
{
|
||||
int i;
|
||||
void *channel;
|
||||
expired_function_t expired_func = NULL;
|
||||
ftdm_mutex_lock(g_schedule_mutex);
|
||||
for (i = 0; i < sizeof(g_timers)/sizeof(g_timers[0]); i++) {
|
||||
/* if there's time left, decrement */
|
||||
if (g_timers[i].time) {
|
||||
g_timers[i].time--;
|
||||
}
|
||||
|
||||
/* if time expired and we have an expired function, call it */
|
||||
if (!g_timers[i].time && g_timers[i].expired) {
|
||||
expired_func = g_timers[i].expired;
|
||||
channel = g_timers[i].channel;
|
||||
memset(&g_timers[i], 0, sizeof(g_timers[i]));
|
||||
expired_func(channel);
|
||||
}
|
||||
}
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
}
|
||||
|
||||
static void release_timers(ftdm_channel_t *channel)
|
||||
{
|
||||
int i;
|
||||
ftdm_mutex_lock(g_schedule_mutex);
|
||||
for (i = 0; i < sizeof(g_timers)/sizeof(g_timers[0]); i++) {
|
||||
/* clear any timer belonging to the given channel */
|
||||
if (g_timers[i].channel == channel) {
|
||||
memset(&g_timers[i], 0, sizeof(g_timers[i]));
|
||||
}
|
||||
}
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
}
|
||||
|
||||
/* hangup the call */
|
||||
static void send_hangup(ftdm_channel_t *channel)
|
||||
{
|
||||
int spanid = ftdm_channel_get_span_id(channel);
|
||||
int chanid = ftdm_channel_get_id(channel);
|
||||
ftdm_log(FTDM_LOG_NOTICE, "-- Requesting hangup in channel %d:%d\n", spanid, chanid);
|
||||
ftdm_channel_call_hangup(channel);
|
||||
}
|
||||
|
||||
/* send answer for an incoming call */
|
||||
static void send_answer(ftdm_channel_t *channel)
|
||||
{
|
||||
/* we move the channel signaling state machine to UP (answered) */
|
||||
int spanid = ftdm_channel_get_span_id(channel);
|
||||
int chanid = ftdm_channel_get_id(channel);
|
||||
ftdm_log(FTDM_LOG_NOTICE, "-- Requesting answer in channel %d:%d\n", spanid, chanid);
|
||||
ftdm_channel_call_answer(channel);
|
||||
schedule_timer(channel, HANGUP_TIMER, send_hangup);
|
||||
}
|
||||
|
||||
/* send progress for an incoming */
|
||||
static void send_progress(ftdm_channel_t *channel)
|
||||
{
|
||||
/* we move the channel signaling state machine to UP (answered) */
|
||||
int spanid = ftdm_channel_get_span_id(channel);
|
||||
int chanid = ftdm_channel_get_id(channel);
|
||||
ftdm_log(FTDM_LOG_NOTICE, "-- Requesting progress\n", spanid, chanid);
|
||||
ftdm_channel_call_indicate(channel, FTDM_CHANNEL_INDICATE_PROGRESS);
|
||||
schedule_timer(channel, ANSWER_TIMER, send_answer);
|
||||
}
|
||||
|
||||
/* This function will be called in an undetermined signaling thread, you must not do
|
||||
* any blocking operations here or the signaling stack may delay other call event processing
|
||||
* The arguments for this function are defined in FIO_SIGNAL_CB_FUNCTION prototype, I just
|
||||
* name them here for your convenience:
|
||||
* ftdm_sigmsg_t *sigmsg
|
||||
* - The sigmsg structure contains the ftdm_channel structure that represents the channel where
|
||||
* the event occurred and the event_id of the signaling event that just occurred.
|
||||
* */
|
||||
static FIO_SIGNAL_CB_FUNCTION(on_signaling_event)
|
||||
{
|
||||
switch (sigmsg->event_id) {
|
||||
/* This event signals the start of an incoming call */
|
||||
case FTDM_SIGEVENT_START:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Incoming call received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
schedule_timer(sigmsg->channel, PROGRESS_TIMER, send_progress);
|
||||
break;
|
||||
/* This event signals progress on an outgoing call */
|
||||
case FTDM_SIGEVENT_PROGRESS_MEDIA:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Progress message received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
break;
|
||||
/* This event signals answer in an outgoing call */
|
||||
case FTDM_SIGEVENT_UP:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Answer received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
/* now the channel is answered and we can use
|
||||
* ftdm_channel_wait() to wait for input/output in a channel (equivalent to poll() or select())
|
||||
* ftdm_channel_read() to read available data in a channel
|
||||
* ftdm_channel_write() to write to the channel */
|
||||
break;
|
||||
/* This event signals hangup from the other end */
|
||||
case FTDM_SIGEVENT_STOP:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Hangup received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
if (g_outgoing_channel == sigmsg->channel) {
|
||||
g_outgoing_channel = NULL;
|
||||
}
|
||||
/* release any timer for this channel */
|
||||
release_timers(sigmsg->channel);
|
||||
/* acknowledge the hangup */
|
||||
ftdm_channel_call_hangup(sigmsg->channel);
|
||||
break;
|
||||
default:
|
||||
ftdm_log(FTDM_LOG_WARNING, "Unhandled event %s in channel %d:%d\n", ftdm_signal_event2str(sigmsg->event_id),
|
||||
sigmsg->span_id, sigmsg->chan_id);
|
||||
break;
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
static void place_call(const ftdm_span_t *span, const char *number)
|
||||
{
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
ftdm_caller_data_t caller_data = {{ 0 }};
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
|
||||
/* set destiny number */
|
||||
ftdm_set_string(caller_data.dnis.digits, number);
|
||||
|
||||
/* set callerid */
|
||||
ftdm_set_string(caller_data.cid_name, "testsangomaboost");
|
||||
ftdm_set_string(caller_data.cid_num.digits, "1234");
|
||||
|
||||
/* request to search for an outgoing channel top down with the given caller data.
|
||||
* it is also an option to use ftdm_channel_open_by_group to let freetdm hunt
|
||||
* an available channel in a given group instead of per span
|
||||
* */
|
||||
status = ftdm_channel_open_by_span(ftdm_span_get_id(span), FTDM_TOP_DOWN, &caller_data, &ftdmchan);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to originate call\n");
|
||||
return;
|
||||
}
|
||||
|
||||
g_outgoing_channel = ftdmchan;
|
||||
|
||||
/* set the caller data for the outgoing channel */
|
||||
ftdm_channel_set_caller_data(ftdmchan, &caller_data);
|
||||
|
||||
status = ftdm_channel_call_place(ftdmchan);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to originate call\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* this is required to initialize the outgoing channel */
|
||||
ftdm_channel_init(ftdmchan);
|
||||
}
|
||||
|
||||
#define ARRLEN(arr) (sizeof(arr)/sizeof(arr[0]))
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* span names can be any null-terminated string, does not need to be a wanpipe port */
|
||||
int span_numbers[32];
|
||||
char span_names[ARRLEN(span_numbers)][ARRLEN(span_numbers)];
|
||||
const char *spanname = NULL;
|
||||
char wpchans[25];
|
||||
unsigned configured = 0;
|
||||
int i, spanno;
|
||||
int numspans = 0;
|
||||
ftdm_status_t status;
|
||||
ftdm_span_t *span_list[ARRLEN(span_numbers)];
|
||||
ftdm_span_t *span;
|
||||
ftdm_channel_config_t chan_config;
|
||||
ftdm_conf_parameter_t parameters[20];
|
||||
char *todial = NULL;
|
||||
int32_t ticks = 0;
|
||||
|
||||
/* register a handler to shutdown things properly */
|
||||
#ifdef _WIN64
|
||||
// still trying to figure this one out otherwise triggers error
|
||||
if (signal(SIGINT, interrupt_requested) < 0) {
|
||||
#else
|
||||
if (signal(SIGINT, interrupt_requested) == SIG_ERR) {
|
||||
#endif
|
||||
fprintf(stderr, "Could not set the SIGINT signal handler: %s\n", strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-' && argv[i][1] == 'd') {
|
||||
i++;
|
||||
if (i >= argc) {
|
||||
fprintf(stderr, "Error, -d specified but no number to dial!\n");
|
||||
exit(1);
|
||||
}
|
||||
todial = argv[i];
|
||||
if (!strlen(todial)) {
|
||||
todial = NULL;
|
||||
}
|
||||
printf("Number to dial: %s\n", todial);
|
||||
continue;
|
||||
}
|
||||
spanno = atoi(argv[i]);
|
||||
span_numbers[numspans] = spanno;
|
||||
snprintf(span_names[numspans], sizeof(span_names[numspans]), "wanpipe%d", spanno);
|
||||
numspans++;
|
||||
}
|
||||
|
||||
if (!numspans) {
|
||||
fprintf(stderr, "please specify a at least 1 wanpipe port number\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* clear any outstanding timers */
|
||||
memset(&g_timers, 0, sizeof(g_timers));
|
||||
|
||||
/* set the logging level to use */
|
||||
ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG);
|
||||
|
||||
/* Initialize the FTDM library */
|
||||
if (ftdm_global_init() != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error loading FreeTDM\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* create the schedule mutex */
|
||||
ftdm_mutex_create(&g_schedule_mutex);
|
||||
|
||||
/* now we can start creating spans */
|
||||
memset(&chan_config, 0, sizeof(chan_config));
|
||||
strncpy(chan_config.group_name, "mygroup", sizeof(chan_config.group_name)-1);
|
||||
chan_config.group_name[sizeof(chan_config.group_name)-1] = 0;
|
||||
for (i = 0; i < numspans; i++) {
|
||||
spanname = span_names[i];
|
||||
/* "wanpipe" is the special I/O identifier for Sangoma devices */
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Creating span %s\n", spanname);
|
||||
status = ftdm_span_create("wanpipe", spanname, &span_list[i]);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_CRIT, "Failed to create span %s\n", spanname);
|
||||
goto done;
|
||||
}
|
||||
span = span_list[i];
|
||||
spanno = span_numbers[i];
|
||||
|
||||
/* set the trunk type for the span */
|
||||
ftdm_span_set_trunk_type(span_list[i], FTDM_TRUNK_T1);
|
||||
|
||||
/* configure B channels (syntax for wanpipe channels is span:low_chan-high_chan) */
|
||||
chan_config.type = FTDM_CHAN_TYPE_B;
|
||||
snprintf(wpchans, sizeof(wpchans), "%d:1-23", spanno);
|
||||
ftdm_configure_span_channels(span, wpchans, &chan_config, &configured);
|
||||
ftdm_log(FTDM_LOG_NOTICE, "registered %d b channels\n", configured);
|
||||
}
|
||||
|
||||
/* At this point FreeTDM is ready to be used, the spans defined in freetdm.conf have the basic I/O board configuration
|
||||
* but no telephony signaling configuration at all. */
|
||||
ftdm_log(FTDM_LOG_NOTICE, "FreeTDM loaded ...\n");
|
||||
|
||||
/* now we can start configuring signaling for the previously created spans */
|
||||
for (i = 0; i < numspans; i++) {
|
||||
spanname = span_names[i];
|
||||
|
||||
/* Retrieve a span by name (as specified in ftdm_span_create()) */
|
||||
if (ftdm_span_find_by_name(spanname, &span) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span %s\n", ftdm_span_get_name(span));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* prepare the configuration parameters that will be sent down to the signaling stack, the array of paramters must be terminated by an
|
||||
* array element with a null .var member */
|
||||
|
||||
/* for sangoma_boost signaling (abstraction signaling used by Sangoma for PRI, BRI and SS7) the first parameter you must send
|
||||
* is sigmod, which must be either sangoma_prid, if you have the PRI stack available, or sangoma_brid for the BRI stack */
|
||||
parameters[0].var = "sigmod";
|
||||
parameters[0].val = "sangoma_prid";
|
||||
|
||||
/* following parameters are signaling stack specific, this ones are for PRI */
|
||||
parameters[1].var = "switchtype";
|
||||
parameters[1].val = "national";
|
||||
|
||||
parameters[2].var = "signalling";
|
||||
parameters[2].val = "pri_cpe";
|
||||
|
||||
/*
|
||||
* parameters[3].var = "nfas_primary";
|
||||
* parameters[3].val = "4"; //span number
|
||||
*
|
||||
* parameters[4].var = "nfas_secondary";
|
||||
* parameters[4].val = "2"; //span number
|
||||
*
|
||||
* parameters[5].var = "nfas_group";
|
||||
* parameters[5].val = "1";
|
||||
* */
|
||||
|
||||
|
||||
/* the last parameter .var member must be NULL! */
|
||||
parameters[3].var = NULL;
|
||||
|
||||
/* send the configuration values down to the stack */
|
||||
if (ftdm_configure_span_signaling(span, "sangoma_boost", on_signaling_event, parameters) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error configuring sangoma_boost signaling abstraction in span %s\n", ftdm_span_get_name(span));
|
||||
goto done;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* configuration succeeded, we can proceed now to start each span
|
||||
* This step will launch at least 1 background (may be more, depending on the signaling stack used)
|
||||
* to handle *ALL* signaling events for this span, your on_signaling_event callback will be called always
|
||||
* in one of those infraestructure threads and you MUST NOT block in that handler to avoid delays and errors
|
||||
* in the signaling processing for any call.
|
||||
* */
|
||||
for (i = 0; i < numspans; i++) {
|
||||
spanname = span_names[i];
|
||||
/* Retrieve a span by name (as specified in ftdm_span_create()) */
|
||||
if (ftdm_span_find_by_name(spanname, &span) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span %s\n", ftdm_span_get_name(span));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (ftdm_span_start(span) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failing starting signaling on span %s\n", ftdm_span_get_name(span));
|
||||
goto done;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app_running = 1;
|
||||
|
||||
/* Retrieve the first created span to place the call (if dialing was specified) */
|
||||
if (ftdm_span_find(1, &span) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span 1\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* The application thread can go on and do anything else, like waiting for a shutdown signal */
|
||||
while(ftdm_running() && app_running) {
|
||||
ftdm_sleep(1000);
|
||||
run_timers();
|
||||
ticks++;
|
||||
if (!(ticks % 10) && todial && !g_outgoing_channel) {
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Originating call to number %s\n", todial);
|
||||
place_call(span, todial);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Shutting down FreeTDM ...\n");
|
||||
|
||||
ftdm_mutex_destroy(&g_schedule_mutex);
|
||||
|
||||
/* whenever you're done, this function will shutdown the signaling threads in any span that was started */
|
||||
ftdm_global_destroy();
|
||||
|
||||
printf("Terminated!\n");
|
||||
|
||||
sleep(2);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
|
@ -37,8 +37,10 @@
|
|||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#define _WIN32_WINNT 0x0501 // To make GetSystemTimes visible in windows.h
|
||||
#include <windows.h>
|
||||
# if (_WIN32_WINNT < 0x0501)
|
||||
# error "Need to target at least Windows XP/Server 2003 because GetSystemTimes is needed"
|
||||
# endif
|
||||
# include <windows.h>
|
||||
#else /* LINUX */
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -122,5 +122,5 @@ FT_DECLARE(void *) ftdm_dso_func_sym(ftdm_dso_lib_t lib, const char *sym, char *
|
|||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
||||
|
|
|
@ -62,10 +62,11 @@ struct tm *localtime_r(const time_t *clock, struct tm *result);
|
|||
ftdm_time_t time_last_throttle_log = 0;
|
||||
ftdm_time_t time_current_throttle_log = 0;
|
||||
|
||||
static ftdm_iterator_t *get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter);
|
||||
static ftdm_status_t ftdm_call_set_call_id(ftdm_channel_t *fchan, ftdm_caller_data_t *caller_data);
|
||||
static ftdm_status_t ftdm_call_clear_call_id(ftdm_caller_data_t *caller_data);
|
||||
static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan);
|
||||
static ftdm_status_t ftdm_channel_sig_indicate(ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
|
||||
static int time_is_init = 0;
|
||||
|
||||
|
@ -1899,10 +1900,9 @@ openchan:
|
|||
ftdm_set_flag(check, FTDM_CHANNEL_INUSE);
|
||||
ftdm_set_flag(check, FTDM_CHANNEL_OUTBOUND);
|
||||
*ftdmchan = check;
|
||||
#if 1
|
||||
|
||||
/* we've got the channel, do not unlock it */
|
||||
goto done;
|
||||
#endif
|
||||
|
||||
unlockchan:
|
||||
ftdm_mutex_unlock(check->mutex);
|
||||
|
@ -2063,25 +2063,25 @@ FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_done(const ftdm_channel_t *ftdmc
|
|||
return condition;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status;
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
|
||||
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_HOLD);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_DIALTONE, 0);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_DIALTONE, 0, usrmsg);
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status;
|
||||
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 0);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 0, usrmsg);
|
||||
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
|
||||
|
@ -2108,7 +2108,7 @@ FT_DECLARE(void) ftdm_ack_indication(ftdm_channel_t *fchan, ftdm_channel_indicat
|
|||
}
|
||||
|
||||
/*! Answer call without locking the channel. The caller must have locked first */
|
||||
static ftdm_status_t _ftdm_channel_call_answer_nl(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
static ftdm_status_t _ftdm_channel_call_answer_nl(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
|
||||
|
@ -2118,7 +2118,7 @@ static ftdm_status_t _ftdm_channel_call_answer_nl(const char *file, const char *
|
|||
* use FTDM_SPAN_USE_SKIP_STATES for now while we update the sig modules */
|
||||
|
||||
if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) {
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1, usrmsg);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
status = FTDM_ECANCELED;
|
||||
goto done;
|
||||
|
@ -2133,7 +2133,7 @@ static ftdm_status_t _ftdm_channel_call_answer_nl(const char *file, const char *
|
|||
}
|
||||
|
||||
if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS_MEDIA) {
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1, usrmsg);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
status = FTDM_ECANCELED;
|
||||
goto done;
|
||||
|
@ -2148,7 +2148,7 @@ static ftdm_status_t _ftdm_channel_call_answer_nl(const char *file, const char *
|
|||
}
|
||||
}
|
||||
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 1, usrmsg);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
status = FTDM_ECANCELED;
|
||||
goto done;
|
||||
|
@ -2159,19 +2159,19 @@ done:
|
|||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status;
|
||||
|
||||
/* we leave the locking up to ftdm_channel_call_indicate, DO NOT lock here since ftdm_channel_call_indicate expects
|
||||
* the lock recursivity to be 1 */
|
||||
status = _ftdm_channel_call_indicate(file, func, line, ftdmchan, FTDM_CHANNEL_INDICATE_ANSWER);
|
||||
status = _ftdm_channel_call_indicate(file, func, line, ftdmchan, FTDM_CHANNEL_INDICATE_ANSWER, usrmsg);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* lock must be acquired by the caller! */
|
||||
static ftdm_status_t _ftdm_channel_call_hangup_nl(const char *file, const char *func, int line, ftdm_channel_t *chan)
|
||||
static ftdm_status_t _ftdm_channel_call_hangup_nl(const char *file, const char *func, int line, ftdm_channel_t *chan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
|
||||
|
@ -2188,7 +2188,7 @@ static ftdm_status_t _ftdm_channel_call_hangup_nl(const char *file, const char *
|
|||
if (ftdm_test_flag(chan, FTDM_CHANNEL_STATE_CHANGE)) {
|
||||
ftdm_channel_cancel_state(file, func, line, chan);
|
||||
}
|
||||
status = ftdm_channel_set_state(file, func, line, chan, FTDM_CHANNEL_STATE_HANGUP, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, chan, FTDM_CHANNEL_STATE_HANGUP, 1, usrmsg);
|
||||
} else {
|
||||
/* the signaling stack did not touch the state,
|
||||
* core is responsible from clearing flags and stuff, however, because ftmod_analog
|
||||
|
@ -2204,20 +2204,20 @@ static ftdm_status_t _ftdm_channel_call_hangup_nl(const char *file, const char *
|
|||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_call_cause_t cause)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_call_cause_t cause, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
|
||||
ftdmchan->caller_data.hangup_cause = cause;
|
||||
|
||||
status = _ftdm_channel_call_hangup_nl(file, func, line, ftdmchan);
|
||||
status = _ftdm_channel_call_hangup_nl(file, func, line, ftdmchan, usrmsg);
|
||||
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
|
||||
|
@ -2225,7 +2225,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char
|
|||
|
||||
ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
status = _ftdm_channel_call_hangup_nl(file, func, line, ftdmchan);
|
||||
status = _ftdm_channel_call_hangup_nl(file, func, line, ftdmchan, usrmsg);
|
||||
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
return status;
|
||||
|
@ -2285,7 +2285,7 @@ FT_DECLARE(uint32_t) ftdm_channel_get_ph_span_id(const ftdm_channel_t *ftdmchan)
|
|||
* someone *MUST* acknowledge the indication, either the signaling stack, this function or the core
|
||||
* at some later point
|
||||
* */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
|
||||
|
@ -2328,26 +2328,26 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch
|
|||
/* FIXME: ring and busy cannot be used with all signaling stacks
|
||||
* (particularly isdn stacks I think, we should emulate or just move to hangup with busy cause) */
|
||||
case FTDM_CHANNEL_INDICATE_RINGING:
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RINGING, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RINGING, 1, usrmsg);
|
||||
break;
|
||||
case FTDM_CHANNEL_INDICATE_BUSY:
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_BUSY, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_BUSY, 1, usrmsg);
|
||||
break;
|
||||
case FTDM_CHANNEL_INDICATE_PROCEED:
|
||||
if (!ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_PROCEED_STATE) ||
|
||||
ftdmchan->state == FTDM_CHANNEL_STATE_PROCEED) {
|
||||
ftdmchan->state >= FTDM_CHANNEL_STATE_PROCEED) {
|
||||
ftdm_ack_indication(ftdmchan, indication, status);
|
||||
goto done;
|
||||
}
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROCEED, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROCEED, 1, usrmsg);
|
||||
break;
|
||||
case FTDM_CHANNEL_INDICATE_PROGRESS:
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1, usrmsg);
|
||||
break;
|
||||
case FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA:
|
||||
if (!ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_SKIP_STATES)) {
|
||||
if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) {
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1, usrmsg);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -2359,14 +2359,14 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1);
|
||||
status = ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1, usrmsg);
|
||||
break;
|
||||
case FTDM_CHANNEL_INDICATE_ANSWER:
|
||||
status = _ftdm_channel_call_answer_nl(file, func, line, ftdmchan);
|
||||
status = _ftdm_channel_call_answer_nl(file, func, line, ftdmchan, usrmsg);
|
||||
break;
|
||||
default:
|
||||
ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "Do not know how to indicate %d\n", indication);
|
||||
status = FTDM_EINVAL;
|
||||
/* See if signalling module can provide this indication */
|
||||
status = ftdm_channel_sig_indicate(ftdmchan, indication, usrmsg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2376,38 +2376,19 @@ done:
|
|||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_send_msg(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_sigmsg_t *sigmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "null channel");
|
||||
#ifdef __WINDOWS__
|
||||
UNREFERENCED_PARAMETER(file);
|
||||
UNREFERENCED_PARAMETER(func);
|
||||
UNREFERENCED_PARAMETER(line);
|
||||
#endif
|
||||
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
if (ftdmchan->span->send_msg) {
|
||||
status = ftdmchan->span->send_msg(ftdmchan, sigmsg);
|
||||
} else {
|
||||
status = FTDM_NOTIMPL;
|
||||
ftdm_log(FTDM_LOG_ERROR, "send_msg method not implemented in this span!\n");
|
||||
}
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_reset(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_reset(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "null channel");
|
||||
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RESET, 1);
|
||||
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RESET, 1, usrmsg);
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
static ftdm_status_t _ftdm_channel_call_place_nl(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
/* this function MUST be called with the channel lock held with lock recursivity of 1 exactly,
|
||||
* and the caller must be aware we might unlock the channel for a brief period of time and then lock it again */
|
||||
static ftdm_status_t _ftdm_channel_call_place_nl(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
|
||||
|
@ -2430,11 +2411,6 @@ static ftdm_status_t _ftdm_channel_call_place_nl(const char *file, const char *f
|
|||
goto done;
|
||||
}
|
||||
|
||||
if (ftdmchan->state != FTDM_CHANNEL_STATE_DOWN) {
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot place call in channel in state %s!\n", ftdm_channel_state2str(ftdmchan->state));
|
||||
goto done;
|
||||
}
|
||||
|
||||
status = ftdmchan->span->outgoing_call(ftdmchan);
|
||||
if (status == FTDM_BREAK) {
|
||||
/* the signaling module detected glare on time */
|
||||
|
@ -2447,13 +2423,24 @@ static ftdm_status_t _ftdm_channel_call_place_nl(const char *file, const char *f
|
|||
goto done;
|
||||
}
|
||||
|
||||
/* in case of success, *before* unlocking the channel, we must set the call started flag and the call id
|
||||
* that is a guarantee that signaling modules expect from us */
|
||||
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_CALL_STARTED);
|
||||
ftdm_call_set_call_id(ftdmchan, &ftdmchan->caller_data);
|
||||
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) {
|
||||
/* be aware this waiting unlocks the channel and locks it back when done */
|
||||
ftdm_wait_for_flag_cleared(ftdmchan, FTDM_CHANNEL_STATE_CHANGE, 100);
|
||||
|
||||
/* if the signaling stack left the channel in state down on success, is expecting us to move to DIALING */
|
||||
if (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN) {
|
||||
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) {
|
||||
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_DIALING, 1, usrmsg);
|
||||
} else {
|
||||
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_DIALING, 0, usrmsg);
|
||||
}
|
||||
} else if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE) &&
|
||||
!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NONBLOCK)) {
|
||||
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
|
||||
ftdm_interrupt_wait(ftdmchan->state_completed_interrupt, 500);
|
||||
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -2465,19 +2452,20 @@ done:
|
|||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status;
|
||||
ftdm_channel_lock(ftdmchan);
|
||||
|
||||
status = _ftdm_channel_call_place_nl(file, func, line, ftdmchan);
|
||||
/* be aware that _ftdm_channl_call_place_nl can unlock/lock the channel quickly if working in blocking mode */
|
||||
status = _ftdm_channel_call_place_nl(file, func, line, ftdmchan, usrmsg);
|
||||
|
||||
ftdm_channel_unlock(ftdmchan);
|
||||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, int line,
|
||||
ftdm_caller_data_t *caller_data, ftdm_hunting_scheme_t *hunting)
|
||||
ftdm_caller_data_t *caller_data, ftdm_hunting_scheme_t *hunting, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
ftdm_channel_t *fchan = NULL;
|
||||
|
@ -2513,9 +2501,10 @@ FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, i
|
|||
|
||||
ftdm_channel_set_caller_data(fchan, caller_data);
|
||||
|
||||
status = _ftdm_channel_call_place_nl(file, func, line, fchan);
|
||||
/* be aware that _ftdm_channl_call_place_nl can unlock/lock the channel quickly if working in blocking mode */
|
||||
status = _ftdm_channel_call_place_nl(file, func, line, fchan, usrmsg);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
_ftdm_channel_call_hangup_nl(file, func, line, fchan);
|
||||
_ftdm_channel_call_hangup_nl(file, func, line, fchan, usrmsg);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -2603,6 +2592,29 @@ FT_DECLARE(ftdm_status_t) ftdm_span_get_sig_status(ftdm_span_t *span, ftdm_signa
|
|||
}
|
||||
}
|
||||
|
||||
static ftdm_status_t ftdm_channel_sig_indicate(ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
if (ftdmchan->span->indicate) {
|
||||
|
||||
ftdm_channel_save_usrmsg(ftdmchan, usrmsg);
|
||||
|
||||
status = ftdmchan->span->indicate(ftdmchan, indication);
|
||||
if (status == FTDM_NOTIMPL) {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Do not know how to indicate %s\n", ftdm_channel_indication2str(indication));
|
||||
} else if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Failed to indicate %s\n", ftdm_channel_indication2str(indication));
|
||||
} else { /* SUCCESS */
|
||||
ftdm_ack_indication(ftdmchan, indication, FTDM_SUCCESS);
|
||||
}
|
||||
ftdm_usrmsg_free(&ftdmchan->usrmsg);
|
||||
} else {
|
||||
return FTDM_NOTIMPL;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* this function must be called with the channel lock */
|
||||
static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
|
@ -2630,6 +2642,7 @@ static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan)
|
|||
ftdm_buffer_destroy(&ftdmchan->pre_buffer);
|
||||
ftdmchan->pre_buffer_size = 0;
|
||||
ftdm_mutex_unlock(ftdmchan->pre_buffer_mutex);
|
||||
|
||||
if (ftdmchan->hangup_timer) {
|
||||
ftdm_sched_cancel_timer(globals.timingsched, ftdmchan->hangup_timer);
|
||||
}
|
||||
|
@ -3504,7 +3517,8 @@ skipdebug:
|
|||
ftdmchan->dtmf_hangup_buf[ftdmchan->span->dtmf_hangup_len - 1] = *p;
|
||||
if (!strcmp(ftdmchan->dtmf_hangup_buf, ftdmchan->span->dtmf_hangup)) {
|
||||
ftdm_log(FTDM_LOG_DEBUG, "DTMF hangup detected.\n");
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
||||
|
||||
ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, ftdmchan, FTDM_CHANNEL_STATE_HANGUP, 0, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -4028,92 +4042,7 @@ done:
|
|||
return status;
|
||||
}
|
||||
|
||||
FT_DECLARE(void) ftdm_call_clear_data(ftdm_caller_data_t *caller_data)
|
||||
{
|
||||
if (caller_data->variables) {
|
||||
hashtable_destroy(caller_data->variables);
|
||||
}
|
||||
caller_data->variables = NULL;
|
||||
memset(&caller_data->raw_data, 0, sizeof(caller_data->raw_data));
|
||||
caller_data->raw_data_len = 0;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_call_remove_var(ftdm_caller_data_t *caller_data, const char *var_name)
|
||||
{
|
||||
if (caller_data->variables) {
|
||||
hashtable_remove(caller_data->variables, (void *)var_name);
|
||||
}
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_call_add_var(ftdm_caller_data_t *caller_data, const char *var_name, const char *value)
|
||||
{
|
||||
char *t_name = 0, *t_val = 0;
|
||||
|
||||
if (!var_name || !value) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
if (!caller_data->variables) {
|
||||
/* initialize on first use */
|
||||
caller_data->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
|
||||
ftdm_assert_return(caller_data->variables, FTDM_FAIL, "Failed to create hash table\n");
|
||||
}
|
||||
|
||||
t_name = ftdm_strdup(var_name);
|
||||
t_val = ftdm_strdup(value);
|
||||
hashtable_insert(caller_data->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(const char *) ftdm_call_get_var(ftdm_caller_data_t *caller_data, const char *var_name)
|
||||
{
|
||||
const char *var = NULL;
|
||||
|
||||
if (!caller_data->variables || !var_name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
var = (const char *)hashtable_search(((struct hashtable*)caller_data->variables), (void *)var_name);
|
||||
return var;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_call_get_var_iterator(const ftdm_caller_data_t *caller_data, ftdm_iterator_t *iter)
|
||||
{
|
||||
ftdm_hash_iterator_t *hashiter = NULL;
|
||||
hashiter = caller_data->variables == NULL ? NULL : hashtable_first(caller_data->variables);
|
||||
|
||||
if (hashiter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(iter = get_iterator(FTDM_ITERATOR_VARS, iter))) {
|
||||
return NULL;
|
||||
}
|
||||
iter->pvt.hashiter = hashiter;
|
||||
return iter;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_call_get_current_var(ftdm_iterator_t *iter, const char **var_name, const char **var_val)
|
||||
{
|
||||
const void *key = NULL;
|
||||
void *val = NULL;
|
||||
|
||||
*var_name = NULL;
|
||||
*var_val = NULL;
|
||||
|
||||
ftdm_assert_return(iter && (iter->type == FTDM_ITERATOR_VARS) && iter->pvt.hashiter, FTDM_FAIL, "Cannot get variable from invalid iterator!\n");
|
||||
|
||||
hashtable_this(iter->pvt.hashiter, &key, NULL, &val);
|
||||
|
||||
*var_name = key;
|
||||
*var_val = val;
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
static ftdm_iterator_t *get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter)
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter)
|
||||
{
|
||||
int allocated = 0;
|
||||
if (iter) {
|
||||
|
@ -4139,7 +4068,7 @@ static ftdm_iterator_t *get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t
|
|||
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter)
|
||||
{
|
||||
if (!(iter = get_iterator(FTDM_ITERATOR_CHANS, iter))) {
|
||||
if (!(iter = ftdm_get_iterator(FTDM_ITERATOR_CHANS, iter))) {
|
||||
return NULL;
|
||||
}
|
||||
iter->pvt.chaniter.index = 1;
|
||||
|
@ -5360,14 +5289,6 @@ FT_DECLARE(ftdm_status_t) ftdm_group_create(ftdm_group_t **group, const char *na
|
|||
static ftdm_status_t ftdm_span_trigger_signal(const ftdm_span_t *span, ftdm_sigmsg_t *sigmsg)
|
||||
{
|
||||
ftdm_status_t status = span->signal_cb(sigmsg);
|
||||
if (sigmsg->channel) {
|
||||
ftdm_call_clear_data(&(sigmsg->channel->caller_data));
|
||||
}
|
||||
if (sigmsg->raw.autofree) {
|
||||
ftdm_safe_free(sigmsg->raw.data);
|
||||
sigmsg->raw.data = NULL;
|
||||
sigmsg->raw.len = 0;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -5390,7 +5311,7 @@ FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span)
|
|||
ftdm_sigmsg_t *sigmsg = NULL;
|
||||
while ((sigmsg = ftdm_queue_dequeue(span->pendingsignals))) {
|
||||
ftdm_span_trigger_signal(span, sigmsg);
|
||||
ftdm_safe_free(sigmsg);
|
||||
ftdm_sigmsg_free(&sigmsg);
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
@ -5403,7 +5324,7 @@ static void execute_safety_hangup(void *data)
|
|||
fchan->hangup_timer = 0;
|
||||
if (fchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
|
||||
ftdm_log_chan(fchan, FTDM_LOG_CRIT, "Forcing hangup since the user did not confirmed our hangup after %dms\n", FORCE_HANGUP_TIMER);
|
||||
_ftdm_channel_call_hangup_nl(__FILE__, __FUNCTION__, __LINE__, fchan);
|
||||
_ftdm_channel_call_hangup_nl(__FILE__, __FUNCTION__, __LINE__, fchan, NULL);
|
||||
} else {
|
||||
ftdm_log_chan(fchan, FTDM_LOG_CRIT, "Not performing safety hangup, channel state is %s\n", ftdm_channel_state2str(fchan->state));
|
||||
}
|
||||
|
@ -5616,17 +5537,30 @@ FT_DECLARE(ftdm_status_t) ftdm_global_init(void)
|
|||
ftdm_mutex_create(&globals.call_id_mutex);
|
||||
|
||||
ftdm_sched_global_init();
|
||||
globals.running = 1;
|
||||
if (ftdm_sched_create(&globals.timingsched, "freetdm-master") != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_CRIT, "Failed to create master timing schedule context\n");
|
||||
return FTDM_FAIL;
|
||||
goto global_init_fail;
|
||||
}
|
||||
if (ftdm_sched_free_run(globals.timingsched) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_CRIT, "Failed to run master timing schedule context\n");
|
||||
return FTDM_FAIL;
|
||||
goto global_init_fail;
|
||||
}
|
||||
|
||||
globals.running = 1;
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
|
||||
global_init_fail:
|
||||
globals.running = 0;
|
||||
ftdm_mutex_destroy(&globals.mutex);
|
||||
ftdm_mutex_destroy(&globals.span_mutex);
|
||||
ftdm_mutex_destroy(&globals.group_mutex);
|
||||
ftdm_mutex_destroy(&globals.call_id_mutex);
|
||||
hashtable_destroy(globals.interface_hash);
|
||||
hashtable_destroy(globals.module_hash);
|
||||
hashtable_destroy(globals.span_hash);
|
||||
hashtable_destroy(globals.group_hash);
|
||||
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void)
|
||||
|
@ -6106,6 +6040,123 @@ static ftdm_status_t ftdm_call_clear_call_id(ftdm_caller_data_t *caller_data)
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen)
|
||||
{
|
||||
if (!sigmsg || !sigmsg->raw.len) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
*data = sigmsg->raw.data;
|
||||
*datalen = sigmsg->raw.len;
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data_detached(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen)
|
||||
{
|
||||
if (!sigmsg || !sigmsg->raw.len) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
*data = sigmsg->raw.data;
|
||||
*datalen = sigmsg->raw.len;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_set_raw_data(ftdm_sigmsg_t *sigmsg, void *data, ftdm_size_t datalen)
|
||||
{
|
||||
ftdm_assert_return(sigmsg, FTDM_FAIL, "Trying to set raw data on a NULL event\n");
|
||||
ftdm_assert_return(!sigmsg->raw.len, FTDM_FAIL, "Overwriting existing raw data\n");
|
||||
ftdm_assert_return(datalen, FTDM_FAIL, "Data length not set\n");
|
||||
|
||||
sigmsg->raw.data = data;
|
||||
sigmsg->raw.len = datalen;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_get_raw_data(ftdm_usrmsg_t *usrmsg, void **data, ftdm_size_t *datalen)
|
||||
{
|
||||
if (!usrmsg || !usrmsg->raw.len) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
*data = usrmsg->raw.data;
|
||||
*datalen = usrmsg->raw.len;
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_set_raw_data(ftdm_usrmsg_t *usrmsg, void *data, ftdm_size_t datalen)
|
||||
{
|
||||
ftdm_assert_return(usrmsg, FTDM_FAIL, "Trying to set raw data on a NULL event\n");
|
||||
ftdm_assert_return(!usrmsg->raw.len, FTDM_FAIL, "Overwriting existing raw data\n");
|
||||
ftdm_assert_return(datalen, FTDM_FAIL, "Data length not set\n");
|
||||
|
||||
usrmsg->raw.data = data;
|
||||
usrmsg->raw.len = datalen;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_save_usrmsg(ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_assert_return(!ftdmchan->usrmsg, FTDM_FAIL, "Info from previous event was not cleared\n");
|
||||
if (usrmsg) {
|
||||
/* Copy sigmsg from user to internal copy so user can set new variables without race condition */
|
||||
ftdmchan->usrmsg = ftdm_calloc(1, sizeof(ftdm_usrmsg_t));
|
||||
memcpy(ftdmchan->usrmsg, usrmsg, sizeof(ftdm_usrmsg_t));
|
||||
|
||||
if (usrmsg->raw.data) {
|
||||
usrmsg->raw.data = NULL;
|
||||
usrmsg->raw.len = 0;
|
||||
}
|
||||
if (usrmsg->variables) {
|
||||
usrmsg->variables = NULL;
|
||||
}
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_free(ftdm_sigmsg_t **sigmsg)
|
||||
{
|
||||
if (!*sigmsg) {
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
if ((*sigmsg)->variables) {
|
||||
hashtable_destroy((*sigmsg)->variables);
|
||||
(*sigmsg)->variables = NULL;
|
||||
}
|
||||
|
||||
if ((*sigmsg)->raw.data) {
|
||||
ftdm_safe_free((*sigmsg)->raw.data);
|
||||
(*sigmsg)->raw.data = NULL;
|
||||
(*sigmsg)->raw.len = 0;
|
||||
}
|
||||
|
||||
ftdm_safe_free(*sigmsg);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_free(ftdm_usrmsg_t **usrmsg)
|
||||
{
|
||||
if (!*usrmsg) {
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
if ((*usrmsg)->variables) {
|
||||
hashtable_destroy((*usrmsg)->variables);
|
||||
(*usrmsg)->variables = NULL;
|
||||
}
|
||||
|
||||
if ((*usrmsg)->raw.data) {
|
||||
ftdm_safe_free((*usrmsg)->raw.data);
|
||||
(*usrmsg)->raw.data = NULL;
|
||||
(*usrmsg)->raw.len = 0;
|
||||
}
|
||||
|
||||
ftdm_safe_free(*usrmsg);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -40,19 +40,7 @@ FTDM_STR2ENUM(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channel_
|
|||
FTDM_ENUM_NAMES(CHANNEL_STATE_STATUS_NAMES, CHANNEL_STATE_STATUS_STRINGS)
|
||||
FTDM_STR2ENUM(ftdm_str2ftdm_state_status, ftdm_state_status2str, ftdm_state_status_t, CHANNEL_STATE_STATUS_NAMES, FTDM_STATE_STATUS_INVALID)
|
||||
|
||||
/* This function is only needed for boost and we should get rid of it at the next refactoring */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_init(ftdm_channel_t *fchan)
|
||||
{
|
||||
ftdm_channel_lock(fchan);
|
||||
|
||||
if (fchan->init_state != FTDM_CHANNEL_STATE_DOWN) {
|
||||
ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, fchan, fchan->init_state, 1);
|
||||
fchan->init_state = FTDM_CHANNEL_STATE_DOWN;
|
||||
}
|
||||
|
||||
ftdm_channel_unlock(fchan);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
static ftdm_status_t ftdm_core_set_state(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int waitrq);
|
||||
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const char *func, int line, ftdm_channel_t *fchan)
|
||||
{
|
||||
|
@ -66,6 +54,8 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const c
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_usrmsg_free(&fchan->usrmsg);
|
||||
|
||||
ftdm_clear_flag(fchan, FTDM_CHANNEL_STATE_CHANGE);
|
||||
|
||||
if (state == FTDM_CHANNEL_STATE_PROGRESS) {
|
||||
|
@ -123,7 +113,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_set_state(const char *file, const char *func, in
|
|||
the current state */
|
||||
_ftdm_channel_complete_state(file, func, line, fchan);
|
||||
}
|
||||
return ftdm_channel_set_state(file, func, line, fchan, state, 0);
|
||||
return ftdm_core_set_state(file, func, line, fchan, state, 0);
|
||||
}
|
||||
|
||||
static int ftdm_parse_state_map(ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, ftdm_state_map_t *state_map)
|
||||
|
@ -225,9 +215,20 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_cancel_state(const char *file, const char
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int waitrq, ftdm_usrmsg_t *usrmsg)
|
||||
{
|
||||
ftdm_channel_save_usrmsg(ftdmchan, usrmsg);
|
||||
|
||||
if (ftdm_core_set_state(file, func, line, ftdmchan, state, waitrq) != FTDM_SUCCESS) {
|
||||
ftdm_usrmsg_free(&ftdmchan->usrmsg);
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/* this function MUST be called with the channel lock held. If waitrq == 1, the channel will be unlocked/locked (never call it with waitrq == 1 with an lock recursivity > 1) */
|
||||
#define DEFAULT_WAIT_TIME 1000
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int waitrq)
|
||||
static ftdm_status_t ftdm_core_set_state(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int waitrq)
|
||||
{
|
||||
ftdm_status_t status;
|
||||
int ok = 1;
|
||||
|
@ -515,7 +516,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_advance_states(ftdm_channel_t *fchan)
|
|||
* already completed implicitly by the state_processor() function via some internal
|
||||
* call to ftdm_set_state() */
|
||||
fchan->state_status = FTDM_STATE_STATUS_PROCESSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
/* required for TryEnterCriticalSection definition. Must be defined before windows.h include */
|
||||
#define _WIN32_WINNT 0x0400
|
||||
# if (_WIN32_WINNT < 0x0400)
|
||||
# error "Need to target at least Windows 95/WINNT 4.0 because TryEnterCriticalSection is needed"
|
||||
# endif
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "private/ftdm_core.h"
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Sangoma Technologies
|
||||
* David Yat Sin <dyatsin@sangoma.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of the original author; nor the names of any contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Contributors:
|
||||
*
|
||||
* Moises Silva <moy@sangoma.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "private/ftdm_core.h"
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_add_var(ftdm_sigmsg_t *sigmsg, const char *var_name, const char *value)
|
||||
{
|
||||
char *t_name = 0, *t_val = 0;
|
||||
|
||||
if (!sigmsg || !var_name || !value) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
if (!sigmsg->variables) {
|
||||
/* initialize on first use */
|
||||
sigmsg->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
|
||||
ftdm_assert_return(sigmsg->variables, FTDM_FAIL, "Failed to create hash table\n");
|
||||
}
|
||||
|
||||
t_name = ftdm_strdup(var_name);
|
||||
t_val = ftdm_strdup(value);
|
||||
hashtable_insert(sigmsg->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_remove_var(ftdm_sigmsg_t *sigmsg, const char *var_name)
|
||||
{
|
||||
if (sigmsg && sigmsg->variables) {
|
||||
hashtable_remove(sigmsg->variables, (void *)var_name);
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(const char *) ftdm_sigmsg_get_var(ftdm_sigmsg_t *sigmsg, const char *var_name)
|
||||
{
|
||||
const char *var = NULL;
|
||||
|
||||
if (!sigmsg || !sigmsg->variables || !var_name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
var = (const char *)hashtable_search(((struct hashtable*)sigmsg->variables), (void *)var_name);
|
||||
return var;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_sigmsg_get_var_iterator(const ftdm_sigmsg_t *sigmsg, ftdm_iterator_t *iter)
|
||||
{
|
||||
ftdm_hash_iterator_t *hashiter = NULL;
|
||||
if (!sigmsg) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hashiter = sigmsg->variables == NULL ? NULL : hashtable_first(sigmsg->variables);
|
||||
|
||||
if (hashiter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(iter = ftdm_get_iterator(FTDM_ITERATOR_VARS, iter))) {
|
||||
return NULL;
|
||||
}
|
||||
iter->pvt.hashiter = hashiter;
|
||||
return iter;
|
||||
}
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_get_current_var(ftdm_iterator_t *iter, const char **var_name, const char **var_val)
|
||||
{
|
||||
const void *key = NULL;
|
||||
void *val = NULL;
|
||||
|
||||
*var_name = NULL;
|
||||
*var_val = NULL;
|
||||
|
||||
ftdm_assert_return(iter && (iter->type == FTDM_ITERATOR_VARS) && iter->pvt.hashiter, FTDM_FAIL, "Cannot get variable from invalid iterator!\n");
|
||||
|
||||
hashtable_this(iter->pvt.hashiter, &key, NULL, &val);
|
||||
|
||||
*var_name = key;
|
||||
*var_val = val;
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_add_var(ftdm_usrmsg_t *usrmsg, const char *var_name, const char *value)
|
||||
{
|
||||
char *t_name = 0, *t_val = 0;
|
||||
|
||||
if (!usrmsg || !var_name || !value) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
if (!usrmsg->variables) {
|
||||
/* initialize on first use */
|
||||
usrmsg->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
|
||||
ftdm_assert_return(usrmsg->variables, FTDM_FAIL, "Failed to create hash table\n");
|
||||
}
|
||||
|
||||
t_name = ftdm_strdup(var_name);
|
||||
t_val = ftdm_strdup(value);
|
||||
hashtable_insert(usrmsg->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
FT_DECLARE(const char *) ftdm_usrmsg_get_var(ftdm_usrmsg_t *usrmsg, const char *var_name)
|
||||
{
|
||||
const char *var = NULL;
|
||||
|
||||
if (!usrmsg || !usrmsg->variables || !var_name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
var = (const char *)hashtable_search(((struct hashtable*)usrmsg->variables), (void *)var_name);
|
||||
return var;
|
||||
}
|
|
@ -182,7 +182,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span)
|
|||
const char *tonemap = "us";
|
||||
const char *hotline = "";
|
||||
uint32_t digit_timeout = 10;
|
||||
uint32_t wait_dialtone_timeout = 30000;
|
||||
uint32_t wait_dialtone_timeout = 5000;
|
||||
uint32_t max_dialstr = MAX_DTMF;
|
||||
uint32_t polarity_delay = 600;
|
||||
const char *var, *val;
|
||||
|
@ -226,7 +226,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span)
|
|||
if (wait_dialtone_timeout < 0) {
|
||||
wait_dialtone_timeout = 0;
|
||||
}
|
||||
ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Wait dial tone ms = %d\n", wait_dialtone_timeout);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Wait dial tone ms = %d\n", wait_dialtone_timeout);
|
||||
} else if (!strcasecmp(var, "enable_callerid")) {
|
||||
if (!(val = va_arg(ap, char *))) {
|
||||
break;
|
||||
|
|
|
@ -285,10 +285,7 @@ static FIO_SPAN_GET_SIG_STATUS_FUNCTION(isdn_get_span_sig_status)
|
|||
*/
|
||||
static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(isdn_outgoing_call)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND);
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DIALING);
|
||||
return status;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,7 +297,14 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(isdn_outgoing_call)
|
|||
#ifdef __TODO__
|
||||
static FIO_CHANNEL_REQUEST_FUNCTION(isdn_channel_request)
|
||||
{
|
||||
#if 1 /* FIXME caller_data.raw_data does not exist anymore, see docs/variables.txt for more info */
|
||||
Q931mes_Generic empty_gen;
|
||||
Q931mes_Generic *gen = &empty_gen;
|
||||
|
||||
memset(&empty_gen, 0, sizeof(empty_gen)) ;
|
||||
#else
|
||||
Q931mes_Generic *gen = (Q931mes_Generic *) caller_data->raw_data;
|
||||
#endif
|
||||
Q931ie_BearerCap BearerCap;
|
||||
Q931ie_ChanID ChanID = { 0 };
|
||||
Q931ie_CallingNum CallingNum;
|
||||
|
@ -1095,12 +1099,16 @@ static L3INT ftdm_isdn_931_34(void *pvt, struct Q931_Call *call, Q931mes_Generic
|
|||
#ifdef __TODO_OR_REMOVE__
|
||||
ftdmchan->caller_data.CRV = gen->CRV;
|
||||
#endif
|
||||
#if 0 /* FIXME */
|
||||
if (cplen > sizeof(caller_data->raw_data)) {
|
||||
cplen = sizeof(caller_data->raw_data);
|
||||
}
|
||||
#endif
|
||||
gen->CRVFlag = !(gen->CRVFlag);
|
||||
#if 0 /* FIXME */
|
||||
memcpy(caller_data->raw_data, msg, cplen);
|
||||
caller_data->raw_data_len = cplen;
|
||||
#endif
|
||||
fail = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1298,12 +1306,20 @@ static int ftdm_isdn_921_21(void *pvt, L2UCHAR *msg, L2INT mlen)
|
|||
|
||||
static __inline__ void state_advance(ftdm_channel_t *ftdmchan)
|
||||
{
|
||||
Q931mes_Generic *gen = (Q931mes_Generic *) ftdmchan->caller_data.raw_data;
|
||||
ftdm_isdn_data_t *isdn_data = ftdmchan->span->signal_data;
|
||||
ftdm_span_t *span = ftdm_channel_get_span(ftdmchan);
|
||||
ftdm_sigmsg_t sig;
|
||||
ftdm_status_t status;
|
||||
|
||||
#if 1 /* FIXME caller_data.raw_data does not exist anymore, see docs/variables.txt for more info */
|
||||
Q931mes_Generic empty_gen;
|
||||
Q931mes_Generic *gen = &empty_gen;
|
||||
|
||||
memset(&empty_gen, 0, sizeof(empty_gen)) ;
|
||||
#else
|
||||
Q931mes_Generic *gen = (Q931mes_Generic *) ftdmchan->caller_data.raw_data;
|
||||
#endif
|
||||
|
||||
ftdm_log(FTDM_LOG_DEBUG, "%d:%d STATE [%s]\n",
|
||||
ftdm_channel_get_span_id(ftdmchan),
|
||||
ftdm_channel_get_id(ftdmchan),
|
||||
|
@ -1431,7 +1447,9 @@ static __inline__ void state_advance(ftdm_channel_t *ftdmchan)
|
|||
gen->MesType = Q931mes_CONNECT;
|
||||
gen->BearerCap = 0;
|
||||
gen->CRVFlag = 1; /* inbound call */
|
||||
#if 0 /* FIXME */
|
||||
Q931Rx43(&isdn_data->q931, gen, ftdmchan->caller_data.raw_data_len);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -93,10 +93,7 @@ static FIO_SPAN_GET_SIG_STATUS_FUNCTION(isdn_get_span_sig_status)
|
|||
*/
|
||||
static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(isdn_outgoing_call)
|
||||
{
|
||||
ftdm_status_t status = FTDM_SUCCESS;
|
||||
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND);
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DIALING);
|
||||
return status;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -185,6 +185,10 @@
|
|||
RelativePath=".\ftmod_r2.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ftmod_r2_io_mf_lib.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -47,8 +47,10 @@
|
|||
#endif
|
||||
#include <stdio.h>
|
||||
#include <openr2.h>
|
||||
#include "freetdm.h"
|
||||
#include "private/ftdm_core.h"
|
||||
#include <freetdm.h>
|
||||
#include <private/ftdm_core.h>
|
||||
|
||||
#include "ftmod_r2_io_mf_lib.h" // ftdm_r2_get_native_channel_mf_generation_iface
|
||||
|
||||
/* when the user stops a span, we clear FTDM_R2_SPAN_STARTED, so that the signaling thread
|
||||
* knows it must stop, and we wait for FTDM_R2_RUNNING to be clear, which tells us the
|
||||
|
@ -105,6 +107,7 @@ typedef struct ft_r2_conf_s {
|
|||
int charge_calls;
|
||||
int forced_release;
|
||||
int allow_collect_calls;
|
||||
int use_channel_native_mf_generation;
|
||||
} ft_r2_conf_t;
|
||||
|
||||
/* r2 configuration stored in span->signal_data */
|
||||
|
@ -286,9 +289,6 @@ static ftdm_call_cause_t ftdm_r2_cause_to_ftdm_cause(ftdm_channel_t *fchan, open
|
|||
case OR2_CAUSE_UNSPECIFIED:
|
||||
return FTDM_CAUSE_NORMAL_UNSPECIFIED;
|
||||
|
||||
case OR2_CAUSE_COLLECT_CALL_REJECTED:
|
||||
return FTDM_CAUSE_CALL_REJECTED;
|
||||
|
||||
case OR2_CAUSE_FORCED_RELEASE:
|
||||
return FTDM_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
|
@ -307,6 +307,7 @@ static openr2_call_disconnect_cause_t ftdm_r2_ftdm_cause_to_openr2_cause(ftdm_ch
|
|||
return OR2_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
case FTDM_CAUSE_USER_BUSY:
|
||||
case FTDM_CAUSE_CALL_REJECTED:
|
||||
return OR2_CAUSE_BUSY_NUMBER;
|
||||
|
||||
case FTDM_CAUSE_SWITCH_CONGESTION:
|
||||
|
@ -334,7 +335,7 @@ static openr2_call_disconnect_cause_t ftdm_r2_ftdm_cause_to_openr2_cause(ftdm_ch
|
|||
return OR2_CAUSE_GLARE;
|
||||
|
||||
}
|
||||
ftdm_log_chan(fchan, FTDM_LOG_WARNING, "freetdm hangup cause %d mapped to openr2 cause %s\n",
|
||||
ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "freetdm hangup cause %d mapped to openr2 cause %s\n",
|
||||
fchan->caller_data.hangup_cause, openr2_proto_get_disconnect_string(OR2_CAUSE_UNSPECIFIED));
|
||||
return OR2_CAUSE_UNSPECIFIED;
|
||||
}
|
||||
|
@ -471,12 +472,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(r2_outgoing_call)
|
|||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DIALING);
|
||||
|
||||
ftdm_channel_set_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS);
|
||||
ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLUSH_TX_BUFFERS, NULL);
|
||||
ftdm_channel_command(ftdmchan, FTDM_COMMAND_FLUSH_RX_BUFFERS, NULL);
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -673,13 +671,13 @@ static void ftdm_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, cons
|
|||
ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan);
|
||||
ftdm_r2_data_t *r2data = ftdmchan->span->signal_data;
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Call offered with ANI = %s, DNIS = %s, Category = %d, ANI restricted = %s\n",
|
||||
ani, dnis, category, ani_restricted ? "Yes" : "No");
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Call offered with ANI = %s, DNIS = %s, Category = %s, ANI restricted = %s\n",
|
||||
ani, dnis, openr2_proto_get_category_string(category), ani_restricted ? "Yes" : "No");
|
||||
|
||||
/* check if this is a collect call and if we should accept it */
|
||||
if (!r2data->allow_collect_calls && category == OR2_CALLING_PARTY_CATEGORY_COLLECT_CALL) {
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_NOTICE, "Rejecting collect call\n");
|
||||
openr2_chan_disconnect_call(r2chan, OR2_CAUSE_COLLECT_CALL_REJECTED);
|
||||
openr2_chan_disconnect_call(r2chan, OR2_CAUSE_UNALLOCATED_NUMBER);
|
||||
} else {
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING);
|
||||
}
|
||||
|
@ -1447,7 +1445,8 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling)
|
|||
/* .double_answer */ -1,
|
||||
/* .charge_calls */ -1,
|
||||
/* .forced_release */ -1,
|
||||
/* .allow_collect_calls */ -1
|
||||
/* .allow_collect_calls */ -1,
|
||||
/* .use_channel_native_mf_generation */ 0
|
||||
};
|
||||
|
||||
ftdm_assert_return(sig_cb != NULL, FTDM_FAIL, "No signaling cb provided\n");
|
||||
|
@ -1566,6 +1565,9 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling)
|
|||
} else if (!strcasecmp(var, "max_dnis")) {
|
||||
r2conf.max_dnis = atoi(val);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with max dnis = %d\n", span->name, r2conf.max_dnis);
|
||||
} else if (!strcasecmp(var, "use_channel_native_mf_generation")) {
|
||||
r2conf.use_channel_native_mf_generation = ftdm_true(val);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Configuring R2 span %s with \"use native channel MF generation\" = %d\n", span->name, r2conf.use_channel_native_mf_generation);
|
||||
} else {
|
||||
snprintf(span->last_error, sizeof(span->last_error), "Unknown R2 parameter [%s]", var);
|
||||
return FTDM_FAIL;
|
||||
|
@ -1617,6 +1619,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling)
|
|||
openr2_context_configure_from_advanced_file(r2data->r2context, r2conf.advanced_protocol_file);
|
||||
}
|
||||
|
||||
if(r2conf.use_channel_native_mf_generation) {
|
||||
openr2_context_set_mflib_interface(r2data->r2context, ftdm_r2_get_native_channel_mf_generation_iface());
|
||||
}
|
||||
|
||||
spanpvt->r2calls = create_hashtable(FTDM_MAX_CHANNELS_SPAN, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
|
||||
if (!spanpvt->r2calls) {
|
||||
snprintf(span->last_error, sizeof(span->last_error), "Cannot create channel calls hash for span.");
|
||||
|
@ -1634,13 +1640,29 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling)
|
|||
openr2_chan_enable_call_files(r2chan);
|
||||
}
|
||||
|
||||
r2call = ftdm_malloc(sizeof(*r2call));
|
||||
if (r2conf.use_channel_native_mf_generation) {
|
||||
/* Allocate a new write handle per r2chan */
|
||||
ftdm_r2_mf_write_handle_t *mf_write_handle = ftdm_calloc(1, sizeof(*mf_write_handle));
|
||||
/* Associate to the FreeTDM channel */
|
||||
mf_write_handle->ftdmchan = span->channels[i];
|
||||
/* Make sure the FreeTDM channel supports MF the generation feature */
|
||||
if (!ftdm_channel_test_feature(mf_write_handle->ftdmchan, FTDM_CHANNEL_FEATURE_MF_GENERATE)) {
|
||||
ftdm_log_chan_msg(mf_write_handle->ftdmchan, FTDM_LOG_ERROR,
|
||||
"FreeTDM channel does not support native MF generation: "
|
||||
"\"use_channel_native_mf_generation\" configuration parameter cannot"
|
||||
" be used\n");
|
||||
goto fail;
|
||||
}
|
||||
/* Associate the mf_write_handle to the openR2 channel */
|
||||
openr2_chan_set_mflib_handles(r2chan, mf_write_handle, NULL);
|
||||
}
|
||||
|
||||
r2call = ftdm_calloc(1, sizeof(*r2call));
|
||||
if (!r2call) {
|
||||
snprintf(span->last_error, sizeof(span->last_error), "Cannot create all R2 call data structures for the span.");
|
||||
ftdm_safe_free(r2chan);
|
||||
goto fail;
|
||||
}
|
||||
memset(r2call, 0, sizeof(*r2call));
|
||||
openr2_chan_set_logging_func(r2chan, ftdm_r2_on_chan_log);
|
||||
openr2_chan_set_client_data(r2chan, span->channels[i]);
|
||||
r2call->r2chan = r2chan;
|
||||
|
@ -1651,6 +1673,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_r2_configure_span_signaling)
|
|||
}
|
||||
r2data->mf_dump_size = r2conf.mf_dump_size;
|
||||
r2data->category = r2conf.category;
|
||||
r2data->allow_collect_calls = r2conf.allow_collect_calls;
|
||||
r2data->flags = 0;
|
||||
spanpvt->r2context = r2data->r2context;
|
||||
|
||||
|
@ -2370,5 +2393,5 @@ EX_DECLARE_DATA ftdm_module_t ftdm_module = {
|
|||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Sebastien Trottier
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of the original author; nor the names of any contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <freetdm.h>
|
||||
#include <private/ftdm_core.h>
|
||||
|
||||
#include <openr2.h>
|
||||
|
||||
#include "ftmod_r2_io_mf_lib.h"
|
||||
|
||||
/* Convert openr2 MF tone enum value to FreeTDM MF tone value
|
||||
1-15 bitwise OR FTDM_MF_DIRECTION_FORWARD/BACKWARD
|
||||
0 (stop playing)
|
||||
openr2_mf_tone_t defined in r2proto.h
|
||||
*/
|
||||
static int ftdm_r2_openr2_mf_tone_to_ftdm_mf_tone(openr2_mf_tone_t
|
||||
openr2_tone_value, int forward_signals)
|
||||
{
|
||||
int tone;
|
||||
|
||||
switch (openr2_tone_value) {
|
||||
case 0: return 0;
|
||||
#define TONE_FROM_NAME(name) case OR2_MF_TONE_##name: tone = name; break;
|
||||
TONE_FROM_NAME(1)
|
||||
TONE_FROM_NAME(2)
|
||||
TONE_FROM_NAME(3)
|
||||
TONE_FROM_NAME(4)
|
||||
TONE_FROM_NAME(5)
|
||||
TONE_FROM_NAME(6)
|
||||
TONE_FROM_NAME(7)
|
||||
TONE_FROM_NAME(8)
|
||||
TONE_FROM_NAME(9)
|
||||
TONE_FROM_NAME(10)
|
||||
TONE_FROM_NAME(11)
|
||||
TONE_FROM_NAME(12)
|
||||
TONE_FROM_NAME(13)
|
||||
TONE_FROM_NAME(14)
|
||||
TONE_FROM_NAME(15)
|
||||
#undef TONE_FROM_NAME
|
||||
default:
|
||||
ftdm_assert(0, "Invalid openr2_tone_value\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Add flag corresponding to direction */
|
||||
if (forward_signals) {
|
||||
tone |= FTDM_MF_DIRECTION_FORWARD;
|
||||
} else {
|
||||
tone |= FTDM_MF_DIRECTION_BACKWARD;
|
||||
}
|
||||
|
||||
return tone;
|
||||
}
|
||||
|
||||
/* MF generation routines (using IO command of a FreeTDM channel)
|
||||
write_init stores the direction of the MF to generate */
|
||||
static void *ftdm_r2_io_mf_write_init(ftdm_r2_mf_write_handle_t *handle, int forward_signals)
|
||||
{
|
||||
ftdm_log_chan(handle->ftdmchan, FTDM_LOG_DEBUG, "ftdm_r2_io_mf_write_init, "
|
||||
"forward = %d\n", forward_signals);
|
||||
|
||||
handle->fwd = forward_signals;
|
||||
return handle;
|
||||
}
|
||||
|
||||
static int ftdm_r2_io_mf_generate_tone(ftdm_r2_mf_write_handle_t *handle, int16_t buffer[], int samples)
|
||||
{
|
||||
/* Our mf_want_generate implementation always return 0, so mf_generate_tone should never be called */
|
||||
ftdm_assert(0, "ftdm_r2_io_mf_generate_tone not implemented\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* \brief mf_select_tone starts tone generation or stops current tone
|
||||
* \return 0 on success, -1 on error
|
||||
*/
|
||||
static int ftdm_r2_io_mf_select_tone(ftdm_r2_mf_write_handle_t *handle, char signal)
|
||||
{
|
||||
int tone; /* (0, 1-15) (0 meaning to stop playing) */
|
||||
|
||||
ftdm_log_chan(handle->ftdmchan, FTDM_LOG_DEBUG, "ftdm_r2_io_mf_select_tone, "
|
||||
"signal = %c\n", signal);
|
||||
|
||||
if (-1 == (tone = ftdm_r2_openr2_mf_tone_to_ftdm_mf_tone(signal, handle->fwd))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Start/stop playback directly here, as select tone is called each time a tone
|
||||
is started or stopped (called if tone changes, but silence is tone 0,
|
||||
triggering a tone change) */
|
||||
if (tone > 0) {
|
||||
ftdm_channel_command(handle->ftdmchan, FTDM_COMMAND_START_MF_PLAYBACK, &tone);
|
||||
} else {
|
||||
/* tone 0 means to stop current tone */
|
||||
ftdm_channel_command(handle->ftdmchan, FTDM_COMMAND_STOP_MF_PLAYBACK, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ftdm_r2_io_mf_want_generate(ftdm_r2_mf_write_handle_t *handle, int signal)
|
||||
{
|
||||
/* Return 0, meaning mf_generate_tone doesn't need to be called */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* MF lib interface that generate MF tones via FreeTDM channel IO commands
|
||||
MF detection using the default openr2 provider (r2engine) */
|
||||
static openr2_mflib_interface_t g_mf_ftdm_io_iface = {
|
||||
/* .mf_read_init */ (openr2_mf_read_init_func)openr2_mf_rx_init,
|
||||
/* .mf_write_init */ (openr2_mf_write_init_func)ftdm_r2_io_mf_write_init,
|
||||
/* .mf_detect_tone */ (openr2_mf_detect_tone_func)openr2_mf_rx,
|
||||
/* .mf_generate_tone */ (openr2_mf_generate_tone_func)ftdm_r2_io_mf_generate_tone,
|
||||
/* .mf_select_tone */ (openr2_mf_select_tone_func)ftdm_r2_io_mf_select_tone,
|
||||
/* .mf_want_generate */ (openr2_mf_want_generate_func)ftdm_r2_io_mf_want_generate,
|
||||
/* .mf_read_dispose */ NULL,
|
||||
/* .mf_write_dispose */ NULL
|
||||
};
|
||||
|
||||
openr2_mflib_interface_t *ftdm_r2_get_native_channel_mf_generation_iface()
|
||||
{
|
||||
return &g_mf_ftdm_io_iface;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
|
||||
*/
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Sebastien Trottier
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of the original author; nor the names of any contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FTMOD_R2_IO_MFLIB_H_
|
||||
#define _FTMOD_R2_IO_MFLIB_H_
|
||||
|
||||
#include <ftdm_declare.h>
|
||||
|
||||
#include <openr2.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* MFC/R2 tone generator handle (mf_write_handle) */
|
||||
typedef struct {
|
||||
/*! FTDM channel performing the MF generation */
|
||||
ftdm_channel_t *ftdmchan;
|
||||
/*! 1 if generating forward tones, otherwise generating reverse tones. */
|
||||
int fwd;
|
||||
} ftdm_r2_mf_write_handle_t;
|
||||
|
||||
/* MF lib interface that generate MF tones via FreeTDM channel IO commands
|
||||
MF detection using the default openr2 provider (r2engine) */
|
||||
openr2_mflib_interface_t *ftdm_r2_get_native_channel_mf_generation_iface(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* endif extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* endif defined _FTMOD_R2_IO_MFLIB_H_ */
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
|
@ -603,6 +603,7 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
ftdm_sigmsg_t sigev;
|
||||
ftdm_channel_state_t initial_state;
|
||||
sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data;
|
||||
uint8_t state_change = 0;
|
||||
|
||||
memset(&sigev, 0, sizeof(sigev));
|
||||
|
||||
|
@ -610,9 +611,6 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
sigev.span_id = ftdmchan->span_id;
|
||||
sigev.channel = ftdmchan;
|
||||
|
||||
/* Acknowledge the state change */
|
||||
ftdm_channel_complete_state(ftdmchan);
|
||||
|
||||
#ifdef FTDM_DEBUG_CHAN_MEMORY
|
||||
if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALING) {
|
||||
ftdm_assert(mprotect(ftdmchan, sizeof(*ftdmchan), PROT_READ) == 0, "Failed to mprotect");
|
||||
|
@ -649,8 +647,7 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending incoming call from %s to %s to FTDM core\n", ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.dnis.digits);
|
||||
|
||||
/* we have enough information to inform FTDM of the call*/
|
||||
sigev.event_id = FTDM_SIGEVENT_START;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_START);
|
||||
}
|
||||
break;
|
||||
case FTDM_CHANNEL_STATE_DIALING: /* outgoing call request */
|
||||
|
@ -674,9 +671,10 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
{
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
/*OUTBOUND...so we were told by the line of this so noifiy the user*/
|
||||
sigev.event_id = FTDM_SIGEVENT_PROCEED;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_PROCEED);
|
||||
|
||||
if (sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY)) {
|
||||
state_change++;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
|
||||
}
|
||||
} else {
|
||||
|
@ -694,9 +692,10 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
{
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
/* OUTBOUND...so we were told by the line of this so notify the user */
|
||||
sigev.event_id = FTDM_SIGEVENT_RINGING;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_RINGING);
|
||||
|
||||
if (sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY)) {
|
||||
state_change++;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
|
||||
}
|
||||
} else {
|
||||
|
@ -710,8 +709,8 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
/*check if the channel is inbound or outbound*/
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
/*OUTBOUND...so we were told by the line of this so noifiy the user*/
|
||||
sigev.event_id = FTDM_SIGEVENT_PROGRESS;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
|
||||
sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_PROGRESS);
|
||||
} else {
|
||||
/* Send a progress message, indicating: Call is not end-to-end ISDN, further call progress may be available */
|
||||
ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN};
|
||||
|
@ -722,8 +721,7 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
|
||||
{
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
sigev.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_PROGRESS_MEDIA);
|
||||
} else {
|
||||
/* Send a progress message, indicating: In-band information/pattern available */
|
||||
ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_IB_AVAIL};
|
||||
|
@ -736,8 +734,8 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
/* check if the channel is inbound or outbound */
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
/* OUTBOUND ... so we were told by the line that the other side answered */
|
||||
sigev.event_id = FTDM_SIGEVENT_UP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
|
||||
sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_UP);
|
||||
|
||||
if (ftdmchan->span->trunk_type == FTDM_TRUNK_BRI_PTMP &&
|
||||
((sngisdn_span_data_t*)ftdmchan->span->signal_data)->signalling == SNGISDN_SIGNALING_NET) {
|
||||
|
@ -757,14 +755,14 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
/* Send a release complete */
|
||||
sngisdn_snd_release(ftdmchan, 0);
|
||||
/*now go to the HANGUP complete state*/
|
||||
state_change++;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
}
|
||||
break;
|
||||
case FTDM_CHANNEL_STATE_TERMINATING: /* call is hung up by the remote end */
|
||||
{
|
||||
/* this state is set when the line is hanging up */
|
||||
sigev.event_id = FTDM_SIGEVENT_STOP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngisdn_send_signal(sngisdn_info, FTDM_SIGEVENT_STOP);
|
||||
}
|
||||
break;
|
||||
case FTDM_CHANNEL_STATE_HANGUP: /* call is hung up locally */
|
||||
|
@ -817,6 +815,7 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
}
|
||||
}
|
||||
/* now go to the HANGUP complete state */
|
||||
state_change++;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
}
|
||||
break;
|
||||
|
@ -825,6 +824,7 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
if (sngisdn_test_flag(sngisdn_info, FLAG_REMOTE_ABORT) ||
|
||||
sngisdn_test_flag(sngisdn_info, FLAG_LOCAL_ABORT)) {
|
||||
/* If the remote side aborted, we will not get anymore message for this call */
|
||||
state_change++;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
} else {
|
||||
/* waiting on remote confirmation before moving to down */
|
||||
|
@ -878,7 +878,27 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!state_change) {
|
||||
/* Acknowledge the state change */
|
||||
ftdm_channel_complete_state(ftdmchan);
|
||||
}
|
||||
|
||||
/* If sngisdn_info->variables is not NULL, it means did not send any
|
||||
* sigevent to the user, therefore we have to free that hashtable */
|
||||
if (sngisdn_info->variables) {
|
||||
hashtable_destroy(sngisdn_info->variables);
|
||||
sngisdn_info->variables = NULL;
|
||||
}
|
||||
|
||||
/* If sngisdn_info->raw_data is not NULL, it means did not send any
|
||||
* sigevent to the user, therefore we have to free that raw data */
|
||||
if (sngisdn_info->raw_data) {
|
||||
ftdm_safe_free(sngisdn_info->raw_data);
|
||||
sngisdn_info->raw_data = NULL;
|
||||
sngisdn_info->raw_data_len = 0;
|
||||
}
|
||||
|
||||
if (ftdmchan->state == initial_state) {
|
||||
ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "state change flag is still set, but we did not change state\n");
|
||||
}
|
||||
|
@ -890,20 +910,18 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
static FIO_CHANNEL_SEND_MSG_FUNCTION(ftdm_sangoma_isdn_send_msg)
|
||||
static FIO_CHANNEL_INDICATE_FUNCTION(ftdm_sangoma_isdn_indicate)
|
||||
{
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
|
||||
switch (sigmsg->event_id) {
|
||||
case FTDM_SIGEVENT_FACILITY:
|
||||
switch (indication) {
|
||||
case FTDM_CHANNEL_INDICATE_FACILITY:
|
||||
sngisdn_snd_fac_req(ftdmchan);
|
||||
status = FTDM_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Unsupported signalling msg requested\n");
|
||||
status = FTDM_BREAK;
|
||||
}
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
status = FTDM_NOTIMPL;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -911,34 +929,25 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_isdn_outgoing_call)
|
|||
{
|
||||
sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data;
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
|
||||
switch (ftdmchan->state) {
|
||||
|
||||
case FTDM_CHANNEL_STATE_DOWN:
|
||||
{
|
||||
if (sngisdn_test_flag(sngisdn_info, FLAG_GLARE)) {
|
||||
/* A call came in after we called ftdm_channel_open_chan for this call, but before we got here */
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Glare detected - aborting outgoing call\n");
|
||||
if (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN) {
|
||||
if (sngisdn_test_flag(sngisdn_info, FLAG_GLARE)) {
|
||||
/* A call came in after we called ftdm_channel_open_chan for this call, but before we got here */
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Glare detected - aborting outgoing call\n");
|
||||
|
||||
sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
|
||||
status = FTDM_BREAK;
|
||||
} else {
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DIALING);
|
||||
status = FTDM_SUCCESS;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
/* the channel is already used...this can't be, end the request */
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Outgoing call requested channel in already in use\n");
|
||||
status = FTDM_BREAK;
|
||||
} else {
|
||||
status = FTDM_SUCCESS;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
/* the channel is already used...this can't be, end the request */
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Outgoing call requested channel in already in use (%s)\n", ftdm_channel_state2str(ftdmchan->state));
|
||||
status = FTDM_BREAK;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_chan_sig_status)
|
||||
|
@ -1090,7 +1099,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config)
|
|||
span->stop = ftdm_sangoma_isdn_stop;
|
||||
span->signal_type = FTDM_SIGTYPE_ISDN;
|
||||
span->outgoing_call = ftdm_sangoma_isdn_outgoing_call;
|
||||
span->send_msg = ftdm_sangoma_isdn_send_msg;
|
||||
span->indicate = ftdm_sangoma_isdn_indicate;
|
||||
span->channel_request = NULL;
|
||||
span->signal_cb = sig_cb;
|
||||
span->get_channel_sig_status = ftdm_sangoma_isdn_get_chan_sig_status;
|
||||
|
|
|
@ -181,6 +181,15 @@ typedef struct sngisdn_chan_data {
|
|||
uint8_t globalFlg;
|
||||
sngisdn_glare_data_t glare;
|
||||
ftdm_timer_id_t timers[SNGISDN_NUM_TIMERS];
|
||||
|
||||
/* variables saved here will be sent to the user application
|
||||
on next SIGEVENT_XXX */
|
||||
ftdm_hash_t* variables;
|
||||
|
||||
/* raw_data saved here will be sent to the user application
|
||||
on next SIGEVENT_XXX */
|
||||
void *raw_data;
|
||||
ftdm_size_t raw_data_len;
|
||||
} sngisdn_chan_data_t;
|
||||
|
||||
/* Span specific data */
|
||||
|
@ -416,6 +425,12 @@ ftdm_status_t set_restart_ind_ie(ftdm_channel_t *ftdmchan, RstInd *rstInd);
|
|||
ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr);
|
||||
ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t *data_len);
|
||||
|
||||
|
||||
ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val);
|
||||
ftdm_status_t sngisdn_add_raw_data(sngisdn_chan_data_t *sngisdn_info, uint8_t* data, ftdm_size_t data_len);
|
||||
ftdm_status_t sngisdn_clear_data(sngisdn_chan_data_t *sngisdn_info);
|
||||
void sngisdn_send_signal(sngisdn_chan_data_t *sngisdn_info, ftdm_signal_event_t event_id);
|
||||
|
||||
uint8_t sngisdn_get_infoTranCap_from_user(ftdm_bearer_cap_t bearer_capability);
|
||||
uint8_t sngisdn_get_usrInfoLyr1Prot_from_user(ftdm_user_layer1_prot_t layer1_prot);
|
||||
ftdm_bearer_cap_t sngisdn_get_infoTranCap_from_stack(uint8_t bearer_capability);
|
||||
|
|
|
@ -160,8 +160,12 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
|
|||
}
|
||||
}
|
||||
|
||||
/* this should be in get_facility_ie function, fix this later */
|
||||
if (signal_data->facility == SNGISDN_OPT_TRUE && conEvnt->facilityStr.eh.pres) {
|
||||
#if 1
|
||||
/* this section will not be needed once asn decoding function with key-value pairs is implemented */
|
||||
if (signal_data->facility == SNGISDN_OPT_TRUE &&
|
||||
signal_data->facility_ie_decode != SNGISDN_OPT_FALSE &&
|
||||
conEvnt->facilityStr.eh.pres) {
|
||||
|
||||
/* Verify whether the Caller Name will come in a subsequent FACILITY message */
|
||||
uint16_t ret_val;
|
||||
char retrieved_str[255];
|
||||
|
@ -187,6 +191,7 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
|
|||
strcpy(ftdmchan->caller_data.cid_name, retrieved_str);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (signal_data->overlap_dial == SNGISDN_OPT_TRUE && !conEvnt->sndCmplt.eh.pres) {
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_COLLECT);
|
||||
|
@ -644,7 +649,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event)
|
|||
break;
|
||||
case FTDM_CHANNEL_STATE_TERMINATING:
|
||||
if (sngisdn_test_flag(sngisdn_info, FLAG_GLARE) &&
|
||||
sngisdn_info->glare.suInstId != suInstId) {
|
||||
sngisdn_info->glare.suInstId != suInstId) {
|
||||
/* This release if for the outbound call that we already started clearing */
|
||||
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Received RELEASE for local glared call\n");
|
||||
|
@ -662,7 +667,6 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event)
|
|||
default:
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Received RELEASE in an invalid state (%s)\n",
|
||||
ftdm_channel_state2str(ftdmchan->state));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -830,7 +834,7 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event)
|
|||
If there will be no information following, but current FACILITY IE contains a caller name, returns 0
|
||||
If there will be information following, returns 1
|
||||
*/
|
||||
|
||||
|
||||
if (sng_isdn_retrieve_facility_caller_name(&facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len, retrieved_str) == 0) {
|
||||
strcpy(ftdmchan->caller_data.cid_name, retrieved_str);
|
||||
} else {
|
||||
|
|
|
@ -156,8 +156,6 @@ void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_i
|
|||
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
|
||||
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROCEED (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
|
||||
|
||||
if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, MI_CALLPROC, signal_data->dchan_id, sngisdn_info->ces)) {
|
||||
|
@ -189,7 +187,6 @@ void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_
|
|||
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
|
||||
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
|
||||
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROGRESS (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
|
||||
if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_PROGRESS, signal_data->dchan_id, sngisdn_info->ces)) {
|
||||
|
@ -216,7 +213,6 @@ void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind
|
|||
|
||||
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
|
||||
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending ALERT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
|
||||
|
||||
|
@ -241,11 +237,10 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan)
|
|||
}
|
||||
|
||||
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
|
||||
|
||||
|
||||
set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
|
||||
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
|
||||
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
|
||||
if (sng_isdn_con_response(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, signal_data->dchan_id, sngisdn_info->ces)) {
|
||||
|
@ -272,14 +267,13 @@ void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan)
|
|||
/* No point in sending a FACILITY message if there is no Facility IE to transmit */
|
||||
return;
|
||||
}
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
facEvnt.facElmt.eh.pres = PRSNT_NODEF;
|
||||
facEvnt.facElmt.facStr.pres = PRSNT_NODEF;
|
||||
facEvnt.facElmt.facStr.val[0] = 0x1C;
|
||||
facEvnt.facElmt.facStr.val[1] = (uint8_t)facEvnt.facElmt.facStr.len;
|
||||
facEvnt.facElmt.facStr.len +=2; /* Need to include the size of identifier + len */
|
||||
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending FACILITY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
|
||||
|
||||
if (sng_isdn_facility_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &facEvnt, MI_FACIL, signal_data->dchan_id, sngisdn_info->ces)) {
|
||||
|
@ -306,7 +300,7 @@ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan)
|
|||
//ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ\n");
|
||||
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, signal_data->dchan_id, sngisdn_info->ces);
|
||||
|
||||
|
@ -327,8 +321,6 @@ void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan)
|
|||
//ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Sending STATUS ENQ\n");
|
||||
|
||||
memset(&staEvnt, 0, sizeof(StaEvnt));
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Status ENQ on suId:%d suInstId:%u spInstId:%d dchan:%d ces:%d\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
|
||||
if (sng_isdn_status_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &staEvnt, MI_STATENQ)) {
|
||||
|
@ -367,8 +359,7 @@ void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan)
|
|||
discEvnt.causeDgn[0].recommend.pres = NOTPRSNT;
|
||||
discEvnt.causeDgn[0].dgnVal.pres = NOTPRSNT;
|
||||
|
||||
set_facility_ie(ftdmchan, &discEvnt.facilityStr);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
set_facility_ie(ftdmchan, &discEvnt.facilityStr);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending DISCONNECT (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId);
|
||||
if (sng_isdn_disc_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &discEvnt)) {
|
||||
|
@ -416,7 +407,6 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare)
|
|||
}
|
||||
|
||||
set_facility_ie(ftdmchan, &relEvnt.facilityStr);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending RELEASE/RELEASE COMPLETE (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, suInstId, spInstId);
|
||||
|
||||
|
|
|
@ -225,26 +225,26 @@ ftdm_status_t get_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
|
|||
}
|
||||
|
||||
if (cgPtyNmb->screenInd.pres == PRSNT_NODEF) {
|
||||
ftdm_call_add_var(caller_data, "isdn.cg_pty2.screen_ind", ftdm_screening2str(cgPtyNmb->screenInd.val));
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.screen_ind", ftdm_screening2str(cgPtyNmb->screenInd.val));
|
||||
}
|
||||
|
||||
if (cgPtyNmb->presInd0.pres == PRSNT_NODEF) {
|
||||
ftdm_call_add_var(caller_data, "isdn.cg_pty2.presentation_ind", ftdm_presentation2str(cgPtyNmb->presInd0.val));
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.presentation_ind", ftdm_presentation2str(cgPtyNmb->presInd0.val));
|
||||
}
|
||||
|
||||
if (cgPtyNmb->nmbPlanId.pres == PRSNT_NODEF) {
|
||||
ftdm_call_add_var(caller_data, "isdn.cg_pty2.npi", ftdm_npi2str(cgPtyNmb->nmbPlanId.val));
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.npi", ftdm_npi2str(cgPtyNmb->nmbPlanId.val));
|
||||
}
|
||||
|
||||
if (cgPtyNmb->typeNmb1.pres == PRSNT_NODEF) {
|
||||
ftdm_call_add_var(caller_data, "isdn.cg_pty2.ton", ftdm_ton2str(cgPtyNmb->typeNmb1.val));
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.ton", ftdm_ton2str(cgPtyNmb->typeNmb1.val));
|
||||
}
|
||||
|
||||
if (cgPtyNmb->nmbDigits.pres == PRSNT_NODEF) {
|
||||
char digits_string [32];
|
||||
memcpy(digits_string, (const char*)cgPtyNmb->nmbDigits.val, cgPtyNmb->nmbDigits.len);
|
||||
digits_string[cgPtyNmb->nmbDigits.len] = '\0';
|
||||
ftdm_call_add_var(caller_data, "isdn.cg_pty2.digits", digits_string);
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.cg_pty2.digits", digits_string);
|
||||
}
|
||||
memcpy(&caller_data->ani, &caller_data->cid_num, sizeof(caller_data->ani));
|
||||
return FTDM_SUCCESS;
|
||||
|
@ -253,6 +253,7 @@ ftdm_status_t get_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
|
|||
ftdm_status_t get_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb)
|
||||
{
|
||||
ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
|
||||
|
||||
if (cdPtyNmb->eh.pres != PRSNT_NODEF) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
@ -343,7 +344,7 @@ ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad)
|
|||
|
||||
memcpy(subaddress, (char*)cgPtySad->sadInfo.val, cgPtySad->sadInfo.len);
|
||||
subaddress[cgPtySad->sadInfo.len] = '\0';
|
||||
ftdm_call_add_var(&ftdmchan->caller_data, "isdn.calling_subaddr", subaddress);
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.calling_subaddr", subaddress);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -358,21 +359,19 @@ ftdm_status_t get_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr
|
|||
|
||||
ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
|
||||
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data;
|
||||
|
||||
if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) {
|
||||
/* size of facilityStr->facilityStr.len is a uint8_t so no need to check
|
||||
for overflow here as facilityStr->facilityStr.len will always be smaller
|
||||
than sizeof(caller_data->raw_data) */
|
||||
/* Max size of Facility IE is 255 */
|
||||
uint8_t my_data [255];
|
||||
|
||||
memset(caller_data->raw_data, 0, sizeof(caller_data->raw_data));
|
||||
/* Always include Facility IE identifier + len so this can be used as a sanity check by the user */
|
||||
caller_data->raw_data[0] = SNGISDN_Q931_FACILITY_IE_ID;
|
||||
caller_data->raw_data[1] = data_len;
|
||||
|
||||
memcpy(&caller_data->raw_data[2], data, data_len);
|
||||
caller_data->raw_data_len = data_len+2;
|
||||
my_data[0] = SNGISDN_Q931_FACILITY_IE_ID;
|
||||
my_data[1] = data_len;
|
||||
memcpy(&my_data[2], data, data_len);
|
||||
|
||||
sngisdn_add_raw_data((sngisdn_chan_data_t*)ftdmchan->call_data, data, data_len+2);
|
||||
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Raw Facility IE copied available\n");
|
||||
} else {
|
||||
/* Call libsng_isdn to process facility IE's here */
|
||||
|
@ -382,7 +381,7 @@ ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8
|
|||
|
||||
ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd)
|
||||
{
|
||||
uint8_t val;
|
||||
uint8_t val;
|
||||
if (!progInd->eh.pres) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
@ -412,7 +411,7 @@ ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd)
|
|||
val = SNGISDN_PROGIND_DESCR_INVALID;
|
||||
break;
|
||||
}
|
||||
ftdm_call_add_var(&ftdmchan->caller_data, "isdn.prog_ind.descr", ftdm_sngisdn_progind_descr2str(val));
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.prog_ind.descr", ftdm_sngisdn_progind_descr2str(val));
|
||||
}
|
||||
|
||||
if (progInd->location.pres) {
|
||||
|
@ -443,7 +442,7 @@ ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd)
|
|||
val = SNGISDN_PROGIND_LOC_INVALID;
|
||||
break;
|
||||
}
|
||||
ftdm_call_add_var(&ftdmchan->caller_data, "isdn.prog_ind.loc", ftdm_sngisdn_progind_loc2str(val));
|
||||
sngisdn_add_var((sngisdn_chan_data_t*)ftdmchan->call_data, "isdn.prog_ind.loc", ftdm_sngisdn_progind_loc2str(val));
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
@ -493,7 +492,7 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
|
|||
uint8_t len,val;
|
||||
ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
|
||||
|
||||
string = ftdm_call_get_var(caller_data, "isdn.cg_pty2.digits");
|
||||
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.digits");
|
||||
if ((string == NULL) || !(*string)) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
@ -510,7 +509,7 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
|
|||
cgPtyNmb->screenInd.pres = PRSNT_NODEF;
|
||||
|
||||
val = FTDM_SCREENING_INVALID;
|
||||
string = ftdm_call_get_var(caller_data, "isdn.cg_pty2.screening_ind");
|
||||
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.screening_ind");
|
||||
if ((string != NULL) && (*string)) {
|
||||
val = ftdm_str2ftdm_screening(string);
|
||||
}
|
||||
|
@ -527,7 +526,7 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
|
|||
cgPtyNmb->presInd0.pres = PRSNT_NODEF;
|
||||
|
||||
val = FTDM_PRES_INVALID;
|
||||
string = ftdm_call_get_var(caller_data, "isdn.cg_pty2.presentation_ind");
|
||||
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.presentation_ind");
|
||||
if ((string != NULL) && (*string)) {
|
||||
val = ftdm_str2ftdm_presentation(string);
|
||||
}
|
||||
|
@ -542,7 +541,7 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
|
|||
cgPtyNmb->nmbPlanId.pres = PRSNT_NODEF;
|
||||
|
||||
val = FTDM_NPI_INVALID;
|
||||
string = ftdm_call_get_var(caller_data, "isdn.cg_pty2.npi");
|
||||
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.npi");
|
||||
if ((string != NULL) && (*string)) {
|
||||
val = ftdm_str2ftdm_npi(string);
|
||||
}
|
||||
|
@ -557,7 +556,7 @@ ftdm_status_t set_calling_num2(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb)
|
|||
|
||||
/* Type of Number */
|
||||
val = FTDM_TON_INVALID;
|
||||
string = ftdm_call_get_var(caller_data, "isdn.cg_pty2.ton");
|
||||
string = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.cg_pty2.ton");
|
||||
if ((string != NULL) && (*string)) {
|
||||
val = ftdm_str2ftdm_ton(string);
|
||||
}
|
||||
|
@ -691,7 +690,7 @@ ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt)
|
|||
ftdm_status_t set_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad)
|
||||
{
|
||||
const char* clg_subaddr = NULL;
|
||||
clg_subaddr = ftdm_call_get_var(&ftdmchan->caller_data, "isdn.calling_subaddr");
|
||||
clg_subaddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.calling_subaddr");
|
||||
if ((clg_subaddr != NULL) && (*clg_subaddr)) {
|
||||
unsigned len = strlen (clg_subaddr);
|
||||
cgPtySad->eh.pres = PRSNT_NODEF;
|
||||
|
@ -721,14 +720,19 @@ ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr
|
|||
|
||||
ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t *data_len)
|
||||
{
|
||||
int len;
|
||||
ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
|
||||
if (caller_data->raw_data_len > 0 && caller_data->raw_data[0] == SNGISDN_Q931_FACILITY_IE_ID) {
|
||||
len = caller_data->raw_data[1];
|
||||
memcpy(data, &caller_data->raw_data[2], len);
|
||||
*data_len = len;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
ftdm_size_t len;
|
||||
uint8_t *mydata;
|
||||
void *vdata;
|
||||
|
||||
if (ftdm_usrmsg_get_raw_data(ftdmchan->usrmsg, &vdata, &len) == FTDM_SUCCESS) {
|
||||
mydata = vdata;
|
||||
if (len > 2 && mydata[0] == SNGISDN_Q931_FACILITY_IE_ID) {
|
||||
len = mydata[1];
|
||||
memcpy(data, &mydata[2], len);
|
||||
*data_len = len;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
}
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
|
@ -738,7 +742,7 @@ ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_s
|
|||
int descr = prog_ind.descr;
|
||||
int loc = prog_ind.loc;
|
||||
|
||||
str = ftdm_call_get_var(&ftdmchan->caller_data, "isdn.prog_ind.descr");
|
||||
str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.descr");
|
||||
if (str && *str) {
|
||||
/* User wants to override progress indicator */
|
||||
descr = ftdm_str2ftdm_sngisdn_progind_descr(str);
|
||||
|
@ -749,7 +753,7 @@ ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_s
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
str = ftdm_call_get_var(&ftdmchan->caller_data, "isdn.prog_ind.loc");
|
||||
str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.loc");
|
||||
if (str && *str) {
|
||||
loc = ftdm_str2ftdm_sngisdn_progind_loc(str);
|
||||
}
|
||||
|
@ -869,7 +873,7 @@ ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId)
|
|||
ftdm_status_t set_bear_cap_ie(ftdm_channel_t *ftdmchan, BearCap *bearCap)
|
||||
{
|
||||
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data;
|
||||
|
||||
|
||||
bearCap->eh.pres = PRSNT_NODEF;
|
||||
bearCap->infoTranCap.pres = PRSNT_NODEF;
|
||||
bearCap->infoTranCap.val = sngisdn_get_infoTranCap_from_user(ftdmchan->caller_data.bearer_capability);
|
||||
|
@ -1202,6 +1206,74 @@ void sngisdn_print_spans(ftdm_stream_handle_t *stream)
|
|||
return;
|
||||
}
|
||||
|
||||
ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val)
|
||||
{
|
||||
char *t_name = 0, *t_val = 0;
|
||||
if (!var || !val) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
if (!sngisdn_info->variables) {
|
||||
/* initialize on first use */
|
||||
sngisdn_info->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
|
||||
ftdm_assert_return(sngisdn_info->variables, FTDM_FAIL, "Failed to create hash table\n");
|
||||
}
|
||||
t_name = ftdm_strdup(var);
|
||||
t_val = ftdm_strdup(val);
|
||||
hashtable_insert(sngisdn_info->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
ftdm_status_t sngisdn_add_raw_data(sngisdn_chan_data_t *sngisdn_info, uint8_t* data, ftdm_size_t data_len)
|
||||
{
|
||||
ftdm_assert_return(!sngisdn_info->raw_data, FTDM_FAIL, "Overwriting existing raw data\n");
|
||||
|
||||
sngisdn_info->raw_data = ftdm_calloc(1, data_len);
|
||||
ftdm_assert_return(sngisdn_info->raw_data, FTDM_FAIL, "Failed to allocate raw data\n");
|
||||
|
||||
memcpy(sngisdn_info->raw_data, data, data_len);
|
||||
sngisdn_info->raw_data_len = data_len;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
void sngisdn_send_signal(sngisdn_chan_data_t *sngisdn_info, ftdm_signal_event_t event_id)
|
||||
{
|
||||
ftdm_sigmsg_t sigev;
|
||||
ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan;
|
||||
|
||||
memset(&sigev, 0, sizeof(sigev));
|
||||
|
||||
sigev.chan_id = ftdmchan->chan_id;
|
||||
sigev.span_id = ftdmchan->span_id;
|
||||
sigev.channel = ftdmchan;
|
||||
sigev.event_id = event_id;
|
||||
|
||||
if (sngisdn_info->variables) {
|
||||
/*
|
||||
* variables now belongs to the ftdm core, and
|
||||
* will be cleared after sigev is processed by user. Set
|
||||
* local pointer to NULL so we do not attempt to
|
||||
* destroy it */
|
||||
sigev.variables = sngisdn_info->variables;
|
||||
sngisdn_info->variables = NULL;
|
||||
}
|
||||
|
||||
if (sngisdn_info->raw_data) {
|
||||
/*
|
||||
* raw_data now belongs to the ftdm core, and
|
||||
* will be cleared after sigev is processed by user. Set
|
||||
* local pointer to NULL so we do not attempt to
|
||||
* destroy it */
|
||||
|
||||
sigev.raw.data = sngisdn_info->raw_data;
|
||||
sigev.raw.len = sngisdn_info->raw_data_len;
|
||||
|
||||
sngisdn_info->raw_data = NULL;
|
||||
sngisdn_info->raw_data_len = 0;
|
||||
}
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
}
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
|
|
@ -139,7 +139,6 @@ void sngisdn_trace_raw_q921(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t d
|
|||
memcpy(raw_data, data, data_len);
|
||||
sigev.raw.data = raw_data;
|
||||
sigev.raw.len = data_len;
|
||||
sigev.raw.autofree = 1;
|
||||
ftdm_span_send_signal(signal_data->ftdm_span, &sigev);
|
||||
}
|
||||
|
||||
|
@ -241,6 +240,11 @@ void sngisdn_trace_raw_q931(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t d
|
|||
sigev.span_id = ftdmchan->physical_span_id;
|
||||
sigev.chan_id = ftdmchan->physical_chan_id;
|
||||
sigev.channel = ftdmchan;
|
||||
} else {
|
||||
/* We could not map the channel, but at least set the span */
|
||||
if (signal_data->ftdm_span->channels[1]) {
|
||||
sigev.span_id = signal_data->ftdm_span->channels[1]->physical_span_id;
|
||||
}
|
||||
}
|
||||
sigev.event_id = FTDM_SIGEVENT_TRACE_RAW;
|
||||
|
||||
|
@ -253,7 +257,6 @@ void sngisdn_trace_raw_q931(sngisdn_span_data_t *signal_data, ftdm_trace_dir_t d
|
|||
memcpy(raw_data, data, data_len);
|
||||
sigev.raw.data = raw_data;
|
||||
sigev.raw.len = data_len;
|
||||
sigev.raw.autofree = 1;
|
||||
ftdm_span_send_signal(signal_data->ftdm_span, &sigev);
|
||||
}
|
||||
}
|
||||
|
@ -833,9 +836,10 @@ static ftdm_status_t sngisdn_get_frame_info(uint8_t *data, uint32_t data_len, ft
|
|||
//ftdm_log(FTDM_LOG_DEBUG, "Decoded IE:%s\n", get_code_2_str(ie_id, dcodQ931IEIDTable));
|
||||
}
|
||||
if (!bchan_no) {
|
||||
uint32_t tmp_len = 0;
|
||||
char tmp[1000];
|
||||
print_hex_dump(tmp, 0, data, 0, data_len);
|
||||
ftdm_log(FTDM_LOG_WARNING, "Failed to determine b-channel on SETUP message\n%s\n", tmp);
|
||||
print_hex_dump(tmp, &tmp_len, data, 0, data_len);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Failed to determine b-channel on SETUP message\n%s\n", tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -396,16 +396,13 @@ int ft_to_sngss7_cfg_all(void)
|
|||
|
||||
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
|
||||
if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
|
||||
|
||||
if (ftmod_ss7_isup_ckt_config(x)) {
|
||||
SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
|
||||
return 1;
|
||||
} else {
|
||||
SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
|
||||
}
|
||||
|
||||
} /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
|
||||
if (ftmod_ss7_isup_ckt_config(x)) {
|
||||
SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
|
||||
return 1;
|
||||
} else {
|
||||
SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
|
||||
}
|
||||
|
||||
/* set the SNGSS7_CONFIGURED flag */
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
|
||||
|
|
|
@ -83,8 +83,8 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name);
|
|||
static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *name);
|
||||
static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *name);
|
||||
static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *name);
|
||||
|
||||
static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *name);
|
||||
static ftdm_status_t handle_status_isup_ckt(ftdm_stream_handle_t *stream, char *id_name);
|
||||
|
||||
static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan);
|
||||
static ftdm_status_t check_arg_count(int args, int min);
|
||||
|
@ -149,6 +149,25 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
|
|||
|
||||
handle_show_status(stream, span, chan, verbose);
|
||||
/******************************************************************/
|
||||
} else if (!strcasecmp(argv[c], "isup")) {
|
||||
/******************************************************************/
|
||||
if (check_arg_count(argc, 4)) goto handle_cli_error_argc;
|
||||
c++;
|
||||
|
||||
if (!strcasecmp(argv[c], "ckt")) {
|
||||
/**************************************************************/
|
||||
if (check_arg_count(argc, 5)) goto handle_cli_error_argc;
|
||||
c++;
|
||||
|
||||
handle_status_isup_ckt(stream, argv[c]);
|
||||
/**************************************************************/
|
||||
} else {
|
||||
/**************************************************************/
|
||||
stream->write_function(stream, "Unknown \"status isup\" command\n");
|
||||
goto handle_cli_error;
|
||||
/**************************************************************/
|
||||
}
|
||||
/******************************************************************/
|
||||
} else {
|
||||
/******************************************************************/
|
||||
stream->write_function(stream, "Unknown \"status\" command\n");
|
||||
|
@ -948,12 +967,14 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,
|
|||
/******************************************************************************/
|
||||
static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
|
||||
{
|
||||
int x;
|
||||
int bit;
|
||||
sngss7_chan_data_t *ss7_info;
|
||||
ftdm_channel_t *ftdmchan;
|
||||
int lspan;
|
||||
int lchan;
|
||||
sngss7_chan_data_t *ss7_info;
|
||||
ftdm_channel_t *ftdmchan;
|
||||
int x;
|
||||
int bit;
|
||||
int lspan;
|
||||
int lchan;
|
||||
const char *text;
|
||||
int flag;
|
||||
|
||||
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
|
||||
|
@ -982,11 +1003,20 @@ static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, i
|
|||
ss7_info->circuit->cic);
|
||||
|
||||
for (bit = 0; bit < 33; bit++) {
|
||||
stream->write_function(stream, "|");
|
||||
if (ss7_info->ckt_flags & ( 0x1 << bit)) {
|
||||
stream->write_function(stream, "%2d=1", bit);
|
||||
} else {
|
||||
stream->write_function(stream, "%2d=0", bit);
|
||||
stream->write_function(stream, "|");
|
||||
flag = bit;
|
||||
text = ftmod_ss7_ckt_flag2str(flag);
|
||||
stream->write_function(stream, "%s",text);
|
||||
}
|
||||
}
|
||||
|
||||
for (bit = 0; bit < 33; bit++) {
|
||||
if (ss7_info->blk_flags & ( 0x1 << bit)) {
|
||||
stream->write_function(stream, "|");
|
||||
flag = bit;
|
||||
text = ftmod_ss7_blk_flag2str(flag);
|
||||
stream->write_function(stream, "%s",text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1037,37 +1067,37 @@ static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span,
|
|||
ftdmchan->physical_chan_id,
|
||||
ss7_info->circuit->cic);
|
||||
|
||||
if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {
|
||||
if((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {
|
||||
stream->write_function(stream, "l_mn=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "l_mn=N|");
|
||||
}
|
||||
|
||||
if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
if((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
stream->write_function(stream, "r_mn=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "r_mn=N|");
|
||||
}
|
||||
|
||||
if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {
|
||||
if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {
|
||||
stream->write_function(stream, "l_hw=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "l_hw=N|");
|
||||
}
|
||||
|
||||
if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {
|
||||
if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {
|
||||
stream->write_function(stream, "r_hw=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "r_hw=N|");
|
||||
}
|
||||
|
||||
if(sngss7_test_ckt_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX)) {
|
||||
if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX)) {
|
||||
stream->write_function(stream, "l_mngmt=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "l_mngmt=N|");
|
||||
}
|
||||
|
||||
if(sngss7_test_ckt_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {
|
||||
if(sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {
|
||||
stream->write_function(stream, "l_ucic=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "l_ucic=N|");
|
||||
|
@ -1142,48 +1172,48 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
|
|||
/* grab the signaling_status */
|
||||
ftdm_channel_get_sig_status(ftdmchan, &sigstatus);
|
||||
|
||||
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|sig_status=%4s|state=%s|",
|
||||
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|ckt=%4d|sig_status=%4s|state=%s|",
|
||||
ckt->span,
|
||||
ckt->chan,
|
||||
ckt->cic,
|
||||
ckt->id,
|
||||
ftdm_signaling_status2str(sigstatus),
|
||||
ftdm_channel_state2str(ftdmchan->state));
|
||||
|
||||
if ((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {
|
||||
if ((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX))) {
|
||||
stream->write_function(stream, "l_mn=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "l_mn=N|");
|
||||
}
|
||||
|
||||
if ((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
if ((sngss7_test_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
stream->write_function(stream, "r_mn=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "r_mn=N|");
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {
|
||||
if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {
|
||||
stream->write_function(stream, "l_hw=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "l_hw=N|");
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {
|
||||
if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {
|
||||
stream->write_function(stream, "r_hw=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "r_hw=N|");
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) {
|
||||
stream->write_function(stream, "relay=Y|");
|
||||
stream->write_function(stream, "relay=Y");
|
||||
}else {
|
||||
stream->write_function(stream, "relay=N|");
|
||||
stream->write_function(stream, "relay=N");
|
||||
}
|
||||
}
|
||||
|
||||
stream->write_function(stream, "flags=0x%X",ss7_info->ckt_flags);
|
||||
|
||||
|
||||
stream->write_function(stream, "\n");
|
||||
} /* if ( hole, sig, voice) */
|
||||
} /* if ( span and chan) */
|
||||
|
@ -1237,10 +1267,10 @@ static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int c
|
|||
continue;
|
||||
} else {
|
||||
/* throw the ckt block flag */
|
||||
sngss7_set_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
|
||||
sngss7_set_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
}
|
||||
|
||||
/* unlock the channel again before we exit */
|
||||
|
@ -1303,13 +1333,13 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c
|
|||
continue;
|
||||
} else {
|
||||
/* throw the ckt block flag */
|
||||
sngss7_set_ckt_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX);
|
||||
sngss7_set_ckt_blk_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX);
|
||||
|
||||
/* clear the block flag */
|
||||
sngss7_clear_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
|
||||
sngss7_clear_ckt_blk_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
}
|
||||
|
||||
/* unlock the channel again before we exit */
|
||||
|
@ -1554,12 +1584,12 @@ static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int c
|
|||
/**************************************************************************/
|
||||
case FTDM_CHANNEL_STATE_RESTART:
|
||||
/* go to idle so that we can redo the restart state*/
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IDLE);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
/* set the state of the channel to restart...the rest is done by the chan monitor */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
}
|
||||
|
@ -1627,7 +1657,7 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
|
|||
}
|
||||
|
||||
/* set the channel to suspended state */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1701,15 +1731,10 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c
|
|||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
|
||||
/* throw the grp maint. block flag */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
|
||||
|
||||
/* bring the sig status down */
|
||||
sigev.chan_id = ftdmchan->chan_id;
|
||||
sigev.span_id = ftdmchan->span_id;
|
||||
sigev.channel = ftdmchan;
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
|
||||
/* if this is the first channel in the range */
|
||||
if (ftdmchan->physical_chan_id == chan) {
|
||||
|
@ -1801,15 +1826,10 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c
|
|||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
|
||||
/* throw the grp maint. block flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
|
||||
|
||||
/* bring the sig status up */
|
||||
sigev.chan_id = ftdmchan->chan_id;
|
||||
sigev.span_id = ftdmchan->span_id;
|
||||
sigev.channel = ftdmchan;
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_UP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
|
||||
|
||||
/* if this is the first channel in the range */
|
||||
if (ftdmchan->physical_chan_id == chan) {
|
||||
|
@ -2154,6 +2174,184 @@ success:
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static ftdm_status_t handle_status_isup_ckt(ftdm_stream_handle_t *stream, char *id_name)
|
||||
{
|
||||
sng_isup_ckt_t *ckt;
|
||||
sngss7_chan_data_t *ss7_info;
|
||||
ftdm_channel_t *ftdmchan;
|
||||
uint32_t id;
|
||||
uint8_t state = 0;
|
||||
uint8_t bits_ab = 0;
|
||||
uint8_t bits_cd = 0;
|
||||
uint8_t bits_ef = 0;
|
||||
|
||||
/* extract the integer version of the id (ckt) */
|
||||
id = atoi(id_name);
|
||||
|
||||
/* extract the global config circuit structure */
|
||||
ckt = &g_ftdm_sngss7_data.cfg.isupCkt[id];
|
||||
|
||||
/* confirm the ckt exists */
|
||||
if (ckt->id == 0) {
|
||||
stream->write_function(stream, "Requested ckt does not exist (%d)\n", id);
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
/* confirm the ckt is a voice channel */
|
||||
if (ckt->type != VOICE) {
|
||||
stream->write_function(stream, "Requested ckt is a sig link/hole and can not be queried (%d)\n", id);
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
/* extract the global structure */
|
||||
ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[id].obj;
|
||||
ftdmchan = ss7_info->ftdmchan;
|
||||
|
||||
/* query the isup stack for the state of the ckt */
|
||||
if (ftmod_ss7_isup_ckt_sta(ckt->id, &state)) {
|
||||
stream->write_function(stream, "Failed to read isup ckt =%d status\n", id);
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
|
||||
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|ckt=%4d|state=0x%02X|",
|
||||
ckt->span,
|
||||
ckt->chan,
|
||||
ckt->cic,
|
||||
ckt->id,
|
||||
state);
|
||||
|
||||
/* extract the bit sections */
|
||||
bits_ab = (state & (SNG_BIT_A + SNG_BIT_B)) >> 0;
|
||||
|
||||
bits_cd = (state & (SNG_BIT_C + SNG_BIT_D)) >> 2;
|
||||
|
||||
bits_ef = (state & (SNG_BIT_E + SNG_BIT_F)) >> 4;
|
||||
|
||||
/* check bits C and D */
|
||||
switch (bits_cd) {
|
||||
/**************************************************************************/
|
||||
case (0):
|
||||
/* ckt is either un-equipped or transient, check bits A and B */
|
||||
switch (bits_ab) {
|
||||
/**********************************************************************/
|
||||
case (0):
|
||||
/* bit a and bit are cleared, transient */
|
||||
stream->write_function(stream, "transient\n");
|
||||
goto success;
|
||||
break;
|
||||
/**********************************************************************/
|
||||
case (1):
|
||||
case (2):
|
||||
/* bit a or bit b are set, spare ... shouldn't happen */
|
||||
stream->write_function(stream, "spare\n");
|
||||
goto success;
|
||||
break;
|
||||
/**********************************************************************/
|
||||
case (3):
|
||||
/* bit a and bit b are set, unequipped */
|
||||
stream->write_function(stream, "unequipped\n");
|
||||
goto success;
|
||||
break;
|
||||
/**********************************************************************/
|
||||
default:
|
||||
stream->write_function(stream, "invalid values for bits A and B (%d)\n",
|
||||
bits_ab);
|
||||
goto success;
|
||||
break;
|
||||
/**********************************************************************/
|
||||
} /* switch (bits_ab) */
|
||||
|
||||
/* shouldn't get here but have a break for properness */
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (1):
|
||||
/* circuit incoming busy */
|
||||
stream->write_function(stream, "incoming busy");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (2):
|
||||
/* circuit outgoing busy */
|
||||
stream->write_function(stream, "outgoing busy");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (3):
|
||||
/* circuit idle */
|
||||
stream->write_function(stream, "idle");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
/* invalid */
|
||||
stream->write_function(stream, "bits C and D are invalid (%d)!\n",
|
||||
bits_cd);
|
||||
goto success;
|
||||
/**************************************************************************/
|
||||
} /* switch (bits_cd) */
|
||||
|
||||
/* check the maintenance block status in bits A and B */
|
||||
switch (bits_ab) {
|
||||
/**************************************************************************/
|
||||
case (0):
|
||||
/* no maintenace block...do nothing */
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (1):
|
||||
/* locally blocked */
|
||||
stream->write_function(stream, "|l_mn");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (2):
|
||||
/* remotely blocked */
|
||||
stream->write_function(stream, "|r_mn");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (3):
|
||||
/* both locally and remotely blocked */
|
||||
stream->write_function(stream, "|l_mn|r_mn");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
stream->write_function(stream, "bits A and B are invlaid (%d)!\n",
|
||||
bits_ab);
|
||||
goto success;
|
||||
/**************************************************************************/
|
||||
} /* switch (bits_ab) */
|
||||
|
||||
/* check the hardware block status in bits e and f */
|
||||
switch (bits_ef) {
|
||||
/**************************************************************************/
|
||||
case (0):
|
||||
/* no maintenace block...do nothing */
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (1):
|
||||
/* locally blocked */
|
||||
stream->write_function(stream, "|l_hw");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (2):
|
||||
/* remotely blocked */
|
||||
stream->write_function(stream, "|r_hw");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (3):
|
||||
/* both locally and remotely blocked */
|
||||
stream->write_function(stream, "|l_hw|r_hw");
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
stream->write_function(stream, "bits E and F are invlaid (%d)!\n",
|
||||
bits_ef);
|
||||
goto success;
|
||||
/**************************************************************************/
|
||||
} /* switch (bits_ef) */
|
||||
|
||||
success:
|
||||
stream->write_function(stream, "\n");
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan)
|
||||
{
|
||||
|
|
|
@ -68,11 +68,15 @@ int ftmod_ss7_shutdown_isup(void);
|
|||
int ftmod_ss7_shutdown_mtp3(void);
|
||||
int ftmod_ss7_shutdown_mtp2(void);
|
||||
int ftmod_ss7_shutdown_relay(void);
|
||||
int ftmod_ss7_disable_relay_channel(uint32_t chanId);
|
||||
|
||||
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);
|
||||
int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
|
||||
|
||||
int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
|
||||
|
||||
int ftmod_ss7_block_isup_ckt(uint32_t cktId);
|
||||
int ftmod_ss7_unblock_isup_ckt(uint32_t cktId);
|
||||
/******************************************************************************/
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
@ -712,6 +716,38 @@ int ftmod_ss7_shutdown_relay(void)
|
|||
return (sng_cntrl_relay(&pst, &cntrl));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ftmod_ss7_disable_relay_channel(uint32_t chanId)
|
||||
{
|
||||
RyMngmt cntrl;
|
||||
Pst pst;
|
||||
|
||||
/* initalize the post structure */
|
||||
smPstInit(&pst);
|
||||
|
||||
/* insert the destination Entity */
|
||||
pst.dstEnt = ENTRY;
|
||||
|
||||
/* initalize the control structure */
|
||||
memset(&cntrl, 0x0, sizeof(RyMngmt));
|
||||
|
||||
/* initalize the control header */
|
||||
smHdrInit(&cntrl.hdr);
|
||||
|
||||
cntrl.hdr.msgType = TCNTRL; /* this is a control request */
|
||||
cntrl.hdr.entId.ent = ENTRY;
|
||||
cntrl.hdr.entId.inst = S_INST;
|
||||
cntrl.hdr.elmId.elmnt = STGEN;
|
||||
|
||||
|
||||
cntrl.hdr.elmId.elmntInst1 = chanId;
|
||||
|
||||
cntrl.t.cntrl.action = ADISIMM; /* Deactivate */
|
||||
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
|
||||
|
||||
return (sng_cntrl_relay(&pst, &cntrl));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId)
|
||||
{
|
||||
|
@ -808,6 +844,69 @@ int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId)
|
|||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ftmod_ss7_block_isup_ckt(uint32_t cktId)
|
||||
{
|
||||
SiMngmt cntrl;
|
||||
Pst pst;
|
||||
|
||||
/* initalize the post structure */
|
||||
smPstInit(&pst);
|
||||
|
||||
/* insert the destination Entity */
|
||||
pst.dstEnt = ENTSI;
|
||||
|
||||
/* initalize the control structure */
|
||||
memset(&cntrl, 0x0, sizeof(SiMngmt));
|
||||
|
||||
/* initalize the control header */
|
||||
smHdrInit(&cntrl.hdr);
|
||||
|
||||
cntrl.hdr.msgType = TCNTRL; /* this is a control request */
|
||||
cntrl.hdr.entId.ent = ENTSI;
|
||||
cntrl.hdr.entId.inst = S_INST;
|
||||
cntrl.hdr.elmId.elmnt = STICIR;
|
||||
|
||||
cntrl.t.cntrl.s.siElmnt.elmntId.circuit = cktId;
|
||||
cntrl.t.cntrl.s.siElmnt.elmntParam.cir.flag = LSI_CNTRL_CIR_FORCE;
|
||||
|
||||
cntrl.t.cntrl.action = ADISIMM; /* block via BLO */
|
||||
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
|
||||
|
||||
return (sng_cntrl_isup(&pst, &cntrl));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ftmod_ss7_unblock_isup_ckt(uint32_t cktId)
|
||||
{
|
||||
SiMngmt cntrl;
|
||||
Pst pst;
|
||||
|
||||
/* initalize the post structure */
|
||||
smPstInit(&pst);
|
||||
|
||||
/* insert the destination Entity */
|
||||
pst.dstEnt = ENTSI;
|
||||
|
||||
/* initalize the control structure */
|
||||
memset(&cntrl, 0x0, sizeof(SiMngmt));
|
||||
|
||||
/* initalize the control header */
|
||||
smHdrInit(&cntrl.hdr);
|
||||
|
||||
cntrl.hdr.msgType = TCNTRL; /* this is a control request */
|
||||
cntrl.hdr.entId.ent = ENTSI;
|
||||
cntrl.hdr.entId.inst = S_INST;
|
||||
cntrl.hdr.elmId.elmnt = STICIR;
|
||||
|
||||
cntrl.t.cntrl.s.siElmnt.elmntId.circuit = cktId;
|
||||
cntrl.t.cntrl.s.siElmnt.elmntParam.cir.flag = LSI_CNTRL_CIR_FORCE;
|
||||
|
||||
cntrl.t.cntrl.action = AENA; /* unblock via UBL */
|
||||
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
|
||||
|
||||
return (sng_cntrl_isup(&pst, &cntrl));
|
||||
}
|
||||
/******************************************************************************/
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -66,6 +66,12 @@ void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -104,6 +110,12 @@ void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -142,6 +154,12 @@ void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCn
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -181,6 +199,12 @@ void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -219,6 +243,12 @@ void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -257,6 +287,12 @@ void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiIn
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -295,6 +331,12 @@ void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -334,6 +376,12 @@ void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -373,6 +421,12 @@ void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit)
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -417,21 +471,10 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
|||
/**************************************************************************/
|
||||
case (SIT_STA_PAUSEIND):
|
||||
case (SIT_STA_RESUMEIND):
|
||||
|
||||
/* the circuit for this type of event may not exist on the local system
|
||||
* so first check if the circuit is local
|
||||
*/
|
||||
if ((circuit >= (g_ftdm_sngss7_data.cfg.procId * 1000)) &&
|
||||
(circuit < ((g_ftdm_sngss7_data.cfg.procId +1) * 1000))) {
|
||||
|
||||
/* the circuit is on the local system, handle normally */
|
||||
goto sta_ind_local;
|
||||
}
|
||||
|
||||
/* the circuit is not local, so find a local circuit with the same intfId
|
||||
* by finding the orginial circuit in our array first, finding the intfId
|
||||
* from there, then go through the local circuits to see if we find a
|
||||
* match and use that circuit instead
|
||||
/* the circuit may or may not be on the local system so we have to find
|
||||
* circuit with the same intfId. The circuit specified might also be
|
||||
* a non-voice cic so we also need to find the first voice cic on this
|
||||
* system with the same intfId.
|
||||
*/
|
||||
intfId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId;
|
||||
|
||||
|
@ -444,6 +487,10 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
|||
|
||||
/* compare the intfIds */
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) {
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type == VOICE) {
|
||||
|
||||
}
|
||||
|
||||
/* we have a match, setup the pointers to the correct values */
|
||||
circuit = x;
|
||||
|
||||
|
@ -472,7 +519,14 @@ move_along:
|
|||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
sta_ind_local:
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx %s on circuit that is not a voice CIC (%d)\n",
|
||||
DECODE_LCC_EVENT(evntType),
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -520,6 +574,12 @@ void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiS
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
@ -561,6 +621,12 @@ void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiR
|
|||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_event_data_t *sngss7_event = NULL;
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != VOICE) {
|
||||
SS7_ERROR("Rx sig event on circuit that is not a voice CIC (%d)\n", circuit);
|
||||
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get the ftdmchan and ss7_chan_data from the circuit */
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
|
|
@ -766,7 +766,18 @@ void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)
|
|||
DECODE_LRY_REASON(sta->t.usta.s.ryErrUsta.reason));
|
||||
|
||||
/* process the event */
|
||||
handle_relay_disconnect_on_error(sta);
|
||||
switch (sta->t.usta.s.ryErrUsta.reason) {
|
||||
/**********************************************************************/
|
||||
case (LRYRSNMGMTREQ):
|
||||
/* do nothing since this is a shutdown */
|
||||
break;
|
||||
/**********************************************************************/
|
||||
default:
|
||||
/* handle the error */
|
||||
handle_relay_disconnect_on_error(sta);
|
||||
break;
|
||||
/**********************************************************************/
|
||||
} /* switch (sta->t.usta.s.ryErrUsta.reason) */
|
||||
|
||||
break;
|
||||
/**************************************************************************/
|
||||
|
|
|
@ -365,6 +365,9 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
|
|||
/* check each channel on the span to see if there is an un-procressed SUS/RES flag */
|
||||
check_for_res_sus_flag(ftdmspan);
|
||||
|
||||
/* check each channel on the span to see if it needs to be reconfigured */
|
||||
check_for_reconfig_flag(ftdmspan);
|
||||
|
||||
/* Poll for events, e.g HW DTMF */
|
||||
switch (ftdm_span_poll_event(ftdmspan, 0, NULL)) {
|
||||
/**********************************************************************/
|
||||
|
@ -492,21 +495,17 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev
|
|||
ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
{
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
sng_isup_inf_t *isup_intf = NULL;
|
||||
sng_isup_inf_t *isup_intf = NULL;
|
||||
int state_flag = 1;
|
||||
int i = 0;
|
||||
ftdm_sigmsg_t sigev;
|
||||
|
||||
memset (&sigev, 0, sizeof (sigev));
|
||||
|
||||
sigev.chan_id = ftdmchan->chan_id;
|
||||
sigev.span_id = ftdmchan->span_id;
|
||||
sigev.channel = ftdmchan;
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "ftmod_sangoma_ss7 processing state %s\n", ftdm_channel_state2str (ftdmchan->state));
|
||||
|
||||
#if 0
|
||||
/* clear the state change flag...since we might be setting a new state */
|
||||
ftdm_channel_complete_state(ftdmchan);
|
||||
|
||||
#endif
|
||||
|
||||
/*check what state we are supposed to be in */
|
||||
switch (ftdmchan->state) {
|
||||
/**************************************************************************/
|
||||
|
@ -529,13 +528,15 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
ftdmchan->caller_data.dnis.digits[i-1] = '\0';
|
||||
|
||||
/*now go to the RING state */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RING);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING);
|
||||
|
||||
} else if (i >= sngss7_info->circuit->min_digits) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Received %d digits (min digits = %d)\n", i, sngss7_info->circuit->min_digits);
|
||||
|
||||
/*now go to the RING state */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RING);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING);
|
||||
|
||||
} else {
|
||||
/* if we are coming from idle state then we have already been here once before */
|
||||
|
@ -561,7 +562,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL);
|
||||
|
||||
/* end the call */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
|
||||
} /* if (ftdm_sched_timer(sngss7_info->t35.sched, */
|
||||
} /* if (ftdmchan->last_state != FTDM_CHANNEL_STATE_IDLE) */
|
||||
} /* checking ST/#digits */
|
||||
|
@ -587,8 +589,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
|
||||
|
||||
/* we have enough information to inform FTDM of the call */
|
||||
sigev.event_id = FTDM_SIGEVENT_START;
|
||||
ftdm_span_send_signal (ftdmchan->span, &sigev);
|
||||
sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_START);
|
||||
|
||||
break;
|
||||
/**************************************************************************/
|
||||
|
@ -618,11 +619,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/*check if the channel is inbound or outbound */
|
||||
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
/*OUTBOUND...so we were told by the line of this so noifiy the user */
|
||||
sigev.event_id = FTDM_SIGEVENT_PROGRESS;
|
||||
ftdm_span_send_signal (ftdmchan->span, &sigev);
|
||||
sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_PROGRESS);
|
||||
|
||||
/* move to progress media */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
|
||||
} else {
|
||||
/* inbound call so we need to send out ACM */
|
||||
ft_to_sngss7_acm(ftdmchan);
|
||||
|
@ -639,8 +640,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
|
||||
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
/* inform the user there is media avai */
|
||||
sigev.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA;
|
||||
ftdm_span_send_signal (ftdmchan->span, &sigev);
|
||||
sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_PROGRESS_MEDIA);
|
||||
}
|
||||
|
||||
|
||||
|
@ -657,8 +657,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/*check if the channel is inbound or outbound */
|
||||
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
|
||||
/*OUTBOUND...so we were told by the line that the other side answered */
|
||||
sigev.event_id = FTDM_SIGEVENT_UP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_UP);
|
||||
} else {
|
||||
/*INBOUND...so FS told us it was going to answer...tell the stack */
|
||||
ft_to_sngss7_anm(ftdmchan);
|
||||
|
@ -676,7 +675,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
SS7_ERROR_CHAN(ftdmchan,"Hanging up call before informing user%s\n", " ");
|
||||
|
||||
/*now go to the HANGUP complete state */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
||||
|
||||
break;
|
||||
/**************************************************************************/
|
||||
|
@ -691,8 +691,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL);
|
||||
|
||||
/*this state is set when the line is hanging up */
|
||||
sigev.event_id = FTDM_SIGEVENT_STOP;
|
||||
ftdm_span_send_signal (ftdmchan->span, &sigev);
|
||||
sngss7_send_signal(sngss7_info, FTDM_SIGEVENT_STOP);
|
||||
|
||||
break;
|
||||
/**************************************************************************/
|
||||
|
@ -721,7 +720,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
}
|
||||
|
||||
/*now go to the HANGUP complete state */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -737,7 +737,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/* check if this hangup is from a tx RSC */
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) {
|
||||
/* go to RESTART State until RSCa is received */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
} else {
|
||||
/* if the hangup is from a rx RSC, rx GRS, or glare don't sent RLC */
|
||||
if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) &&
|
||||
|
@ -749,7 +750,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
}
|
||||
|
||||
/*now go to the DOWN state */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
}
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Completing remotely requested hangup!%s\n", "");
|
||||
|
@ -758,15 +760,16 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/* if this hang up is do to a rx RESET we need to sit here till the RSP arrives */
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX_RSP)) {
|
||||
/* go to the down state as we have already received RSC-RLC */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
}
|
||||
|
||||
/* if it's a local release the user sends us to down */
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Completing locally requested hangup!%s\n", "");
|
||||
} else if (sngss7_test_ckt_flag (sngss7_info, FLAG_GLARE)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Completing requested hangup due to glare!%s\n", "");
|
||||
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
} else {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Completing requested hangup for unknown reason!%s\n", "");
|
||||
}
|
||||
|
@ -836,28 +839,27 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
!(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX))) {
|
||||
|
||||
/* now check if there is an active block */
|
||||
if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {
|
||||
if (!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) &&
|
||||
!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) &&
|
||||
!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) &&
|
||||
!(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {
|
||||
|
||||
/* check if the sig status is down, and bring it up if it isn't */
|
||||
if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", "");
|
||||
/* all flags are down so we can bring up the sig status */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_UP;
|
||||
ftdm_span_send_signal (ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
|
||||
} /* if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) */
|
||||
} /* if !blocked */
|
||||
} else {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Reset flags present (0x%X)\n", sngss7_info->ckt_flags);
|
||||
|
||||
/* there is still another reset pending so go back to reset*/
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
}
|
||||
} /* if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) */
|
||||
|
||||
|
@ -906,59 +908,52 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/**************************************************************************/
|
||||
case FTDM_CHANNEL_STATE_RESTART: /* CICs needs a Reset */
|
||||
|
||||
if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK)) {
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK)) {
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX))) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Incoming Reset request on CIC in UCIC block, removing UCIC block%s\n", "");
|
||||
|
||||
/* set the unblk flag */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
|
||||
|
||||
/* clear the block flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
|
||||
|
||||
/* process the flag */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
|
||||
/* break out of the processing for now */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we're not coming from HANGUP_COMPLETE we need to check for resets
|
||||
* we can also check if we are in a PAUSED state (no point in sending message
|
||||
*/
|
||||
if ((ftdmchan->last_state != FTDM_CHANNEL_STATE_HANGUP_COMPLETE) &&
|
||||
(!sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED))) {
|
||||
|
||||
/* check if this is an outgoing RSC */
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) {
|
||||
/* check if this is an outgoing RSC */
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) {
|
||||
|
||||
/* send a reset request */
|
||||
ft_to_sngss7_rsc (ftdmchan);
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);
|
||||
/* send a reset request */
|
||||
ft_to_sngss7_rsc (ftdmchan);
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);
|
||||
|
||||
} /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */
|
||||
|
||||
/* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */
|
||||
if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &&
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {
|
||||
} /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */
|
||||
|
||||
/* send out the grs */
|
||||
ft_to_sngss7_grs (ftdmchan);
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
|
||||
/* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */
|
||||
if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
|
||||
!(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &&
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {
|
||||
|
||||
}/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
|
||||
} /* if ( last_state != HANGUP && !PAUSED */
|
||||
/* send out the grs */
|
||||
ft_to_sngss7_grs (ftdmchan);
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
|
||||
|
||||
}/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
|
||||
|
||||
/* if the sig_status is up...bring it down */
|
||||
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN;
|
||||
ftdm_span_send_signal (ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX)) {
|
||||
|
@ -972,13 +967,15 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
switch (ftdmchan->last_state){
|
||||
/******************************************************************/
|
||||
case (FTDM_CHANNEL_STATE_TERMINATING):
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
|
||||
break;
|
||||
/******************************************************************/
|
||||
case (FTDM_CHANNEL_STATE_HANGUP):
|
||||
case (FTDM_CHANNEL_STATE_HANGUP_COMPLETE):
|
||||
/* go back to the last state after taking care of the rest of the restart state */
|
||||
ftdm_set_state_locked (ftdmchan, ftdmchan->last_state);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, ftdmchan->last_state);
|
||||
break;
|
||||
/******************************************************************/
|
||||
case (FTDM_CHANNEL_STATE_IN_LOOP):
|
||||
|
@ -986,7 +983,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
|
||||
|
||||
/* go to down */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
break;
|
||||
/******************************************************************/
|
||||
default:
|
||||
|
@ -996,7 +994,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/* change the state to terminatting, it will throw us back here
|
||||
* once the call is done
|
||||
*/
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
|
||||
break;
|
||||
/******************************************************************/
|
||||
} /* switch (ftdmchan->last_state) */
|
||||
|
@ -1010,7 +1009,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
SS7_DEBUG_CHAN(ftdmchan, "Reset processed moving to DOWN (0x%X)\n", sngss7_info->ckt_flags);
|
||||
|
||||
/* go to a down state to clear the channel and send the response */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
} else {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Waiting on Reset Rsp/Grp Reset to move to DOWN (0x%X)\n", sngss7_info->ckt_flags);
|
||||
}
|
||||
|
@ -1020,72 +1020,75 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
/**************************************************************************/
|
||||
case FTDM_CHANNEL_STATE_SUSPENDED: /* circuit has been blocked */
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Current flags: 0x%X\n", sngss7_info->ckt_flags);
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Current flags: ckt=0x%X, blk=0x%X\n",
|
||||
sngss7_info->ckt_flags,
|
||||
sngss7_info->blk_flags);
|
||||
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing RESUME%s\n", "");
|
||||
|
||||
/* clear the RESUME flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
|
||||
|
||||
/* clear the PAUSE flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
|
||||
|
||||
/* if there are any resets present */
|
||||
if ((sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) ||
|
||||
(sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) ||
|
||||
(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) ||
|
||||
(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX))) {
|
||||
|
||||
/* go back to the reset state */
|
||||
/* don't bring up the sig status but also move to reset */
|
||||
goto suspend_goto_restart;
|
||||
} else {
|
||||
|
||||
/* bring the sig status back up */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_UP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
|
||||
}
|
||||
|
||||
/* go back to the last state */
|
||||
goto suspend_goto_last;
|
||||
} /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */
|
||||
|
||||
if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) {
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) &&
|
||||
(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP))) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE%s\n", "");
|
||||
|
||||
/* bring the sig status down */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
|
||||
/* go back to the last state */
|
||||
goto suspend_goto_last;
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
} /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { */
|
||||
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_RX flag %s\n", "");
|
||||
|
||||
/* bring the sig status down */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
|
||||
/* send a BLA */
|
||||
ft_to_sngss7_bla (ftdmchan);
|
||||
|
||||
/* throw the done flag */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN);
|
||||
|
||||
/* check the last state and return to it to allow the call to finish */
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX_DN)){
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_RX flag %s\n", "");
|
||||
|
||||
/* clear the block flags */
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN);
|
||||
|
||||
/* clear the unblock flag */
|
||||
sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
|
||||
sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
|
||||
|
||||
/* bring the sig status up */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_UP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
|
||||
|
||||
/* send a uba */
|
||||
ft_to_sngss7_uba (ftdmchan);
|
||||
|
@ -1095,31 +1098,36 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
}
|
||||
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX)) {
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_TX flag %s\n", "");
|
||||
|
||||
/* bring the sig status down */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
|
||||
/* send a blo */
|
||||
ft_to_sngss7_blo (ftdmchan);
|
||||
|
||||
/* throw the done flag */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN);
|
||||
|
||||
/* check the last state and return to it to allow the call to finish */
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)){
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX_DN)){
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_TX flag %s\n", "");
|
||||
|
||||
/* clear the block flags */
|
||||
sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX);
|
||||
sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN);
|
||||
|
||||
/* clear the unblock flag */
|
||||
sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX);
|
||||
|
||||
/* bring the sig status up */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_UP;
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
|
||||
|
||||
/* send a ubl */
|
||||
ft_to_sngss7_ubl (ftdmchan);
|
||||
|
@ -1129,36 +1137,45 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
}
|
||||
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_BLOCK_RX flag %s\n", "");
|
||||
|
||||
/* send a BLA */
|
||||
/*ft_to_sngss7_bla(ftdmchan);*/
|
||||
|
||||
/* throw the done flag */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN);
|
||||
|
||||
/* check the last state and return to it to allow the call to finish */
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX_DN)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_UNBLK_RX flag %s\n", "");
|
||||
|
||||
/* clear the block flags */
|
||||
sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX);
|
||||
sngss7_clear_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN);
|
||||
|
||||
/* clear the unblock flag */
|
||||
sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX);
|
||||
|
||||
/* send a uba */
|
||||
/*ft_to_sngss7_uba(ftdmchan);*/
|
||||
|
||||
|
||||
/* check the last state and return to it to allow the call to finish */
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK)) {
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK_DN)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_BLOCK flag %s\n", "");
|
||||
|
||||
/* bring the channel signaling status to down */
|
||||
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN;
|
||||
ftdm_span_send_signal (ftdmchan->span, &sigev);
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
|
||||
/* remove any reset flags */
|
||||
clear_rx_grs_flags(sngss7_info);
|
||||
|
@ -1167,19 +1184,24 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
clear_tx_grs_data(sngss7_info);
|
||||
clear_rx_rsc_flags(sngss7_info);
|
||||
clear_tx_rsc_flags(sngss7_info);
|
||||
|
||||
/* throw the done flag */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK_DN);
|
||||
|
||||
/* bring the channel down */
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", "");;
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK_DN)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", "");
|
||||
|
||||
/* remove the UCIC block flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK_DN);
|
||||
|
||||
/* remove the UCIC unblock flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
|
||||
|
||||
/* throw the channel into reset to sync states */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
|
||||
|
@ -1188,12 +1210,16 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
|||
goto suspend_goto_restart;
|
||||
}
|
||||
|
||||
SS7_ERROR_CHAN(ftdmchan,"No block flag processed!%s\n", "");
|
||||
|
||||
suspend_goto_last:
|
||||
ftdm_set_state_locked (ftdmchan, ftdmchan->last_state);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, ftdmchan->last_state);
|
||||
break;
|
||||
|
||||
suspend_goto_restart:
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
break;
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -1209,7 +1235,8 @@ suspend_goto_restart:
|
|||
break;
|
||||
/**************************************************************************/
|
||||
case FTDM_CHANNEL_STATE_IDLE:
|
||||
ftdm_set_state_locked(ftdmchan, ftdmchan->last_state);
|
||||
state_flag = 0;
|
||||
ftdm_set_state(ftdmchan, ftdmchan->last_state);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
|
@ -1219,7 +1246,12 @@ suspend_goto_restart:
|
|||
break;
|
||||
/**************************************************************************/
|
||||
}/*switch (ftdmchan->state) */
|
||||
|
||||
#if 1
|
||||
if (state_flag) {
|
||||
/* clear the state change flag...since we might be setting a new state */
|
||||
ftdm_channel_complete_state(ftdmchan);
|
||||
}
|
||||
#endif
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1228,17 +1260,7 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
|
|||
{
|
||||
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
|
||||
|
||||
/* lock the channel while we check whether it is availble */
|
||||
ftdm_mutex_lock (ftdmchan->mutex);
|
||||
|
||||
/* check if there is a pending state change, give it a bit to clear */
|
||||
if (check_for_state_change(ftdmchan)) {
|
||||
SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", sngss7_info->circuit->cic);
|
||||
/* check if we need to die */
|
||||
SS7_ASSERT;
|
||||
/* end the request */
|
||||
goto outgoing_fail;
|
||||
};
|
||||
/* the core has this channel already locked so need to lock again */
|
||||
|
||||
/* check if the channel sig state is UP */
|
||||
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) {
|
||||
|
@ -1247,9 +1269,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
|
|||
}
|
||||
|
||||
/* check if there is a remote block */
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
|
||||
/* the channel is blocked...can't send any calls here */
|
||||
SS7_ERROR_CHAN(ftdmchan, "Requested channel is remotely blocked, re-hunt channel!%s\n", " ");
|
||||
|
@ -1257,9 +1279,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
|
|||
}
|
||||
|
||||
/* check if there is a local block */
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {
|
||||
if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {
|
||||
|
||||
/* KONRAD FIX ME : we should check if this is a TEST call and allow it */
|
||||
|
||||
|
@ -1272,11 +1294,7 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
|
|||
switch (ftdmchan->state){
|
||||
/**************************************************************************/
|
||||
case FTDM_CHANNEL_STATE_DOWN:
|
||||
/* inform the monitor thread that we want to make a call */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DIALING);
|
||||
|
||||
/* unlock the channel */
|
||||
ftdm_mutex_unlock (ftdmchan->mutex);
|
||||
/* inform the monitor thread that we want to make a call by returning FTDM_SUCCESS */
|
||||
|
||||
goto outgoing_successful;
|
||||
break;
|
||||
|
@ -1294,20 +1312,14 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
|
|||
|
||||
outgoing_fail:
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Call Request failed%s\n", " ");
|
||||
/* unlock the channel */
|
||||
ftdm_mutex_unlock (ftdmchan->mutex);
|
||||
return FTDM_FAIL;
|
||||
|
||||
outgoing_break:
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Call Request re-hunt%s\n", " ");
|
||||
/* unlock the channel */
|
||||
ftdm_mutex_unlock (ftdmchan->mutex);
|
||||
return FTDM_BREAK;
|
||||
|
||||
outgoing_successful:
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Call Request successful%s\n", " ");
|
||||
/* unlock the channel */
|
||||
ftdm_mutex_unlock (ftdmchan->mutex);
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1385,6 +1397,9 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
|
|||
/* lock the channel */
|
||||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
|
||||
/* flag the circuit as active */
|
||||
sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE);
|
||||
|
||||
/* check if the interface is paused or resumed */
|
||||
if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "ISUP intf %d is PAUSED\n", sngss7_intf->id);
|
||||
|
@ -1410,7 +1425,7 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
|
|||
sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
|
||||
#endif
|
||||
/* throw the channel to suspend */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
|
||||
/* unlock the channel */
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
|
@ -1583,6 +1598,8 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
|
|||
{
|
||||
/*this function is called by the FT-core to unload the signaling module */
|
||||
|
||||
int x;
|
||||
|
||||
ftdm_log (FTDM_LOG_INFO, "Starting ftmod_sangoma_ss7 unload...\n");
|
||||
|
||||
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {
|
||||
|
@ -1610,6 +1627,26 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
|
|||
}
|
||||
|
||||
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) {
|
||||
/* go through all the relays channels and configure it */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
|
||||
/* check if this relay channel has been configured already */
|
||||
if ((g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) {
|
||||
|
||||
/* send the specific configuration */
|
||||
if (ftmod_ss7_disable_relay_channel(x)) {
|
||||
SS7_CRITICAL("Relay Channel %d disable failed!\n", x);
|
||||
return 1;
|
||||
} else {
|
||||
SS7_INFO("Relay Channel %d disable DONE!\n", x);
|
||||
}
|
||||
|
||||
/* set the SNGSS7_CONFIGURED flag */
|
||||
g_ftdm_sngss7_data.cfg.relay[x].flags &= !SNGSS7_CONFIGURED;
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */
|
||||
|
||||
ftmod_ss7_shutdown_relay();
|
||||
sng_isup_free_relay();
|
||||
sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY);
|
||||
|
|
|
@ -76,6 +76,17 @@ typedef enum {
|
|||
SNGSS7_SSP_STA_CFM_EVENT
|
||||
} sng_event_type_t;
|
||||
|
||||
typedef enum {
|
||||
SNG_BIT_A = (1 << 0),
|
||||
SNG_BIT_B = (1 << 1),
|
||||
SNG_BIT_C = (1 << 2),
|
||||
SNG_BIT_D = (1 << 3),
|
||||
SNG_BIT_E = (1 << 4),
|
||||
SNG_BIT_F = (1 << 5),
|
||||
SNG_BIT_G = (1 << 6),
|
||||
SNG_BIT_H = (1 << 7)
|
||||
} sng_bit_enums_t;
|
||||
|
||||
typedef enum {
|
||||
VOICE = 0,
|
||||
SIG,
|
||||
|
@ -294,7 +305,6 @@ typedef struct sng_isup_intf {
|
|||
typedef struct sng_isup_ckt {
|
||||
uint32_t options;
|
||||
uint32_t flags;
|
||||
uint32_t ckt_flags;
|
||||
uint32_t procId;
|
||||
uint32_t id;
|
||||
uint32_t ccSpanId;
|
||||
|
@ -431,6 +441,10 @@ typedef struct sngss7_chan_data {
|
|||
uint32_t spId;
|
||||
uint8_t globalFlg;
|
||||
uint32_t ckt_flags;
|
||||
uint32_t blk_flags;
|
||||
ftdm_hash_t* variables; /* send on next sigevent */
|
||||
ftdm_size_t raw_data_len;
|
||||
void *raw_data; /* send on next sigevent */
|
||||
sngss7_glare_data_t glare;
|
||||
sngss7_timer_data_t t35;
|
||||
}sngss7_chan_data_t;
|
||||
|
@ -489,23 +503,98 @@ typedef enum {
|
|||
FLAG_GLARE = (1 << 13),
|
||||
FLAG_INFID_RESUME = (1 << 14),
|
||||
FLAG_INFID_PAUSED = (1 << 15),
|
||||
FLAG_CKT_UCIC_BLOCK = (1 << 16),
|
||||
FLAG_CKT_UCIC_UNBLK = (1 << 17),
|
||||
FLAG_CKT_LC_BLOCK_RX = (1 << 18),
|
||||
FLAG_CKT_LC_UNBLK_RX = (1 << 19),
|
||||
FLAG_CKT_MN_BLOCK_RX = (1 << 20),
|
||||
FLAG_CKT_MN_UNBLK_RX = (1 << 21),
|
||||
FLAG_CKT_MN_BLOCK_TX = (1 << 22),
|
||||
FLAG_CKT_MN_UNBLK_TX = (1 << 23),
|
||||
FLAG_GRP_HW_BLOCK_RX = (1 << 24),
|
||||
FLAG_GRP_HW_BLOCK_TX = (1 << 25),
|
||||
FLAG_GRP_MN_BLOCK_RX = (1 << 26),
|
||||
FLAG_GRP_MN_BLOCK_TX = (1 << 27),
|
||||
FLAG_GRP_HW_UNBLK_TX = (1 << 28),
|
||||
FLAG_GRP_MN_UNBLK_TX = (1 << 29),
|
||||
FLAG_RELAY_DOWN = (1 << 30)
|
||||
FLAG_RELAY_DOWN = (1 << 30),
|
||||
FLAG_CKT_RECONFIG = (1 << 31)
|
||||
} sng_ckt_flag_t;
|
||||
|
||||
#define CKT_FLAGS_STRING \
|
||||
"RX_RSC", \
|
||||
"TX_RSC", \
|
||||
"TX_RSC_REQ_SENT", \
|
||||
"TX_RSC_RSP_RECIEVED", \
|
||||
"RX_GRS", \
|
||||
"RX_GRS_DONE", \
|
||||
"RX_GRS_CMPLT", \
|
||||
"GRS_BASE", \
|
||||
"TX_GRS", \
|
||||
"TX_GRS_REQ_SENT", \
|
||||
"TX_GRS_RSP_RECIEVED", \
|
||||
"REMOTE_REL", \
|
||||
"LOCAL_REL", \
|
||||
"GLARE", \
|
||||
"INF_RESUME", \
|
||||
"INF_PAUSED", \
|
||||
"RELAY_DOWN", \
|
||||
"CKT_RECONFIG"
|
||||
FTDM_STR2ENUM_P(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t)
|
||||
|
||||
/* ckt blocking flags */
|
||||
typedef enum {
|
||||
FLAG_CKT_UCIC_BLOCK = (1 << 0),
|
||||
FLAG_CKT_UCIC_BLOCK_DN = (1 << 1),
|
||||
FLAG_CKT_UCIC_UNBLK = (1 << 2),
|
||||
FLAG_CKT_UCIC_UNBLK_DN = (1 << 3),
|
||||
FLAG_CKT_LC_BLOCK_RX = (1 << 4),
|
||||
FLAG_CKT_LC_BLOCK_RX_DN = (1 << 5),
|
||||
FLAG_CKT_LC_UNBLK_RX = (1 << 6),
|
||||
FLAG_CKT_LC_UNBLK_RX_DN = (1 << 7),
|
||||
FLAG_CKT_MN_BLOCK_RX = (1 << 8),
|
||||
FLAG_CKT_MN_BLOCK_RX_DN = (1 << 9),
|
||||
FLAG_CKT_MN_UNBLK_RX = (1 << 10),
|
||||
FLAG_CKT_MN_UNBLK_RX_DN = (1 << 11),
|
||||
FLAG_CKT_MN_BLOCK_TX = (1 << 12),
|
||||
FLAG_CKT_MN_BLOCK_TX_DN = (1 << 13),
|
||||
FLAG_CKT_MN_UNBLK_TX = (1 << 14),
|
||||
FLAG_CKT_MN_UNBLK_TX_DN = (1 << 15),
|
||||
FLAG_GRP_HW_BLOCK_RX = (1 << 16),
|
||||
FLAG_GRP_HW_BLOCK_RX_DN = (1 << 17),
|
||||
FLAG_GRP_HW_BLOCK_TX = (1 << 18),
|
||||
FLAG_GRP_HW_BLOCK_TX_DN = (1 << 19),
|
||||
FLAG_GRP_MN_BLOCK_RX = (1 << 20),
|
||||
FLAG_GRP_MN_BLOCK_RX_DN = (1 << 21),
|
||||
FLAG_GRP_MN_BLOCK_TX = (1 << 22),
|
||||
FLAG_GRP_MN_BLOCK_TX_DN = (1 << 23),
|
||||
FLAG_GRP_HW_UNBLK_TX = (1 << 24),
|
||||
FLAG_GRP_HW_UNBLK_TX_DN = (1 << 25),
|
||||
FLAG_GRP_MN_UNBLK_TX = (1 << 26),
|
||||
FLAG_GRP_MN_UNBLK_TX_DN = (1 << 27)
|
||||
} sng_ckt_block_flag_t;
|
||||
|
||||
#define BLK_FLAGS_STRING \
|
||||
"UCIC BLK", \
|
||||
"UCIC BLK DN", \
|
||||
"UCIC UNBLK", \
|
||||
"UCIC UNBLK DN", \
|
||||
"RX LC BLK", \
|
||||
"RX LC BLK DN", \
|
||||
"RX LC UNBLK", \
|
||||
"RX LC UNBLK DN", \
|
||||
"RX CKT BLK", \
|
||||
"RX CKT BLK DN", \
|
||||
"RX CKT UNBLK", \
|
||||
"RX CKT UNBLK DN", \
|
||||
"TX CKT BLK", \
|
||||
"TX CKT BLK DN", \
|
||||
"TX CKT UNBLK", \
|
||||
"TX CKT UNBLK DN", \
|
||||
"RX GRP MN BLK", \
|
||||
"RX GRP MN BLK DN", \
|
||||
"RX GRP MN UNBLK", \
|
||||
"RX GRP MN UNBLK DN", \
|
||||
"TX GRP MN BLK", \
|
||||
"TX GRP MN BLK DN", \
|
||||
"TX GRP MN UNBLK", \
|
||||
"TX GRP MN UNBLK DN", \
|
||||
"RX GRP HW BLK", \
|
||||
"RX GRP HW BLK DN", \
|
||||
"RX GRP HW UNBLK", \
|
||||
"RX GRP HW UNBLK DN", \
|
||||
"TX GRP HW BLK", \
|
||||
"TX GRP HW BLK DN", \
|
||||
"TX GRP HW UNBLK", \
|
||||
"TX GRP HW UNBLK DN"
|
||||
FTDM_STR2ENUM_P(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t)
|
||||
|
||||
/* valid for every cfg array except circuits */
|
||||
typedef enum {
|
||||
SNGSS7_CONFIGURED = (1 << 0),
|
||||
|
@ -594,12 +683,17 @@ int ftmod_ss7_shutdown_isup(void);
|
|||
int ftmod_ss7_shutdown_mtp3(void);
|
||||
int ftmod_ss7_shutdown_mtp2(void);
|
||||
int ftmod_ss7_shutdown_relay(void);
|
||||
int ftmod_ss7_disable_relay_channel(uint32_t chanId);
|
||||
|
||||
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);
|
||||
int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
|
||||
|
||||
int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
|
||||
|
||||
int ftmod_ss7_block_isup_ckt(uint32_t cktId);
|
||||
int ftmod_ss7_unblock_isup_ckt(uint32_t cktId);
|
||||
|
||||
|
||||
/* in ftmod_sangoma_ss7_sta.c */
|
||||
int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm);
|
||||
int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm);
|
||||
|
@ -607,6 +701,7 @@ int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm);
|
|||
int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm);
|
||||
int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status);
|
||||
int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm);
|
||||
int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state);
|
||||
|
||||
|
||||
/* in ftmod_sangoma_ss7_out.c */
|
||||
|
@ -723,12 +818,25 @@ int find_ssf_type_in_map(const char *ssfType);
|
|||
int find_cic_cntrl_in_map(const char *cntrlType);
|
||||
|
||||
ftdm_status_t check_status_of_all_isup_intf(void);
|
||||
ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan);
|
||||
|
||||
void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id);
|
||||
void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status);
|
||||
ftdm_status_t sngss7_add_var(sngss7_chan_data_t *ss7_info, const char* var, const char* val);
|
||||
ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len);
|
||||
|
||||
/* in ftmod_sangoma_ss7_timers.c */
|
||||
void handle_isup_t35(void *userdata);
|
||||
/******************************************************************************/
|
||||
|
||||
/* MACROS *********************************************************************/
|
||||
#define SS7_STATE_CHANGE(ftdmchan, new_state) \
|
||||
if (ftdmchan->state == new_state) { \
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE); \
|
||||
} else { \
|
||||
ftdm_set_state(ftdmchan, new_state); \
|
||||
}
|
||||
|
||||
#define SS7_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a , ##__VA_ARGS__ );
|
||||
#define SS7_INFO(a,...) ftdm_log(FTDM_LOG_INFO,a , ##__VA_ARGS__ );
|
||||
#define SS7_WARN(a,...) ftdm_log(FTDM_LOG_WARNING,a , ##__VA_ARGS__ );
|
||||
|
@ -860,6 +968,10 @@ void handle_isup_t35(void *userdata);
|
|||
#define sngss7_clear_ckt_flag(obj, flag) ((obj)->ckt_flags &= ~(flag))
|
||||
#define sngss7_set_ckt_flag(obj, flag) ((obj)->ckt_flags |= (flag))
|
||||
|
||||
#define sngss7_test_ckt_blk_flag(obj, flag) ((obj)->blk_flags & flag)
|
||||
#define sngss7_clear_ckt_blk_flag(obj, flag) ((obj)->blk_flags &= ~(flag))
|
||||
#define sngss7_set_ckt_blk_flag(obj, flag) ((obj)->blk_flags |= (flag))
|
||||
|
||||
#define sngss7_test_options(obj, option) ((obj)->options & option)
|
||||
#define sngss7_clear_options(obj, option) ((obj)->options &= ~(option))
|
||||
#define sngss7_set_options(obj, option) ((obj)->options |= (option))
|
||||
|
|
|
@ -187,7 +187,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
|
|||
copy_cgPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cgPtyNum);
|
||||
|
||||
/* check if the user would like a custom NADI value for the calling Pty Num */
|
||||
clg_nadi = ftdm_call_get_var(&ftdmchan->caller_data, "ss7_clg_nadi");
|
||||
clg_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_nadi");
|
||||
if ((clg_nadi != NULL) && (*clg_nadi)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling NADI value \"%s\"\n", clg_nadi);
|
||||
iam.cgPtyNum.natAddrInd.val = atoi(clg_nadi);
|
||||
|
@ -196,7 +196,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
|
|||
SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLG, using \"%d\"\n", iam.cgPtyNum.natAddrInd.val);
|
||||
}
|
||||
|
||||
cld_nadi = ftdm_call_get_var(&ftdmchan->caller_data, "ss7_cld_nadi");
|
||||
cld_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi");
|
||||
if ((cld_nadi != NULL) && (*cld_nadi)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called NADI value \"%s\"\n", cld_nadi);
|
||||
iam.cdPtyNum.natAddrInd.val = atoi(cld_nadi);
|
||||
|
@ -206,7 +206,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
|
|||
}
|
||||
|
||||
/* check if the user would like us to send a clg_sub-address */
|
||||
clg_subAddr = ftdm_call_get_var(&ftdmchan->caller_data, "ss7_clg_subaddr");
|
||||
clg_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_subaddr");
|
||||
if ((clg_subAddr != NULL) && (*clg_subAddr)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling Sub-Address value \"%s\"\n", clg_subAddr);
|
||||
|
||||
|
@ -245,7 +245,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
|
|||
}
|
||||
|
||||
/* check if the user would like us to send a cld_sub-address */
|
||||
cld_subAddr = ftdm_call_get_var(&ftdmchan->caller_data, "ss7_cld_subaddr");
|
||||
cld_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_subaddr");
|
||||
if ((cld_subAddr != NULL) && (*cld_subAddr)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called Sub-Address value \"%s\"\n", cld_subAddr);
|
||||
|
||||
|
@ -282,9 +282,6 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
|
|||
} /* if (subAddrIE[0] != '0') */
|
||||
} /* if ((cld_subAddr != NULL) && (*cld_subAddr)) */
|
||||
|
||||
|
||||
|
||||
|
||||
sng_cc_con_request (sngss7_info->spId,
|
||||
sngss7_info->suInstId,
|
||||
sngss7_info->spInstId,
|
||||
|
@ -299,7 +296,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
|
|||
ftdmchan->caller_data.dnis.digits,
|
||||
iam.cdPtyNum.natAddrInd.val);
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -379,7 +376,7 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
|
|||
ADDRCMPLT);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ACM\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -403,7 +400,7 @@ void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan)
|
|||
5);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ANM\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -438,7 +435,7 @@ void ft_to_sngss7_rel (ftdm_channel_t * ftdmchan)
|
|||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx REL cause=%d \n",
|
||||
sngss7_info->circuit->cic,
|
||||
ftdmchan->caller_data.hangup_cause );
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -461,7 +458,7 @@ void ft_to_sngss7_rlc (ftdm_channel_t * ftdmchan)
|
|||
&rlc);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RLC\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -482,7 +479,7 @@ void ft_to_sngss7_rsc (ftdm_channel_t * ftdmchan)
|
|||
NULL);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RSC\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -503,7 +500,7 @@ void ft_to_sngss7_rsca (ftdm_channel_t * ftdmchan)
|
|||
NULL);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RSC-RLC\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -524,7 +521,7 @@ void ft_to_sngss7_blo (ftdm_channel_t * ftdmchan)
|
|||
NULL);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx BLO\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -545,7 +542,7 @@ void ft_to_sngss7_bla (ftdm_channel_t * ftdmchan)
|
|||
NULL);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx BLA\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -567,7 +564,7 @@ ft_to_sngss7_ubl (ftdm_channel_t * ftdmchan)
|
|||
NULL);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx UBL\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -588,7 +585,7 @@ void ft_to_sngss7_uba (ftdm_channel_t * ftdmchan)
|
|||
NULL);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx UBA\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -609,7 +606,7 @@ void ft_to_sngss7_lpa (ftdm_channel_t * ftdmchan)
|
|||
NULL);
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx LPA\n", sngss7_info->circuit->cic);
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -654,7 +651,7 @@ void ft_to_sngss7_gra (ftdm_channel_t * ftdmchan)
|
|||
sngss7_info->circuit->cic,
|
||||
(sngss7_info->circuit->cic + sngss7_span->rx_grs.range));
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -688,7 +685,7 @@ void ft_to_sngss7_grs (ftdm_channel_t * ftdmchan)
|
|||
sngss7_info->circuit->cic,
|
||||
(sngss7_info->circuit->cic + sngss7_span->tx_grs.range));
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -737,7 +734,7 @@ void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan)
|
|||
|
||||
/* clean out the saved data */
|
||||
memset(&sngss7_span->rx_cgb, 0x0, sizeof(sngss7_group_data_t));
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -787,7 +784,7 @@ void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan)
|
|||
/* clean out the saved data */
|
||||
memset(&sngss7_span->rx_cgu, 0x0, sizeof(sngss7_group_data_t));
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -838,7 +835,7 @@ void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan)
|
|||
/* clean out the saved data */
|
||||
memset(&sngss7_span->tx_cgb, 0x0, sizeof(sngss7_group_data_t));
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
@ -889,7 +886,7 @@ void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan)
|
|||
/* clean out the saved data */
|
||||
memset(&sngss7_span->tx_cgu, 0x0, sizeof(sngss7_group_data_t));
|
||||
|
||||
ftdm_call_clear_data(&ftdmchan->caller_data);
|
||||
|
||||
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,10 +45,11 @@
|
|||
ftdm_status_t handle_relay_connect(RyMngmt *sta);
|
||||
ftdm_status_t handle_relay_disconnect(RyMngmt *sta);
|
||||
|
||||
static ftdm_status_t enable_all_ckts_for_relay(void);
|
||||
/*static ftdm_status_t enable_all_ckts_for_relay(void);*/
|
||||
static ftdm_status_t reconfig_all_ckts_for_relay(void);
|
||||
static ftdm_status_t disable_all_ckts_for_relay(void);
|
||||
static ftdm_status_t block_all_ckts_for_relay(uint32_t procId);
|
||||
static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId);
|
||||
static ftdm_status_t disable_all_sigs_for_relay(uint32_t procId);
|
||||
static ftdm_status_t disble_all_mtp2_sigs_for_relay(void);
|
||||
/******************************************************************************/
|
||||
|
@ -61,12 +62,12 @@ ftdm_status_t handle_relay_connect(RyMngmt *sta)
|
|||
|
||||
/* test if this is the first time the channel comes up */
|
||||
if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) {
|
||||
SS7_DEBUG("Relay Channel %d initial connection UP\n", sng_relay->id);
|
||||
SS7_INFO("Relay Channel %d initial connection UP\n", sng_relay->id);
|
||||
|
||||
/* mark the channel as being up */
|
||||
sngss7_set_flag(sng_relay, SNGSS7_RELAY_INIT);
|
||||
} else {
|
||||
SS7_DEBUG("Relay Channel %d connection UP\n", sng_relay->id);
|
||||
SS7_INFO("Relay Channel %d connection UP\n", sng_relay->id);
|
||||
|
||||
/* react based on type of channel */
|
||||
switch (sng_relay->type) {
|
||||
|
@ -75,18 +76,17 @@ ftdm_status_t handle_relay_connect(RyMngmt *sta)
|
|||
/* reconfigure all ISUP ckts, since the main system would have lost all configs */
|
||||
if (reconfig_all_ckts_for_relay()) {
|
||||
SS7_ERROR("Failed to reconfigure ISUP Ckts!\n");
|
||||
|
||||
/* we're done....this is very bad! */
|
||||
} else {
|
||||
enable_all_ckts_for_relay();
|
||||
}
|
||||
|
||||
break;
|
||||
/******************************************************************/
|
||||
case (LRY_CT_TCP_SERVER):
|
||||
/*unblock_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);*/
|
||||
/* bring the sig links on the client system back up */
|
||||
ftmod_ss7_enable_grp_mtp3Link(sta->t.usta.s.ryUpUsta.id);
|
||||
|
||||
|
||||
/* unbloock the ckts on the client system */
|
||||
unblock_all_ckts_for_relay(sta->t.usta.s.ryUpUsta.id);
|
||||
|
||||
break;
|
||||
/******************************************************************/
|
||||
default:
|
||||
|
@ -104,16 +104,20 @@ ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta)
|
|||
|
||||
/* check which procId is in error, if it is 1, disable the ckts */
|
||||
if (sta->t.usta.s.ryErrUsta.errPid == 1 ) {
|
||||
disable_all_ckts_for_relay();
|
||||
|
||||
/* we've lost the server, bring down the mtp2 links */
|
||||
disble_all_mtp2_sigs_for_relay();
|
||||
|
||||
/* we've lost the server, bring the sig status down on all ckts */
|
||||
disable_all_ckts_for_relay();
|
||||
}
|
||||
|
||||
/* check if the channel is a server, means we just lost a MGW */
|
||||
if (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryErrUsta.errPid].type == LRY_CT_TCP_SERVER) {
|
||||
block_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);
|
||||
|
||||
/* we've lost the client, bring down all mtp3 links for this procId */
|
||||
disable_all_sigs_for_relay(sta->t.usta.s.ryErrUsta.errPid);
|
||||
|
||||
/* we've lost the client, bring down all the ckts for this procId */
|
||||
block_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);
|
||||
}
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
|
@ -170,7 +174,7 @@ ftdm_status_t disable_all_ckts_for_relay(void)
|
|||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/******************************************************************************/
|
||||
ftdm_status_t enable_all_ckts_for_relay(void)
|
||||
{
|
||||
|
@ -207,7 +211,7 @@ ftdm_status_t enable_all_ckts_for_relay(void)
|
|||
SS7_DEBUG_CHAN(ftdmchan, "ISUP interface (%d) set to resume, resuming channel\n", sngIntf->id);
|
||||
/* throw the channel infId status flags to PAUSED ... they will be executed next process cycle */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
|
||||
}
|
||||
} /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
|
||||
|
||||
|
@ -218,34 +222,33 @@ ftdm_status_t enable_all_ckts_for_relay(void)
|
|||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
ftdm_status_t reconfig_all_ckts_for_relay(void)
|
||||
{
|
||||
#if 1
|
||||
int x;
|
||||
int ret;
|
||||
sngss7_chan_data_t *sngss7_info = NULL;
|
||||
|
||||
/* go through all the circuits on our ProcId */
|
||||
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
|
||||
/**************************************************************************/
|
||||
if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
|
||||
|
||||
ret = ftmod_ss7_isup_ckt_config(x);
|
||||
if (ret) {
|
||||
SS7_CRITICAL("ISUP CKT %d configuration FAILED (%d)!\n", x, ret);
|
||||
return 1;
|
||||
} else {
|
||||
SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
|
||||
}
|
||||
/* grab the private data structure */
|
||||
sngss7_info = g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
|
||||
|
||||
/* mark the circuit for re-configuration */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG);
|
||||
|
||||
} /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
|
||||
/* clear the relay flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_RELAY_DOWN);
|
||||
}
|
||||
|
||||
/* set the SNGSS7_CONFIGURED flag */
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
|
||||
|
||||
/* move to the next circuit */
|
||||
x++;
|
||||
/**************************************************************************/
|
||||
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
|
||||
#endif
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -253,23 +256,26 @@ ftdm_status_t reconfig_all_ckts_for_relay(void)
|
|||
ftdm_status_t block_all_ckts_for_relay(uint32_t procId)
|
||||
{
|
||||
int x;
|
||||
|
||||
SS7_INFO("BLOcking all ckts on ProcID = %d\n", procId);
|
||||
int ret;
|
||||
|
||||
/* we just lost connection to this procId, send out a block for all these circuits */
|
||||
x = (procId * 1000) + 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
|
||||
/**************************************************************************/
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
|
||||
/* send out a BLO */
|
||||
sng_cc_sta_request (1,
|
||||
0,
|
||||
0,
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].id,
|
||||
0,
|
||||
SIT_STA_CIRBLOREQ,
|
||||
NULL);
|
||||
|
||||
/* send a block request via stack manager */
|
||||
ret = ftmod_ss7_block_isup_ckt(g_ftdm_sngss7_data.cfg.isupCkt[x].id);
|
||||
if (ret) {
|
||||
SS7_INFO("Successfully BLOcked CIC:%d(ckt:%d) due to Relay failure\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].id);
|
||||
} else {
|
||||
SS7_ERROR("Failed to BLOck CIC:%d(ckt:%d) due to Relay failure\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].id);
|
||||
}
|
||||
|
||||
} /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
|
||||
|
||||
/* move along */
|
||||
|
@ -304,6 +310,42 @@ ftdm_status_t disble_all_mtp2_sigs_for_relay(void)
|
|||
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
static ftdm_status_t unblock_all_ckts_for_relay(uint32_t procId)
|
||||
{
|
||||
int x;
|
||||
int ret;
|
||||
|
||||
/* we just got connection to this procId, send out a unblock for all these circuits
|
||||
* since we blocked them when we lost the connection
|
||||
*/
|
||||
x = (procId * 1000) + 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
|
||||
/**************************************************************************/
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
|
||||
|
||||
/* send a block request via stack manager */
|
||||
ret = ftmod_ss7_unblock_isup_ckt(g_ftdm_sngss7_data.cfg.isupCkt[x].id);
|
||||
if (ret) {
|
||||
SS7_INFO("Successfully unblocked CIC:%d(ckt:%d) due to Relay connection\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].id);
|
||||
} else {
|
||||
SS7_ERROR("Failed to unblock CIC:%d(ckt:%d) due to Relay connection\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].id);
|
||||
}
|
||||
|
||||
} /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
|
||||
|
||||
/* move along */
|
||||
x++;
|
||||
/**************************************************************************/
|
||||
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
|
|
|
@ -48,6 +48,7 @@ int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm);
|
|||
int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm);
|
||||
int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status);
|
||||
int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm);
|
||||
int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state);
|
||||
/******************************************************************************/
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
@ -188,6 +189,43 @@ int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm)
|
|||
return(sng_sta_relay(&pst, &sta, cfm));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ftmod_ss7_isup_ckt_sta(uint32_t id, unsigned char *state)
|
||||
{
|
||||
SiMngmt sta;
|
||||
SiMngmt cfm;
|
||||
Pst pst;
|
||||
int ret;
|
||||
|
||||
memset(&sta, 0x0, sizeof(sta));
|
||||
|
||||
/* initalize the post structure */
|
||||
smPstInit(&pst);
|
||||
|
||||
/* insert the destination Entity */
|
||||
pst.dstEnt = ENTSI;
|
||||
|
||||
/* check the for the correct ProcId and make sure it goes to the right system */
|
||||
if (g_ftdm_sngss7_data.cfg.procId != 1) {
|
||||
pst.dstProcId = 1;
|
||||
}
|
||||
|
||||
/* request the status of an inftId */
|
||||
sta.hdr.entId.ent = ENTSI;
|
||||
sta.hdr.entId.inst = S_INST;
|
||||
sta.hdr.msgType = TSSTA;
|
||||
sta.hdr.elmId.elmnt = SI_STCIRGRP;
|
||||
|
||||
sta.t.ssta.elmntId.circuit = id;
|
||||
sta.t.ssta.param.cirgr.range = 1;
|
||||
|
||||
ret = sng_sta_isup(&pst, &sta, &cfm);
|
||||
|
||||
*state = cfm.t.ssta.cfm.s.cir.state[0];
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
|
|
|
@ -83,8 +83,20 @@ int find_ssf_type_in_map(const char *ssfType);
|
|||
int find_cic_cntrl_in_map(const char *cntrlType);
|
||||
|
||||
ftdm_status_t check_status_of_all_isup_intf(void);
|
||||
ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan);
|
||||
|
||||
void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id);
|
||||
void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status);
|
||||
ftdm_status_t sngss7_add_var(sngss7_chan_data_t *ss7_info, const char* var, const char* val);
|
||||
ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len);
|
||||
/******************************************************************************/
|
||||
|
||||
FTDM_ENUM_NAMES(CKT_FLAGS_NAMES, CKT_FLAGS_STRING)
|
||||
FTDM_STR2ENUM(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t, CKT_FLAGS_NAMES, 31)
|
||||
|
||||
FTDM_ENUM_NAMES(BLK_FLAGS_NAMES, BLK_FLAGS_STRING)
|
||||
FTDM_STR2ENUM(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t, BLK_FLAGS_NAMES, 31)
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
|
||||
{
|
||||
|
@ -526,8 +538,18 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
|
|||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
|
||||
int i;
|
||||
|
||||
|
||||
SS7_INFO("Rx GRS (%d:%d)\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic,
|
||||
(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic + sngss7_span->rx_grs.range));
|
||||
|
||||
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
|
||||
|
||||
/* confirm this is a voice channel, otherwise we do nothing */
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* extract the channel in question */
|
||||
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
|
||||
|
@ -548,10 +570,6 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
|
|||
ftdm_sangoma_ss7_process_state_change (ftdmchan);
|
||||
}
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan, "Rx GRS (%d:%d)\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic,
|
||||
(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic + sngss7_span->rx_grs.range));
|
||||
|
||||
/* flag the channel as having received a reset */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX);
|
||||
|
||||
|
@ -560,14 +578,14 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
|
|||
case FTDM_CHANNEL_STATE_RESTART:
|
||||
|
||||
/* go to idle so that we can redo the restart state*/
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IDLE);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_IDLE);
|
||||
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
|
||||
/* set the state of the channel to restart...the rest is done by the chan monitor */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
} /* switch (ftdmchan->state) */
|
||||
|
@ -590,12 +608,14 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
|
|||
int byte = 0;
|
||||
int bit = 0;
|
||||
|
||||
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Found Rx GRS on span %s...checking circuits\n", ftdmspan->name);
|
||||
|
||||
/* check all the circuits in the range to see if they are done resetting */
|
||||
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
|
||||
|
||||
/* confirm this is a voice channel, otherwise we do nothing */
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* extract the channel in question */
|
||||
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
|
||||
|
@ -625,6 +645,11 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
|
|||
/* check all the circuits in the range to see if they are done resetting */
|
||||
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
|
||||
|
||||
/* confirm this is a voice channel, otherwise we do nothing */
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* extract the channel in question */
|
||||
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n",i);
|
||||
|
@ -638,13 +663,13 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
|
|||
sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);
|
||||
|
||||
/* move the channel to the down state */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
|
||||
/* update the status map if the ckt is in blocked state */
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
if ((sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
|
||||
(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) ||
|
||||
(sngss7_test_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {
|
||||
|
||||
sngss7_span->rx_grs.status[byte] = (sngss7_span->rx_grs.status[byte] | (1 << bit));
|
||||
} /* if blocked */
|
||||
|
@ -659,6 +684,12 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
|
|||
|
||||
GRS_UNLOCK_ALL:
|
||||
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
|
||||
|
||||
/* confirm this is a voice channel, otherwise we do nothing */
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[i].type != VOICE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* extract the channel in question */
|
||||
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
|
||||
|
@ -680,6 +711,10 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
|
|||
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
|
||||
int i;
|
||||
|
||||
SS7_INFO("Rx GRA (%d:%d)\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic,
|
||||
(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic + sngss7_span->rx_gra.range));
|
||||
|
||||
for (i = sngss7_span->rx_gra.circuit; i < (sngss7_span->rx_gra.circuit + sngss7_span->rx_gra.range + 1); i++) {
|
||||
|
||||
/* extract the channel in question */
|
||||
|
@ -702,9 +737,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
|
|||
ftdm_sangoma_ss7_process_state_change (ftdmchan);
|
||||
}
|
||||
|
||||
SS7_INFO_CHAN(ftdmchan, "Rx GRA (%d:%d)\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic,
|
||||
(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic + sngss7_span->rx_gra.range));
|
||||
|
||||
|
||||
switch (ftdmchan->state) {
|
||||
/**********************************************************************/
|
||||
|
@ -714,7 +747,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
|
|||
sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
|
||||
|
||||
/* go to DOWN */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
|
||||
|
||||
break;
|
||||
/**********************************************************************/
|
||||
|
@ -743,7 +776,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
|
|||
}
|
||||
|
||||
/* go to terminating to hang up the call */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
|
||||
break;
|
||||
/**********************************************************************/
|
||||
}
|
||||
|
@ -795,7 +828,7 @@ ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)
|
|||
|
||||
/* throw the channel into SUSPENDED to process the flag */
|
||||
/* after doing this once the sig status will be down */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
ftdm_set_state (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
}
|
||||
|
||||
/* if the RESUME flag is up go to SUSPENDED to process the flag */
|
||||
|
@ -808,7 +841,7 @@ ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)
|
|||
}
|
||||
|
||||
/* got SUSPENDED state to clear the flag */
|
||||
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
ftdm_set_state (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
}
|
||||
|
||||
/* unlock the channel */
|
||||
|
@ -849,10 +882,10 @@ ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan)
|
|||
}
|
||||
|
||||
/* throw the ckt block flag */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
|
||||
/* unlock the channel again before we exit */
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
|
@ -1348,6 +1381,276 @@ ftdm_status_t check_status_of_all_isup_intf(void)
|
|||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
ftdm_status_t sngss7_add_var(sngss7_chan_data_t *sngss7_info, const char* var, const char* val)
|
||||
{
|
||||
char *t_name = 0;
|
||||
char *t_val = 0;
|
||||
|
||||
/* confirm the user has sent us a value */
|
||||
if (!var || !val) {
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
if (!sngss7_info->variables) {
|
||||
/* initialize on first use */
|
||||
sngss7_info->variables = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
|
||||
ftdm_assert_return(sngss7_info->variables, FTDM_FAIL, "Failed to create hash table\n");
|
||||
}
|
||||
|
||||
t_name = ftdm_strdup(var);
|
||||
t_val = ftdm_strdup(val);
|
||||
|
||||
hashtable_insert(sngss7_info->variables, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE);
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len)
|
||||
{
|
||||
ftdm_assert_return(!sngss7_info->raw_data, FTDM_FAIL, "Overwriting existing raw data\n");
|
||||
|
||||
sngss7_info->raw_data = ftdm_calloc(1, data_len);
|
||||
ftdm_assert_return(sngss7_info->raw_data, FTDM_FAIL, "Failed to allocate raw data\n");
|
||||
|
||||
memcpy(sngss7_info->raw_data, data, data_len);
|
||||
sngss7_info->raw_data_len = data_len;
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id)
|
||||
{
|
||||
ftdm_sigmsg_t sigev;
|
||||
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
|
||||
|
||||
memset(&sigev, 0, sizeof(sigev));
|
||||
|
||||
sigev.chan_id = ftdmchan->chan_id;
|
||||
sigev.span_id = ftdmchan->span_id;
|
||||
sigev.channel = ftdmchan;
|
||||
sigev.event_id = event_id;
|
||||
|
||||
if (sngss7_info->variables) {
|
||||
/*
|
||||
* variables now belongs to the ftdm core, and
|
||||
* will be cleared after sigev is processed by user. Set
|
||||
* local pointer to NULL so we do not attempt to
|
||||
* destroy it */
|
||||
sigev.variables = sngss7_info->variables;
|
||||
sngss7_info->variables = NULL;
|
||||
}
|
||||
|
||||
if (sngss7_info->raw_data) {
|
||||
/*
|
||||
* raw_data now belongs to the ftdm core, and
|
||||
* will be cleared after sigev is processed by user. Set
|
||||
* local pointer to NULL so we do not attempt to
|
||||
* destroy it */
|
||||
|
||||
sigev.raw.data = sngss7_info->raw_data;
|
||||
sigev.raw.len = sngss7_info->raw_data_len;
|
||||
|
||||
sngss7_info->raw_data = NULL;
|
||||
sngss7_info->raw_data_len = 0;
|
||||
}
|
||||
ftdm_span_send_signal(ftdmchan->span, &sigev);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status)
|
||||
{
|
||||
ftdm_sigmsg_t sig;
|
||||
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Signalling link status changed to %s\n",
|
||||
ftdm_signaling_status2str(status));
|
||||
|
||||
memset(&sig, 0, sizeof(sig));
|
||||
|
||||
sig.chan_id = ftdmchan->chan_id;
|
||||
sig.span_id = ftdmchan->span_id;
|
||||
sig.channel = ftdmchan;
|
||||
sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
|
||||
sig.ev_data.sigstatus.status = status;
|
||||
|
||||
if (ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS) {
|
||||
SS7_ERROR_CHAN(ftdmchan, "Failed to change channel status to %s\n",
|
||||
ftdm_signaling_status2str(status));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan)
|
||||
{
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
sngss7_chan_data_t *sngss7_info = NULL;
|
||||
sng_isup_inf_t *sngss7_intf = NULL;
|
||||
uint8_t state;
|
||||
uint8_t bits_ab = 0;
|
||||
uint8_t bits_cd = 0;
|
||||
uint8_t bits_ef = 0;
|
||||
int x;
|
||||
int ret;
|
||||
|
||||
for (x = 1; x < (ftdmspan->chan_count + 1); x++) {
|
||||
/**************************************************************************/
|
||||
/* extract the channel structure and sngss7 channel data */
|
||||
ftdmchan = ftdmspan->channels[x];
|
||||
|
||||
/* if the call data is NULL move on */
|
||||
if (ftdmchan->call_data == NULL) {
|
||||
SS7_WARN_CHAN(ftdmchan, "Found ftdmchan with no sig module data!%s\n", " ");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* grab the private data */
|
||||
sngss7_info = ftdmchan->call_data;
|
||||
|
||||
/* check the reconfig flag */
|
||||
if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG)) {
|
||||
/* confirm the state of all isup interfaces*/
|
||||
check_status_of_all_isup_intf();
|
||||
|
||||
sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
|
||||
|
||||
/* check if the interface is paused or resumed */
|
||||
if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "ISUP intf %d is PAUSED\n", sngss7_intf->id);
|
||||
/* throw the pause flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
|
||||
} else {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "ISUP intf %d is RESUMED\n", sngss7_intf->id);
|
||||
/* throw the resume flag */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
|
||||
}
|
||||
|
||||
/* query for the status of the ckt */
|
||||
if (ftmod_ss7_isup_ckt_sta(sngss7_info->circuit->id, &state)) {
|
||||
SS7_ERROR("Failed to read isup ckt = %d status\n", sngss7_info->circuit->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* extract the bit sections */
|
||||
bits_ab = (state & (SNG_BIT_A + SNG_BIT_B)) >> 0;
|
||||
bits_cd = (state & (SNG_BIT_C + SNG_BIT_D)) >> 2;
|
||||
bits_ef = (state & (SNG_BIT_E + SNG_BIT_F)) >> 4;
|
||||
|
||||
if (bits_cd == 0x0) {
|
||||
/* check if circuit is UCIC or transient */
|
||||
if (bits_ab == 0x3) {
|
||||
/* bit a and bit b are set, unequipped */
|
||||
ret = ftmod_ss7_isup_ckt_config(sngss7_info->circuit->id);
|
||||
if (ret) {
|
||||
SS7_CRITICAL("ISUP CKT %d re-configuration FAILED!\n",x);
|
||||
} else {
|
||||
SS7_INFO("ISUP CKT %d re-configuration DONE!\n", x);
|
||||
}
|
||||
|
||||
/* reset the circuit to sync states */
|
||||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
|
||||
/* flag the circuit as active */
|
||||
sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE);
|
||||
|
||||
/* throw the channel into reset */
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
|
||||
|
||||
/* throw the channel to suspend */
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
|
||||
/* unlock the channel */
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
|
||||
} /* if (bits_ab == 0x3) */
|
||||
} else {
|
||||
/* check the maintenance block status in bits A and B */
|
||||
switch (bits_ab) {
|
||||
/**************************************************************************/
|
||||
case (0):
|
||||
/* no maintenace block...do nothing */
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (1):
|
||||
/* locally blocked */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (2):
|
||||
/* remotely blocked */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (3):
|
||||
/* both locally and remotely blocked */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
break;
|
||||
/**************************************************************************/
|
||||
} /* switch (bits_ab) */
|
||||
|
||||
/* check the hardware block status in bits e and f */
|
||||
switch (bits_ef) {
|
||||
/**************************************************************************/
|
||||
case (0):
|
||||
/* no maintenace block...do nothing */
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (1):
|
||||
/* locally blocked */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (2):
|
||||
/* remotely blocked */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
case (3):
|
||||
/* both locally and remotely blocked */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX);
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
break;
|
||||
/**************************************************************************/
|
||||
default:
|
||||
break;
|
||||
/**************************************************************************/
|
||||
} /* switch (bits_ef) */
|
||||
}
|
||||
|
||||
/* clear the re-config flag ... no matter what */
|
||||
sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG);
|
||||
|
||||
} /* if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG)) */
|
||||
} /* for (x = 1; x < (span->chan_count + 1); x++) */
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
/******************************************************************************/
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
|
|
|
@ -67,7 +67,7 @@ void handle_isup_t35(void *userdata)
|
|||
ftdmchan->caller_data.hangup_cause = 28;
|
||||
|
||||
/* end the call */
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
|
||||
|
||||
/*unlock*/
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
|
|
|
@ -2668,7 +2668,7 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
|
|||
if (sng_isup->tpause != 0) {
|
||||
g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = sng_isup->tpause;
|
||||
} else {
|
||||
g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = 150;
|
||||
g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = 3000;
|
||||
}
|
||||
if (sng_isup->tstaenq != 0) {
|
||||
g_ftdm_sngss7_data.cfg.isupIntf[i].tstaenq = sng_isup->tstaenq;
|
||||
|
|
|
@ -172,7 +172,7 @@ typedef enum {
|
|||
/*! \brief I/O channel type */
|
||||
typedef enum {
|
||||
FTDM_CHAN_TYPE_B, /*!< Bearer channel */
|
||||
FTDM_CHAN_TYPE_DQ921, /*< DQ921 channel (D-channel) */
|
||||
FTDM_CHAN_TYPE_DQ921, /*!< DQ921 channel (D-channel) */
|
||||
FTDM_CHAN_TYPE_DQ931, /*!< DQ931 channel */
|
||||
FTDM_CHAN_TYPE_FXS, /*!< FXS analog channel */
|
||||
FTDM_CHAN_TYPE_FXO, /*!< FXO analog channel */
|
||||
|
@ -214,6 +214,7 @@ typedef void *(*ftdm_queue_dequeue_func_t)(ftdm_queue_t *queue);
|
|||
typedef ftdm_status_t (*ftdm_queue_wait_func_t)(ftdm_queue_t *queue, int ms);
|
||||
typedef ftdm_status_t (*ftdm_queue_get_interrupt_func_t)(ftdm_queue_t *queue, ftdm_interrupt_t **interrupt);
|
||||
typedef ftdm_status_t (*ftdm_queue_destroy_func_t)(ftdm_queue_t **queue);
|
||||
|
||||
typedef struct ftdm_queue_handler {
|
||||
ftdm_queue_create_func_t create;
|
||||
ftdm_queue_enqueue_func_t enqueue;
|
||||
|
@ -223,7 +224,6 @@ typedef struct ftdm_queue_handler {
|
|||
ftdm_queue_destroy_func_t destroy;
|
||||
} ftdm_queue_handler_t;
|
||||
|
||||
|
||||
/*! \brief Type Of Number (TON) */
|
||||
typedef enum {
|
||||
FTDM_TON_UNKNOWN = 0,
|
||||
|
@ -318,8 +318,6 @@ typedef struct {
|
|||
uint8_t plan;
|
||||
} ftdm_number_t;
|
||||
|
||||
typedef void * ftdm_variable_container_t;
|
||||
|
||||
/*! \brief Caller information */
|
||||
typedef struct ftdm_caller_data {
|
||||
char cid_date[8]; /*!< Caller ID date */
|
||||
|
@ -333,21 +331,23 @@ typedef struct ftdm_caller_data {
|
|||
uint8_t pres; /*!< Presentation*/
|
||||
char collected[FTDM_DIGITS_LIMIT]; /*!< Collected digits so far */
|
||||
int hangup_cause; /*!< Hangup cause */
|
||||
char raw_data[1024]; /*!< Protocol specific raw caller data */
|
||||
uint32_t raw_data_len; /*!< Raw data length */
|
||||
/* these 2 are undocumented right now, only used by boost: */
|
||||
/* bearer capability */
|
||||
ftdm_bearer_cap_t bearer_capability;
|
||||
/* user information layer 1 protocol */
|
||||
ftdm_user_layer1_prot_t bearer_layer1;
|
||||
ftdm_calling_party_category_t cpc; /*!< Calling party category */
|
||||
ftdm_variable_container_t variables; /*!< Variables attached to this call */
|
||||
/* We need call_id inside caller_data for the user to be able to retrieve
|
||||
|
||||
ftdm_channel_t *fchan; /*!< FreeTDM channel associated (can be NULL) */
|
||||
|
||||
/*
|
||||
* We need call_id inside caller_data for the user to be able to retrieve
|
||||
* the call_id when ftdm_channel_call_place is called. This is the only time
|
||||
* that the user can use caller_data.call_id to obtain the call_id. The user
|
||||
* should use the call_id from sigmsg otherwise */
|
||||
* should use the call_id from sigmsg otherwise
|
||||
*/
|
||||
uint32_t call_id; /*!< Unique call ID for this call */
|
||||
ftdm_channel_t *fchan; /*!< FreeTDM channel associated (can be NULL) */
|
||||
|
||||
void *priv; /*!< Private data for the FreeTDM user */
|
||||
} ftdm_caller_data_t;
|
||||
|
||||
|
@ -533,9 +533,10 @@ typedef enum {
|
|||
FTDM_CHANNEL_INDICATE_BUSY,
|
||||
/* Using this indication is equivalent to call ftdm_channel_call_answer API */
|
||||
FTDM_CHANNEL_INDICATE_ANSWER,
|
||||
FTDM_CHANNEL_INDICATE_FACILITY,
|
||||
FTDM_CHANNEL_INDICATE_INVALID,
|
||||
} ftdm_channel_indication_t;
|
||||
#define INDICATION_STRINGS "NONE", "RINGING", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "BUSY", "ANSWER", "INVALID"
|
||||
#define INDICATION_STRINGS "NONE", "RINGING", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "BUSY", "ANSWER", "FACILITY", "INVALID"
|
||||
|
||||
/*! \brief Move from string to ftdm_channel_indication_t and viceversa */
|
||||
FTDM_STR2ENUM_P(ftdm_str2channel_indication, ftdm_channel_indication2str, ftdm_channel_indication_t)
|
||||
|
@ -547,7 +548,14 @@ typedef struct {
|
|||
ftdm_status_t status;
|
||||
} ftdm_event_indication_completed_t;
|
||||
|
||||
/*! \brief Generic signaling message */
|
||||
typedef void * ftdm_variable_container_t;
|
||||
|
||||
typedef struct {
|
||||
ftdm_size_t len;
|
||||
void *data;
|
||||
} ftdm_raw_data_t;
|
||||
|
||||
/*! \brief Generic signaling message received from the stack */
|
||||
struct ftdm_sigmsg {
|
||||
ftdm_signal_event_t event_id; /*!< The type of message */
|
||||
ftdm_channel_t *channel; /*!< Related channel */
|
||||
|
@ -555,17 +563,20 @@ struct ftdm_sigmsg {
|
|||
uint32_t span_id; /*!< easy access to span_id */
|
||||
uint32_t call_id; /*!< unique call id for this call */
|
||||
void *call_priv; /*!< Private data for the FreeTDM user from ftdm_caller_data->priv */
|
||||
ftdm_variable_container_t variables;
|
||||
union {
|
||||
ftdm_event_sigstatus_t sigstatus; /*!< valid if event_id is FTDM_SIGEVENT_SIGSTATUS_CHANGED */
|
||||
ftdm_event_trace_t trace; /*!< valid if event_id is FTDM_SIGEVENT_TRACE or FTDM_SIGEVENT_TRACE_RAW */
|
||||
ftdm_event_collected_t collected; /*!< valid if event_id is FTDM_SIGEVENT_COLLECTED_DIGIT */
|
||||
ftdm_event_indication_completed_t indication_completed; /*!< valid if the event_id is FTDM_SIGEVENT_INDICATION_COMPLETED */
|
||||
} ev_data;
|
||||
struct {
|
||||
uint8_t autofree; /*!< Whether the freetdm core will free it after message delivery */
|
||||
uint32_t len; /*!< Data len */
|
||||
void *data; /*!< Signaling module specific data */
|
||||
} raw;
|
||||
ftdm_raw_data_t raw;
|
||||
};
|
||||
|
||||
/*! \brief Generic user message sent to the stack */
|
||||
struct ftdm_usrmsg {
|
||||
ftdm_variable_container_t variables;
|
||||
ftdm_raw_data_t raw;
|
||||
};
|
||||
|
||||
/*! \brief Crash policy
|
||||
|
@ -673,6 +684,9 @@ typedef enum {
|
|||
FTDM_COMMAND_SET_RX_QUEUE_SIZE = 54,
|
||||
FTDM_COMMAND_SET_TX_QUEUE_SIZE = 55,
|
||||
FTDM_COMMAND_SET_POLARITY = 56,
|
||||
FTDM_COMMAND_START_MF_PLAYBACK = 57,
|
||||
FTDM_COMMAND_STOP_MF_PLAYBACK = 58,
|
||||
|
||||
FTDM_COMMAND_COUNT,
|
||||
} ftdm_command_t;
|
||||
|
||||
|
@ -698,7 +712,7 @@ struct ftdm_memory_handler {
|
|||
* You don't need these unless your implementing an I/O interface module (most users don't) */
|
||||
#define FIO_CHANNEL_REQUEST_ARGS (ftdm_span_t *span, uint32_t chan_id, ftdm_direction_t direction, ftdm_caller_data_t *caller_data, ftdm_channel_t **ftdmchan)
|
||||
#define FIO_CHANNEL_OUTGOING_CALL_ARGS (ftdm_channel_t *ftdmchan)
|
||||
#define FIO_CHANNEL_SEND_MSG_ARGS (ftdm_channel_t *ftdmchan, ftdm_sigmsg_t *sigmsg)
|
||||
#define FIO_CHANNEL_INDICATE_ARGS (ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication)
|
||||
#define FIO_CHANNEL_SET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
|
||||
#define FIO_CHANNEL_GET_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status)
|
||||
#define FIO_SPAN_SET_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status)
|
||||
|
@ -731,7 +745,7 @@ struct ftdm_memory_handler {
|
|||
* You don't need these unless your implementing an I/O interface module (most users don't) */
|
||||
typedef ftdm_status_t (*fio_channel_request_t) FIO_CHANNEL_REQUEST_ARGS ;
|
||||
typedef ftdm_status_t (*fio_channel_outgoing_call_t) FIO_CHANNEL_OUTGOING_CALL_ARGS ;
|
||||
typedef ftdm_status_t (*fio_channel_send_msg_t) FIO_CHANNEL_SEND_MSG_ARGS;
|
||||
typedef ftdm_status_t (*fio_channel_indicate_t) FIO_CHANNEL_INDICATE_ARGS;
|
||||
typedef ftdm_status_t (*fio_channel_set_sig_status_t) FIO_CHANNEL_SET_SIG_STATUS_ARGS;
|
||||
typedef ftdm_status_t (*fio_channel_get_sig_status_t) FIO_CHANNEL_GET_SIG_STATUS_ARGS;
|
||||
typedef ftdm_status_t (*fio_span_set_sig_status_t) FIO_SPAN_SET_SIG_STATUS_ARGS;
|
||||
|
@ -778,7 +792,7 @@ typedef ftdm_status_t (*fio_api_t) FIO_API_ARGS ;
|
|||
* You don't need these unless your implementing an I/O interface module (most users don't) */
|
||||
#define FIO_CHANNEL_REQUEST_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_REQUEST_ARGS
|
||||
#define FIO_CHANNEL_OUTGOING_CALL_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_OUTGOING_CALL_ARGS
|
||||
#define FIO_CHANNEL_SEND_MSG_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_SEND_MSG_ARGS
|
||||
#define FIO_CHANNEL_INDICATE_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_INDICATE_ARGS
|
||||
#define FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_SET_SIG_STATUS_ARGS
|
||||
#define FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_CHANNEL_GET_SIG_STATUS_ARGS
|
||||
#define FIO_SPAN_SET_SIG_STATUS_FUNCTION(name) ftdm_status_t name FIO_SPAN_SET_SIG_STATUS_ARGS
|
||||
|
@ -847,6 +861,16 @@ typedef enum {
|
|||
FTDM_ALARM_GENERAL = (1 << 30)
|
||||
} ftdm_alarm_flag_t;
|
||||
|
||||
/*! \brief MF generation direction flags
|
||||
* \note Used in bitwise OR with channel ID as argument to MF_PLAYBACK I/O command, so value must be higher that 255
|
||||
* \see FTDM_COMMAND_START_MF_PLAYBACK
|
||||
* */
|
||||
|
||||
typedef enum {
|
||||
FTDM_MF_DIRECTION_FORWARD = (1 << 8),
|
||||
FTDM_MF_DIRECTION_BACKWARD = (1 << 9)
|
||||
} ftdm_mf_direction_flag_t;
|
||||
|
||||
/*! \brief Override the default queue handler */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_global_set_queue_handler(ftdm_queue_handler_t *handler);
|
||||
|
||||
|
@ -866,23 +890,26 @@ FT_DECLARE(int) ftdm_channel_get_availability(ftdm_channel_t *ftdmchan);
|
|||
* there is no guarantee of whether the event will arrive after or before your execution thread returns
|
||||
* from ftdm_channel_call_answer
|
||||
*/
|
||||
#define ftdm_channel_call_answer(ftdmchan) _ftdm_channel_call_answer(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
|
||||
#define ftdm_channel_call_answer(ftdmchan) _ftdm_channel_call_answer(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), NULL)
|
||||
#define ftdm_channel_call_answer_ex(ftdmchan, usrmsg) _ftdm_channel_call_answer(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (usrmsg))
|
||||
|
||||
/*! \brief Answer call recording the source code point where the it was called (see ftdm_channel_call_answer for an easy to use macro) */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Place an outgoing call in the given channel
|
||||
* \deprecated This macro is deprecated since leaves the door open to glare issues, use ftdm_call_place instead
|
||||
*/
|
||||
#define ftdm_channel_call_place(ftdmchan) _ftdm_channel_call_place(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
|
||||
#define ftdm_channel_call_place(ftdmchan) _ftdm_channel_call_place(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), NULL)
|
||||
#define ftdm_channel_call_place_ex(ftdmchan, usrmsg) _ftdm_channel_call_place_ex(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (usrmsg))
|
||||
|
||||
/*! \brief Place an outgoing call recording the source code point where it was called (see ftdm_channel_call_place for an easy to use macro)
|
||||
* \deprecated This function is deprecated since leaves the door open to glare issues, use ftdm_call_place instead
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Place an outgoing call with the given caller data in a channel according to the hunting scheme provided */
|
||||
#define ftdm_call_place(callerdata, hunting) _ftdm_call_place(__FILE__, __FUNCTION__, __LINE__, (callerdata), (hunting))
|
||||
#define ftdm_call_place(callerdata, hunting) _ftdm_call_place(__FILE__, __FUNCTION__, __LINE__, (callerdata), (hunting), NULL)
|
||||
#define ftdm_call_place_ex(callerdata, hunting, usrmsg) _ftdm_call_place(__FILE__, __FUNCTION__, __LINE__, (callerdata), (hunting), (usrmsg))
|
||||
|
||||
/*! \brief Place an outgoing call with the given caller data in a channel according to the hunting scheme provided and records
|
||||
* the place where it was called. See ftdm_call_place for an easy to use macro
|
||||
|
@ -899,7 +926,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char
|
|||
* \note When this function is successful you are guaranteed to receive FTDM_SIGEVENT_DIALING, this event could even be delivered
|
||||
* before your execution thread returns from this function
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, int line, ftdm_caller_data_t *caller_data, ftdm_hunting_scheme_t *hunting);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, int line, ftdm_caller_data_t *caller_data, ftdm_hunting_scheme_t *hunting, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Indicate a new condition in an incoming call
|
||||
*
|
||||
|
@ -914,48 +941,48 @@ FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, i
|
|||
* \note You cannot send more than one indication at the time. You must wait for the completed event before
|
||||
* calling this function again (unless the return code was different than FTDM_SUCCESS)
|
||||
*/
|
||||
#define ftdm_channel_call_indicate(ftdmchan, indication) _ftdm_channel_call_indicate(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (indication))
|
||||
#define ftdm_channel_call_indicate(ftdmchan, indication) _ftdm_channel_call_indicate(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (indication), NULL)
|
||||
#define ftdm_channel_call_indicate_ex(ftdmchan, indication, usrmsg) _ftdm_channel_call_indicate(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (indication), (usrmsg))
|
||||
|
||||
/*! \brief Indicate a new condition in an incoming call recording the source code point where it was called (see ftdm_channel_call_indicate for an easy to use macro) */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication);
|
||||
|
||||
/*! \brief Send a message on a call */
|
||||
#define ftdm_channel_call_send_msg(ftdmchan, sigmsg) _ftdm_channel_call_send_msg(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (sigmsg))
|
||||
|
||||
/*! \brief Send a signal on a call recording the source code point where it was called (see ftdm_channel_call_send_msg for an easy to use macro) */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_send_msg(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_sigmsg_t *sigmsg);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Hangup the call without cause */
|
||||
#define ftdm_channel_call_hangup(ftdmchan) _ftdm_channel_call_hangup(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
|
||||
#define ftdm_channel_call_hangup(ftdmchan) _ftdm_channel_call_hangup(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), NULL)
|
||||
#define ftdm_channel_call_hangup_ex(ftdmchan, usrmsg) _ftdm_channel_call_hangup(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (usrmsg))
|
||||
|
||||
/*! \brief Hangup the call without cause recording the source code point where it was called (see ftdm_channel_call_hangup for an easy to use macro)*/
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Hangup the call with cause */
|
||||
#define ftdm_channel_call_hangup_with_cause(ftdmchan, cause) _ftdm_channel_call_hangup_with_cause(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (cause))
|
||||
#define ftdm_channel_call_hangup_with_cause(ftdmchan, cause) _ftdm_channel_call_hangup_with_cause(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (cause), NULL)
|
||||
#define ftdm_channel_call_hangup_with_cause_ex(ftdmchan, cause, usrmsg) _ftdm_channel_call_hangup_with_cause(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (cause), (usrmsg))
|
||||
|
||||
/*! \brief Hangup the call with cause recording the source code point where it was called (see ftdm_channel_call_hangup_with_cause for an easy to use macro) */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_call_cause_t);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_call_cause_t, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Reset the channel */
|
||||
#define ftdm_channel_reset(ftdmchan) _ftdm_channel_reset(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
|
||||
#define ftdm_channel_reset(ftdmchan) _ftdm_channel_reset(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), NULL)
|
||||
#define ftdm_channel_reset_ex(ftdmchan, usrmsg) _ftdm_channel_reset(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), usrmsg)
|
||||
|
||||
/*! \brief Reset the channel (see _ftdm_channel_reset for an easy to use macro)
|
||||
* \note if there was a call on this channel, call will be cleared without any notifications to the user
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_reset(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_reset(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Put a call on hold (if supported by the signaling stack) */
|
||||
#define ftdm_channel_call_hold(ftdmchan) _ftdm_channel_call_hold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
|
||||
#define ftdm_channel_call_hold(ftdmchan) _ftdm_channel_call_hold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), NULL)
|
||||
#define ftdm_channel_call_hold_ex(ftdmchan, usrmsg) _ftdm_channel_call_hold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (usrmsg))
|
||||
|
||||
/*! \brief Put a call on hold recording the source code point where it was called (see ftdm_channel_call_hold for an easy to use macro) */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Unhold a call */
|
||||
#define ftdm_channel_call_unhold(ftdmchan) _ftdm_channel_call_unhold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan))
|
||||
#define ftdm_channel_call_unhold(ftdmchan) _ftdm_channel_call_unhold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), NULL)
|
||||
#define ftdm_channel_call_unhold_ex(ftdmchan, usrmsg) _ftdm_channel_call_unhold(__FILE__, __FUNCTION__, __LINE__, (ftdmchan), (usrmsg))
|
||||
|
||||
/*! \brief Unhold a call recording the source code point where it was called (see ftdm_channel_call_unhold for an easy to use macro) */
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_unhold(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief Check if the call is answered already */
|
||||
FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_answered(const ftdm_channel_t *ftdmchan);
|
||||
|
@ -1369,12 +1396,65 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
|
|||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t datasize, ftdm_size_t *datalen);
|
||||
|
||||
/*! \brief Get a custom variable from the sigmsg
|
||||
* \note The variable pointer returned is only valid while the before the event is processed and it'll be destroyed once the event is processed. */
|
||||
FT_DECLARE(const char *) ftdm_sigmsg_get_var(ftdm_sigmsg_t *sigmsg, const char *var_name);
|
||||
|
||||
/*! \brief Get an iterator to iterate over the sigmsg variables
|
||||
* \param sigmsg The message structure containing the variables
|
||||
* \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator.
|
||||
* \note The iterator pointer returned is only valid while the channel is open and it'll be destroyed when the channel is closed.
|
||||
* This iterator is completely non-thread safe, if you are adding variables or removing variables while iterating
|
||||
* results are unpredictable
|
||||
*/
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_sigmsg_get_var_iterator(const ftdm_sigmsg_t *sigmsg, ftdm_iterator_t *iter);
|
||||
|
||||
/*! \brief Get raw data from sigmsg
|
||||
* \param sigmsg The message structure containing the variables
|
||||
* \param data data will point to available data pointer if available
|
||||
* \param datalen datalen will be set to length of data available
|
||||
* \retval FTDM_SUCCESS data is available
|
||||
* \retval FTDM_FAIL no data available
|
||||
* \note data is only valid within the duration of the callback, to receive a data pointer that does not get
|
||||
* \note destroyed when callback returns, see ftdm_sigmsg_get_raw_data_detached
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen);
|
||||
|
||||
/*! \brief Get raw data from event
|
||||
* \param sigmsg The message structure containing the variables
|
||||
* \param data data will point to available data pointer if available
|
||||
* \param datalen datalen will be set to length of data available
|
||||
* \retval FTDM_SUCCESS data is available
|
||||
* \retval FTDM_FAIL no data available
|
||||
* \note Once this function returns, User owns data, and is responsible to free data using ftdm_safe_free();
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_get_raw_data_detached(ftdm_sigmsg_t *sigmsg, void **data, ftdm_size_t *datalen);
|
||||
|
||||
/*! \brief Add a custom variable to the user message
|
||||
* \note This variables may be used by signaling modules to override signaling parameters
|
||||
* \todo Document which signaling variables are available
|
||||
* */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_add_var(ftdm_usrmsg_t *usrmsg, const char *var_name, const char *value);
|
||||
|
||||
/*! \brief Attach raw data to usrmsg
|
||||
* \param usrmsg The message structure containing the variables
|
||||
* \param data pointer to data
|
||||
* \param datalen datalen length of data
|
||||
* \retval FTDM_SUCCESS success, data was successfully saved
|
||||
* \retval FTDM_FAIL failed, event already had data attached to it.
|
||||
* \note data must have been allocated using ftdm_calloc, FreeTDM will free data once the usrmsg is processed.
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_set_raw_data(ftdm_usrmsg_t *usrmsg, void *data, ftdm_size_t datalen);
|
||||
|
||||
/*! \brief Get iterator current value (depends on the iterator type)
|
||||
* \note Channel iterators return a pointer to ftdm_channel_t
|
||||
* Variable iterators return a pointer to the variable name (not the variable value)
|
||||
*/
|
||||
FT_DECLARE(void *) ftdm_iterator_current(ftdm_iterator_t *iter);
|
||||
|
||||
/*! \brief Get variable name and value for the current iterator position */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_get_current_var(ftdm_iterator_t *iter, const char **var_name, const char **var_val);
|
||||
|
||||
/*! \brief Advance iterator */
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter);
|
||||
|
||||
|
@ -1383,28 +1463,11 @@ FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter);
|
|||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_iterator_free(ftdm_iterator_t *iter);
|
||||
|
||||
/*! \brief Add a custom variable to the call
|
||||
* \note This variables may be used by signaling modules to override signaling parameters
|
||||
* \todo Document which signaling variables are available
|
||||
/*! \brief Clears all the temporary data attached to this call
|
||||
* \note Clears caller_data->variables and caller_data->raw_data.
|
||||
* */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_call_add_var(ftdm_caller_data_t *caller_data, const char *var_name, const char *value);
|
||||
|
||||
/*! \brief Get a custom variable from the call.
|
||||
* \note The variable pointer returned is only valid during the callback receiving SIGEVENT. */
|
||||
FT_DECLARE(const char *) ftdm_call_get_var(ftdm_caller_data_t *caller_data, const char *var_name);
|
||||
|
||||
/*! \brief Get an iterator to iterate over the channel variables
|
||||
* \param caller_data The signal msg structure containing the variables
|
||||
* \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator.
|
||||
* \note The iterator pointer returned is only valid while the signal message and it'll be destroyed when the signal message is processed.
|
||||
* This iterator is completely non-thread safe, if you are adding variables or removing variables while iterating
|
||||
* results are unpredictable
|
||||
*/
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_call_get_var_iterator(const ftdm_caller_data_t *caller_data, ftdm_iterator_t *iter);
|
||||
|
||||
/*! \brief Get variable name and value for the current iterator position */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_call_get_current_var(ftdm_iterator_t *iter, const char **var_name, const char **var_val);
|
||||
|
||||
FT_DECLARE(void) ftdm_call_clear_data(ftdm_caller_data_t *caller_data);
|
||||
|
||||
/*! \brief Get the span pointer associated to the channel */
|
||||
FT_DECLARE(ftdm_span_t *) ftdm_channel_get_span(const ftdm_channel_t *ftdmchan);
|
||||
|
||||
|
@ -1632,11 +1695,6 @@ FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *c
|
|||
*/
|
||||
FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *channel);
|
||||
|
||||
/*! \brief Initialize channel state for an outgoing call
|
||||
* \deprecated This API is only used for boost signaling
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_init(ftdm_channel_t *ftdmchan);
|
||||
|
||||
/*! \brief Enable/disable blocking mode in the channels for this span */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_span_set_blocking_mode(const ftdm_span_t *span, ftdm_bool_t enabled);
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ typedef struct ftdm_conf_node ftdm_conf_node_t;
|
|||
typedef struct ftdm_group ftdm_group_t;
|
||||
typedef size_t ftdm_size_t;
|
||||
typedef struct ftdm_sigmsg ftdm_sigmsg_t;
|
||||
typedef struct ftdm_usrmsg ftdm_usrmsg_t;
|
||||
typedef struct ftdm_io_interface ftdm_io_interface_t;
|
||||
typedef struct ftdm_stream_handle ftdm_stream_handle_t;
|
||||
typedef struct ftdm_queue ftdm_queue_t;
|
||||
|
|
|
@ -49,6 +49,6 @@ FT_DECLARE(char *) ftdm_build_dso_path(const char *name, char *path, ftdm_size_t
|
|||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
||||
|
||||
|
|
|
@ -467,6 +467,7 @@ struct ftdm_channel {
|
|||
ftdm_interrupt_t *state_completed_interrupt; /*!< Notify when a state change is completed */
|
||||
int32_t txdrops;
|
||||
int32_t rxdrops;
|
||||
ftdm_usrmsg_t *usrmsg;
|
||||
};
|
||||
|
||||
struct ftdm_span {
|
||||
|
@ -492,7 +493,7 @@ struct ftdm_span {
|
|||
teletone_multi_tone_t tone_finder[FTDM_TONEMAP_INVALID+1];
|
||||
ftdm_channel_t *channels[FTDM_MAX_CHANNELS_SPAN+1];
|
||||
fio_channel_outgoing_call_t outgoing_call;
|
||||
fio_channel_send_msg_t send_msg;
|
||||
fio_channel_indicate_t indicate;
|
||||
fio_channel_set_sig_status_t set_channel_sig_status;
|
||||
fio_channel_get_sig_status_t get_channel_sig_status;
|
||||
fio_span_set_sig_status_t set_span_sig_status;
|
||||
|
@ -587,6 +588,10 @@ FT_DECLARE(ftdm_status_t) ftdm_span_close_all(void);
|
|||
FT_DECLARE(ftdm_status_t) ftdm_channel_open_chan(ftdm_channel_t *ftdmchan);
|
||||
FT_DECLARE(void) ftdm_ack_indication(ftdm_channel_t *ftdmchan, ftdm_channel_indication_t indication, ftdm_status_t status);
|
||||
|
||||
|
||||
FT_DECLARE(ftdm_iterator_t *) ftdm_get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Retrieves an event from the span
|
||||
*
|
||||
|
@ -624,27 +629,55 @@ FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span);
|
|||
/*! \brief clear the tone detector state */
|
||||
FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan);
|
||||
|
||||
/* start/stop echo cancelling at the beginning/end of a call */
|
||||
/*! \brief adjust echocanceller for beginning of call */
|
||||
FT_DECLARE(void) ftdm_set_echocancel_call_begin(ftdm_channel_t *chan);
|
||||
|
||||
/*! \brief adjust echocanceller for end of call */
|
||||
FT_DECLARE(void) ftdm_set_echocancel_call_end(ftdm_channel_t *chan);
|
||||
|
||||
/*! \brief Clear all variables attached to the call
|
||||
* \note Variables are cleared at the end of each call back, so it is not necessary for the user to call this function.
|
||||
/*! \brief save data from user */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_save_usrmsg(ftdm_channel_t *ftdmchan, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*! \brief free usrmsg and variables/raw data attached to it */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_free(ftdm_usrmsg_t **usrmsg);
|
||||
|
||||
/*! \brief Get a custom variable from the user message
|
||||
* \note The variable pointer returned is only valid while the before the event is processed and it'll be destroyed once the event is processed. */
|
||||
FT_DECLARE(const char *) ftdm_usrmsg_get_var(ftdm_usrmsg_t *usrmsg, const char *var_name);
|
||||
|
||||
/*! \brief Get raw data from user message
|
||||
* \param usrmsg The message structure containing the variables
|
||||
* \param data data will point to available data pointer if available
|
||||
* \param datalen datalen will be set to length of data available
|
||||
* \retval FTDM_SUCCESS data is available
|
||||
* \retval FTDM_FAIL no data available
|
||||
* \note data is only valid within the duration of the callback, to receive a data pointer that does not get
|
||||
* \note destroyed when callback returns, see ftdm_sigmsg_get_raw_data_detached
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_usrmsg_get_raw_data(ftdm_usrmsg_t *usrmsg, void **data, ftdm_size_t *datalen);
|
||||
|
||||
/*! \brief free sigmsg and variables/raw data attached to it */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_free(ftdm_sigmsg_t **sigmsg);
|
||||
|
||||
/*! \brief Add a custom variable to the event
|
||||
* \note This variables may be used by signaling modules to override signaling parameters
|
||||
* \todo Document which signaling variables are available
|
||||
* */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_call_clear_vars(ftdm_caller_data_t *caller_data);
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_add_var(ftdm_sigmsg_t *sigmsg, const char *var_name, const char *value);
|
||||
|
||||
/*! \brief Remove a variable attached to the call
|
||||
* \note Removes a variable that was attached to the call.
|
||||
* \todo Document which call variables are available
|
||||
* */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_call_remove_var(ftdm_caller_data_t *caller_data, const char *var_name);
|
||||
/*! \brief Remove a custom variable from the event
|
||||
* \note The variable pointer returned is only valid while the before the event is processed and it'll be destroyed once the event is processed. */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_remove_var(ftdm_sigmsg_t *sigmsg, const char *var_name);
|
||||
|
||||
/*! \brief Clears all the temporary data attached to this call
|
||||
* \note Clears caller_data->variables and caller_data->raw_data.
|
||||
* */
|
||||
FT_DECLARE(void) ftdm_call_clear_data(ftdm_caller_data_t *caller_data);
|
||||
|
||||
/*! \brief Attach raw data to sigmsg
|
||||
* \param sigmsg The message structure containing the variables
|
||||
* \param data pointer to data
|
||||
* \param datalen datalen length of data
|
||||
* \retval FTDM_SUCCESS success, data was successfully saved
|
||||
* \retval FTDM_FAIL failed, event already had data attached to it.
|
||||
* \note data must have been allocated using ftdm_calloc, FreeTDM will free data once the usrmsg is processed.
|
||||
*/
|
||||
FT_DECLARE(ftdm_status_t) ftdm_sigmsg_set_raw_data(ftdm_sigmsg_t *sigmsg, void *data, ftdm_size_t datalen);
|
||||
|
||||
/*!
|
||||
\brief Assert condition
|
||||
|
|
|
@ -188,7 +188,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_cancel_state(const char *file, const char
|
|||
* \note If this function is called with the wait parameter set to a non-zero value, the recursivity
|
||||
* of the channel lock must be == 1 because the channel will be unlocked/locked when waiting */
|
||||
FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *func, int line,
|
||||
ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int wait);
|
||||
ftdm_channel_t *ftdmchan, ftdm_channel_state_t state, int wait, ftdm_usrmsg_t *usrmsg);
|
||||
|
||||
/*!\brief Set the state of a channel immediately and implicitly complete the previous state if needed
|
||||
* \note FTDM_SIGEVENT_INDICATION_COMPLETED will be sent if the state change
|
||||
|
@ -207,7 +207,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_set_state(const char *file, const char *func, in
|
|||
#define ftdm_set_state_locked(obj, s) \
|
||||
do { \
|
||||
ftdm_channel_lock(obj); \
|
||||
ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s, 0); \
|
||||
ftdm_channel_set_state(__FILE__, __FUNCTION__, __LINE__, obj, s, 0, NULL); \
|
||||
ftdm_channel_unlock(obj); \
|
||||
} while(0);
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ typedef enum {
|
|||
FTDM_CHANNEL_FEATURE_HWEC = (1<<7), /*!< Channel has a hardware echo canceller */
|
||||
FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE = (1<<8), /*!< hardware echo canceller is disabled when there are no calls on this channel */
|
||||
FTDM_CHANNEL_FEATURE_IO_STATS = (1<<9), /*!< Channel supports IO statistics (HDLC channels only) */
|
||||
FTDM_CHANNEL_FEATURE_MF_GENERATE = (1<<10), /*!< Channel can generate R2 MF tones (read-only) */
|
||||
} ftdm_channel_feature_t;
|
||||
|
||||
/*!< Channel flags. This used to be an enum but we reached the 32bit limit for enums, is safer this way */
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
#include "freetdm.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static FIO_SIGNAL_CB_FUNCTION(on_signal)
|
||||
{
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
static int R = 0;
|
||||
#if 0
|
||||
static void handle_SIGINT(int sig)
|
||||
{
|
||||
if (sig);
|
||||
R = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ftdm_conf_parameter_t parameters[20];
|
||||
ftdm_span_t *span;
|
||||
int local_port, remote_port;
|
||||
|
||||
local_port = remote_port = 53000;
|
||||
|
||||
ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG);
|
||||
#if 0
|
||||
if (argc < 2) {
|
||||
printf("invalid arguments\n");
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ftdm_global_init() != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error loading FreeTDM\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (ftdm_global_configuration() != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error configuring FreeTDM\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("FreeTDM loaded\n");
|
||||
|
||||
if (ftdm_span_find_by_name("wp1", &span) != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error finding FreeTDM span %s\n", argv[1]);
|
||||
goto done;
|
||||
}
|
||||
parameters[0].var = "sigmod";
|
||||
parameters[0].val = "sangoma_prid";
|
||||
parameters[1].var = "switchtype";
|
||||
parameters[1].val = "euroisdn";
|
||||
parameters[1].var = "signalling";
|
||||
parameters[1].val = "pri_cpe";
|
||||
parameters[2].var = NULL;
|
||||
if (ftdm_configure_span_signaling(span, "sangoma_boost", on_signal, parameters) == FTDM_SUCCESS) {
|
||||
ftdm_span_start(span);
|
||||
} else {
|
||||
fprintf(stderr, "Error starting SS7_BOOST\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
while(ftdm_running() && R) {
|
||||
ftdm_sleep(1 * 1000);
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
ftdm_global_destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
|
@ -1,472 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Sangoma Technologies
|
||||
* Moises Silva <moy@sangoma.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of the original author; nor the names of any contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sample program for the boost signaling absraction.
|
||||
* Usage: boostsample <span name>
|
||||
* The span name must be a valid span defined in freetdm.conf
|
||||
* compile this program linking to the freetdm library (ie -lfreetdm)
|
||||
**/
|
||||
|
||||
#ifndef __linux__
|
||||
#define _CRT_SECURE_NO_WARNINGS 1
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "freetdm.h"
|
||||
|
||||
|
||||
/* arbitrary limit for max calls in this sample program */
|
||||
#define MAX_CALLS 255
|
||||
|
||||
/* some timers (in seconds) to fake responses in incoming calls */
|
||||
#define PROGRESS_TIMER 1
|
||||
#define ANSWER_TIMER 5
|
||||
#define HANGUP_TIMER 15
|
||||
|
||||
/* simple variable used to stop the application */
|
||||
static int app_running = 0;
|
||||
|
||||
typedef void (*expired_function_t)(ftdm_channel_t *channel);
|
||||
typedef struct dummy_timer_s {
|
||||
int time;
|
||||
ftdm_channel_t *channel;
|
||||
expired_function_t expired;
|
||||
} dummy_timer_t;
|
||||
|
||||
/* dummy second resolution timers */
|
||||
static dummy_timer_t g_timers[MAX_CALLS];
|
||||
|
||||
/* mutex to protect the timers (both, the test thread and the signaling thread may modify them) */
|
||||
static ftdm_mutex_t *g_schedule_mutex;
|
||||
|
||||
/* mutex to protect the channel */
|
||||
static ftdm_mutex_t *g_channel_mutex;
|
||||
|
||||
/* unique outgoing channel */
|
||||
static ftdm_channel_t *g_outgoing_channel = NULL;
|
||||
|
||||
static void interrupt_requested(int signal)
|
||||
{
|
||||
app_running = 0;
|
||||
}
|
||||
|
||||
static void schedule_timer(ftdm_channel_t *channel, int sec, expired_function_t expired)
|
||||
{
|
||||
int i;
|
||||
ftdm_mutex_lock(g_schedule_mutex);
|
||||
for (i = 0; i < sizeof(g_timers)/sizeof(g_timers[0]); i++) {
|
||||
/* check the timer slot is free to use */
|
||||
if (!g_timers[i].time) {
|
||||
g_timers[i].time = sec;
|
||||
g_timers[i].channel = channel;
|
||||
g_timers[i].expired = expired;
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to schedule timer\n");
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
}
|
||||
|
||||
static void run_timers(void)
|
||||
{
|
||||
int i;
|
||||
void *channel;
|
||||
expired_function_t expired_func = NULL;
|
||||
ftdm_mutex_lock(g_schedule_mutex);
|
||||
for (i = 0; i < sizeof(g_timers)/sizeof(g_timers[0]); i++) {
|
||||
/* if there's time left, decrement */
|
||||
if (g_timers[i].time) {
|
||||
g_timers[i].time--;
|
||||
}
|
||||
|
||||
/* if time expired and we have an expired function, call it */
|
||||
if (!g_timers[i].time && g_timers[i].expired) {
|
||||
expired_func = g_timers[i].expired;
|
||||
channel = g_timers[i].channel;
|
||||
memset(&g_timers[i], 0, sizeof(g_timers[i]));
|
||||
expired_func(channel);
|
||||
}
|
||||
}
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
}
|
||||
|
||||
static void release_timers(ftdm_channel_t *channel)
|
||||
{
|
||||
int i;
|
||||
ftdm_mutex_lock(g_schedule_mutex);
|
||||
for (i = 0; i < sizeof(g_timers)/sizeof(g_timers[0]); i++) {
|
||||
/* clear any timer belonging to the given channel */
|
||||
if (g_timers[i].channel == channel) {
|
||||
memset(&g_timers[i], 0, sizeof(g_timers[i]));
|
||||
}
|
||||
}
|
||||
ftdm_mutex_unlock(g_schedule_mutex);
|
||||
}
|
||||
|
||||
/* hangup the call */
|
||||
static void send_hangup(ftdm_channel_t *channel)
|
||||
{
|
||||
char dtmfbuff[100];
|
||||
int rc;
|
||||
int spanid = ftdm_channel_get_span_id(channel);
|
||||
int chanid = ftdm_channel_get_id(channel);
|
||||
rc = ftdm_channel_dequeue_dtmf(channel, dtmfbuff, sizeof(dtmfbuff));
|
||||
if (rc) {
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Not hanging up channel %d:%d because has DTMF: %s\n", spanid, chanid, dtmfbuff);
|
||||
schedule_timer(channel, HANGUP_TIMER, send_hangup);
|
||||
return;
|
||||
}
|
||||
ftdm_log(FTDM_LOG_NOTICE, "-- Requesting hangup in channel %d:%d\n", spanid, chanid);
|
||||
ftdm_channel_call_hangup(channel);
|
||||
}
|
||||
|
||||
/* send answer for an incoming call */
|
||||
static void send_answer(ftdm_channel_t *channel)
|
||||
{
|
||||
/* we move the channel signaling state machine to UP (answered) */
|
||||
int spanid = ftdm_channel_get_span_id(channel);
|
||||
int chanid = ftdm_channel_get_id(channel);
|
||||
ftdm_log(FTDM_LOG_NOTICE, "-- Requesting answer in channel %d:%d\n", spanid, chanid);
|
||||
ftdm_channel_call_answer(channel);
|
||||
schedule_timer(channel, HANGUP_TIMER, send_hangup);
|
||||
}
|
||||
|
||||
/* send progress for an incoming */
|
||||
static void send_progress(ftdm_channel_t *channel)
|
||||
{
|
||||
/* we move the channel signaling state machine to UP (answered) */
|
||||
int spanid = ftdm_channel_get_span_id(channel);
|
||||
int chanid = ftdm_channel_get_id(channel);
|
||||
ftdm_log(FTDM_LOG_NOTICE, "-- Requesting progress\n", spanid, chanid);
|
||||
ftdm_channel_call_indicate(channel, FTDM_CHANNEL_INDICATE_PROGRESS);
|
||||
schedule_timer(channel, ANSWER_TIMER, send_answer);
|
||||
}
|
||||
|
||||
/* This function will be called in an undetermined signaling thread, you must not do
|
||||
* any blocking operations here or the signaling stack may delay other call event processing
|
||||
* The arguments for this function are defined in FIO_SIGNAL_CB_FUNCTION prototype, I just
|
||||
* name them here for your convenience:
|
||||
* ftdm_sigmsg_t *sigmsg
|
||||
* - The sigmsg structure contains the ftdm_channel structure that represents the channel where
|
||||
* the event occurred and the event_id of the signaling event that just occurred.
|
||||
* */
|
||||
static FIO_SIGNAL_CB_FUNCTION(on_signaling_event)
|
||||
{
|
||||
switch (sigmsg->event_id) {
|
||||
/* This event signals the start of an incoming call */
|
||||
case FTDM_SIGEVENT_START:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Incoming call received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
schedule_timer(sigmsg->channel, PROGRESS_TIMER, send_progress);
|
||||
break;
|
||||
/* This event signals progress on an outgoing call */
|
||||
case FTDM_SIGEVENT_PROGRESS_MEDIA:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Progress message received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
break;
|
||||
/* This event signals answer in an outgoing call */
|
||||
case FTDM_SIGEVENT_UP:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Answer received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
ftdm_channel_command(sigmsg->channel, FTDM_COMMAND_ENABLE_DTMF_DETECT, NULL);
|
||||
/* now the channel is answered and we can use
|
||||
* ftdm_channel_wait() to wait for input/output in a channel (equivalent to poll() or select())
|
||||
* ftdm_channel_read() to read available data in a channel
|
||||
* ftdm_channel_write() to write to the channel */
|
||||
break;
|
||||
/* This event signals hangup from the other end */
|
||||
case FTDM_SIGEVENT_STOP:
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Hangup received in channel %d:%d\n", sigmsg->span_id, sigmsg->chan_id);
|
||||
ftdm_mutex_lock(g_channel_mutex);
|
||||
if (g_outgoing_channel == sigmsg->channel) {
|
||||
g_outgoing_channel = NULL;
|
||||
}
|
||||
ftdm_mutex_unlock(g_channel_mutex);
|
||||
/* release any timer for this channel */
|
||||
release_timers(sigmsg->channel);
|
||||
/* acknowledge the hangup */
|
||||
ftdm_channel_call_hangup(sigmsg->channel);
|
||||
break;
|
||||
default:
|
||||
ftdm_log(FTDM_LOG_WARNING, "Unhandled event %s in channel %d:%d\n", ftdm_signal_event2str(sigmsg->event_id),
|
||||
sigmsg->span_id, sigmsg->chan_id);
|
||||
break;
|
||||
}
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
static void place_call(const ftdm_span_t *span, const char *number)
|
||||
{
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
ftdm_caller_data_t caller_data = {{ 0 }};
|
||||
ftdm_status_t status = FTDM_FAIL;
|
||||
|
||||
/* set destiny number */
|
||||
ftdm_set_string(caller_data.dnis.digits, number);
|
||||
|
||||
/* set callerid */
|
||||
ftdm_set_string(caller_data.cid_name, "testsangomaboost");
|
||||
ftdm_set_string(caller_data.cid_num.digits, "1234");
|
||||
|
||||
/* request to search for an outgoing channel top down with the given caller data.
|
||||
* it is also an option to use ftdm_channel_open_by_group to let freetdm hunt
|
||||
* an available channel in a given group instead of per span
|
||||
* */
|
||||
status = ftdm_channel_open_by_span(ftdm_span_get_id(span), FTDM_TOP_DOWN, &caller_data, &ftdmchan);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to originate call\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ftdm_mutex_lock(g_channel_mutex);
|
||||
g_outgoing_channel = ftdmchan;
|
||||
ftdm_mutex_unlock(g_channel_mutex);
|
||||
|
||||
/* set the caller data for the outgoing channel */
|
||||
ftdm_channel_set_caller_data(ftdmchan, &caller_data);
|
||||
|
||||
status = ftdm_channel_call_place(ftdmchan);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Failed to originate call\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* this is required to initialize the outgoing channel */
|
||||
ftdm_channel_init(ftdmchan);
|
||||
}
|
||||
|
||||
static void *media_thread(ftdm_thread_t *th, void *data)
|
||||
{
|
||||
/* The application thread can go on and do anything else, like waiting for a shutdown signal */
|
||||
ftdm_wait_flag_t flags = FTDM_NO_FLAGS;
|
||||
ftdm_status_t status;
|
||||
ftdm_channel_t *chan;
|
||||
char iobuff[160];
|
||||
char dnis_str[] = "1234";
|
||||
int tx_dtmf = 0;
|
||||
ftdm_size_t datalen = 0;
|
||||
memset(iobuff, 0, sizeof(iobuff));
|
||||
while(ftdm_running() && app_running) {
|
||||
ftdm_mutex_lock(g_channel_mutex);
|
||||
chan = g_outgoing_channel;
|
||||
ftdm_mutex_unlock(g_channel_mutex);
|
||||
if (chan && tx_dtmf) {
|
||||
flags = FTDM_WRITE | FTDM_READ;
|
||||
ftdm_channel_wait(chan, &flags, 100);
|
||||
if (flags & FTDM_WRITE) {
|
||||
datalen = sizeof(iobuff);
|
||||
status = ftdm_channel_write(chan, iobuff, datalen, &datalen);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "writing to channel failed\n");
|
||||
}
|
||||
}
|
||||
if (flags & FTDM_READ) {
|
||||
datalen = sizeof(iobuff);
|
||||
status = ftdm_channel_read(chan, iobuff, &datalen);
|
||||
if (status != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "reading from channel failed\n");
|
||||
}
|
||||
}
|
||||
} else if (chan && ftdm_channel_call_check_answered(chan)) {
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Transmitting DNIS %s\n", dnis_str);
|
||||
ftdm_channel_command(g_outgoing_channel, FTDM_COMMAND_SEND_DTMF, dnis_str);
|
||||
tx_dtmf = 1;
|
||||
} else {
|
||||
tx_dtmf = 0;
|
||||
ftdm_sleep(100);
|
||||
}
|
||||
}
|
||||
printf("Shutting down media thread ...\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ftdm_conf_parameter_t parameters[20];
|
||||
ftdm_span_t *span;
|
||||
char *todial = NULL;
|
||||
const char *sigtype = NULL;
|
||||
int32_t ticks = 0;
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: %s <span name> <cpe|net> [number to dial if any]\n", argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* register a handler to shutdown things properly */
|
||||
#ifdef _WIN64
|
||||
// still trying to figure this one out otherwise triggers error
|
||||
if (signal(SIGINT, interrupt_requested) < 0) {
|
||||
#else
|
||||
if (signal(SIGINT, interrupt_requested) == SIG_ERR) {
|
||||
#endif
|
||||
fprintf(stderr, "Could not set the SIGINT signal handler: %s\n", strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!strcmp(argv[2], "cpe")) {
|
||||
sigtype = "pri_cpe";
|
||||
} else if (!strcmp(argv[2], "net")) {
|
||||
sigtype = "pri_net";
|
||||
} else {
|
||||
fprintf(stderr, "Valid signaling types are cpe and net only\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf("Using signalling %s\n", sigtype);
|
||||
|
||||
if (argc >= 4) {
|
||||
todial = argv[3];
|
||||
if (!strlen(todial)) {
|
||||
todial = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* clear any outstanding timers */
|
||||
memset(&g_timers, 0, sizeof(g_timers));
|
||||
|
||||
/* set the logging level to use */
|
||||
ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG);
|
||||
|
||||
/* Initialize the FTDM library */
|
||||
if (ftdm_global_init() != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error loading FreeTDM\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* create the schedule and channel mutex */
|
||||
ftdm_mutex_create(&g_schedule_mutex);
|
||||
ftdm_mutex_create(&g_channel_mutex);
|
||||
|
||||
/* Load the FreeTDM configuration */
|
||||
if (ftdm_global_configuration() != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error configuring FreeTDM\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* At this point FreeTDM is ready to be used, the spans defined in freetdm.conf have the basic I/O board configuration
|
||||
* but no telephony signaling configuration at all. */
|
||||
printf("FreeTDM loaded ...\n");
|
||||
|
||||
/* Retrieve a span by name (according to freetdm.conf) */
|
||||
if (ftdm_span_find_by_name(argv[1], &span) != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error finding FreeTDM span %s\n", argv[1]);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* prepare the configuration parameters that will be sent down to the signaling stack, the array of paramters must be terminated by an
|
||||
* array element with a null .var member */
|
||||
|
||||
/* for sangoma_boost signaling (abstraction signaling used by Sangoma for PRI, BRI and SS7) the first parameter you must send
|
||||
* is sigmod, which must be either sangoma_prid, if you have the PRI stack available, or sangoma_brid for the BRI stack */
|
||||
parameters[0].var = "sigmod";
|
||||
parameters[0].val = "sangoma_prid";
|
||||
|
||||
/* following parameters are signaling stack specific, this ones are for PRI */
|
||||
parameters[1].var = "switchtype";
|
||||
parameters[1].val = "national";
|
||||
|
||||
parameters[2].var = "signalling";
|
||||
parameters[2].val = sigtype;
|
||||
|
||||
/*
|
||||
* parameters[3].var = "nfas_primary";
|
||||
* parameters[3].val = "4"; //span number
|
||||
*
|
||||
* parameters[4].var = "nfas_secondary";
|
||||
* parameters[4].val = "2"; //span number
|
||||
*
|
||||
* parameters[5].var = "nfas_group";
|
||||
* parameters[5].val = "1";
|
||||
* */
|
||||
|
||||
/* the last parameter .var member must be NULL! */
|
||||
parameters[3].var = NULL;
|
||||
|
||||
/* send the configuration values down to the stack */
|
||||
if (ftdm_configure_span_signaling(span, "sangoma_boost", on_signaling_event, parameters) != FTDM_SUCCESS) {
|
||||
fprintf(stderr, "Error configuring sangoma_boost signaling abstraction in span %s\n", ftdm_span_get_name(span));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* configuration succeeded, we can proceed now to start the span
|
||||
* This step will launch at least 1 background (may be more, depending on the signaling stack used)
|
||||
* to handle *ALL* signaling events for this span, your on_signaling_event callback will be called always
|
||||
* in one of those infraestructure threads and you MUST NOT block in that handler to avoid delays and errors
|
||||
* in the signaling processing for any call.
|
||||
* */
|
||||
ftdm_span_start(span);
|
||||
|
||||
if (ftdm_thread_create_detached(media_thread, NULL) != FTDM_SUCCESS){
|
||||
fprintf(stderr, "Error launching media thread\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
app_running = 1;
|
||||
|
||||
/* The application thread can go on and do anything else, like waiting for a shutdown signal */
|
||||
while(ftdm_running() && app_running) {
|
||||
ftdm_sleep(1000);
|
||||
run_timers();
|
||||
ticks++;
|
||||
if (!(ticks % 10) && todial && !g_outgoing_channel) {
|
||||
ftdm_log(FTDM_LOG_NOTICE, "Originating call to number %s\n", todial);
|
||||
place_call(span, todial);
|
||||
}
|
||||
}
|
||||
printf("Shutting down FreeTDM ...\n");
|
||||
done:
|
||||
|
||||
ftdm_mutex_destroy(&g_schedule_mutex);
|
||||
ftdm_mutex_destroy(&g_channel_mutex);
|
||||
|
||||
/* whenever you're done, this function will shutdown the signaling threads in any span that was started */
|
||||
ftdm_global_destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
|
@ -102,7 +102,10 @@ struct stfu_instance {
|
|||
|
||||
int32_t ts_offset;
|
||||
int32_t ts_drift;
|
||||
|
||||
int32_t max_drift;
|
||||
uint32_t drift_dropped_packets;
|
||||
uint32_t drift_max_dropped;
|
||||
|
||||
int32_t ts_diff;
|
||||
int32_t last_ts_diff;
|
||||
int32_t same_ts;
|
||||
|
@ -258,7 +261,7 @@ stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen)
|
|||
return s;
|
||||
}
|
||||
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second)
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift_ms)
|
||||
{
|
||||
struct stfu_instance *i;
|
||||
|
||||
|
@ -277,6 +280,12 @@ stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_
|
|||
stfu_n_init_aqueue(&i->b_queue, qlen);
|
||||
stfu_n_init_aqueue(&i->c_queue, qlen);
|
||||
|
||||
i->max_drift = (int32_t)(max_drift_ms * (samples_per_second / 1000) * -1);
|
||||
|
||||
if (max_drift_ms && samples_per_packet) {
|
||||
i->drift_max_dropped = (samples_per_second * 2) / samples_per_packet;
|
||||
}
|
||||
|
||||
i->in_queue = &i->a_queue;
|
||||
i->out_queue = &i->b_queue;
|
||||
i->old_queue = &i->c_queue;
|
||||
|
@ -396,6 +405,9 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
if (i->last_ts_diff == i->ts_diff) {
|
||||
if (++i->same_ts == 5) {
|
||||
i->samples_per_packet = i->ts_diff;
|
||||
if (i->max_drift && i->samples_per_packet) {
|
||||
i->drift_max_dropped = (i->samples_per_second * 2) / i->samples_per_packet;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
i->same_ts = 0;
|
||||
|
@ -409,11 +421,24 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
}
|
||||
}
|
||||
|
||||
if (timer_ts && ts && !i->ts_offset) {
|
||||
i->ts_offset = timer_ts - ts;
|
||||
}
|
||||
if (timer_ts) {
|
||||
if (ts && !i->ts_offset) {
|
||||
i->ts_offset = timer_ts - ts;
|
||||
}
|
||||
|
||||
i->ts_drift = ts + (i->ts_offset - timer_ts);
|
||||
i->ts_drift = ts + (i->ts_offset - timer_ts);
|
||||
|
||||
if (i->max_drift) {
|
||||
if (i->ts_drift < i->max_drift) {
|
||||
if (++i->drift_dropped_packets < i->drift_max_dropped) {
|
||||
stfu_log(STFU_LOG_EMERG, "%s TOO LATE !!! %u \n\n\n", i->name, ts);
|
||||
return STFU_ITS_TOO_LATE;
|
||||
}
|
||||
} else {
|
||||
i->drift_dropped_packets = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i->sync_in) {
|
||||
good_ts = 1;
|
||||
|
@ -493,12 +518,12 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void
|
|||
|
||||
|
||||
if (stfu_log != null_logger && i->debug) {
|
||||
stfu_log(STFU_LOG_EMERG, "I: %s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d %d\n", i->name,
|
||||
stfu_log(STFU_LOG_EMERG, "I: %s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d %d/%d\n", i->name,
|
||||
i->qlen, i->period_packet_in_count, i->period_time, i->consecutive_good_count,
|
||||
i->decrement_time, i->period_clean_count, i->decrement_time, i->consecutive_bad_count,
|
||||
ts, ts / i->samples_per_packet,
|
||||
i->period_missing_count, i->period_need_range_avg,
|
||||
i->last_wr_ts, ts, i->diff, i->diff_total / least1(i->period_packet_in_count), i->ts_drift);
|
||||
i->last_wr_ts, ts, i->diff, i->diff_total / least1(i->period_packet_in_count), i->ts_drift, i->max_drift);
|
||||
}
|
||||
|
||||
if (last || i->in_queue->array_len == i->in_queue->array_size) {
|
||||
|
@ -597,7 +622,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)
|
|||
|
||||
if (!i->ready) {
|
||||
if (stfu_log != null_logger && i->debug) {
|
||||
stfu_log(STFU_LOG_EMERG, "%s XXXSKIP\n", i->name);
|
||||
stfu_log(STFU_LOG_EMERG, "%s JITTERBUFFER NOT READY: IGNORING FRAME\n", i->name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -612,7 +637,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i)
|
|||
}
|
||||
if (i->cur_ts == 0) {
|
||||
if (stfu_log != null_logger && i->debug) {
|
||||
stfu_log(STFU_LOG_EMERG, "%s XXXPUNT\n", i->name);
|
||||
stfu_log(STFU_LOG_EMERG, "%s JITTERBUFFER ERROR: PUNTING\n", i->name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ typedef void (*stfu_n_call_me_t)(stfu_instance_t *i, void *);
|
|||
|
||||
void stfu_n_report(stfu_instance_t *i, stfu_report_t *r);
|
||||
void stfu_n_destroy(stfu_instance_t **i);
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second);
|
||||
stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift_ms);
|
||||
stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen);
|
||||
stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, uint32_t timer_ts, int last);
|
||||
stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i);
|
||||
|
|
|
@ -249,6 +249,8 @@ struct switch_runtime {
|
|||
switch_dbtype_t odbc_dbtype;
|
||||
char hostname[256];
|
||||
int multiple_registrations;
|
||||
uint32_t max_db_handles;
|
||||
uint32_t db_handle_timeout;
|
||||
};
|
||||
|
||||
extern struct switch_runtime runtime;
|
||||
|
|
|
@ -79,6 +79,7 @@ SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_
|
|||
|
||||
#define switch_channel_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE)
|
||||
#define switch_channel_media_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_TRUE)
|
||||
#define switch_channel_media_up(_channel) (switch_channel_test_flag(_channel, CF_ANSWERED) || switch_channel_test_flag(_channel, CF_EARLY_MEDIA))
|
||||
|
||||
#define switch_channel_up(_channel) (switch_channel_get_state(_channel) < CS_HANGUP)
|
||||
#define switch_channel_down(_channel) (switch_channel_get_state(_channel) >= CS_HANGUP)
|
||||
|
|
|
@ -2075,52 +2075,40 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_sessio
|
|||
*/
|
||||
|
||||
#define CACHE_DB_LEN 256
|
||||
typedef enum {
|
||||
CDF_INUSE = (1 << 0),
|
||||
CDF_PRUNE = (1 << 1)
|
||||
} cache_db_flag_t;
|
||||
typedef enum {
|
||||
CDF_INUSE = (1 << 0),
|
||||
CDF_PRUNE = (1 << 1)
|
||||
} cache_db_flag_t;
|
||||
|
||||
typedef enum {
|
||||
SCDB_TYPE_CORE_DB,
|
||||
SCDB_TYPE_ODBC
|
||||
} switch_cache_db_handle_type_t;
|
||||
typedef enum {
|
||||
SCDB_TYPE_CORE_DB,
|
||||
SCDB_TYPE_ODBC
|
||||
} switch_cache_db_handle_type_t;
|
||||
|
||||
typedef union {
|
||||
switch_core_db_t *core_db_dbh;
|
||||
switch_odbc_handle_t *odbc_dbh;
|
||||
} switch_cache_db_native_handle_t;
|
||||
typedef union {
|
||||
switch_core_db_t *core_db_dbh;
|
||||
switch_odbc_handle_t *odbc_dbh;
|
||||
} switch_cache_db_native_handle_t;
|
||||
|
||||
typedef struct {
|
||||
char *db_path;
|
||||
} switch_cache_db_core_db_options_t;
|
||||
typedef struct {
|
||||
char *db_path;
|
||||
} switch_cache_db_core_db_options_t;
|
||||
|
||||
typedef struct {
|
||||
char *dsn;
|
||||
char *user;
|
||||
char *pass;
|
||||
} switch_cache_db_odbc_options_t;
|
||||
typedef struct {
|
||||
char *dsn;
|
||||
char *user;
|
||||
char *pass;
|
||||
} switch_cache_db_odbc_options_t;
|
||||
|
||||
typedef union {
|
||||
switch_cache_db_core_db_options_t core_db_options;
|
||||
switch_cache_db_odbc_options_t odbc_options;
|
||||
} switch_cache_db_connection_options_t;
|
||||
typedef union {
|
||||
switch_cache_db_core_db_options_t core_db_options;
|
||||
switch_cache_db_odbc_options_t odbc_options;
|
||||
} switch_cache_db_connection_options_t;
|
||||
|
||||
typedef struct {
|
||||
char name[CACHE_DB_LEN];
|
||||
switch_cache_db_handle_type_t type;
|
||||
switch_cache_db_native_handle_t native_handle;
|
||||
time_t last_used;
|
||||
switch_mutex_t *mutex;
|
||||
switch_mutex_t *io_mutex;
|
||||
switch_memory_pool_t *pool;
|
||||
int32_t flags;
|
||||
unsigned long hash;
|
||||
char creator[CACHE_DB_LEN];
|
||||
char last_user[CACHE_DB_LEN];
|
||||
} switch_cache_db_handle_t;
|
||||
struct switch_cache_db_handle;
|
||||
typedef struct switch_cache_db_handle switch_cache_db_handle_t;
|
||||
|
||||
|
||||
static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type)
|
||||
static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type)
|
||||
{
|
||||
const char *type_str = "INVALID";
|
||||
|
||||
|
@ -2140,6 +2128,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_sessio
|
|||
return type_str;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_cache_db_handle_type_t) switch_cache_db_get_type(switch_cache_db_handle_t *dbh);
|
||||
|
||||
/*!
|
||||
\brief Returns the handle to the pool, immediately available for other
|
||||
threads to use.
|
||||
|
@ -2152,11 +2142,6 @@ SWITCH_DECLARE(void) switch_cache_db_dismiss_db_handle(switch_cache_db_handle_t
|
|||
\param [in] The handle
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t ** dbh);
|
||||
/*!
|
||||
\brief Removes the handle from the pool and frees up the handle resources.
|
||||
\param [in] The handle
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t ** dbh);
|
||||
/*!
|
||||
\brief Gets a new cached handle from the pool, potentially creating a new connection.
|
||||
The connection is bound to the thread until it (the thread) terminates unless
|
||||
|
@ -2217,19 +2202,40 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand
|
|||
const char *test_sql, const char *drop_sql, const char *reactive_sql);
|
||||
SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries);
|
||||
SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries);
|
||||
/*!
|
||||
\brief Tries to detach all free connections from current thread.
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_cache_db_detach(void);
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
|
||||
SWITCH_DECLARE(void) switch_cache_db_flush_handles(void);
|
||||
SWITCH_DECLARE(const char *) switch_core_banner(void);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session);
|
||||
SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number);
|
||||
|
||||
/*!
|
||||
\brief Add user registration
|
||||
\param [in] user
|
||||
\param [in] realm
|
||||
\param [in] token
|
||||
\param [in] url - a freeswitch dial string
|
||||
\param [in] expires
|
||||
\param [in] network_ip
|
||||
\param [in] network_port
|
||||
\param [in] network_proto - one of tls, tcp, udp
|
||||
\param [out] err - Error if it exists
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
|
||||
const char *network_ip, const char *network_port, const char *network_proto);
|
||||
/*!
|
||||
\brief Delete user registration
|
||||
\param [in] user
|
||||
\param [in] realm
|
||||
\param [in] token
|
||||
\param [out] err - Error if it exists
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, const char *realm, const char *token);
|
||||
/*!
|
||||
\brief Expire user registrations
|
||||
\param [in] force delete all registrations
|
||||
\param [out] err - Error if it exists
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force);
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
*/
|
||||
#define switch_normalize_volume(x) if (x > 4) x = 4; if (x < -4) x = -4;
|
||||
#define switch_normalize_volume_granular(x) if (x > 12) x = 12; if (x < -12) x = -12;
|
||||
|
||||
#ifndef SWITCH_RESAMPLE_H
|
||||
#define SWITCH_RESAMPLE_H
|
||||
|
@ -158,6 +159,14 @@ SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples
|
|||
\param vol the volume factor -4 -> 4
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol);
|
||||
|
||||
/*!
|
||||
\brief Change the volume of a signed linear audio frame with more granularity
|
||||
\param data the audio data
|
||||
\param samples the number of 2 byte samples
|
||||
\param vol the volume factor -12 -> 12
|
||||
*/
|
||||
SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t samples, int32_t vol);
|
||||
///\}
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples);
|
||||
|
|
|
@ -232,7 +232,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi
|
|||
SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session,
|
||||
uint32_t queue_frames,
|
||||
uint32_t max_queue_frames,
|
||||
uint32_t samples_per_packet, uint32_t samples_per_second);
|
||||
uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift);
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp_session, const char *name);
|
||||
|
||||
|
|
|
@ -1504,6 +1504,8 @@ typedef enum {
|
|||
SWITCH_EVENT_NAT,
|
||||
SWITCH_EVENT_RECORD_START,
|
||||
SWITCH_EVENT_RECORD_STOP,
|
||||
SWITCH_EVENT_PLAYBACK_START,
|
||||
SWITCH_EVENT_PLAYBACK_STOP,
|
||||
SWITCH_EVENT_CALL_UPDATE,
|
||||
SWITCH_EVENT_FAILURE,
|
||||
SWITCH_EVENT_SOCKET_DATA,
|
||||
|
|
|
@ -189,10 +189,12 @@ static inline char switch_itodtmf(char i)
|
|||
char r = i;
|
||||
|
||||
if (i > 9 && i < 14) {
|
||||
r = i + 55;
|
||||
r += 55;
|
||||
} else {
|
||||
r += 48;
|
||||
}
|
||||
|
||||
return r + 48;
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int switch_dtmftoi(char *s)
|
||||
|
|
|
@ -1223,7 +1223,7 @@ static switch_status_t load_agent(const char *agent_name)
|
|||
cc_agent_update("reject_delay_time", reject_delay_time, agent_name);
|
||||
}
|
||||
if (busy_delay_time) {
|
||||
cc_agent_update("busy_delay_time", reject_delay_time, agent_name);
|
||||
cc_agent_update("busy_delay_time", busy_delay_time, agent_name);
|
||||
}
|
||||
|
||||
if (type && res == CC_STATUS_AGENT_ALREADY_EXIST) {
|
||||
|
|
|
@ -90,11 +90,11 @@ static switch_status_t select_url(const char *user,
|
|||
|
||||
if (exclude_contact) {
|
||||
sql = switch_mprintf("select url, '%q' "
|
||||
"from registrations where user='%q' and realm='%q' "
|
||||
"from registrations where reg_user='%q' and realm='%q' "
|
||||
"and url not like '%%%s%%'", (concat != NULL) ? concat : "", user, domain, exclude_contact);
|
||||
} else {
|
||||
sql = switch_mprintf("select url, '%q' "
|
||||
"from registrations where user='%q' and realm='%q'",
|
||||
"from registrations where reg_user='%q' and realm='%q'",
|
||||
(concat != NULL) ? concat : "", user, domain);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2893,7 +2893,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
|||
switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
|
||||
char *user = NULL, *domain = NULL, *dup_domain = NULL;
|
||||
const char *dest = NULL;
|
||||
static switch_call_cause_t cause = SWITCH_CAUSE_NONE;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_NONE;
|
||||
unsigned int timelimit = 60;
|
||||
switch_channel_t *new_channel = NULL;
|
||||
switch_event_t *params = NULL, *var_event_orig = var_event;
|
||||
|
|
|
@ -595,11 +595,12 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||
callback_t *cbt = (callback_t *) pArg;
|
||||
char *key = NULL;
|
||||
int i = 0;
|
||||
int r = 0;
|
||||
|
||||
switch_memory_pool_t *pool = cbt->pool;
|
||||
|
||||
additional = switch_core_alloc(pool, sizeof(lcr_obj_t));
|
||||
additional->fields = switch_core_alloc(pool, sizeof(switch_event_t));
|
||||
switch_event_create(&additional->fields, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
|
||||
for (i = 0; i < argc ; i++) {
|
||||
if (CF("lcr_digits")) {
|
||||
|
@ -652,9 +653,9 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding %s to head of list\n", additional->carrier_name);
|
||||
if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
r = -1; goto end;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
r = 0; goto end;
|
||||
}
|
||||
|
||||
|
||||
|
@ -676,7 +677,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||
additional->prev = current;
|
||||
if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
r = -1; goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -697,7 +698,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||
current->prev = additional;
|
||||
if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
r = -1; goto end;
|
||||
}
|
||||
break;
|
||||
} else if (current->next == NULL) {
|
||||
|
@ -707,13 +708,19 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa
|
|||
additional->prev = current;
|
||||
if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
r = -1; goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
end:
|
||||
|
||||
switch_event_destroy(&additional->fields);
|
||||
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
static int intrastatelata_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
|
|
|
@ -114,7 +114,13 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
|||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_event_t *event;
|
||||
char dtmf_buf[128] = "";
|
||||
int is_auto = 0;
|
||||
int is_auto = 0, play_announce = 1;
|
||||
const char *var;
|
||||
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "valet_announce_slot"))) {
|
||||
play_announce = switch_true(var);
|
||||
}
|
||||
|
||||
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) {
|
||||
|
@ -254,7 +260,9 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
|||
switch_core_session_t *b_session;
|
||||
|
||||
if ((b_session = switch_core_session_locate(uuid))) {
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
if (play_announce) {
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
}
|
||||
switch_ivr_session_transfer(b_session, dest, "inline", NULL);
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
switch_core_session_rwunlock(b_session);
|
||||
|
@ -263,7 +271,9 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
|||
}
|
||||
}
|
||||
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
if (play_announce) {
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue