diff --git a/.gitignore b/.gitignore
index 304b42c1f9..2480b83823 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,12 @@
*.ilk
*.bsc
*.pch
+*.tar
+*.gz
+*.tgz
+*.xz
+*.bz2
+*.tbz2
core.*
/Path
/w32/Library/lastversion
@@ -40,46 +46,47 @@ core.*
!/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
+.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/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
configure.lineno
-/freeswitch
-/fs_cli
-/fs_encode
-/fs_ivrd
-/libtool
-/modules.conf
-/quiet_libtool
-/tone2wav
-/scripts/fsxs
-/scripts/gentls_cert
-/a.out.dSYM
-/freeswitch-sounds-*
+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
@@ -97,6 +104,7 @@ 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
diff --git a/Freeswitch.2010.sln b/Freeswitch.2010.sln
index edee701d51..464cb2e273 100644
--- a/Freeswitch.2010.sln
+++ b/Freeswitch.2010.sln
@@ -1569,18 +1569,18 @@ Global
{0A18A071-125E-442F-AFF7-A3F68ABECF99}.All|x64 Setup.ActiveCfg = Release DirectSound|x64
{0A18A071-125E-442F-AFF7-A3F68ABECF99}.All|x64 Setup.Build.0 = Release DirectSound|x64
{0A18A071-125E-442F-AFF7-A3F68ABECF99}.All|x86 Setup.ActiveCfg = Release DirectSound|x64
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug|Win32
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug|Win32
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.ActiveCfg = Debug|x64
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.Build.0 = Debug|x64
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64 Setup.ActiveCfg = Debug|x64
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x86 Setup.ActiveCfg = Debug|Win32
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.ActiveCfg = Release|x64
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.Build.0 = Release|x64
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64 Setup.ActiveCfg = Release|x64
- {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x86 Setup.ActiveCfg = Release|Win32
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug DirectSound|Win32
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug DirectSound|Win32
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.ActiveCfg = Debug DirectSound|x64
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.Build.0 = Debug DirectSound|x64
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64 Setup.ActiveCfg = Debug DirectSound|x64
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x86 Setup.ActiveCfg = Debug DirectSound|Win32
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release DirectSound|Win32
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release DirectSound|Win32
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.ActiveCfg = Release DirectSound|x64
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.Build.0 = Release DirectSound|x64
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64 Setup.ActiveCfg = Release DirectSound|x64
+ {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x86 Setup.ActiveCfg = Release DirectSound|Win32
{08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}.All|Win32.ActiveCfg = Release|x64
{08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}.All|x64.ActiveCfg = Release|x64
{08DAD348-9E0A-4A2E-97F1-F1E7E24A7836}.All|x64.Build.0 = Release|x64
diff --git a/Makefile.am b/Makefile.am
index 8d35068c35..37a01d27fb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -349,7 +349,7 @@ scripts/fsxs: scripts/fsxs.in
-e "s|@INCLUDES\@|-I$(prefix)/include|" \
-e "s|@SOLINK\@|$(SOLINK)|" \
-e "s|@LDFLAGS\@|-L$(prefix)/lib|" \
- -e "s|@LIBS\@|`./libs/apr/apr-1-config --libs` `./libs/apr-util/apu-1-config --libs`|" \
+ -e "s|@LIBS\@||" \
$(top_srcdir)/scripts/fsxs.in > scripts/fsxs
##
diff --git a/build/getg729.sh.in b/build/getg729.sh.in
new file mode 100755
index 0000000000..c8a7227425
--- /dev/null
+++ b/build/getg729.sh.in
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+TAR=@TAR@
+ZCAT=@ZCAT@
+WGET=@WGET@
+CURL=@CURL@
+
+if [ -f "$WGET" ] ; then
+ DOWNLOAD_CMD=$WGET
+else
+ if [ -f "$CURL" ] ; then
+ DOWNLOAD_CMD="$CURL -O"
+ fi
+fi
+
+base=http://files.freeswitch.org/g729/
+tarfile=$1
+url=`echo $tarfile | grep "://"`
+
+if [ ! -z $url ] ; then
+ base=$tarfile/
+ tarfile=$2
+fi
+
+if [ ! -f $tarfile ] ; then
+ $DOWNLOAD_CMD $base$tarfile
+ if [ ! -f $tarfile ] ; then
+ echo cannot find $tarfile
+ exit 1
+ fi
+fi
+
+exit 0
+
diff --git a/build/modules.conf.in b/build/modules.conf.in
index 2be000f6b3..63a0ab491e 100644
--- a/build/modules.conf.in
+++ b/build/modules.conf.in
@@ -42,12 +42,14 @@ codecs/mod_amr
#codecs/mod_silk
#codecs/mod_codec2
codecs/mod_g729
+#codecs/mod_com_g729
codecs/mod_h26x
codecs/mod_bv
codecs/mod_ilbc
codecs/mod_speex
codecs/mod_siren
#codecs/mod_celt
+#codecs/mod_opus
#codecs/mod_sangoma_codec
#codecs/mod_dahdi_codec
#dialplans/mod_dialplan_directory
@@ -78,6 +80,7 @@ event_handlers/mod_cdr_sqlite
#event_handlers/mod_cdr_pg_csv
#event_handlers/mod_radius_cdr
#event_handlers/mod_erlang_event
+#event_handlers/mod_snmp
formats/mod_native_file
formats/mod_sndfile
#formats/mod_shout
diff --git a/conf/autoload_configs/cdr_pg_csv.conf.xml b/conf/autoload_configs/cdr_pg_csv.conf.xml
index 2f2efa9b26..4fec817b45 100644
--- a/conf/autoload_configs/cdr_pg_csv.conf.xml
+++ b/conf/autoload_configs/cdr_pg_csv.conf.xml
@@ -1,21 +1,40 @@
-
-
-
-
-
+
+
+
+
+
+
+
-
- "${local_ip_v4}","${caller_id_name}","${caller_id_number}","${destination_number}","${context}","${start_stamp}","${answer_stamp}","${end_stamp}","${duration}","${billsec}","${hangup_cause}","${uuid}","${bleg_uuid}","${accountcode}","${read_codec}","${write_codec}","${sip_hangup_disposition}","${ani}"
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/conf/autoload_configs/easyroute.conf.xml b/conf/autoload_configs/easyroute.conf.xml
index 7cd490942f..350a50989b 100644
--- a/conf/autoload_configs/easyroute.conf.xml
+++ b/conf/autoload_configs/easyroute.conf.xml
@@ -11,6 +11,9 @@
+
+
+
+
@@ -51,6 +52,7 @@
+
@@ -77,6 +79,7 @@
+
diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml
index 8342f120fc..4f72c6a65d 100644
--- a/conf/autoload_configs/switch.conf.xml
+++ b/conf/autoload_configs/switch.conf.xml
@@ -23,6 +23,10 @@
+
+
+
+
+
+
-
+
+
+
diff --git a/conf/freeswitch.xml b/conf/freeswitch.xml
index 80e7728e0d..6914128e55 100644
--- a/conf/freeswitch.xml
+++ b/conf/freeswitch.xml
@@ -61,7 +61,4 @@
-
-
-
diff --git a/conf/jingle_profiles/client.xml b/conf/jingle_profiles/client.xml
index 66c34929a3..cac70692e8 100644
--- a/conf/jingle_profiles/client.xml
+++ b/conf/jingle_profiles/client.xml
@@ -24,7 +24,7 @@
-
+
diff --git a/configure.in b/configure.in
index d91cf11419..a0c9418751 100644
--- a/configure.in
+++ b/configure.in
@@ -730,6 +730,8 @@ AC_PATH_PROGS(WGET, wget)
AC_PATH_PROGS(CURL, curl)
GETLIB="cd $switch_srcdir/libs && ${SHELL} $switch_builddir/build/getlib.sh"
AC_SUBST(GETLIB)
+GETG729="cd $switch_srcdir/libs && ${SHELL} $switch_builddir/build/getg729.sh"
+AC_SUBST(GETG729)
GETSOUNDS="${SHELL} $switch_builddir/build/getsounds.sh"
AC_SUBST(GETSOUNDS)
@@ -916,6 +918,7 @@ AC_CONFIG_FILES([Makefile
src/mod/applications/mod_osp/Makefile
src/mod/applications/mod_stress/Makefile
src/mod/applications/mod_hash/Makefile
+ src/mod/codecs/mod_com_g729/Makefile
src/mod/endpoints/mod_portaudio/Makefile
src/mod/endpoints/mod_skinny/Makefile
src/mod/endpoints/mod_skypopen/Makefile
@@ -930,6 +933,7 @@ AC_CONFIG_FILES([Makefile
src/include/switch_am_config.h
build/getsounds.sh
build/getlib.sh
+ build/getg729.sh
build/freeswitch.pc
build/modmake.rules
libs/xmlrpc-c/include/xmlrpc-c/config.h
@@ -1023,6 +1027,7 @@ AC_OUTPUT
##
## Registering for ClueCon
##
+if ! test -f noreg ; then
echo ""
echo ""
echo $ECHO_N "Registering you for ClueCon http://www.cluecon.com $ECHO_C" 1>&6
@@ -1040,6 +1045,7 @@ sleep 1
AC_MSG_RESULT([ See you in August. ;-)])
sleep 2
echo ""
+fi
##
## Configuration summary
diff --git a/docs/ChangeLog b/docs/ChangeLog
index 41f94d78ab..356cbdc852 100644
--- a/docs/ChangeLog
+++ b/docs/ChangeLog
@@ -35,6 +35,7 @@ freeswitch (1.0.7)
config: Disallow global-intercept and group-intercept can intercept an outbound call in default dialplan (r:890871ba/FS-2777)
config: fix single domain assumption in default config to be more portable *cough* bkw *cough* (r:f987903e)
config: Bump Doxygen.conf version to 1.0.6... belatedly (r:cfeae1ba)
+ config: docs for acl (r:57b410eb)
core: Add RTCP support (FSRTP-14)
core: handle some errors on missing db handle conditions
core: add ... and shutdown as a fail-safe when no modules are loaded
@@ -164,6 +165,24 @@ freeswitch (1.0.7)
core: drop rtp frame that was already replaced with a cng frame (r:34a0ca50)
core: fix partial match counting as exact match in dmachine (r:5eb951aa)
core: try to adjust the timer to be ok with the horrible 10000 microsecond kernel resolution on amazon ec3 but that doesn't mean it's not horribly wrong to run the kernel that slow (r:903b2901)
+ core: make exact matches return sooner in dmachine (r:e897646e)
+ core: don't let inherit_codec work when we have ep_codec_string set and the B-leg codec is not in that list since it will lead to failure (r:f79f9766)
+ core: set maximum query run time to 30 seconds at least on drivers that support SQL_ATTR_QUERY_TIMEOUT (r:5bb525e1)
+ core: dd switch_cache_db_affected_rows() to switch_core_sqldb (and switch_odbc) and expose it through Lua dbh:affected_rows() (r:d79cf484/FS-2962)
+ core: add bind meta on A-D and refactor (r:27869d7a)
+ core: add temp_hold_music var that is only valid until you transfer the call and finishing touches on bind meta to A-D (r:b262f44c)
+ core: add function to help set session read codec to slinear (r:1a08df9b)
+ core: add rtp_bug IGNORE_DTMF_DURATION to speed up dtmf detection of RFC2833 on strange carriers (r:b3fc001e)
+ core: Fix crash when re-connecting to non-working database server (r:29daaa07/FS-2960)
+ core: treat EINTR returns as a BREAK (now mapped to SWITCH_STATUS_INTR), we appriciate the interrupted syscalls but we would like to continue working properly (r:316963c5)
+ core: eat rtp frames with the wrong payload type number (r:fe1711fd)
+ core: up assert vaule on header loop detection to 1 meeeeelyonne for hmmhesegs (r:d9c56345)
+ core: Fix race condition in originate where USER_BUSY is reported as a no answer (r:cc06fdb5/FS-2992)
+ core: Allow check ip change to be optional (r:1cf79386/FS-2917)
+ core: handle 2833 in do_flush instead of dropping valid dtmf (r:3fa3e11c/FS-3002)
+ core: add record_restart_time_limit_on_dtmf var (r:7a1dcb69)
+ core: fix unreachable condition with a null args to make any key stop playback/record etc without dequing and remove hard-coded flush digits in play_and_get_digits be sure to flush it yourself before using (r:976859bb)
+ core: Fix a lock on reloadxml when stderr write is blocked. Also remove an error parsing print since reason generated were wrong and duplicate. (r:2d6161e8)
embedded languages: Provide core level support for conditional Set Global Variable (r:c017c24b/FSCORE-612)
embedded languages: add insertFile front end to switch_ivr_insert_file and reswig (r:c4e350ab)
lang: Improve French phrase files (FSCONFIG-23)
@@ -188,11 +207,14 @@ freeswitch (1.0.7)
libesl: Make last_event pointer last longer (r:a15f51d5/ESL-37)
libesl: use a packet buffer for ESL (r:2081bf97)
libesl: Noevent/Noevents disparity (r:d29d83d7/ESL-53)
+ libesl: FS-2957 esl lib on windows fails to build (r:5254df04/FS-2957)
+ libesl: Small fix on ESL that cause event_id to be set wrong on headers that had value failure. (r:eb88304a)
libfreetdm: implemented freetdm config nodes and ss7 initial configuration
libfreetdm: fix codec for CAS signaling (r:b76e7f18)
libfreetdm: freetdm: ss7- added support for incoming group blocks, started adding support for ansi (r:c219a73c)
libg7221: A bunch of tweaks to the G.722.1 codec (r:5d548570)
libgnutls: link to libgcrypt as well, please report any platforms this breaks, but it should be portable (r:c569fb0f/FS-1248)
+ libjs: non-portable comment syntax in .s files
libopenzap: Add CLI tracing
libs: Merged OpenZAP and FreeTDM into the FreeSWITCH tree.
libs: Add support for TLS on Windows using openssl (r:1abe3b93/MODSOFIA-92)
@@ -207,6 +229,7 @@ freeswitch (1.0.7)
libspandsp: Fix Windows build after libspandsp update (r:d70cc852/FSBUILD-293)
libspandsp: Fix for T.30 processing of operator interrupts, to improve compatibility with some machines, which seem to send them when no operator is around. (r:84ee0ae6)
libspandsp: spandsp t38 fax receiving error in win XP - regression from f029f7ef (r:761cec8f/FS-2766)
+ libspandsp: Added missing error codes when an ECM FAX is abandoned with the T30_ERR message (r:ec57dc7a)
mod_avmd: Initial check in - Advanced Voicemail Detect (r:10c6a30a) (by Eric Des Courtis)
mod_avmd: Add to windows build (r:df4bd935)
mod_avmd: Fix mem leak (r:cd951384/FS-2839)
@@ -229,8 +252,12 @@ freeswitch (1.0.7)
mod_callcenter: Fix bad return type so it compile on archlinux, thx bougyman (r:3a475986)
mod_callcenter: Make callcenter_config agent get return the value of the item requested. Also added queue param max-wait-time-with-no-agent-time-reached: If the max-wai-time-with-no-agent is already reached for the queue, then new caller can wait for x amount of second before it kicked out of the queue rather than get rejected automatically. (r:81a03869)
mod_callcenter: Add new event socket agent-offering. Plus some documentation and better handling of bad agent type -- FS-2869 (r:80174cf3/FS-2869)
+ mod_callcenter: Add error response for queue load and queue reload (FS-2988) (r:49a5effc/FS-2988)
mod_cdr_sqlite: initial commit (r:f625fe3b)
mod_cdr_sqlite: config file for mod_cdr_sqlite (r:25bc8fe3)
+ mod_cdr_sqlite: Drop transaction BEGIN/END around INSERT. We're only executing one command, and autocommit will automatically rollback if the INSERT fails. Sync state_handlers with mod_cdr_csv. Minor libpq fixups. (r:0f95b870)
+ mod_celt: Bump celt to 0.10.0 (r:231fbe5e)
+ mod_celt: update code in mod_celt to match API of 0.10.0 (r:6e4c30ea)
mod_cidlookup: null xml is bad (r:095815f8)
mod_cid_lookup: honor skipcitystate when using whitepages (r:a66654de/FSMOD-53)
mod_commands: make break uuid_break and add cascade flag
@@ -252,6 +279,7 @@ freeswitch (1.0.7)
mod_commands: Dramatic jitterbuffer changes (r:d5470961)
mod_commands: add uuid_buglist to fetch the current media-bugs attached to a given session uuid (r:f6eab64c)
mod_commands: add recovery_refresh app and api and use it in mod_conference to send a message to the channel telling it to sync its recovery snapshot (r:650393fb)
+ mod_commands: add moh by default to uuid_broadcast when only broadcasting to A leg use aleg arg to disable this (r:d164a797)
mod_conference: Fix reporting of volume up/down (MODAPP-419)
mod_conference: add last talking time per member to conference xml list
mod_conference: add terminate-on-silence conference param
@@ -265,6 +293,10 @@ freeswitch (1.0.7)
mod_conference: Add a chan var conference_enter_sound to override conference enter-sound param on the profile (r:651acc62)
mod_conference: Add an unique id to the conference obj so that we can track conferences. (r:479f3de2)
mod_conference: Fix corrupted audio when playing "you are now (un)muted..." (r:10257c7d/FS-2768)
+ mod_conference: clear last_transferred conference when you exit the conference app (r:fb017a52)
+ mod_conference: Add energy level to conference_add_event_member_data (r:8d6d52e0)
+ mod_conference: if more digits than the length of the correct pin the remaining digits are accounted for next retry (r:b88cd345/FS-3000)
+ mod_conference: Fix unexpected behavior with endconf and auto-outcalls and pre_answer (r:6f58e6aa/FS-2771)
mod_curl: use method=post when post requested (r:c6a4ddd0/FSMOD-69)
mod_db: fix stack corruption (MODAPP-407)
mod_dialplan_xml: Add in the INFO log the caller id number when processing a request (Currenly only show the caller name) (r:e1df5e13)
@@ -282,12 +314,16 @@ freeswitch (1.0.7)
mod_dptools: refactor export code and add new bridge_export app which is like export but exports across when one channel bridges another (r:4aa9a838)
mod_dptools: add bind_digit_action application (r:9537197b)
mod_dptools: emit event when user presses DTMFs (r:37298f56)
+ mod_dptools: Log error when there's no IVR menus configured when you call 'ivr' DP app (r:30034891)
+ mod_easyroute: Fix possible segfaults and memory leak during unload, and add new setting odbc-retries (r:7fbc47f8/FS-2973)
mod_erlang_event: Make XML fetch reply ACKs distinguishable, update freeswitch.erl (r:9d44ed04)
mod_erlang_event: Add 3 new commands; session_event, session_noevents, session_nixevent (r:698fa045)
mod_erlang_event: generate long node names the same as erlang does (r:9ad509c2)
mod_erlang_event: Improve some logging to include UUIDs (r:c0d51b83)
mod_erlang_event: Support for reading erlang cookie from a file (r:094ffe37)
mod_erlang_event: Rewrite XML fetch conditional wait to be more sane (Reported by James Aimonetti) (r:6941c6eb/FS-2775)
+ mod_erlang_event: Don't urlencode events (and destroy an event after use) (r:4eccdfef)
+ mod_erlang_event Add proper locking for the list of XML bindings (r:9fe440b2)
mod_event_socket: fix up other users of switch_event_xmlize() to use SWITCH_EVENT_NONE (r:d6eb7562)
mod_event_socket: Fix small mem leaks (r:e4f90584/MODEVENT-68)
mod_event_socket: Add "-ERR" to api cmd response when failure occurs (r:58759052/FS-2827)
@@ -301,6 +337,8 @@ freeswitch (1.0.7)
mod_fifo: add outbound_ring_timeout param to mod_fifo (r:3885eea7)
mod_fifo: add default_lag to fifo (r:dd4fb5be)
mod_fifo: Fix crash when using fifo_destroy_after_use (r:ee562c82/FS-2879)
+ mod_fifo: don't seg in edge case error conditions (r:9ee13b72)
+ mod_fifo: set tracking data before enabling hooks (r:34267869)
mod_freetdm: Fix for TON and NPI not passed through to channel variables on incoming calls
mod_freetdm: add pvt data to freetdm channels fix fxs features (r:9d456900)
mod_freetdm: export and import boost custom data (r:edb2d582)
@@ -334,6 +372,7 @@ freeswitch (1.0.7)
mod_freetdm: created cmake files for freetdm (r:fc55997b)
mod_freetdm: ss7 - added support to control mtp2, mtp3, and isup timers via freetdm.conf.xml (r:4455d581)
mod_freetdm: made ftmod_r2 use FTDM_SPAN_USE_SIGNALS_QUEUE and properly send FTDM_SIGEVENT_SIGSTATUS_CHANGED (r:af5f0a4a)
+ mod_fsk: add mod_fsk (r:fcc912a9)
mod_gsmopen: copy from branch
mod_gsmopen: fix FS-2793, compilation stops (r:355c0dbb/FS-2793)
mod_gsmopen: retry serial initialization if failed, zeroing audio buffers, slower retry on soundcard busy (EAGAIN) (r:c7aefe93)
@@ -351,6 +390,7 @@ freeswitch (1.0.7)
mod_hash: use 5 seconds connection timeouts for remote connections (r:7431fbe9)
mod_hash: use esl_recv_timed with a 5000ms timeout when doing api commands (r:27d8378f)
mod_hash: limit_remote_thread sending invalid handle to esl_connect_timeout causing core (r:6cdd3e2a/MODAPP-446)
+ mod_hash: avoid scheduler caling a function on null hash during shutdown (r:8458adeb)
mod_h323: initial t.38 support. remake logical channel opening. add missing param name in example config. (r:8c58074c)
mod_h323: some t.38 and lockinng improvements. replace ptrace with switch_log_printf. (r:5efe5c88)
mod_h323: add missing conf prameter (r:0b353d7a)
@@ -379,6 +419,8 @@ freeswitch (1.0.7)
mod_lua: Made 2nd arg to freeswitch.Dbh:query (cb func) optional (r:87db11af)
mod_lua: Added SAF_ROUTING_EXEC flag to lua app, so it can be run inline (r:7d5ca1c0)
mod_lua: spelling error in -ERR return code encounterd -> encountered (r:86e7cdc5/FS-2949)
+ mod_lua: Make dbh:connected accessible from Lua - thanks Grmt (r:09e6fd3f)
+ mod_lua: Added optional core: prefix to first arg passed to freeswitch.Dbh for giving direct access to sqlite db (r:a0181479)
mod_managed: Added wrapper for switch_event_bind for .net (r:a5f07a80/MODLANG-165)
mod_managed: add additional support (r:5be58aac)
mod_managed: add mono 2.8 patch file see FS-2774 (r:6a948bd9/FS-2774)
@@ -442,6 +484,7 @@ freeswitch (1.0.7)
mod_snapshot: fix bad codepaths in mod_snapshot (r:844ac220)
mod_sndfile: Add support for .alaw and .ulaw to mod_sndfile (r:facf09b8/MODFORM-41)
mod_sndfile: return break in mod_sndfile when seek returns failure (r:564dc7e4)
+ mod_snmp: initial checkin of mod_snmp (r:6e2b1bd3)
mod_sofia: Send SIP MESSAGE to unregistered users by prefixing sip: to user@domain
mod_sofia: fix callee being updated with callee information
mod_sofia: set appearance-index in update statement for SLA
@@ -548,6 +591,20 @@ freeswitch (1.0.7)
mod_sofia: improve fail2ban logging (r:f4d52d4c/FS-2943)
mod_sofia: refactor sofia_contact to try the profile_name first then the domain to resolve the profile then fall back to querying every profile to reduce confusion with multi-homers (d'oh) also special profile name * will force a search-all situation (r:81608da0)
mod_sofia: support allowing pidf-ful presence clients to share the same account and 'appear offline' without influencing each other =/ also refactor the contact generation string based on nat into a helper function (r:97a68c50)
+ mod_sofia: gateway not identified when extension-in-contact is set (r:7b289941/FS-502)
+ mod_sofia: Fix erroneous error log on SQL statement (r:2c595a6c/FS-2961)
+ mod_sofia: Fix routing behavior of inbound calls from gateways that only match gateway based on the gw request uri param (r:0132cd3f)
+ mod_sofia: don't say we are not for polycom phones (safe rport) when its not really nat (r:9462f53c)
+ mod_sofia: Set route header as a var on channel like Diversion header (r:d41e6498)
+ mod_sofia: fix seg related to ptime mismatch + CNG + PLC (if you ever get purple ptime mismatch warnings you want this patch) (r:54de293b)
+ mod_sofia: be more iOS friendly when using TCP or TLS because the phone never sleeps thus drains the battery (r:159ae989)
+ mod_sofia: add send-presence-on-register (true|false|first-only) param to sofia and api command sofia global debug [presence|sla|none]
+ mod_sofia: disable media timeout when encountering a recvonly stream (r:029d68ce)
+ mod_sofia: fix sofia flush_inbound_reg to work when @domain is given (r:68bf642c)
+ mod_sofia: fix session timer failure when freeswitch is generating the sdp and there are enough dynamic codecs enabled to conflict with the 2833 pt (4 by default) (r:018a3800)
+ mod_sofia: Places ;fs_path= within the contact string <...> when using NDLB-connectile-dysfunction-2.0, instead of just appending to the end of the contact string. (r:afc02747/FS-2989)
+ mod_sofia: Fix handling SUBSCRIBE to "park+" fifo, the NOTIFY data was not being generated from mod_fifo data. (r:3dd9d5c0/FS-3007)
+ mod_sofia: fsctl pause improvements (r:008e527c/FS-3012)
mod_spandsp: initial checkin of mod_fax/mod_voipcodecs merge into mod_spandsp (r:fa9a59a8)
mod_spandsp: rework of new mod_spandsp to have functions broken up into different c files (r:65400642)
mod_spandsp: improve duplicate digit detection and add 'min_dup_digit_spacing_ms' channel variable for use with the dtmf detector (r:eab4f246/FSMOD-45)
@@ -559,6 +616,7 @@ freeswitch (1.0.7)
mod_spandsp: deadlock in mod_spandsp (mod_spandsp_fax.c) (r:b02c69bb/FS-1690)
mod_spandsp: T.38 reINVITE glare condition causes FAX processing to stop. (r:04aa7ef9/FS-1682)
mod_spandsp: improve nat handling when using stun or host as ext-rtp-ip (r:03e74c51/FS-526)
+ mod_spandsp: Fire event when fax is finished; indicates result of fax attempt (r:314a2a1e/FS-3004)
mod_spidermonkey: allow vars to be set containing vars from languages (r:5cd072a3)
mod_spidermonkey: fix seg in js hangup (r:7d554c11)
mod_spidermonkey: Fix mod_spidermonkey build on FreeBSD, (Undefined symbol PR_LocalTimeParameters). (r:3edb8419)
@@ -579,10 +637,14 @@ freeswitch (1.0.7)
mod_voicemail: add quotes to vm_cc command generated internally to escape spaces in the caller id name (r:5f012813)
mod_voicemail: Play caller id of callee prior to playing a vmail (r:e7b97907/FS-2719)
mod_voicemail: FS-1776 Add support for per user operator exten override param vm-operator-extension (r:df5b3498/FS-1776)
+ mod_voicemail: Set email address from within directory (r:83ce26b2/FS-2972)
+ mod_voicemail: add events for record/change greeting and record name (r:54421f59)
+ mod_voicemail: let vmain-key and operator-key be set empty (r:de49305a)
mod_xml_cdr: add force_process_cdr var to process b leg cdr on a case by case basis when b leg cdr is disabled (XML-17)
mod_xml_cdr: add leg param to query string (XML-24)
mod_xml_cdr: fix locked sessions (XML-26)
mod_xml_cdr: fix minor memory leaks and config bug (r:19253d83/MODEVENT-62)
+ mod_xml_cdr: Fix prefix-a-leg not respected for url submission (r:ea9021a2/FS-2998)
mod_xml_rpc: Fix crash if unauthorized XML RPC is attempted (r:9835395c/FS-184)
scripts: added honeypot.pl and blacklist.pl which add extra SIP security options (r:b6a81ba7)
scripts: do simple verification to make sure we are getting IP addresses from VoIP abuse blacklist (r:b0049160)
diff --git a/freeswitch.spec b/freeswitch.spec
index 7fb9f80d8e..1000a89239 100644
--- a/freeswitch.spec
+++ b/freeswitch.spec
@@ -27,6 +27,14 @@
# Maintainer(s): Michal Bielicki 910
@@ -282,14 +295,72 @@ German language phrases module and directory structure for say module and voicem
Summary: Provides a unified interface to hardware TDM cards and ss7 stacks for FreeSWITCH
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
-%{?with_sang_isdn: Requires: wanpipe }
-%{?with_sang_isdn: Requires: libsng_isdn }
-%{?with_sang_isdn: BuildRequires: wanpipe }
-%{?with_sang_isdn: BuildRequires: libang_isdn }
%description freetdm
FreeTDM
+%if %{build_sng_isdn}
+
+%package freetdm-sng-isdn
+Summary: Sangoma ISDN Module for FreeTDM
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: %{name}-freetdm = %{version}-%{release}
+Requires: wanpipe
+Requires: libsng_isdn
+BuildRequires: wanpipe
+BuildRequires: libsng_isdn
+
+%description freetdm-sng-isdn
+Sangoma ISDN Module for freetdm
+
+%endif
+
+%if %{build_sng_ss7}
+
+%package freetdm-sng-ss7
+Summary: Provides a unified interface to hardware TDM cards and ss7 stacks for FreeSWITCH, Sangoma SS7 Module
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: %{name}-freetdm = %{version}-%{release}
+Requires: wanpipe
+Requires: libsng_ss7
+BuildRequires: wanpipe
+BuildRequires: libsng_ss7
+
+%description freetdm-sng-ss7
+Sangoma SMG-SS7 drivers for FreeTDM
+
+%endif
+
+
+%if %{build_sng_tc}
+
+%package sangoma-codec
+Summary: Sangoma D100 and D500 Codec Card Support
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: sng-tc-linux
+BuildRequires: sng-tc-linux
+
+%description sangoma-codec
+Sangoma D100 and D500 Codec Card Support
+
+%endif
+
+%package skypopen
+Summary: Skype Endpoint
+Group: System/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: libX11
+BuildRequires: libX11-devel
+
+%description skypopen
+This software (Skypopen) uses the Skype API but is not endorsed, certified or otherwise approved in any way by Skype.
+Skypopen is an endpoint (channel driver) that uses the Skype client as an interface to the Skype network, and allows
+incoming and outgoing Skype calls to/from FreeSWITCH (that can be bridged, originated, answered, etc. as in all other
+endpoints, e.g. Sofia-SIP).
+
######################################################################################################################
#
# Unpack and prepare Source archives, copy stuff around etc ..
@@ -309,6 +380,8 @@ cp %{SOURCE8} libs/
cp %{SOURCE9} libs/
cp %{SOURCE10} libs/
cp %{SOURCE11} libs/
+cp %{SOURCE12} libs/
+cp %{SOURCE13} libs/
######################################################################################################################
#
@@ -358,7 +431,11 @@ ASR_TTS_MODULES="asr_tts/mod_pocketsphinx asr_tts/mod_flite asr_tts/mod_unimrcp"
#
######################################################################################################################
CODECS_MODULES="codecs/mod_bv codecs/mod_h26x codecs/mod_speex codecs/mod_celt codecs/mod_codec2 codecs/mod_ilbc codecs/mod_mp4v \
- codecs/mod_silk codecs/mod_siren codecs/mod_theora"
+ codecs/mod_opus codecs/mod_silk codecs/mod_siren codecs/mod_theora "
+#
+%if %{build_sng_tc}
+CODECS_MODULES+="codecs/mod_sangoma_codec"
+%endif
######################################################################################################################
#
# Dialplan Modules
@@ -377,7 +454,7 @@ DIRECTORIES_MODULES=""
#
######################################################################################################################
ENDPOINTS_MODULES="endpoints/mod_dingaling endpoints/mod_loopback ../../libs/freetdm/mod_freetdm endpoints/mod_portaudio \
- endpoints/mod_sofia"
+ endpoints/mod_sofia endpoints/mod_skinny endpoints/mod_skypopen"
######################################################################################################################
#
@@ -483,11 +560,13 @@ fi
%{?configure_options}
#Create the version header file here
-cat src/include/switch_version.h.in | sed "s/@SVN_VERSION@/%{version}/g" > src/include/switch_version.h
-touch .noversion
+#cat src/include/switch_version.h.in | sed "s/@SVN_VERSION@/%{version}/g" > src/include/switch_version.h
+#touch .noversion
%{__make}
+cd libs/esl
+%{__make} pymod
######################################################################################################################
#
@@ -503,6 +582,11 @@ touch .noversion
%{__mkdir} -p %{buildroot}%{logfiledir}
%{__mkdir} -p %{buildroot}%{runtimedir}
+#install the esl stuff
+cd libs/esl
+%{__make} DESTDIR=%{buildroot} pymod-install
+cd ../..
+
%ifos linux
# Install init files
# On SuSE:
@@ -522,6 +606,23 @@ touch .noversion
# Add monit file
%{__install} -D -m 644 build/freeswitch.monitrc %{buildroot}/etc/monit.d/freeswitch.monitrc
%endif
+######################################################################################################################
+#
+# Remove files that are not wanted if they exist
+#
+######################################################################################################################
+
+%if %{build_sng_ss7}
+#do not delete a thing
+%else
+%{__rm} -f %{buildroot}/%{prefix}/mod/ftmod_sangoma_ss7*
+%endif
+%if %{build_sng_isdn}
+#do not delete a thing
+%else
+%{__rm} -f %{buildroot}/%{prefix}/mod/ftmod_sangoma_isdn*
+%endif
+
######################################################################################################################
@@ -545,8 +646,6 @@ fi
chkconfig --add freeswitch
-
-
%postun
######################################################################################################################
#
@@ -790,6 +889,7 @@ fi
%{prefix}/mod/mod_mp4v.so*
%{prefix}/mod/mod_native_file.so*
%{prefix}/mod/mod_nibblebill.so*
+%{prefix}/mod/mod_opus.so*
%{prefix}/mod/mod_pocketsphinx.so*
%{prefix}/mod/mod_portaudio.so*
%{prefix}/mod/mod_portaudio_stream.so*
@@ -798,6 +898,7 @@ fi
%{prefix}/mod/mod_shout.so*
%{prefix}/mod/mod_silk.so*
%{prefix}/mod/mod_siren.so*
+%{prefix}/mod/mod_skinny.so*
%{prefix}/mod/mod_sndfile.so*
%{prefix}/mod/mod_snom.so*
%{prefix}/mod/mod_sofia.so*
@@ -831,7 +932,7 @@ fi
%{prefix}/include/*.h
######################################################################################################################
#
-# OpenZAP Module for TDM Interaction
+# FreeTDM Module for TDM Interaction
#
######################################################################################################################
%files freetdm
@@ -844,7 +945,26 @@ fi
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/zt.conf
%{prefix}/lib/libfreetdm.so*
%{prefix}/mod/mod_freetdm.so*
-%{prefix}/mod/ftm*.so*
+%{prefix}/mod/ftmod_skel*.so*
+%{prefix}/mod/ftmod_[a-r,t-z]*.so*
+
+%if %{build_sng_tc}
+%files sangoma-codec
+%defattr(-, freeswitch, daemon)
+%{prefix}/mod/mod_sangoma_codec.so*
+%endif
+
+%if %{build_sng_ss7}
+%files freetdm-sng-ss7
+%defattr(-, freeswitch, daemon)
+%{prefix}/mod/ftmod_sangoma_ss7.so*
+%endif
+
+%if %{build_sng_isdn}
+%files freetdm-sng-isdn
+%defattr(-, freeswitch, daemon)
+%{prefix}/mod/ftmod_sangoma_isdn.so*
+%endif
######################################################################################################################
#
@@ -899,9 +1019,14 @@ fi
%defattr(-,freeswitch,daemon)
%{prefix}/mod/mod_python*.so*
%attr(0644, root, bin) /usr/lib/python*/site-packages/freeswitch.py*
+%attr(0755, root, bin) /usr/lib/python*/site-packages/_ESL.so*
+%attr(0755, root, bin) /usr/lib/python*/site-packages/ESL.py*
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/autoload_configs
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/python.conf.xml
+%files skypopen
+%defattr(-,freeswitch,daemon)
+%{prefix}/mod/mod_skypopen.so*
######################################################################################################################
#
# Language Modules
@@ -956,6 +1081,17 @@ fi
#
######################################################################################################################
%changelog
+* Wed Feb 16 2011 - michal.bielicki@seventhsignal.de
+- added mod_skinny
+- added sangoma libraries
+- added sangoma codec module for D100 and D150 and D500
+- added skypopen module
+- fixes for ss7 freetdm modules
+- added mod_opus
+- added selector for sangoma modules
+- addded python esl module to rpm
+- some minor cleanups
+- cut sangoma modules into separate rpms as addons for freetdm
* Tue Jan 18 2011 - michal.bielicki@seventhsignal.de
- Fedora adjustments
* Fri Oct 15 2010 - michal.bielicki@seventhsignal.de
@@ -1090,3 +1226,4 @@ fi
- Added devel package
* Thu Mar 15 2007 - peter+rpmspam@suntel.com.tr
- Initial RPM release
+
diff --git a/fscomm/widgets/codecwidget.cpp b/fscomm/widgets/codecwidget.cpp
index 42b10febfd..2f82e1a8cc 100644
--- a/fscomm/widgets/codecwidget.cpp
+++ b/fscomm/widgets/codecwidget.cpp
@@ -131,6 +131,8 @@ void CodecWidget::setCodecString(QString codecList)
QStringList parsed = codecList.split("{");
QString var = parsed.at(1);
var = var.split("}").at(0);
+ // warning switch_core_get_Variable may return an unsafe pointer in some cases.
+ // revise to use switch_core_get_variable_dup, and then free it after you are done.
var = switch_core_get_variable(var.toAscii().data());
if ( ! var.isEmpty() ) {
codecList = var;
diff --git a/libs/esl/Makefile b/libs/esl/Makefile
index ab50bac4d9..fbc870ac24 100644
--- a/libs/esl/Makefile
+++ b/libs/esl/Makefile
@@ -95,4 +95,7 @@ managedmod: $(MYLIB)
phpmod-install: phpmod
$(MAKE) -C php install
+pymod-install: pymod
+ $(MAKE) -C python install
+
everymod: perlmod phpmod luamod pymod rubymod javamod managedmod
diff --git a/libs/esl/fs_cli.c b/libs/esl/fs_cli.c
index 1e3bf04ca1..a70d63fab5 100644
--- a/libs/esl/fs_cli.c
+++ b/libs/esl/fs_cli.c
@@ -8,6 +8,7 @@
#include
#define CMD_BUFLEN 1024
+static int WARN_STOP = 0;
#ifdef WIN32
#define strdup(src) _strdup(src)
@@ -535,6 +536,13 @@ static BOOL console_readConsole(HANDLE conIn, char* buf, int len, int* pRed, int
static void handle_SIGINT(int sig)
{
if (sig);
+
+ WARN_STOP = 1;
+
+ signal(SIGINT, handle_SIGINT);
+#ifdef SIGTSTP
+ signal(SIGTSTP, handle_SIGINT);
+#endif
return;
}
@@ -581,16 +589,36 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
while(thread_running && handle->connected) {
esl_status_t status = esl_recv_event_timed(handle, 10, 1, NULL);
+ int aok = 1;
+
if (status == ESL_FAIL) {
- esl_log(ESL_LOG_WARNING, "Disconnected.\n");
+ if (aok) esl_log(ESL_LOG_WARNING, "Disconnected.\n");
running = -1; thread_running = 0;
} else if (status == ESL_SUCCESS) {
+#ifndef WIN32
+ fd_set can_write;
+ int fd;
+ struct timeval to;
+
+ fd = fileno(stdout);
+ memset(&to, 0, sizeof(to));
+ FD_ZERO(&can_write);
+ FD_SET(fd, &can_write);
+ to.tv_sec = 0;
+ to.tv_usec = 100000;
+ if (select(fd + 1, NULL, &can_write, NULL, &to) > 0) {
+ aok = FD_ISSET(fd, &can_write);
+ } else {
+ aok = 0;
+ }
+#endif
+
if (handle->last_event) {
const char *type = esl_event_get_header(handle->last_event, "content-type");
int known = 0;
if (!esl_strlen_zero(type)) {
- if (!strcasecmp(type, "log/data")) {
+ if (aok && !strcasecmp(type, "log/data")) {
const char *userdata = esl_event_get_header(handle->last_event, "user-data");
if (esl_strlen_zero(userdata) || esl_strlen_zero(filter_uuid) || !strcasecmp(filter_uuid, userdata)) {
@@ -617,7 +645,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
} else if (!strcasecmp(type, "text/disconnect-notice")) {
running = -1; thread_running = 0;
known++;
- } else if (!strcasecmp(type, "text/event-plain")) {
+ } else if (aok && !strcasecmp(type, "text/event-plain")) {
char *foo;
esl_event_serialize(handle->last_ievent, &foo, ESL_FALSE);
printf("RECV EVENT\n%s\n", foo);
@@ -627,7 +655,7 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
}
}
- if (!known) {
+ if (aok && !known) {
char *foo;
printf("INCOMING DATA [%s]\n%s\n", type, handle->last_event->body ? handle->last_event->body : "");
esl_event_serialize(handle->last_event, &foo, ESL_FALSE);
@@ -637,6 +665,11 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
}
}
+ if (WARN_STOP) {
+ if (aok) printf("Type control-D or /exit or /quit or /bye to exit.\n\n");
+ WARN_STOP = 0;
+ }
+
usleep(1000);
}
@@ -1023,6 +1056,9 @@ int main(int argc, char *argv[])
}
signal(SIGINT, handle_SIGINT);
+#ifdef SIGTSTP
+ signal(SIGTSTP, handle_SIGINT);
+#endif
#ifdef SIGQUIT
signal(SIGQUIT, handle_SIGQUIT);
#endif
diff --git a/libs/esl/java/Makefile b/libs/esl/java/Makefile
index 9474a83276..3606edf331 100644
--- a/libs/esl/java/Makefile
+++ b/libs/esl/java/Makefile
@@ -1,4 +1,4 @@
-LOCAL_CFLAGS=-I../src/include -I/usr/java/jdk1.6.0_14/include -I/usr/java/jdk1.6.0_14/include/linux -I/usr/lib/jvm/java-6-openjdk/include/
+LOCAL_CFLAGS=-I../src/include -I/usr/java/jdk1.6.0_14/include -I/usr/java/jdk1.6.0_14/include/linux -I/usr/lib/jvm/java-6-openjdk/include/ -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux
GCC_WARNING_JUNK=-w
CLASSES=org/freeswitch/esl/*
diff --git a/libs/esl/php/Makefile b/libs/esl/php/Makefile
index 44fdd22dae..e970ff7d82 100644
--- a/libs/esl/php/Makefile
+++ b/libs/esl/php/Makefile
@@ -25,6 +25,6 @@ swigclean:
reswig: swigclean esl_wrap.cpp
install: ESL.so
- cp ESL.so $(shell php-config --extension-dir)
- cp ESL.php $(shell php -r 'echo ini_get("include_path");' | cut -d: -f2)
- echo 'extension=ESL.so' >> $(shell php-config --configure-options | tr " " "\n" | grep -- --with-config-file-scan-dir | cut -f2 -d=)/esl.ini
+ cp ESL.so $(DESTDIR)/$(shell php-config --extension-dir)
+ cp ESL.php /$(DESTDIR)/$(shell php -r 'echo ini_get("include_path");' | cut -d: -f2)
+ echo 'extension=ESL.so' >> $(DESTDIR)/$(shell php-config --configure-options | tr " " "\n" | grep -- --with-config-file-scan-dir | cut -f2 -d=)/esl.ini
diff --git a/libs/esl/python/Makefile b/libs/esl/python/Makefile
index 758aeaf500..7504665561 100644
--- a/libs/esl/python/Makefile
+++ b/libs/esl/python/Makefile
@@ -1,5 +1,6 @@
LOCAL_CFLAGS=`python ./python-config --includes`
LOCAL_LDFLAGS=`python ./python-config --ldflags`
+SITE_DIR=$(DESTDIR)/`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
all: _ESL.so
@@ -12,6 +13,10 @@ esl_wrap.o: esl_wrap.cpp
_ESL.so: esl_wrap.o
$(CXX) $(SOLINK) esl_wrap.o $(MYLIB) $(LOCAL_LDFLAGS) -o _ESL.so -L. $(LIBS)
+install: _ESL.so
+ install -m 755 _ESL.so $(SITE_DIR)
+ install -m 755 ESL.py $(SITE_DIR)
+
clean:
rm -f *.o *.so *~
diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am
index 96f1c9a10f..a26035b2ef 100644
--- a/libs/freetdm/Makefile.am
+++ b/libs/freetdm/Makefile.am
@@ -39,7 +39,6 @@ libdir = @libdir@
library_includedir = $(prefix)/include
INCS = -I$(FT_SRCDIR)/$(SRC)/include -I$(FT_SRCDIR)/$(SRC)/include/private
-INCS += -I$(FT_SRCDIR)/$(SRC)/ftmod/ftmod_sangoma_boost
if HAVE_SNG_SS7
INCS += -I/usr/include/sng_ss7
@@ -109,7 +108,6 @@ core-install: install-libLTLIBRARIES
# tools & test programs
#
noinst_PROGRAMS = testtones detect_tones detect_dtmf testpri testr2 testanalog testapp testcid
-noinst_PROGRAMS += testsangomaboost
testapp_SOURCES = $(SRC)/testapp.c
testapp_LDADD = libfreetdm.la
@@ -143,17 +141,6 @@ testr2_SOURCES = $(SRC)/testr2.c
testr2_LDADD = libfreetdm.la
testr2_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
-if HAVE_SCTP
-noinst_PROGRAMS += testboost
-testboost_SOURCES = $(SRC)/testboost.c
-testboost_LDADD = libfreetdm.la
-testboost_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
-endif
-
-testsangomaboost_SOURCES = $(SRC)/testsangomaboost.c
-testsangomaboost_LDADD = libfreetdm.la
-testsangomaboost_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
-
testanalog_SOURCES = $(SRC)/testanalog.c
testanalog_LDADD = libfreetdm.la
testanalog_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
@@ -201,14 +188,6 @@ ftmod_isdn_la_LDFLAGS = -shared -module -avoid-version $(LIBISDN_LDFLAGS) $(PCA
ftmod_isdn_la_LIBADD = libfreetdm.la $(LIBISDN_LIBS) $(PCAP_LIBS)
endif
-if HAVE_SCTP
-mod_LTLIBRARIES += ftmod_sangoma_boost.la
-ftmod_sangoma_boost_la_SOURCES = $(SRC)/ftmod/ftmod_sangoma_boost/sangoma_boost_client.c $(SRC)/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c
-ftmod_sangoma_boost_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
-ftmod_sangoma_boost_la_LDFLAGS = -shared -module -avoid-version
-ftmod_sangoma_boost_la_LIBADD = libfreetdm.la
-endif
-
if HAVE_LIBPRI
mod_LTLIBRARIES += ftmod_libpri.la
ftmod_libpri_la_SOURCES = $(SRC)/ftmod/ftmod_libpri/ftmod_libpri.c $(SRC)/ftmod/ftmod_libpri/lpwrap_pri.c
@@ -240,7 +219,8 @@ ftmod_sangoma_ss7_la_SOURCES = \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c \
$(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c \
- $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
+ $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c \
+ $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
ftmod_sangoma_ss7_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE
ftmod_sangoma_ss7_la_LDFLAGS = -shared -module -avoid-version -lsng_ss7
diff --git a/libs/freetdm/TODO b/libs/freetdm/TODO
index 6b8ef8f826..6b4cf71f5f 100644
--- a/libs/freetdm/TODO
+++ b/libs/freetdm/TODO
@@ -11,3 +11,12 @@
cannot be shown to end users, we already provide extensive logging for problem
troubleshooting.
+- Implement threaded IO.
+ Currently IO modules only work on-demand, where the user (ie, FreeSWITCH) drives the read/write
+ of media. If the user stops reading, some functions are not possible
+ (DTMF detection or Hangup tone detection). It would be useful to implement a FreeTDM mode
+ where the media is driven by a group of threads that are always reading (and possibly writing)
+ then when the user does ftdm_channel_read(), the media would be read from the buffers filled
+ by the media thread and not from the underlying IO device, this gives a chance to FreeTDM to
+ still perform hangup detection or other media services even if the application is not reading.
+
diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac
index a070e994a3..38f849b9e6 100644
--- a/libs/freetdm/configure.ac
+++ b/libs/freetdm/configure.ac
@@ -121,8 +121,7 @@ AC_CHECK_LIB([dl], [dlopen])
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([m], [cos])
-AC_CHECK_HEADERS([netinet/sctp.h netdb.h sys/select.h])
-AM_CONDITIONAL([HAVE_SCTP],[test "${ac_cv_header_netinet_sctp_h}" = "yes"])
+AC_CHECK_HEADERS([netdb.h sys/select.h])
AC_CHECK_FUNC([gethostbyname_r],
[], [AC_CHECK_LIB([nsl], [gethostbyname_r])]
@@ -267,7 +266,7 @@ fi
#
HAVE_SNG_SS7="no"
AC_MSG_RESULT([${as_nl}<<>> Sangoma SS7 stack])
-AC_CHECK_LIB([sng_ss7], [sng_isup_init], [HAVE_SNG_SS7="yes"])
+AC_CHECK_LIB([sng_ss7], [sng_isup_init_gen], [HAVE_SNG_SS7="yes"])
AC_MSG_RESULT([checking whether to build ftmod_sangoma_ss7... ${HAVE_SNG_SS7}])
AM_CONDITIONAL([HAVE_SNG_SS7], [test "${HAVE_SNG_SS7}" = "yes"])
diff --git a/libs/freetdm/cyginstall.sh b/libs/freetdm/cyginstall.sh
old mode 100644
new mode 100755
diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c
index 970cb5b993..4dc6cfcfd2 100755
--- a/libs/freetdm/mod_freetdm/mod_freetdm.c
+++ b/libs/freetdm/mod_freetdm/mod_freetdm.c
@@ -1055,21 +1055,18 @@ switch_io_routines_t freetdm_io_routines = {
static const char* channel_get_variable(switch_core_session_t *session, switch_event_t *var_event, const char *variable_name)
{
const char *variable = NULL;
-
if (var_event) {
if ((variable = switch_event_get_header(var_event, variable_name))) {
return variable;
}
}
+
if (session) {
switch_channel_t *channel = switch_core_session_get_channel(session);
if ((variable = switch_channel_get_variable(channel, variable_name))) {
return variable;
}
}
- if ((variable = switch_core_get_variable(variable_name))) {
- return variable;
- }
return NULL;
}
@@ -1555,6 +1552,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));
if (globals.sip_headers) {
switch_channel_set_variable(channel, "sip_h_X-FreeTDM-SpanName", ftdm_channel_get_span_name(sigmsg->channel));
@@ -1570,8 +1569,8 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-ANI2", "%s", channel_caller_data->aniII);
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS", "%s", channel_caller_data->dnis.digits);
- switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-TON", "%s", channel_caller_data->dnis.type);
- switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-Plan", "%s", channel_caller_data->dnis.plan);
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-TON", "%d", channel_caller_data->dnis.type);
+ switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-DNIS-Plan", "%d", channel_caller_data->dnis.plan);
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS", "%s", channel_caller_data->rdnis.digits);
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-TON", "%d", channel_caller_data->rdnis.type);
@@ -1583,21 +1582,13 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
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 channel variable to the dial plan */
- iter = ftdm_channel_get_var_iterator(sigmsg->channel, NULL);
- for (curr = iter ; curr; curr = ftdm_iterator_next(curr)) {
- ftdm_channel_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);
- }
-
/* Add any call variable to the dial plan */
iter = ftdm_call_get_var_iterator(channel_caller_data, iter);
for (curr = iter ; curr; curr = ftdm_iterator_next(curr)) {
ftdm_call_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);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call Variable: %s = %s\n", name, var_value);
}
ftdm_iterator_free(iter);
@@ -2152,8 +2143,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal)
switch(sigmsg->event_id) {
case FTDM_SIGEVENT_START:
{
- ftdm_call_add_var(caller_data, "screening_ind", ftdm_screening2str(caller_data->screen));
- ftdm_call_add_var(caller_data, "presentation_ind", ftdm_presentation2str(caller_data->pres));
return ftdm_channel_from_event(sigmsg, &session);
}
break;
@@ -2360,8 +2349,9 @@ static int add_config_list_nodes(switch_xml_t swnode, ftdm_conf_node_t *rootnode
static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confname)
{
- switch_xml_t signode, ss7configs, isup;
- ftdm_conf_node_t *rootnode;
+ switch_xml_t signode, ss7configs, isup, gen, param;
+ ftdm_conf_node_t *rootnode, *list;
+ char *var, *val;
/* try to find the conf in the hash first */
rootnode = switch_core_hash_find(globals.ss7_configs, confname);
@@ -2405,15 +2395,63 @@ static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confn
return NULL;
}
+ /* add sng_gen */
+ gen = switch_xml_child(isup, "sng_gen");
+ if (gen == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_gen for sng_isup config %s\n", confname);
+ ftdm_conf_node_destroy(rootnode);
+ return NULL;
+ }
+
+ if ((FTDM_SUCCESS != ftdm_conf_node_create("sng_gen", &list, rootnode))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to create %s node for %s\n", "sng_gen", confname);
+ ftdm_conf_node_destroy(rootnode);
+ return NULL;
+ }
+
+ for (param = switch_xml_child(gen, "param"); param; param = param->next) {
+ var = (char *) switch_xml_attr_soft(param, "name");
+ val = (char *) switch_xml_attr_soft(param, "value");
+ ftdm_conf_node_add_param(list, var, val);
+ }
+
+ /* add relay channels */
+ if (add_config_list_nodes(isup, rootnode, "sng_relay", "relay_channel", NULL, NULL)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process sng_relay for sng_isup config %s\n", confname);
+ ftdm_conf_node_destroy(rootnode);
+ return NULL;
+ }
+
+ /* add mtp1 links */
+ if (add_config_list_nodes(isup, rootnode, "mtp1_links", "mtp1_link", NULL, NULL)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp1_links for sng_isup config %s\n", confname);
+ ftdm_conf_node_destroy(rootnode);
+ return NULL;
+ }
+
+ /* add mtp2 links */
+ if (add_config_list_nodes(isup, rootnode, "mtp2_links", "mtp2_link", NULL, NULL)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp2_links for sng_isup config %s\n", confname);
+ ftdm_conf_node_destroy(rootnode);
+ return NULL;
+ }
+
+ /* add mtp3 links */
+ if (add_config_list_nodes(isup, rootnode, "mtp3_links", "mtp3_link", NULL, NULL)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp3_links for sng_isup config %s\n", confname);
+ ftdm_conf_node_destroy(rootnode);
+ return NULL;
+ }
+
/* add mtp linksets */
- if (add_config_list_nodes(isup, rootnode, "mtp_linksets", "mtp_linkset", "mtp_links", "mtp_link")) {
+ if (add_config_list_nodes(isup, rootnode, "mtp_linksets", "mtp_linkset", NULL, NULL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp_linksets for sng_isup config %s\n", confname);
ftdm_conf_node_destroy(rootnode);
return NULL;
}
/* add mtp routes */
- if (add_config_list_nodes(isup, rootnode, "mtp_routes", "mtp_route", NULL, NULL)) {
+ if (add_config_list_nodes(isup, rootnode, "mtp_routes", "mtp_route", "linksets", "linkset")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp_routes for sng_isup config %s\n", confname);
ftdm_conf_node_destroy(rootnode);
return NULL;
@@ -2426,6 +2464,13 @@ static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confn
return NULL;
}
+ /* add cc spans */
+ if (add_config_list_nodes(isup, rootnode, "cc_spans", "cc_span", NULL, NULL)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process cc_spans for sng_isup config %s\n", confname);
+ ftdm_conf_node_destroy(rootnode);
+ return NULL;
+ }
+
switch_core_hash_insert(globals.ss7_configs, confname, rootnode);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added SS7 node configuration %s\n", confname);
@@ -2645,7 +2690,7 @@ static switch_status_t load_config(void)
ftdm_conf_parameter_t spanparameters[30];
char *id = (char *) switch_xml_attr(myspan, "id");
char *name = (char *) switch_xml_attr(myspan, "name");
- char *configname = (char *) switch_xml_attr(myspan, "config");
+ char *configname = (char *) switch_xml_attr(myspan, "cfgprofile");
ftdm_span_t *span = NULL;
uint32_t span_id = 0;
unsigned paramindex = 0;
@@ -4206,7 +4251,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
switch_console_set_complete("add ftdm gains");
switch_console_set_complete("add ftdm dtmf on");
switch_console_set_complete("add ftdm dtmf off");
-
+ switch_console_set_complete("add ftdm core state");
+ switch_console_set_complete("add ftdm core flag");
+ switch_console_set_complete("add ftdm core calls");
SWITCH_ADD_APP(app_interface, "disable_ec", "Disable Echo Canceller", "Disable Echo Canceller", disable_ec_function, "", SAF_NONE);
SWITCH_ADD_APP(app_interface, "disable_dtmf", "Disable DTMF Detection", "Disable DTMF Detection", disable_dtmf_function, "", SAF_NONE);
diff --git a/libs/freetdm/msvc/freetdm.2010.vcxproj b/libs/freetdm/msvc/freetdm.2010.vcxproj
index 71eb6dbf22..aecb9ef79c 100644
--- a/libs/freetdm/msvc/freetdm.2010.vcxproj
+++ b/libs/freetdm/msvc/freetdm.2010.vcxproj
@@ -188,6 +188,7 @@
+
@@ -209,6 +210,7 @@
+
diff --git a/libs/freetdm/msvc/freetdm.2010.vcxproj.filters b/libs/freetdm/msvc/freetdm.2010.vcxproj.filters
index ed642baf3d..e6dc40d372 100644
--- a/libs/freetdm/msvc/freetdm.2010.vcxproj.filters
+++ b/libs/freetdm/msvc/freetdm.2010.vcxproj.filters
@@ -71,6 +71,9 @@
Header Files
+
+ Header Files
+
@@ -124,5 +127,8 @@
Source Files
+
+ Source Files
+
\ No newline at end of file
diff --git a/libs/freetdm/msvc/testboost/testboost.2010.vcxproj b/libs/freetdm/msvc/testboost/testboost.2010.vcxproj
index 62061485c2..314440bf9f 100644
--- a/libs/freetdm/msvc/testboost/testboost.2010.vcxproj
+++ b/libs/freetdm/msvc/testboost/testboost.2010.vcxproj
@@ -105,7 +105,7 @@
4100;%(DisableSpecificWarnings)
- ..\..\debug\freetdm.lib;%(AdditionalDependencies)
+ %(AdditionalDependencies)
true
Console
false
@@ -162,7 +162,7 @@
4100;%(DisableSpecificWarnings)
- freetdm.lib;%(AdditionalDependencies)
+ %(AdditionalDependencies)
true
Console
false
@@ -199,7 +199,7 @@
MachineX64
- freetdm.lib;%(AdditionalDependencies)
+ %(AdditionalDependencies)
../../$(PlatformName)\$(Configuration);%(AdditionalLibraryDirectories)
diff --git a/libs/freetdm/msvc/testboost/testsangomaboost.2010.vcxproj b/libs/freetdm/msvc/testboost/testsangomaboost.2010.vcxproj
index 5994da6f1a..4077a60aba 100644
--- a/libs/freetdm/msvc/testboost/testsangomaboost.2010.vcxproj
+++ b/libs/freetdm/msvc/testboost/testsangomaboost.2010.vcxproj
@@ -105,7 +105,7 @@
4100;%(DisableSpecificWarnings)
- ..\..\debug\freetdm.lib;%(AdditionalDependencies)
+ %(AdditionalDependencies)
true
Console
false
@@ -162,7 +162,7 @@
4100;%(DisableSpecificWarnings)
- freetdm.lib;%(AdditionalDependencies)
+ %(AdditionalDependencies)
true
Console
false
@@ -199,7 +199,7 @@
MachineX64
- freetdm.lib;%(AdditionalDependencies)
+ %(AdditionalDependencies)
../../$(PlatformName)\$(Configuration);%(AdditionalLibraryDirectories)
diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c
index 529a30f120..cd2c4850a4 100644
--- a/libs/freetdm/src/ftdm_io.c
+++ b/libs/freetdm/src/ftdm_io.c
@@ -65,7 +65,6 @@ 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_clear_vars(ftdm_channel_t *ftdmchan);
static ftdm_status_t ftdm_channel_done(ftdm_channel_t *ftdmchan);
static int time_is_init = 0;
@@ -2176,8 +2175,6 @@ static ftdm_status_t _ftdm_channel_call_hangup_nl(const char *file, const char *
{
ftdm_status_t status = FTDM_SUCCESS;
- ftdm_set_echocancel_call_end(chan);
-
if (chan->state != FTDM_CHANNEL_STATE_DOWN) {
if (chan->state == FTDM_CHANNEL_STATE_HANGUP) {
/* make user's life easier, and just ignore double hangup requests */
@@ -2506,10 +2503,12 @@ FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, i
}
/* we have a locked channel and are not afraid of using it! */
- status = hunting->result_cb(fchan, caller_data);
- if (status != FTDM_SUCCESS) {
- status = FTDM_ECANCELED;
- goto done;
+ if (hunting->result_cb) {
+ status = hunting->result_cb(fchan, caller_data);
+ if (status != FTDM_SUCCESS) {
+ status = FTDM_ECANCELED;
+ goto done;
+ }
}
ftdm_channel_set_caller_data(fchan, caller_data);
@@ -2631,7 +2630,6 @@ 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);
- ftdm_channel_clear_vars(ftdmchan);
if (ftdmchan->hangup_timer) {
ftdm_sched_cancel_timer(globals.timingsched, ftdmchan->hangup_timer);
}
@@ -2741,10 +2739,9 @@ static ftdm_status_t ftdmchan_activate_dtmf_buffer(ftdm_channel_t *ftdmchan)
if (!ftdmchan->dtmf_buffer) {
if (ftdm_buffer_create(&ftdmchan->dtmf_buffer, 1024, 3192, 0) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Failed to allocate DTMF Buffer!\n");
- snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "buffer error");
return FTDM_FAIL;
} else {
- ftdm_log(FTDM_LOG_DEBUG, "Created DTMF Buffer!\n");
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Created DTMF buffer\n");
}
}
@@ -3586,8 +3583,17 @@ static FIO_READ_FUNCTION(ftdm_raw_read)
return status;
}
-static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)
+/* This function takes care of automatically generating DTMF or FSK tones when needed */
+static ftdm_status_t handle_tone_generation(ftdm_channel_t *ftdmchan)
{
+ /*
+ * datalen: size in bytes of the chunk of data the user requested to read (this function
+ * is called from the ftdm_channel_read function)
+ * dblen: size currently in use in any of the tone generation buffers (data available in the buffer)
+ * gen_dtmf_buffer: buffer holding the raw ASCII digits that the user requested to generate
+ * dtmf_buffer: raw linear tone data generated by teletone to be written to the devices
+ * fsk_buffer: raw linear FSK modulated data for caller id
+ */
ftdm_buffer_t *buffer = NULL;
ftdm_size_t dblen = 0;
int wrote = 0;
@@ -3602,7 +3608,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)
}
if (ftdm_buffer_read(ftdmchan->gen_dtmf_buffer, digits, dblen) && !ftdm_strlen_zero_buf(digits)) {
- ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generating DTMF [%s]\n", digits);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Generating DTMF [%s]\n", digits);
cur = digits;
@@ -3616,7 +3622,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)
ftdm_buffer_write(ftdmchan->dtmf_buffer, ftdmchan->tone_session.buffer, wrote * 2);
x++;
} else {
- ftdm_log(FTDM_LOG_ERROR, "%d:%d Problem Adding DTMF SEQ [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, digits);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Problem adding DTMF sequence [%s]\n", digits);
return FTDM_FAIL;
}
}
@@ -3629,6 +3635,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)
if (!ftdmchan->buffer_delay || --ftdmchan->buffer_delay == 0) {
+ /* time to pick a buffer, either the dtmf or fsk buffer */
if (ftdmchan->dtmf_buffer && (dblen = ftdm_buffer_inuse(ftdmchan->dtmf_buffer))) {
buffer = ftdmchan->dtmf_buffer;
} else if (ftdmchan->fsk_buffer && (dblen = ftdm_buffer_inuse(ftdmchan->fsk_buffer))) {
@@ -3636,22 +3643,39 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)
}
}
+ /* if we picked a buffer, time to read from it and write the linear data to the device */
if (buffer) {
- ftdm_size_t dlen = datalen;
uint8_t auxbuf[1024];
+ ftdm_size_t dlen = ftdmchan->packet_len;
ftdm_size_t len, br, max = sizeof(auxbuf);
+ /* if the codec is not linear, then data is really twice as much cuz
+ tone generation is done in linear (we assume anything different than linear is G.711) */
if (ftdmchan->native_codec != FTDM_CODEC_SLIN) {
dlen *= 2;
}
-
+
+ /* we do not expect the user chunks to be bigger than auxbuf */
+ ftdm_assert((dlen <= sizeof(auxbuf)), "Unexpected size for user data chunk size\n");
+
+ /* dblen is the size in use for dtmf_buffer or fsk_buffer, and dlen is the size
+ * of the io chunks to write, we pick the smaller one */
len = dblen > dlen ? dlen : dblen;
+ /* we can't read more than the size of our auxiliary buffer */
+ ftdm_assert((len <= sizeof(auxbuf)), "Unexpected size to read into auxbuf\n");
+
br = ftdm_buffer_read(buffer, auxbuf, len);
+
+ /* the amount read can't possibly be bigger than what we requested */
+ ftdm_assert((br <= len), "Unexpected size read from tone generation buffer\n");
+
+ /* if we read less than the chunk size, we must fill in with silence the rest */
if (br < dlen) {
memset(auxbuf + br, 0, dlen - br);
}
+ /* finally we convert to the native format for the channel if necessary */
if (ftdmchan->native_codec != FTDM_CODEC_SLIN) {
if (ftdmchan->native_codec == FTDM_CODEC_ULAW) {
fio_slin2ulaw(auxbuf, max, &dlen);
@@ -3660,6 +3684,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)
}
}
+ /* write the tone to the channel */
return ftdm_raw_write(ftdmchan, auxbuf, &dlen);
}
@@ -3739,7 +3764,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data
rdata[i] = ftdmchan->rxgain_table[rdata[i]];
}
}
- handle_dtmf(ftdmchan, *datalen);
+ handle_tone_generation(ftdmchan);
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) && ftdmchan->effective_codec != ftdmchan->native_codec) {
if (ftdmchan->native_codec == FTDM_CODEC_ULAW && ftdmchan->effective_codec == FTDM_CODEC_SLIN) {
@@ -3936,7 +3961,8 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *dat
if (!ftdmchan->buffer_delay &&
((ftdmchan->dtmf_buffer && ftdm_buffer_inuse(ftdmchan->dtmf_buffer)) ||
(ftdmchan->fsk_buffer && ftdm_buffer_inuse(ftdmchan->fsk_buffer)))) {
- /* read size writing DTMF ATM */
+ /* generating some kind of tone at the moment (see handle_tone_generation),
+ * we ignore user data ... */
goto done;
}
@@ -4003,20 +4029,13 @@ done:
}
FT_DECLARE(void) ftdm_call_clear_data(ftdm_caller_data_t *caller_data)
-{
- ftdm_call_clear_vars(caller_data);
- memset(&caller_data->raw_data, 0, sizeof(caller_data->raw_data));
- caller_data->raw_data_len = 0;
- return;
-}
-
-FT_DECLARE(ftdm_status_t) ftdm_call_clear_vars(ftdm_caller_data_t *caller_data)
{
if (caller_data->variables) {
hashtable_destroy(caller_data->variables);
}
caller_data->variables = NULL;
- return FTDM_SUCCESS;
+ 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)
@@ -4028,7 +4047,6 @@ FT_DECLARE(ftdm_status_t) ftdm_call_remove_var(ftdm_caller_data_t *caller_data,
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;
@@ -4095,72 +4113,6 @@ FT_DECLARE(ftdm_status_t) ftdm_call_get_current_var(ftdm_iterator_t *iter, const
return FTDM_SUCCESS;
}
-
-static ftdm_status_t ftdm_channel_clear_vars(ftdm_channel_t *ftdmchan)
-{
- ftdm_channel_lock(ftdmchan);
-
- if (ftdmchan->variable_hash) {
- hashtable_destroy(ftdmchan->variable_hash);
- }
- ftdmchan->variable_hash = NULL;
-
- ftdm_channel_unlock(ftdmchan);
- return FTDM_SUCCESS;
-}
-
-FT_DECLARE(ftdm_status_t) ftdm_channel_add_var(ftdm_channel_t *ftdmchan, const char *var_name, const char *value)
-{
- char *t_name = 0, *t_val = 0;
-
- ftdm_status_t status = FTDM_FAIL;
-
- if (!var_name || !value) {
- return FTDM_FAIL;
- }
-
- ftdm_channel_lock(ftdmchan);
-
- if (!ftdmchan->variable_hash) {
- /* initialize on first use */
- ftdmchan->variable_hash = create_hashtable(16, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
- if (!ftdmchan->variable_hash) {
- goto done;
- }
- }
-
- t_name = ftdm_strdup(var_name);
- t_val = ftdm_strdup(value);
-
- hashtable_insert(ftdmchan->variable_hash, t_name, t_val, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE);
-
- status = FTDM_SUCCESS;
-
-done:
- ftdm_channel_unlock(ftdmchan);
-
- return status;
-}
-
-
-FT_DECLARE(const char *) ftdm_channel_get_var(ftdm_channel_t *ftdmchan, const char *var_name)
-{
- const char *var = NULL;
-
- ftdm_channel_lock(ftdmchan);
-
- if (!ftdmchan->variable_hash || !var_name) {
- goto done;
- }
-
- var = (const char *)hashtable_search(ftdmchan->variable_hash, (void *)var_name);
-
-done:
- ftdm_channel_unlock(ftdmchan);
-
- return var;
-}
-
static ftdm_iterator_t *get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter)
{
int allocated = 0;
@@ -4185,25 +4137,6 @@ static ftdm_iterator_t *get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t
return iter;
}
-FT_DECLARE(ftdm_iterator_t *) ftdm_channel_get_var_iterator(const ftdm_channel_t *ftdmchan, ftdm_iterator_t *iter)
-{
- ftdm_hash_iterator_t *hashiter = NULL;
- ftdm_channel_lock(ftdmchan);
- hashiter = ftdmchan->variable_hash == NULL ? NULL : hashtable_first(ftdmchan->variable_hash);
- ftdm_channel_unlock(ftdmchan);
-
-
- if (hashiter == NULL) {
- return NULL;
- }
-
- if (!(iter = get_iterator(FTDM_ITERATOR_VARS, iter))) {
- return NULL;
- }
- iter->pvt.hashiter = hashiter;
- return iter;
-}
-
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))) {
@@ -4214,24 +4147,6 @@ FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *spa
return iter;
}
-FT_DECLARE(ftdm_status_t) ftdm_channel_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_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter)
{
ftdm_assert_return(iter && iter->type, NULL, "Invalid iterator\n");
@@ -4949,7 +4864,7 @@ FT_DECLARE(int) ftdm_load_module(const char *name)
{
ftdm_dso_lib_t lib;
int count = 0, x = 0;
- char path[128] = "";
+ char path[512] = "";
char *err;
ftdm_module_t *mod;
@@ -5502,6 +5417,7 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t
sigmsg->chan_id = sigmsg->channel->chan_id;
sigmsg->span_id = sigmsg->channel->span_id;
sigmsg->call_id = sigmsg->channel->caller_data.call_id;
+ sigmsg->call_priv = sigmsg->channel->caller_data.priv;
}
/* some core things to do on special events */
@@ -5533,10 +5449,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t
}
ftdm_set_flag(sigmsg->channel, FTDM_CHANNEL_CALL_STARTED);
ftdm_call_set_call_id(sigmsg->channel, &sigmsg->channel->caller_data);
- if (sigmsg->channel->dtmfdbg.requested) {
- ftdm_channel_command(sigmsg->channel, FTDM_COMMAND_ENABLE_DEBUG_DTMF, NULL);
- }
-
/* when cleaning up the public API I added this because mod_freetdm.c on_fxs_signal was
* doing it during SIGEVENT_START, but now that flags are private they can't, wonder if
* is needed at all?
diff --git a/libs/freetdm/src/ftdm_state.c b/libs/freetdm/src/ftdm_state.c
index de62c0f0e7..9fe2b911dc 100644
--- a/libs/freetdm/src/ftdm_state.c
+++ b/libs/freetdm/src/ftdm_state.c
@@ -83,6 +83,8 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_complete_state(const char *file, const c
msg.channel = fchan;
msg.event_id = FTDM_SIGEVENT_DIALING;
ftdm_span_send_signal(fchan->span, &msg);
+ } else if (state == FTDM_CHANNEL_STATE_HANGUP) {
+ ftdm_set_echocancel_call_end(fchan);
}
/* MAINTENANCE WARNING
diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
index 0217a5172a..540d7cb6e9 100644
--- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
+++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
@@ -676,12 +676,6 @@ static void ftdm_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, cons
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");
- /* nothing went wrong during call setup, MF has ended, we can and must disable the MF dump */
- if (r2data->mf_dump_size) {
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_INPUT_DUMP, NULL);
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_OUTPUT_DUMP, NULL);
- }
-
/* 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");
@@ -720,25 +714,41 @@ static void dump_mf(openr2_chan_t *r2chan)
{
char dfile[512];
FILE *f = NULL;
+ int rc = 0;
ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan);
ftdm_r2_data_t *r2data = ftdmchan->span->signal_data;
if (r2data->mf_dump_size) {
char *logname = R2CALL(ftdmchan)->logname;
- ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in prefix %s\n", logname);
- snprintf(dfile, sizeof(dfile), logname ? "%s.s%dc%d.input.alaw" : "%s/s%dc%d.input.alaw",
- logname ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id);
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in prefix %s\n", !ftdm_strlen_zero(logname)
+ ? logname : r2data->logdir);
+ snprintf(dfile, sizeof(dfile), !ftdm_strlen_zero(logname) ? "%s.s%dc%d.input.alaw" : "%s/s%dc%d.input.alaw",
+ !ftdm_strlen_zero(logname) ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id);
f = fopen(dfile, "wb");
- ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO input in file %s\n", dfile);
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, f);
- fclose(f);
+ if (f) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO input in file %s\n", dfile);
+ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, f);
+ rc = fclose(f);
+ if (rc) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failure closing IO input file %s: %s\n", dfile, strerror(errno));
+ }
+ } else {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Could not dump IO input in file %s, error: %s", dfile, strerror(errno));
+ }
- snprintf(dfile, sizeof(dfile), logname ? "%s.s%dc%d.output.alaw" : "%s/s%dc%d.output.alaw",
- logname ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id);
+ snprintf(dfile, sizeof(dfile), !ftdm_strlen_zero(logname) ? "%s.s%dc%d.output.alaw" : "%s/s%dc%d.output.alaw",
+ !ftdm_strlen_zero(logname) ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id);
f = fopen(dfile, "wb");
- ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in file %s\n", dfile);
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_OUTPUT, f);
- fclose(f);
+ if (f) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in file %s\n", dfile);
+ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_OUTPUT, f);
+ rc = fclose(f);
+ if (rc) {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failure closing IO output file %s: %s\n", dfile, strerror(errno));
+ }
+ } else {
+ ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Could not dump IO output in file %s, error: %s", dfile, strerror(errno));
+ }
}
}
@@ -761,6 +771,12 @@ static void ftdm_r2_on_call_accepted(openr2_chan_t *r2chan, openr2_call_mode_t m
R2CALL(ftdmchan)->accepted = 1;
+ /* nothing went wrong during call setup, MF has ended, we can and must disable the MF dump */
+ if (r2data->mf_dump_size) {
+ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_INPUT_DUMP, NULL);
+ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_OUTPUT_DUMP, NULL);
+ }
+
if (OR2_DIR_BACKWARD == openr2_chan_get_direction(r2chan)) {
if (R2CALL(ftdmchan)->answer_pending) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Answer was pending, answering now.\n");
@@ -769,11 +785,6 @@ static void ftdm_r2_on_call_accepted(openr2_chan_t *r2chan, openr2_call_mode_t m
return;
}
} else {
- /* nothing went wrong during call setup, MF has ended, we can and must disable the MF dump */
- if (r2data->mf_dump_size) {
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_INPUT_DUMP, NULL);
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_OUTPUT_DUMP, NULL);
- }
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
}
}
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/BOOST.limitations b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/BOOST.limitations
deleted file mode 100644
index 663b7d376a..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/BOOST.limitations
+++ /dev/null
@@ -1,20 +0,0 @@
-== Boost sigmod current limitations ==
-- we don't support having openzap spans with physical channels
- belonging to other physical spans. this is due to netborder sangoma abstraction, therefore
- any openzap span using sigboost must have only channels belonging to the corresponding
- physical span.
-
- This is the reason we added group functionality in openzap core, furthermore, previous groups in openzap
- were only possible through adding of b-channels to a single span, but this forces the user to create groups
- of channels only whithin the same type of trunk among other things.
-
-- all spans must be configured and then started, cannot configure, start, configure start etc
- this is due to netborder telesoft abstraction. that requires configuring everything and
- then starting everything at once.
-
-- sangoma_prid and sangoma_brid on Windows had to be compiled hacking make/Makefile.platform to comment all VC runtime checks,
- otherwise when running in debug mode exceptions are thrown due to loss of data ie short to char conversions.
-
-== TODO ==
-- proper upper layer management of HW alarms (this must be done in mod_openzap.c)
-
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/boost-tasks.txt b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/boost-tasks.txt
deleted file mode 100644
index f0eab3a277..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/boost-tasks.txt
+++ /dev/null
@@ -1,146 +0,0 @@
-== General Design ==
-
-NBE will do its current loading of spans and configuration process through Sangoma Board Manager (SBM).
-After doing SangomaBoardManager::getInstance().configure -> start. It will proceed to initalize
-the openzap stack (just as the TelesoftStack is loaded after starting SMB. The procedure will be:
-
-- create a static or malloced zap_io_interface_t
-- call zap_global_set_logger with the logging hooks.
-- call zap_global_set_memhandler() with the memory hooks.
-- call zap_global_init() to initialize the stack
-- call zap_add_io_iface() to add the I/O iface.
-- iterate over all SBM spans configured for BRI or any boost-managed signaling and:
- * call zap_span_create(NBE I/O mod, in_ptrSpan, SMB span name)
- * Fill in some members like:
- span->trunk_type = E1/T1/J1/FXO/FXS etc ...
- * iterate over all channels in SMB span and:
- * zap_span_add_channel(zap_span, sock, type:CAS|BCHAN|DCHAN|ETC)
- * call zap_configure_span("sangoma_boost", span, sigmsg_callback, "param1", value1, "param2", value1 ...)
- * zap_span_start(span);
-
-
-At this point, NBE would receive signaling msgs via sigmsg_callback registered when configuring
-and NBE would request hangup or making calls throug openzap API, like zap_set_state_* and zap_channel_outgoing_call() to place calls.
-
-When NBE wants to check for link status.
-
- zap_get_siglink_state() which would return
- ZAP_SIG_STATE_UP (D-chan UP, R2 bits in IDLE, ss7?)
- ZAP_SIG_STATE_SUSPENDED (D-chan in power saving mode?)
- ZAP_SIG_STATE_DOWN (D-chan down, R2 bits in blocked, ss7?)
-
- Whenever a state in sig link changes, the sigmsg_callback will be used to notify NBE or any other user.
-
-NOTE: right now hardware alarms notification in openzap is seriously broken,
-see ozmod_libpri.c process_event ... reads an event from hardware (zap_event_t *),
-then checks the event type, if its ZAP_OOB_ALARM_TRAP prepares a zap_sigmsg_t
-(signaling event) setting its event_id to ZAP_OOB_ALARM_TRAP, which is *WRONG*
-because event_id is of type zap_signal_event_t and not zap_oob_event_t!
-this means on alarm the user will get ZAP_SIGEVENT_PROGRESS_MEDIA!! which is
-value 7 that is in conflict with ZAP_OOB_ALARM_TRAP, I think a separate
-callback should be used if the outside user wants to be notified about
-hardware events like HW DTMF or so. Currently there is alreadya generic DTMF
-listener.
-
-== Tasks Stage 1 / OpenZAP and Boost changes (To be tested with FreeSWITCH) ==
-
-- Change malloc and other mem functions in openzap
- to use internal hooks provided via zap_global_set_memhandler()
- which would be called before zap_global_init(), this is
- already done for the logger via zap_global_set_logger()
-
- question: should the mem routines allow for memory pool ptr?
- this could be useful to provide a memory pool to
- the whole module.
-
- question: should we allow hooks for threads and locking?
- I think we can skip this one unless needed. They already
- use their own threading abstraction which is working for
- Linux and Windows. If we ever need to profile threading
- we can add profiling hooks.
-
- question: I had to add openzap calls to the hash table and libteletone implementations, is that acceptable?
-
-- Modify zap_global_init() API
-
- This API must just initialize vars, mutexes etc.
- and NOT DO ANY CONFIGURATION LOADING, PARSING, SPAN CREATION and I/O
- configuration, which is what is currently doing.
- We don't want zap_global_init() to create the spans based on that configuration
- since NBE will have its own configuration and will take care of creating
- the needed data structures on its own.
-
-- Add new zap_std_io_config() API
-
- This API will parse the standard openzap.conf module and create the spans.
- This will be used by FS but not by NBE, which will create the openzap spans by itself.
- The NBE flow to initialize openzap will be:
-
-- Add new API zap_global_add_io_iface(),
-
- This API will add a new I/O interface structure to the internal openzap hash of I/O structs.
- This is needed because NBE I/O structure will NOT be loaded from an openzap module (.so/.dll)
- but rather just registered on runtime (probably from a static structure in NBE code).
- This openzap hash is used by zap_api_execute() for example, to find the module that can
- handle a given API, ie (oz libpri status). This is an example of how an openzap I/O interface
- can decide to implement just the ->api() member to handle commands and NOTHING else,
- so I/O interfaces not necessary are hardware-related.
-
-- Add new zap_channel_get_siglink_state(zap_channel, zap_siglink_status_t &status)
-
-- Modify mod_openzap.c to read proto= setting in boost spans, this will determine wich boost sig
- module will handle the configuration and those channels.
-
-
-
- Then as first config arg to zap_config_span() the boost proto module name would be included as "sigmod" which will be used
- by ozmod_sangoma_boost to decide which sig module must handle that span configuration
-
-- Create minimal boost mod interface.
-
- ozmod_boost_ss7 should load sig boost mods and get interface via dlsym(boost_get_interface) boost_get_interface(boost_iface);
- The boost interface will have
- * const char *name // boost sigmod name (brid,ss7d)
- * set_write_boost_msg_cb(callback) // tell the stack how to send us boost messages
- * set_sig_status_cb(callback); // tell the stack how to notify us about link status changes
- * write_boost_msg(struct boost_msg) // send a boost msg to the stack
- * configure_span(zap_span_t span, "configuration", value, "configuration", value) // configure a given span
- * get_sig_status(openzap_sigstatus_t status)
- * start(span) // to start a given openzap span
- * stop(span) // to stop the stack on a given openzap span
-
-- Migrate current sangoma_brid sig module to openzap
- * Make sangoma_brid a library
- * Move from using malloc, threading, locking, logging and I/O to openzap functions. Export the boost sigmod interface and its supporting code.
-
-== State 2 Tasks ==
-
-- Create the I/O NBE interface and supporting functions. It must be possible to poll over the span
- given that ozmod_sangoma_boost BRI module and others may need to *wait* for data. The poll()
- function in I/O NBE interface would wait on a pthread condition or Windows event, which would
- be triggered by some external NBE component registered with Sangoma Board Manager (SMB) for d-chan
- data, whenever d-chan data arrives, saves the data in a buffer and triggers the condition to wakeup
- any waiter, then the waiter (sangoma_brid or any other boost client) calls zap_channel_read which calls
- our own I/O NBE interface read method and retrieves the data from the buffer.
-
- Dropped alternative design:
- Another option is to add a new API zap_span_push_incoming_data(span/chan, data); However this changes
- the model openzap has followed and I don't think fits that well, since now we have 2 different models
- to support in openzap.
-
-== TODO ==
-
-- how about logging specific modules, like, just ozmod_boost, or just the BRI stack?
- more work to be done so the BRI module uses zap_log instead of current syslog
- then work to be done to be able to filter logs from specific openzap code? is it worth it?
-
-- remove FORCE_SEGFAULT from sprid
-
-
-=== Shortcomings ==
-
-- we had to drop smg support in the branch where we work on sangoma prid.
- After all, most people using sangoma_prid is using freeswitch/openzap and not Sangoma Media Gateway
- The problem is in freeswitch/openzap mode, sangoma_boost ozmod takes care of span events (POLLPRI)
- where in SMG and Netborder POLLPRI is done typically by sangoma board manager.
-
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftdm_sangoma_boost.h b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftdm_sangoma_boost.h
deleted file mode 100644
index 6fbf272d07..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftdm_sangoma_boost.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2007, Anthony Minessale II
- * 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 FTDM_SANGOMA_BOOST_H
-#define FTDM_SANGOMA_BOOST_H
-#include "sangoma_boost_client.h"
-#include "freetdm.h"
-
-#define MAX_CHANS_PER_TRUNKGROUP 1024
-
-typedef enum {
- FTDM_SANGOMA_BOOST_RUNNING = (1 << 0),
- FTDM_SANGOMA_BOOST_RESTARTING = (1 << 1),
- FTDM_SANGOMA_BOOST_EVENTS_RUNNING = (1 << 2),
-} ftdm_sangoma_boost_flag_t;
-
-typedef struct ftdm_sangoma_boost_data {
- sangomabc_connection_t mcon;
- sangomabc_connection_t pcon;
- int iteration;
- uint32_t flags;
- boost_sigmod_interface_t *sigmod;
- ftdm_queue_t *boost_queue;
-} ftdm_sangoma_boost_data_t;
-
-typedef struct ftdm_sangoma_boost_trunkgroup {
- ftdm_mutex_t *mutex;
- ftdm_size_t size; /* Number of b-channels in group */
- unsigned int last_used_index; /* index of last b-channel used */
- ftdm_channel_t* ftdmchans[MAX_CHANS_PER_TRUNKGROUP];
- //TODO need to merge congestion timeouts to this struct
-} ftdm_sangoma_boost_trunkgroup_t;
-#endif
-
-/* 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:
- */
-
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2008.vcproj
deleted file mode 100644
index 73e421818f..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2008.vcproj
+++ /dev/null
@@ -1,373 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2010.vcxproj b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2010.vcxproj
deleted file mode 100644
index 78689c36db..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2010.vcxproj
+++ /dev/null
@@ -1,206 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Debug
- x64
-
-
- Release
- Win32
-
-
- Release
- x64
-
-
-
- ftmod_sangoma_boost
- {D021EF2A-460D-4827-A0F7-41FDECF46F1B}
- ftmod_sangoma_boost
- Win32Proj
-
-
-
- DynamicLibrary
- Unicode
- true
-
-
- DynamicLibrary
- Unicode
-
-
- DynamicLibrary
- Unicode
- true
-
-
- DynamicLibrary
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>10.0.30319.1
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- true
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
- false
- $(SolutionDir)$(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- true
- $(SolutionDir)$(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- false
- AllRules.ruleset
-
-
- AllRules.ruleset
-
-
- AllRules.ruleset
-
-
- AllRules.ruleset
-
-
-
-
-
- Disabled
- ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
-
-
- Level4
- true
- EditAndContinue
- 4100;%(DisableSpecificWarnings)
-
-
- freetdm.lib;%(AdditionalDependencies)
- $(OutDir);%(AdditionalLibraryDirectories)
- true
- Windows
- MachineX86
-
-
-
-
- MaxSpeed
- true
- ..\..\include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)
- MultiThreadedDLL
- true
-
-
- Level4
- true
- ProgramDatabase
- 4100;%(DisableSpecificWarnings)
-
-
- true
- Windows
- true
- true
- MachineX86
-
-
-
-
- X64
-
-
- Disabled
- ..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)
- true
- EnableFastChecks
- MultiThreadedDebugDLL
-
-
- Level4
- true
- ProgramDatabase
- 4100;%(DisableSpecificWarnings)
-
-
- freetdm.lib;%(AdditionalDependencies)
- $(OutDir);%(AdditionalLibraryDirectories)
- true
- Windows
- MachineX64
-
-
-
-
- X64
-
-
- MaxSpeed
- true
- ..\..\include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)
- MultiThreadedDLL
- true
-
-
- Level4
- false
- ProgramDatabase
- 4100;%(DisableSpecificWarnings)
-
-
- true
- Windows
- true
- true
- MachineX64
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {93b8812c-3ec4-4f78-8970-ffbfc99e167d}
- false
-
-
-
-
-
-
\ No newline at end of file
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2010.vcxproj.filters b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2010.vcxproj.filters
deleted file mode 100644
index 2aeed155cd..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2010.vcxproj.filters
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
\ No newline at end of file
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c
deleted file mode 100644
index d0bc14c8d8..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c
+++ /dev/null
@@ -1,2730 +0,0 @@
-/*
- * Copyright (c) 2007, Anthony Minessale II
- * 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
- * David Yat Sin
- * Nenad Corbic
- *
- */
-
-/* NOTE:
-On __WINDOWS__ platform this code works with sigmod ONLY, don't try to make sense of any socket code for win
-I basically ifdef out everything that the compiler complained about
-*/
-
-#include "private/ftdm_core.h"
-#include "sangoma_boost_client.h"
-#include "ftdm_sangoma_boost.h"
-#ifdef HAVE_SYS_SELECT_H
-#include
-#endif
-
-/* Boost signaling modules global hash and its mutex */
-ftdm_mutex_t *g_boost_modules_mutex = NULL;
-ftdm_hash_t *g_boost_modules_hash = NULL;
-
-#define MAX_TRUNK_GROUPS 64
-//TODO need to merge congestion_timeouts with ftdm_sangoma_boost_trunkgroups
-static time_t congestion_timeouts[MAX_TRUNK_GROUPS];
-
-static ftdm_sangoma_boost_trunkgroup_t *g_trunkgroups[MAX_TRUNK_GROUPS];
-
-static ftdm_io_interface_t ftdm_sangoma_boost_interface;
-static ftdm_status_t ftdm_sangoma_boost_list_sigmods(ftdm_stream_handle_t *stream);
-
-#define BOOST_QUEUE_SIZE 500
-
-/* get freetdm span and chan depending on the span mode */
-#define BOOST_SPAN(ftdmchan) ((ftdm_sangoma_boost_data_t*)(ftdmchan)->span->signal_data)->sigmod ? ftdmchan->physical_span_id : ftdmchan->physical_span_id-1
-#define BOOST_CHAN(ftdmchan) ((ftdm_sangoma_boost_data_t*)(ftdmchan)->span->signal_data)->sigmod ? ftdmchan->physical_chan_id : ftdmchan->physical_chan_id-1
-
-/**
- * \brief SANGOMA boost notification flag
- */
-typedef enum {
- SFLAG_SENT_FINAL_MSG = (1 << 0),
- SFLAG_SENT_ACK = (1 << 1),
- SFLAG_RECVD_ACK = (1 << 2),
- SFLAG_HANGUP = (1 << 3),
- SFLAG_TERMINATING = (1 << 4)
-} sflag_t;
-
-typedef uint16_t sangoma_boost_request_id_t;
-
-/**
- * \brief SANGOMA boost request status
- */
-typedef enum {
- BST_FREE,
- BST_WAITING,
- BST_READY,
- BST_FAIL
-} sangoma_boost_request_status_t;
-
-/**
- * \brief SANGOMA boost request structure
- */
-typedef struct {
- sangoma_boost_request_status_t status;
- sangomabc_short_event_t event;
- ftdm_span_t *span;
- ftdm_channel_t *ftdmchan;
- int hangup_cause;
- int flags;
-} sangoma_boost_request_t;
-
-typedef struct {
- int call_setup_id;
- int last_event_id;
-} sangoma_boost_call_t;
-
-#define CALL_DATA(ftdmchan) ((sangoma_boost_call_t*)((ftdmchan)->call_data))
-
-//#define MAX_REQ_ID FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN * FTDM_MAX_CHANNELS_PHYSICAL_SPAN
-#define MAX_REQ_ID 6000
-
-static uint16_t SETUP_GRID[FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN+1][FTDM_MAX_CHANNELS_PHYSICAL_SPAN+1] = {{ 0 }};
-
-static sangoma_boost_request_t OUTBOUND_REQUESTS[MAX_REQ_ID+1] = {{ 0 }};
-
-static ftdm_mutex_t *request_mutex = NULL;
-
-static uint8_t req_map[MAX_REQ_ID+1] = { 0 };
-static uint8_t nack_map[MAX_REQ_ID+1] = { 0 };
-
-/**
- * \brief Releases span and channel from setup grid
- *
- * \note This is ALWAYS based on freetdm span/chan numbers! not boost event numbers
- * is totally brain damaged to use event->span or event->chan to release the request
- * use BOOST_SPAN_EVENT and BOOST_SPAN_CHAN to get the right index!!
- *
- * \param span Span number
- * \param chan Channel number
- * \param func Calling function
- * \param line Line number on request
- * \return NULL if not found, channel otherwise
- */
-static void __release_request_id_span_chan(int span, int chan, const char *func, int line)
-{
- int id;
-
- ftdm_mutex_lock(request_mutex);
- if ((id = SETUP_GRID[span][chan])) {
- ftdm_assert(id <= MAX_REQ_ID, "Invalid request id\n");
- req_map[id] = 0;
- SETUP_GRID[span][chan] = 0;
- }
- ftdm_mutex_unlock(request_mutex);
-}
-#define release_request_id_span_chan(s, c) __release_request_id_span_chan(s, c, __FUNCTION__, __LINE__)
-
-/**
- * \brief Releases request ID
- * \param func Calling function
- * \param line Line number on request
- * \return NULL if not found, channel otherwise
- */
-static void __release_request_id(sangoma_boost_request_id_t r, const char *func, int line)
-{
- ftdm_assert(r <= MAX_REQ_ID, "Invalid request id\n");
- ftdm_mutex_lock(request_mutex);
- req_map[r] = 0;
- ftdm_mutex_unlock(request_mutex);
-}
-#define release_request_id(r) __release_request_id(r, __FUNCTION__, __LINE__)
-
-static sangoma_boost_request_id_t last_req = 0;
-
-/**
- * \brief Gets the first available tank request ID
- * \param func Calling function
- * \param line Line number on request
- * \return 0 on failure, request ID on success
- */
-static sangoma_boost_request_id_t __next_request_id(const char *func, int line)
-{
- sangoma_boost_request_id_t r = 0, i = 0;
- int found=0;
-
- ftdm_mutex_lock(request_mutex);
- //r = ++last_req;
- //while(!r || req_map[r]) {
-
- for (i=1; i<= MAX_REQ_ID; i++){
- r = ++last_req;
-
- if (r >= MAX_REQ_ID) {
- r = last_req = 1;
- }
-
- if (req_map[r]) {
- /* Busy find another */
- continue;
-
- }
-
- req_map[r] = 1;
- found=1;
- break;
-
- }
-
- ftdm_mutex_unlock(request_mutex);
-
- if (!found) {
- return 0;
- }
-
- return r;
-}
-#define next_request_id() __next_request_id(__FUNCTION__, __LINE__)
-
-
-static void print_request_ids(void)
-{
- sangoma_boost_request_id_t i = 0;
- int cnt=0;
-
- ftdm_mutex_lock(request_mutex);
-
- for (i=1; i<= MAX_REQ_ID; i++){
- if (req_map[i]) {
- ftdm_log(FTDM_LOG_CRIT, "Used Request ID=%i\n",i);
- cnt++;
- }
- }
-
- ftdm_mutex_unlock(request_mutex);
- ftdm_log(FTDM_LOG_CRIT, "Total Request IDs=%i\n",cnt);
-
- return;
-}
-
-
-/**
- * \brief Finds the channel that triggered an event
- * \param span Span where to search the channel
- * \param event SANGOMA event
- * \param force Do not wait for the channel to be available if in use
- * \return NULL if not found, channel otherwise
- */
-static ftdm_channel_t *find_ftdmchan(ftdm_span_t *span, sangomabc_short_event_t *event, int force)
-{
- uint32_t i;
- ftdm_channel_t *ftdmchan = NULL;
-
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- uint32_t targetspan = BOOST_EVENT_SPAN(sangoma_boost_data->sigmod, event);
- uint32_t targetchan = BOOST_EVENT_CHAN(sangoma_boost_data->sigmod, event);
-
- /* NC: Sanity check in case the call setup id does not relate
- to span. This can happen if RESTART is received on a
- full load. Where stray ACK messages can arrive after
- a RESTART has taken place.
- */
- if (!span) {
- ftdm_log(FTDM_LOG_CRIT, "No Span for Event=%s s%dc%d cid=%d\n",
- BOOST_DECODE_EVENT_ID(event->event_id),
- targetspan,
- targetchan,
- event->call_setup_id);
- return NULL;
- }
-
-
- for(i = 1; i <= span->chan_count; i++) {
- if (span->channels[i]->physical_span_id == targetspan && span->channels[i]->physical_chan_id == targetchan) {
- ftdmchan = span->channels[i];
- if (force || (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN && !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE))) {
- break;
- } else {
- ftdmchan = NULL;
- ftdm_log(FTDM_LOG_DEBUG, "Channel %d:%d ~ %d:%d is already in use in state %s\n",
- span->channels[i]->span_id,
- span->channels[i]->chan_id,
- span->channels[i]->physical_span_id,
- span->channels[i]->physical_chan_id,
- ftdm_channel_state2str(span->channels[i]->state));
- break;
- }
- }
- }
-
- return ftdmchan;
-}
-
-static int check_congestion(int trunk_group)
-{
- if (congestion_timeouts[trunk_group]) {
- time_t now = time(NULL);
-
- if (now >= congestion_timeouts[trunk_group]) {
- congestion_timeouts[trunk_group] = 0;
- } else {
- return 1;
- }
- }
-
- return 0;
-}
-
-
-/**
- * \brief Requests an sangoma boost channel on a span (outgoing call)
- * \param span Span where to get a channel
- * \param chan_id Specific channel to get (0 for any)
- * \param direction Call direction
- * \param caller_data Caller information
- * \param ftdmchan Channel to initialise
- * \return Success or failure
- */
-static FIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- ftdm_status_t status = FTDM_FAIL;
- sangoma_boost_request_id_t r;
- sangomabc_event_t event = {0};
- /* sanity has to be more than 8 seconds.
- * In PRI specs, timeout is 4 seconds for remote switch to respond to a SETUP,
- * and PRI stack will retransmit a second SETUP after the first timeout, so
- * we should allow for at least 8 seconds.
- */
-
- int boost_request_timeout = 10000;
- sangoma_boost_request_status_t st;
- char dnis[128] = "";
- char *gr = NULL;
- uint32_t count = 0;
- int tg=0;
-
- /* NC: On large number of calls 10 seconds is not enough.
- Resetting to 30 seconds. Especially on ss7 when
- links are reset during large call volume */
- if (!sangoma_boost_data->sigmod) {
- boost_request_timeout = 30000;
- }
-
- if (sangoma_boost_data->sigmod) {
- ftdm_log(FTDM_LOG_CRIT, "This function should not be called when sigmod was configured in boost\n");
- *ftdmchan = NULL;
- return FTDM_FAIL;
- }
-
- if (ftdm_test_flag(span, FTDM_SPAN_SUSPENDED)) {
- ftdm_log(FTDM_LOG_CRIT, "SPAN is Suspended.\n");
- *ftdmchan = NULL;
- return FTDM_FAIL;
- }
-
- if (check_congestion(tg)) {
- ftdm_log(FTDM_LOG_CRIT, "All circuits are busy. Trunk Group=%i (CONGESTION)\n",tg+1);
- *ftdmchan = NULL;
- return FTDM_FAIL;
- }
-
- if (count >= span->chan_count) {
- ftdm_log(FTDM_LOG_CRIT, "All circuits are busy.\n");
- *ftdmchan = NULL;
- return FTDM_FAIL;
- }
-
- r = next_request_id();
- if (r == 0) {
- ftdm_log(FTDM_LOG_CRIT, "All tanks ids are busy.\n");
- *ftdmchan = NULL;
- return FTDM_FAIL;
- }
-
- /* After this point we must release request id before we leave the function
- in case of an error. */
-
- ftdm_set_string(dnis, caller_data->dnis.digits);
-
- if ((gr = strchr(dnis, '@'))) {
- *gr++ = '\0';
- }
-
- if (gr && *(gr+1)) {
- tg = atoi(gr+1);
- if (tg > 0) {
- tg--;
- }
- }
-
- sangomabc_call_init(&event, caller_data->cid_num.digits, dnis, r);
-
- event.trunk_group = tg;
-
-
- ftdm_span_channel_use_count(span, &count);
-
- if (gr && *(gr+1)) {
- switch(*gr) {
- case 'g':
- event.hunt_group = SIGBOOST_HUNTGRP_SEQ_ASC;
- break;
- case 'G':
- event.hunt_group = SIGBOOST_HUNTGRP_SEQ_DESC;
- break;
- case 'r':
- event.hunt_group = SIGBOOST_HUNTGRP_RR_ASC;
- break;
- case 'R':
- event.hunt_group = SIGBOOST_HUNTGRP_RR_DESC;
- break;
- default:
- ftdm_log(FTDM_LOG_WARNING, "Failed to determine huntgroup (%s)\n", gr);
- event.hunt_group = SIGBOOST_HUNTGRP_SEQ_ASC;
- }
- }
-
- ftdm_set_string(event.calling_name, caller_data->cid_name);
- ftdm_set_string(event.rdnis.digits, caller_data->rdnis.digits);
- if (strlen(caller_data->rdnis.digits)) {
- event.rdnis.digits_count = (uint8_t)strlen(caller_data->rdnis.digits)+1;
- event.rdnis.ton = caller_data->rdnis.type;
- event.rdnis.npi = caller_data->rdnis.plan;
- }
-
- event.calling.screening_ind = caller_data->screen;
- event.calling.presentation_ind = caller_data->pres;
-
- event.calling.ton = caller_data->cid_num.type;
- event.calling.npi = caller_data->cid_num.plan;
-
- event.called.ton = caller_data->dnis.type;
- event.called.npi = caller_data->dnis.plan;
-
- /* we're making a contract now that FreeTDM values for capability, layer 1 and such will be the same as for boost */
- event.bearer.capability = caller_data->bearer_capability;
- event.bearer.uil1p = caller_data->bearer_layer1;
-
- if (caller_data->raw_data_len) {
- ftdm_set_string(event.custom_data, caller_data->raw_data);
- event.custom_data_size = (uint16_t)caller_data->raw_data_len;
- }
-
- OUTBOUND_REQUESTS[r].status = BST_WAITING;
- OUTBOUND_REQUESTS[r].span = span;
-
- if (sangomabc_connection_write(&sangoma_boost_data->mcon, &event) <= 0) {
- ftdm_log(FTDM_LOG_CRIT, "Failed to tx boost event [%s]\n", strerror(errno));
- status = OUTBOUND_REQUESTS[r].status = FTDM_FAIL;
- if (!sangoma_boost_data->sigmod) {
- *ftdmchan = NULL;
- }
- goto done;
- }
-
- while(ftdm_running() && OUTBOUND_REQUESTS[r].status == BST_WAITING) {
- ftdm_sleep(1);
- if (--boost_request_timeout <= 0) {
- status = FTDM_FAIL;
- if (!sangoma_boost_data->sigmod) {
- *ftdmchan = NULL;
- }
- ftdm_log(FTDM_LOG_CRIT, "Csid:%d Timed out waiting for boost channel request response, current status: BST_WAITING\n", r);
- goto done;
- }
- }
-
- if (OUTBOUND_REQUESTS[r].status == BST_READY && OUTBOUND_REQUESTS[r].ftdmchan) {
- *ftdmchan = OUTBOUND_REQUESTS[r].ftdmchan;
- status = FTDM_SUCCESS;
- } else {
- status = FTDM_FAIL;
- if (!sangoma_boost_data->sigmod) {
- *ftdmchan = NULL;
- }
- }
-
- done:
-
- st = OUTBOUND_REQUESTS[r].status;
- OUTBOUND_REQUESTS[r].status = BST_FREE;
-
- if (status == FTDM_FAIL) {
- if (st == BST_FAIL) {
- caller_data->hangup_cause = OUTBOUND_REQUESTS[r].hangup_cause;
- } else {
- caller_data->hangup_cause = FTDM_CAUSE_RECOVERY_ON_TIMER_EXPIRE;
- }
- }
-
- if (st == BST_FAIL) {
- release_request_id(r);
- } else if (st != BST_READY) {
- ftdm_assert_return(r <= MAX_REQ_ID, FTDM_FAIL, "Invalid index\n");
- nack_map[r] = 1;
- if (sangoma_boost_data->sigmod) {
- sangomabc_exec_command(&sangoma_boost_data->mcon,
- BOOST_SPAN((*ftdmchan)),
- BOOST_CHAN((*ftdmchan)),
- r,
- SIGBOOST_EVENT_CALL_START_NACK,
- 0, 0);
- } else {
- sangomabc_exec_command(&sangoma_boost_data->mcon,
- 0,
- 0,
- r,
- SIGBOOST_EVENT_CALL_START_NACK,
- 0, 0);
- }
- }
-
- return status;
-}
-
-/**
- * \brief Starts an sangoma boost channel (outgoing call)
- * \param ftdmchan Channel to initiate call on
- * \return Success
- */
-static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(sangoma_boost_outgoing_call)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
-
- if (!sangoma_boost_data->sigmod) {
- return FTDM_SUCCESS;
- }
-
- ftdm_set_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND);
-
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DIALING);
-
- return FTDM_SUCCESS;
-}
-
-/**
- * \brief Handler for call start ack no media event
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_call_progress(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan;
-
-
- if ((ftdmchan = find_ftdmchan(span, event, 1))) {
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
- ftdm_mutex_lock(ftdmchan->mutex);
- if (!sangoma_boost_data->sigmod && ftdmchan->state == FTDM_CHANNEL_STATE_HOLD) {
- if ((event->flags & SIGBOOST_PROGRESS_MEDIA)) {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_PROGRESS_MEDIA;
- ftdm_log(FTDM_LOG_DEBUG, "Channel init state updated to PROGRESS_MEDIA [Csid:%d]\n", event->call_setup_id);
- } else if ((event->flags & SIGBOOST_PROGRESS_RING)) {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_PROGRESS;
- ftdm_log(FTDM_LOG_DEBUG, "Channel init state updated to PROGRESS [Csid:%d]\n", event->call_setup_id);
- } else {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_IDLE;
- ftdm_log(FTDM_LOG_DEBUG, "Channel init state updated to IDLE [Csid:%d]\n", event->call_setup_id);
- }
- } else {
- if ((event->flags & SIGBOOST_PROGRESS_MEDIA)) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
- } else if ((event->flags & SIGBOOST_PROGRESS_RING)) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS);
- } else {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IDLE);
- }
- }
- ftdm_mutex_unlock(ftdmchan->mutex);
- }
-}
-
-/**
- * \brief Handler for call start ack event
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_call_start_ack(sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
-
- ftdm_channel_t *ftdmchan = NULL;
- uint32_t event_span = BOOST_EVENT_SPAN(mcon->sigmod, event);
- uint32_t event_chan = BOOST_EVENT_CHAN(mcon->sigmod, event);
-
-
- if (nack_map[event->call_setup_id]) {
- /* In this scenario outgoing call was alrady stopped
- via NACK and now we are expecting an NACK_ACK.
- If we receive an ACK its a race condition thus
- ignor it */
- return;
- }
-
- if (mcon->sigmod) {
- ftdmchan = OUTBOUND_REQUESTS[event->call_setup_id].ftdmchan;
- } else {
- ftdmchan = find_ftdmchan(OUTBOUND_REQUESTS[event->call_setup_id].span, event, 0);
- }
-
-
- if (ftdmchan) {
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
- if (!mcon->sigmod && ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_ERROR, "Failed to open FTDM channel [%s]\n", ftdmchan->last_error);
- } else {
-
- /* Only bind the setup id to GRID when we are sure that channel is ready
- otherwise we could overwite the original call */
- OUTBOUND_REQUESTS[event->call_setup_id].event = *event;
- SETUP_GRID[event_span][event_chan] = event->call_setup_id;
-
- ftdm_set_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND);
- ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_INUSE);
- ftdmchan->sflags = SFLAG_RECVD_ACK;
-
- if ((event->flags & SIGBOOST_PROGRESS_MEDIA)) {
- if (sangoma_boost_data->sigmod) {
- ftdm_log(FTDM_LOG_DEBUG, "Channel state changing to PROGRESS_MEDIA [Csid:%d]\n", event->call_setup_id);
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
- } else {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_PROGRESS_MEDIA;
- ftdm_log(FTDM_LOG_DEBUG, "Channel init state changed to PROGRESS_MEDIA [Csid:%d]\n", event->call_setup_id);
- }
- } else if ((event->flags & SIGBOOST_PROGRESS_RING)) {
- if (sangoma_boost_data->sigmod) {
- ftdm_log(FTDM_LOG_DEBUG, "Channel state changing to PROGRESS [Csid:%d]\n", event->call_setup_id);
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS);
- } else {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_PROGRESS;
- ftdm_log(FTDM_LOG_DEBUG, "Channel init state changed to PROGRESS [Csid:%d]\n", event->call_setup_id);
- }
- } else {
- if (sangoma_boost_data->sigmod) {
- /* should we set a state here? */
- } else {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_IDLE;
- ftdm_log(FTDM_LOG_DEBUG, "Channel init state changed to IDLE [Csid:%d]\n", event->call_setup_id);
- }
- }
- if (!sangoma_boost_data->sigmod) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HOLD);
- ftdm_log(FTDM_LOG_DEBUG, "Assigned chan %d:%d (%d:%d) to CSid=%d\n",
- ftdmchan->span_id, ftdmchan->chan_id, event_span, event_chan, event->call_setup_id);
- OUTBOUND_REQUESTS[event->call_setup_id].ftdmchan = ftdmchan;
- }
- OUTBOUND_REQUESTS[event->call_setup_id].flags = event->flags;
- OUTBOUND_REQUESTS[event->call_setup_id].status = BST_READY;
- return;
- }
-
- } else {
-
- ftdm_assert(!mcon->sigmod, "CALL STOP ACK: Invalid Sigmod Path");
-
- if ((ftdmchan = find_ftdmchan(OUTBOUND_REQUESTS[event->call_setup_id].span, (sangomabc_short_event_t*)event, 1))) {
- int r;
- /* NC: If we get CALL START ACK and channel is in active state
- then we are completely out of sync with the other end.
- Treat CALL START ACK as CALL STOP and hangup the current call.
- */
-
- if (ftdmchan->state == FTDM_CHANNEL_STATE_UP ||
- ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA ||
- ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS) {
- ftdm_log(FTDM_LOG_CRIT, "FTDMCHAN CALL ACK STATE UP -> Changed to TERMINATING %d:%d\n", event_span, event_chan);
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING, r);
- } else if (ftdmchan->state == FTDM_CHANNEL_STATE_HANGUP || ftdm_test_sflag(ftdmchan, SFLAG_HANGUP)) {
- ftdm_log(FTDM_LOG_CRIT, "FTDMCHAN CALL ACK STATE HANGUP -> Changed to HANGUP COMPLETE %d:%d\n", event_span, event_chan);
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, r);
- } else {
- ftdm_log(FTDM_LOG_CRIT, "FTDMCHAN STATE INVALID State %s on IN CALL ACK %d:%d\n",
- ftdm_channel_state2str(ftdmchan->state), event_span, event_chan);
- }
- ftdm_set_sflag(ftdmchan, SFLAG_SENT_FINAL_MSG);
- ftdmchan=NULL;
- }
- }
-
-
- if (!ftdmchan) {
- ftdm_log(FTDM_LOG_CRIT, "START ACK CANT FIND A CHAN %d:%d\n", event_span, event_chan);
- } else {
- /* only reason to be here is failed to open channel when we we're in sigmod */
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
- ftdm_set_sflag(ftdmchan, SFLAG_SENT_FINAL_MSG);
- }
-
- sangomabc_exec_command(mcon,
- event->span,
- event->chan,
- event->call_setup_id,
- SIGBOOST_EVENT_CALL_STOPPED,
- FTDM_CAUSE_DESTINATION_OUT_OF_ORDER, 0);
- OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL;
- OUTBOUND_REQUESTS[event->call_setup_id].hangup_cause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER;
-}
-
-/**
- * \brief Handler for call done event
- * \param span Span where event was fired
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_call_done(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan;
- int r = 0;
-
- if ((ftdmchan = find_ftdmchan(span, event, 1))) {
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
- ftdm_mutex_lock(ftdmchan->mutex);
-
- if (sangoma_boost_data->sigmod) {
- /* not really completely done, but if we ever get an incoming call before moving to HANGUP_COMPLETE
- * handle_incoming_call() will take care of moving the state machine to release the channel */
- sangomabc_exec_command(&sangoma_boost_data->mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_RELEASED,
- 0, 0);
- }
-
- if (ftdmchan->state == FTDM_CHANNEL_STATE_DOWN || ftdmchan->state == FTDM_CHANNEL_STATE_HANGUP_COMPLETE || ftdm_test_sflag(ftdmchan, SFLAG_TERMINATING)) {
- goto done;
- }
-
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, r);
- if (r) {
- ftdm_mutex_unlock(ftdmchan->mutex);
- return;
- }
- }
-
- done:
-
- if (ftdmchan) {
- ftdm_mutex_unlock(ftdmchan->mutex);
- }
-
- if (event->call_setup_id) {
- release_request_id(event->call_setup_id);
- } else {
- release_request_id_span_chan(BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- }
-}
-
-
-/**
- * \brief Handler for call start nack event
- * \param span Span where event was fired
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_call_start_nack(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- if (event->release_cause == SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY) {
- uint32_t count = 0;
- int delay = 0;
- int tg=event->trunk_group;
-
- ftdm_span_channel_use_count(span, &count);
-
- delay = (int) (count / 100) * 2;
-
- if (delay > 10) {
- delay = 10;
- } else if (delay < 1) {
- delay = 1;
- }
-
- if (tg < 0 || tg >= MAX_TRUNK_GROUPS) {
- ftdm_log(FTDM_LOG_CRIT, "Invalid All Ckt Busy trunk group number %i\n", tg);
- tg=0;
- }
-
- congestion_timeouts[tg] = time(NULL) + delay;
- event->release_cause = 17;
-
- } else if (event->release_cause == SIGBOOST_CALL_SETUP_CSUPID_DBL_USE) {
- event->release_cause = 17;
- }
-
- if (event->call_setup_id) {
- if (sangoma_boost_data->sigmod) {
- ftdmchan = OUTBOUND_REQUESTS[event->call_setup_id].ftdmchan;
- CALL_DATA(ftdmchan)->last_event_id = event->event_id;
- CALL_DATA(ftdmchan)->call_setup_id = event->call_setup_id;
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
- ftdm_clear_sflag_locked(ftdmchan, SFLAG_SENT_FINAL_MSG);
- } else {
- sangomabc_exec_command(mcon,
- 0,
- 0,
- event->call_setup_id,
- SIGBOOST_EVENT_CALL_START_NACK_ACK,
- 0, 0);
- OUTBOUND_REQUESTS[event->call_setup_id].event = *event;
- OUTBOUND_REQUESTS[event->call_setup_id].status = BST_FAIL;
- OUTBOUND_REQUESTS[event->call_setup_id].hangup_cause = event->release_cause;
- ftdm_log(FTDM_LOG_DEBUG, "setting outbound request status %d to BST_FAIL\n", event->call_setup_id);
- }
- return;
- } else {
- if ((ftdmchan = find_ftdmchan(span, event, 1))) {
- int r = 0;
-
- /* if there is no call setup id this should not be an outbound channel for sure */
- ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND), "Yay, outbound flag should not be set here!\n");
-
- CALL_DATA(ftdmchan)->last_event_id = event->event_id;
- ftdm_mutex_lock(ftdmchan->mutex);
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING, r);
- if (r == FTDM_SUCCESS) {
- ftdmchan->caller_data.hangup_cause = event->release_cause;
- }
- ftdm_mutex_unlock(ftdmchan->mutex);
- if (r) {
- return;
- }
- }
- }
-
- if (ftdmchan) {
- ftdm_set_sflag_locked(ftdmchan, SFLAG_SENT_FINAL_MSG);
- }
-
- /* nobody else will do it so we have to do it ourselves */
- sangomabc_exec_command(mcon,
- event->span,
- event->chan,
- event->call_setup_id,
- SIGBOOST_EVENT_CALL_START_NACK_ACK,
- 0, 0);
-}
-
-static void handle_call_released(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan;
-
- if ((ftdmchan = find_ftdmchan(span, event, 1))) {
- ftdm_log(FTDM_LOG_DEBUG, "Releasing completely chan s%dc%d\n", BOOST_EVENT_SPAN(mcon->sigmod, event),
- BOOST_EVENT_CHAN(mcon->sigmod, event));
- ftdm_channel_close(&ftdmchan);
- } else {
- ftdm_log(FTDM_LOG_CRIT, "Odd, We could not find chan: s%dc%d to release the call completely!!\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- }
-}
-
-/**
- * \brief Handler for call stop event
- * \param span Span where event was fired
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_call_stop(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan;
-
- if ((ftdmchan = find_ftdmchan(span, event, 1))) {
- int r = 0;
-
- ftdm_mutex_lock(ftdmchan->mutex);
-
- if (ftdm_test_sflag(ftdmchan, SFLAG_HANGUP) ||
- ftdmchan->state == FTDM_CHANNEL_STATE_DOWN ||
- ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
-
- /* NC: Checking for state DOWN because ss7box can
- send CALL_STOP twice in a row. If we do not check for
- STATE_DOWN we will set the state back to termnating
- and block the channel forever
- */
-
- /* racing condition where both sides initiated a hangup
- * Do not change current state as channel is already clearing
- * itself through local initiated hangup */
-
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_STOPPED_ACK,
- 0, 0);
- ftdm_mutex_unlock(ftdmchan->mutex);
- return;
- } else if (ftdmchan->state == FTDM_CHANNEL_STATE_HOLD) {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_TERMINATING;
- ftdm_log(FTDM_LOG_DEBUG, "Channel init state updated to TERMINATING [Csid:%d]\n", event->call_setup_id);
- OUTBOUND_REQUESTS[event->call_setup_id].hangup_cause = event->release_cause;
- ftdmchan->caller_data.hangup_cause = event->release_cause;
- ftdm_mutex_unlock(ftdmchan->mutex);
- return;
- } else {
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING, r);
- }
-
- if (r == FTDM_SUCCESS) {
- ftdmchan->caller_data.hangup_cause = event->release_cause;
- }
-
- ftdm_mutex_unlock(ftdmchan->mutex);
-
- if (r) {
- return;
- }
- } else { /* we have to do it ourselves.... */
- ftdm_log(FTDM_LOG_CRIT, "Odd, We could not find chan: s%dc%d\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- release_request_id_span_chan(BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- }
-}
-
-/**
- * \brief Handler for call answer event
- * \param span Span where event was fired
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_call_answer(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan;
-
- if ((ftdmchan = find_ftdmchan(span, event, 1))) {
- ftdm_mutex_lock(ftdmchan->mutex);
-
- if (ftdm_test_sflag(ftdmchan, SFLAG_HANGUP) ||
- ftdmchan->state == FTDM_CHANNEL_STATE_DOWN ||
- ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
-
- /* NC: Do nothing here because we are in process
- of stopping the call. So ignore the ANSWER. */
- ftdm_log(FTDM_LOG_DEBUG, "Got answer but call is already hangup %d:%d\n", BOOST_EVENT_SPAN(mcon->sigmod, event),
- BOOST_EVENT_CHAN(mcon->sigmod, event));
-
- } else if (ftdmchan->state == FTDM_CHANNEL_STATE_HOLD) {
- ftdmchan->init_state = FTDM_CHANNEL_STATE_UP;
-
- } else {
- int r = 0;
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_UP, r);
- }
- ftdm_mutex_unlock(ftdmchan->mutex);
- } else {
- ftdm_log(FTDM_LOG_CRIT, "Could not find channel %d:%d on answer message!\n", BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- sangomabc_exec_command(mcon,
- event->span,
- event->chan,
- event->call_setup_id,
- SIGBOOST_EVENT_CALL_STOPPED,
- FTDM_CAUSE_DESTINATION_OUT_OF_ORDER, 0);
- }
-}
-
-static __inline__ void stop_loop(ftdm_channel_t *ftdmchan);
-
-/**
- * \brief Handler for call start event
- * \param span Span where event was fired
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_call_start(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_event_t *event)
-{
- ftdm_channel_t *ftdmchan = NULL;
- int hangup_cause = FTDM_CAUSE_CALL_REJECTED;
- int retry = 1;
-
-tryagain:
-
- if (!(ftdmchan = find_ftdmchan(span, (sangomabc_short_event_t*)event, 0))) {
- if ((ftdmchan = find_ftdmchan(span, (sangomabc_short_event_t*)event, 1))) {
- int r;
-
- /* NC: If we get CALL START and channel is in active state
- then we are completely out of sync with the other end.
- Treat CALL START as CALL STOP and hangup the current call.
- The incoming call will also be NACKed.
- */
-
- if (ftdmchan->state == FTDM_CHANNEL_STATE_UP ||
- ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS_MEDIA ||
- ftdmchan->state == FTDM_CHANNEL_STATE_PROGRESS) {
- ftdm_log(FTDM_LOG_CRIT, "s%dc%d: FTDMCHAN STATE UP -> Changed to TERMINATING\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING, r);
- } else if (ftdmchan->state == FTDM_CHANNEL_STATE_HANGUP || ftdm_test_sflag(ftdmchan, SFLAG_HANGUP)) {
- ftdm_log(FTDM_LOG_CRIT, "s%dc%d: FTDMCHAN STATE HANGUP -> Changed to HANGUP COMPLETE\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, r);
- } else if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALING) {
- ftdm_log(FTDM_LOG_WARNING, "s%dc%d: Collision, hanging up incoming call\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- /* dont hangup the outgoing call, the other side will send a call start nack too
- * and there we will move to terminating. If we move to terminating here. We used to move
- * to terminating here, but that introduces a problem in handle_call_start_nack where
- * when receiving call start nack we move the channel from DOWN to TERMINATING ( cuz we already
- * hangup here ) and the channel gets stuck in terminating forever. So at this point we're trusting
- * the other side to send the call start nack ( or proceed with the call )
- * ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING, r);
- */
- } else if (ftdmchan->state == FTDM_CHANNEL_STATE_IN_LOOP && retry) {
- retry = 0;
- stop_loop(ftdmchan);
- ftdm_channel_advance_states(ftdmchan);
- goto tryagain;
- } else {
- ftdm_log(FTDM_LOG_ERROR, "s%dc%d: rejecting incoming call in channel state %s\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event),
- ftdm_channel_state2str(ftdmchan->state));
- }
- ftdm_set_sflag(ftdmchan, SFLAG_SENT_FINAL_MSG);
- ftdmchan = NULL;
- } else {
- ftdm_log(FTDM_LOG_CRIT, "s%dc%d: incoming call in invalid channel (channel not found)!\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- }
- goto error;
- }
-
- if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_ERROR, "s%dc%d: failed to open channel on incoming call, rejecting!\n",
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- goto error;
- }
-
- ftdm_log(FTDM_LOG_DEBUG, "Got call start from s%dc%d mapped to freetdm logical s%dc%d, physical s%dc%d\n",
- event->span, event->chan,
- ftdmchan->span_id, ftdmchan->chan_id,
- ftdmchan->physical_span_id, ftdmchan->physical_chan_id);
-
- ftdmchan->sflags = 0;
- ftdm_set_string(ftdmchan->caller_data.cid_num.digits, (char *)event->calling.digits);
- ftdm_set_string(ftdmchan->caller_data.cid_name, (char *)event->calling.digits);
- ftdm_set_string(ftdmchan->caller_data.ani.digits, (char *)event->calling.digits);
- ftdm_set_string(ftdmchan->caller_data.dnis.digits, (char *)event->called.digits);
- ftdm_set_string(ftdmchan->caller_data.rdnis.digits, (char *)event->rdnis.digits);
- if (event->custom_data_size) {
- ftdm_set_string(ftdmchan->caller_data.raw_data, event->custom_data);
- ftdmchan->caller_data.raw_data_len = event->custom_data_size;
- }
-
- if (strlen(event->calling_name)) {
- ftdm_set_string(ftdmchan->caller_data.cid_name, (char *)event->calling_name);
- }
-
- ftdmchan->caller_data.cid_num.plan = event->calling.npi;
- ftdmchan->caller_data.cid_num.type = event->calling.ton;
-
- ftdmchan->caller_data.ani.plan = event->calling.npi;
- ftdmchan->caller_data.ani.type = event->calling.ton;
-
- ftdmchan->caller_data.dnis.plan = event->called.npi;
- ftdmchan->caller_data.dnis.type = event->called.ton;
-
- ftdmchan->caller_data.rdnis.plan = event->rdnis.npi;
- ftdmchan->caller_data.rdnis.type = event->rdnis.ton;
-
- ftdmchan->caller_data.screen = event->calling.screening_ind;
- ftdmchan->caller_data.pres = event->calling.presentation_ind;
-
- ftdmchan->caller_data.bearer_capability = event->bearer.capability;
- ftdmchan->caller_data.bearer_layer1 = event->bearer.uil1p;
-
- /* more info about custom data: http://www.ss7box.com/smg_manual.html#ISUP-IN-RDNIS-NEW */
- if (event->custom_data_size) {
- char* p = NULL;
-
- p = strstr((char*)event->custom_data,"PRI001-ANI2-");
- if (p!=NULL) {
- int ani2 = 0;
- sscanf(p, "PRI001-ANI2-%d", &ani2);
- snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", ani2);
- }
- }
-
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING);
- return;
-
- error:
- hangup_cause = ftdmchan ? ftdmchan->caller_data.hangup_cause : FTDM_CAUSE_REQUESTED_CHAN_UNAVAIL;
- sangomabc_exec_command(mcon,
- event->span,
- event->chan,
- event->call_setup_id,
- SIGBOOST_EVENT_CALL_START_NACK,
- hangup_cause, 0);
-
-}
-
-static void handle_call_loop_start(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_status_t res = FTDM_FAIL;
- ftdm_channel_t *ftdmchan;
-
- if (!(ftdmchan = find_ftdmchan(span, (sangomabc_short_event_t*)event, 0))) {
- ftdm_log(FTDM_LOG_CRIT, "CANNOT START LOOP, CHAN NOT AVAILABLE %d:%d\n", BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- return;
- }
-
- if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_CRIT, "CANNOT START LOOP, CANT OPEN CHAN %d:%d\n", BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- return;
- }
-
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_IN_LOOP, res);
- if (res != FTDM_SUCCESS) {
- ftdm_channel_t *toclose = ftdmchan;
- ftdm_log(FTDM_LOG_CRIT, "yay, could not set the state of the channel to IN_LOOP, loop will fail\n");
- ftdm_channel_close(&toclose);
- return;
- }
- ftdm_log(FTDM_LOG_DEBUG, "%d:%d starting loop\n", ftdmchan->span_id, ftdmchan->chan_id);
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_ENABLE_LOOP, NULL);
-}
-
-static __inline__ void stop_loop(ftdm_channel_t *ftdmchan)
-{
- ftdm_status_t res = FTDM_FAIL;
- ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
- /* even when we did not sent a msg we set this flag to avoid sending call stop in the DOWN state handler */
- ftdm_set_flag(ftdmchan, SFLAG_SENT_FINAL_MSG);
- ftdm_set_state_r(ftdmchan, FTDM_CHANNEL_STATE_DOWN, res);
- if (res != FTDM_SUCCESS) {
- ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "yay, could not set the state of the channel from IN_LOOP to DOWN\n");
- }
-}
-
-static void handle_call_loop_stop(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan;
- if (!(ftdmchan = find_ftdmchan(span, (sangomabc_short_event_t*)event, 1))) {
- ftdm_log(FTDM_LOG_CRIT, "CANNOT STOP LOOP, INVALID CHAN REQUESTED %d:%d\n", BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- return;
- }
- if (ftdmchan->state != FTDM_CHANNEL_STATE_IN_LOOP) {
- ftdm_log(FTDM_LOG_WARNING, "Got stop loop request in a channel that is not in loop, ignoring ...\n");
- return;
- }
- stop_loop(ftdmchan);
-}
-
-/**
- * \brief Handler for heartbeat event
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static void handle_heartbeat(sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- int err;
-
- err = sangomabc_connection_writep(mcon, (sangomabc_event_t*)event);
-
- if (err <= 0) {
- ftdm_log(FTDM_LOG_CRIT, "Failed to tx on boost connection [%s]: %s\n", strerror(errno));
- }
- return;
-}
-
-/**
- * \brief Handler for restart ack event
- * \param mcon sangoma boost connection
- * \param span Span where event was fired
- * \param event Event to handle
- */
-static void handle_restart_ack(sangomabc_connection_t *mcon, ftdm_span_t *span, sangomabc_short_event_t *event)
-{
- ftdm_log(FTDM_LOG_DEBUG, "RECV RESTART ACK\n");
-}
-
-/**
- * \brief Handler for restart event
- * \param mcon sangoma boost connection
- * \param span Span where event was fired
- * \param event Event to handle
- */
-static void handle_restart(sangomabc_connection_t *mcon, ftdm_span_t *span, sangomabc_short_event_t *event)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- mcon->rxseq_reset = 0;
- ftdm_set_flag((&sangoma_boost_data->mcon), MSU_FLAG_DOWN);
- ftdm_set_flag_locked(span, FTDM_SPAN_SUSPENDED);
- ftdm_set_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RESTARTING);
-
-}
-
-/**
- * \brief Handler for incoming digit event
- * \param mcon sangoma boost connection
- * \param span Span where event was fired
- * \param event Event to handle
- */
-static void handle_incoming_digit(sangomabc_connection_t *mcon, ftdm_span_t *span, sangomabc_event_t *event)
-{
- ftdm_channel_t *ftdmchan = NULL;
- char digits[MAX_DIALED_DIGITS + 2] = "";
-
- if (!(ftdmchan = find_ftdmchan(span, (sangomabc_short_event_t *)event, 1))) {
- ftdm_log(FTDM_LOG_ERROR, "Invalid channel\n");
- return;
- }
-
- if (event->called_number_digits_count == 0) {
- ftdm_log(FTDM_LOG_WARNING, "Error Incoming digit with len %s %d [w%dg%d]\n",
- event->called_number_digits,
- event->called_number_digits_count,
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
- return;
- }
-
- ftdm_log(FTDM_LOG_WARNING, "Incoming digit with len %s %d [w%dg%d]\n",
- event->called_number_digits,
- event->called_number_digits_count,
- BOOST_EVENT_SPAN(mcon->sigmod, event), BOOST_EVENT_CHAN(mcon->sigmod, event));
-
- memcpy(digits, event->called_number_digits, event->called_number_digits_count);
- ftdm_channel_queue_dtmf(ftdmchan, digits);
-
- return;
-}
-
-
-/**
- * \brief Checks if span has state changes pending and processes
- * \param span Span where event was fired
- * \param event Event to handle
- * \return The locked FTDM channel associated to the event if any, NULL otherwise
- */
-static ftdm_channel_t* event_process_states(ftdm_span_t *span, sangomabc_short_event_t *event)
-{
- ftdm_channel_t *ftdmchan = NULL;
- ftdm_sangoma_boost_data_t *signal_data = span->signal_data;
-
- switch (event->event_id) {
- case SIGBOOST_EVENT_CALL_START_NACK:
- case SIGBOOST_EVENT_CALL_START_NACK_ACK:
- if (event->call_setup_id && !signal_data->sigmod) {
- return NULL;
- }
- //if event->span and event->chan is valid, fall-through
- case SIGBOOST_EVENT_CALL_START:
- case SIGBOOST_EVENT_CALL_START_ACK:
- case SIGBOOST_EVENT_CALL_STOPPED:
- case SIGBOOST_EVENT_CALL_PROGRESS:
- case SIGBOOST_EVENT_CALL_ANSWERED:
- case SIGBOOST_EVENT_CALL_STOPPED_ACK:
- case SIGBOOST_EVENT_DIGIT_IN:
- case SIGBOOST_EVENT_INSERT_CHECK_LOOP:
- case SIGBOOST_EVENT_REMOVE_CHECK_LOOP:
- case SIGBOOST_EVENT_CALL_RELEASED:
- if (!(ftdmchan = find_ftdmchan(span, (sangomabc_short_event_t*)event, 1))) {
- ftdm_log(FTDM_LOG_CRIT, "could not find channel %d:%d to process pending state changes!\n",
- BOOST_EVENT_SPAN(signal_data->sigmod, event),
- BOOST_EVENT_CHAN(signal_data->sigmod, event));
- return NULL;
- }
- break;
- case SIGBOOST_EVENT_HEARTBEAT:
- case SIGBOOST_EVENT_SYSTEM_RESTART_ACK:
- case SIGBOOST_EVENT_SYSTEM_RESTART:
- case SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE:
- return NULL;
- default:
- ftdm_log(FTDM_LOG_CRIT, "Unhandled event id: %d\n", event->event_id);
- return NULL;
- }
-
- ftdm_mutex_lock(ftdmchan->mutex);
- ftdm_channel_advance_states(ftdmchan);
- return ftdmchan;
-}
-
-/**
- * \brief Handler for sangoma boost event
- * \param span Span where event was fired
- * \param mcon sangoma boost connection
- * \param event Event to handle
- */
-static int parse_sangoma_event(ftdm_span_t *span, sangomabc_connection_t *mcon, sangomabc_short_event_t *event)
-{
- ftdm_channel_t* ftdmchan = NULL;
-
- if (!ftdm_running()) {
- ftdm_log(FTDM_LOG_WARNING, "System is shutting down.\n");
- return -1;
- }
-
- ftdm_assert_return(event->call_setup_id <= MAX_REQ_ID, -1, "Unexpected call setup id\n");
-
- /* process all pending state changes for that channel before
- * processing the new boost event */
- ftdmchan = event_process_states(span, event);
-
- switch(event->event_id) {
- case SIGBOOST_EVENT_CALL_START:
- handle_call_start(span, mcon, (sangomabc_event_t*)event);
- break;
- case SIGBOOST_EVENT_CALL_STOPPED:
- handle_call_stop(span, mcon, event);
- break;
- case SIGBOOST_EVENT_CALL_RELEASED:
- handle_call_released(span, mcon, event);
- break;
- case SIGBOOST_EVENT_CALL_START_ACK:
- handle_call_start_ack(mcon, event);
- break;
- case SIGBOOST_EVENT_CALL_PROGRESS:
- handle_call_progress(span, mcon, event);
- break;
- case SIGBOOST_EVENT_CALL_START_NACK:
- handle_call_start_nack(span, mcon, event);
- break;
- case SIGBOOST_EVENT_CALL_ANSWERED:
- handle_call_answer(span, mcon, event);
- break;
- case SIGBOOST_EVENT_HEARTBEAT:
- handle_heartbeat(mcon, event);
- break;
- case SIGBOOST_EVENT_CALL_STOPPED_ACK:
- handle_call_done(span, mcon, event);
- break;
- case SIGBOOST_EVENT_CALL_START_NACK_ACK:
- /* On NACK ack span chan are always invalid
- All there is to do is to clear the id */
- if (event->call_setup_id) {
- nack_map[event->call_setup_id] = 0;
- release_request_id(event->call_setup_id);
- } else {
- handle_call_done(span, mcon, event);
- }
- break;
- case SIGBOOST_EVENT_INSERT_CHECK_LOOP:
- handle_call_loop_start(span, mcon, event);
- break;
- case SIGBOOST_EVENT_REMOVE_CHECK_LOOP:
- handle_call_loop_stop(span, mcon, event);
- break;
- case SIGBOOST_EVENT_SYSTEM_RESTART_ACK:
- handle_restart_ack(mcon, span, event);
- break;
- case SIGBOOST_EVENT_SYSTEM_RESTART:
- handle_restart(mcon, span, event);
- break;
- case SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE:
- //handle_gap_abate(event);
- break;
- case SIGBOOST_EVENT_DIGIT_IN:
- handle_incoming_digit(mcon, span, (sangomabc_event_t*)event);
- break;
- default:
- ftdm_log(FTDM_LOG_WARNING, "No handler implemented for [%s]\n", sangomabc_event_id_name(event->event_id));
- break;
- }
-
- if(ftdmchan != NULL) {
- ftdm_channel_advance_states(ftdmchan);
- ftdm_mutex_unlock(ftdmchan->mutex);
- }
-
- return 0;
-
-}
-
-/**
- * \brief Handler for channel state change
- * \param ftdmchan Channel to handle
- */
-static ftdm_status_t state_advance(ftdm_channel_t *ftdmchan)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
- sangomabc_connection_t *mcon = &sangoma_boost_data->mcon;
- ftdm_sigmsg_t sig;
- ftdm_status_t status;
-
-
- ftdm_assert_return(ftdmchan->last_state != ftdmchan->state, FTDM_FAIL, "Channel state already processed\n");
-
- ftdm_log(FTDM_LOG_DEBUG, "%d:%d PROCESSING STATE [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, ftdm_channel_state2str(ftdmchan->state));
-
- memset(&sig, 0, sizeof(sig));
- sig.chan_id = ftdmchan->chan_id;
- sig.span_id = ftdmchan->span_id;
- sig.channel = ftdmchan;
-
- ftdm_channel_complete_state(ftdmchan);
-
- switch (ftdmchan->state) {
- case FTDM_CHANNEL_STATE_DOWN:
- {
- int call_stopped_ack_sent = 0;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
-
- if (ftdmchan->last_state == FTDM_CHANNEL_STATE_IN_LOOP) {
- ftdm_log(FTDM_LOG_DEBUG, "%d:%d terminating loop\n", ftdmchan->span_id, ftdmchan->chan_id);
- } else {
- release_request_id_span_chan(ftdmchan->physical_span_id, ftdmchan->physical_chan_id);
-
- if (!ftdm_test_sflag(ftdmchan, SFLAG_SENT_FINAL_MSG)) {
- ftdm_set_sflag_locked(ftdmchan, SFLAG_SENT_FINAL_MSG);
-
- if (ftdmchan->call_data && CALL_DATA(ftdmchan)->last_event_id == SIGBOOST_EVENT_CALL_START_NACK) {
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- CALL_DATA(ftdmchan)->call_setup_id,
- SIGBOOST_EVENT_CALL_START_NACK_ACK,
- 0, 0);
-
- } else {
- /* we got a call stop msg, time to reply with call stopped ack */
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_STOPPED_ACK,
- 0, 0);
- call_stopped_ack_sent = 1;
- }
- }
- }
-
- ftdmchan->sflags = 0;
- memset(ftdmchan->call_data, 0, sizeof(sangoma_boost_call_t));
- if (sangoma_boost_data->sigmod && call_stopped_ack_sent) {
- /* we dont want to call ftdm_channel_close just yet until call released is received */
- ftdm_log(FTDM_LOG_DEBUG, "Waiting for call release confirmation before declaring chan %d:%d as available \n",
- ftdmchan->span_id, ftdmchan->chan_id);
- } else {
- ftdm_channel_t *toclose = ftdmchan;
- ftdm_channel_close(&toclose);
- }
- }
- break;
- case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
- {
- if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
- sig.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA;
- if ((status = ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS)) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
- }
- } else {
- if (!ftdm_test_sflag(ftdmchan, SFLAG_SENT_ACK)) {
- ftdm_set_sflag(ftdmchan, SFLAG_SENT_ACK);
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_START_ACK,
- 0, 0);
- }
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_PROGRESS,
- 0, SIGBOOST_PROGRESS_MEDIA);
- }
- }
- break;
- case FTDM_CHANNEL_STATE_PROGRESS:
- {
- if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
- sig.event_id = FTDM_SIGEVENT_PROGRESS;
- if ((status = ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS)) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
- }
- } else {
- if (!ftdm_test_sflag(ftdmchan, SFLAG_SENT_ACK)) {
- ftdm_set_sflag(ftdmchan, SFLAG_SENT_ACK);
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_START_ACK,
- 0, SIGBOOST_PROGRESS_RING);
- }
- }
- }
- break;
- case FTDM_CHANNEL_STATE_IDLE:
- case FTDM_CHANNEL_STATE_HOLD:
- {
- /* twiddle */
- }
- break;
- case FTDM_CHANNEL_STATE_RING:
- {
- if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
- sig.event_id = FTDM_SIGEVENT_START;
- if ((status = ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS)) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
- }
- }
- }
- break;
- case FTDM_CHANNEL_STATE_RESTART:
- {
- sig.event_id = FTDM_SIGEVENT_RESTART;
- status = ftdm_span_send_signal(ftdmchan->span, &sig);
- ftdm_set_sflag_locked(ftdmchan, SFLAG_SENT_FINAL_MSG);
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
- }
- break;
- case FTDM_CHANNEL_STATE_UP:
- {
- if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
- sig.event_id = FTDM_SIGEVENT_UP;
- if ((status = ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS)) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP);
- }
- } else {
- if (!(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_PROGRESS) || ftdm_test_flag(ftdmchan, FTDM_CHANNEL_MEDIA))) {
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_START_ACK,
- 0, 0);
- }
-
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_ANSWERED,
- 0, 0);
- }
- }
- break;
- case FTDM_CHANNEL_STATE_DIALING:
- {
- char dnis[128] = "";
- sangoma_boost_request_id_t r;
- sangomabc_event_t event = {0};
-
- ftdm_assert(sangoma_boost_data->sigmod != NULL, "We should be in sigmod here!\n");
-
- ftdm_set_string(dnis, ftdmchan->caller_data.dnis.digits);
-
- r = next_request_id();
- if (r == 0) {
- ftdm_log(FTDM_LOG_CRIT, "All boost request ids are busy.\n");
- ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
- break;
- }
-
- sangomabc_call_init(&event, ftdmchan->caller_data.cid_num.digits, dnis, r);
-
- event.span = (uint8_t)ftdmchan->physical_span_id;
- event.chan = (uint8_t)ftdmchan->physical_chan_id;
- /* because we already have a span/chan here we bind to the SETUP_GRID now and not on call start ack */
- SETUP_GRID[event.span][event.chan] = event.call_setup_id;
-
- ftdm_set_string(event.calling_name, ftdmchan->caller_data.cid_name);
- ftdm_set_string(event.rdnis.digits, ftdmchan->caller_data.rdnis.digits);
- if (strlen(ftdmchan->caller_data.rdnis.digits)) {
- event.rdnis.digits_count = (uint8_t)strlen(ftdmchan->caller_data.rdnis.digits)+1;
- event.rdnis.ton = ftdmchan->caller_data.rdnis.type;
- event.rdnis.npi = ftdmchan->caller_data.rdnis.plan;
- }
-
- event.calling.screening_ind = ftdmchan->caller_data.screen;
- event.calling.presentation_ind = ftdmchan->caller_data.pres;
-
- event.calling.ton = ftdmchan->caller_data.cid_num.type;
- event.calling.npi = ftdmchan->caller_data.cid_num.plan;
-
- event.called.ton = ftdmchan->caller_data.dnis.type;
- event.called.npi = ftdmchan->caller_data.dnis.plan;
-
- if (ftdmchan->caller_data.raw_data_len) {
- ftdm_set_string(event.custom_data, ftdmchan->caller_data.raw_data);
- event.custom_data_size = (uint16_t)ftdmchan->caller_data.raw_data_len;
- }
-
- OUTBOUND_REQUESTS[r].status = BST_WAITING;
- OUTBOUND_REQUESTS[r].span = ftdmchan->span;
- OUTBOUND_REQUESTS[r].ftdmchan = ftdmchan;
-
- ftdm_log(FTDM_LOG_DEBUG, "Dialing number %s over boost channel with request id %d\n", event.called_number_digits, r);
- if (sangomabc_connection_write(&sangoma_boost_data->mcon, &event) <= 0) {
- release_request_id(r);
- ftdm_log(FTDM_LOG_CRIT, "Failed to tx boost event [%s]\n", strerror(errno));
- ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
- }
-
- }
- break;
- case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
- {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
- }
- break;
- case FTDM_CHANNEL_STATE_HANGUP:
- {
- ftdm_set_sflag_locked(ftdmchan, SFLAG_HANGUP);
-
- if (ftdm_test_sflag(ftdmchan, SFLAG_SENT_FINAL_MSG) || ftdm_test_sflag(ftdmchan, SFLAG_TERMINATING)) {
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
- } else {
- ftdm_set_sflag_locked(ftdmchan, SFLAG_SENT_FINAL_MSG);
- if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_ANSWERED) ||
- ftdm_test_flag(ftdmchan, FTDM_CHANNEL_PROGRESS) ||
- ftdm_test_flag(ftdmchan, FTDM_CHANNEL_MEDIA) ||
- ftdm_test_sflag(ftdmchan, SFLAG_RECVD_ACK)) {
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_STOPPED,
- ftdmchan->caller_data.hangup_cause, 0);
- } else {
- sangomabc_exec_command(mcon,
- BOOST_SPAN(ftdmchan),
- BOOST_CHAN(ftdmchan),
- 0,
- SIGBOOST_EVENT_CALL_START_NACK,
- ftdmchan->caller_data.hangup_cause, 0);
- }
- }
- }
- break;
- case FTDM_CHANNEL_STATE_TERMINATING:
- {
- ftdm_set_sflag_locked(ftdmchan, SFLAG_TERMINATING);
- sig.event_id = FTDM_SIGEVENT_STOP;
- status = ftdm_span_send_signal(ftdmchan->span, &sig);
- }
- break;
- case FTDM_CHANNEL_STATE_IN_LOOP:
- {
- /* nothing to do, we sent the FTDM_COMMAND_ENABLE_LOOP command in handle_call_loop_start() right away */
- }
- break;
- default:
- break;
- }
- return FTDM_SUCCESS;
-}
-
-/**
- * \brief Initialises outgoing requests array
- */
-static __inline__ void init_outgoing_array(void)
-{
- memset(&OUTBOUND_REQUESTS, 0, sizeof(OUTBOUND_REQUESTS));
-}
-
-/**
- * \brief Checks current state on a span
- * \param span Span to check status on
- */
-static __inline__ void check_state(ftdm_span_t *span)
-{
- ftdm_channel_t *ftdmchan = NULL;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- int susp = ftdm_test_flag(span, FTDM_SPAN_SUSPENDED);
-
- if (susp && ftdm_check_state_all(span, FTDM_CHANNEL_STATE_DOWN)) {
- susp = 0;
- }
-
- if (ftdm_test_flag(span, FTDM_SPAN_STATE_CHANGE) || susp) {
- uint32_t j;
- ftdm_clear_flag_locked(span, FTDM_SPAN_STATE_CHANGE);
- if (susp) {
- for(j = 1; j <= span->chan_count; j++) {
- if (ftdm_test_flag((span->channels[j]), FTDM_CHANNEL_STATE_CHANGE) || susp) {
- ftdm_mutex_lock(span->channels[j]->mutex);
- ftdm_clear_flag((span->channels[j]), FTDM_CHANNEL_STATE_CHANGE);
- if (susp && span->channels[j]->state != FTDM_CHANNEL_STATE_DOWN) {
- ftdm_set_state(span->channels[j], FTDM_CHANNEL_STATE_RESTART);
- }
- ftdm_channel_advance_states(span->channels[j]);
- ftdm_mutex_unlock(span->channels[j]->mutex);
- }
- }
- } else {
- while ((ftdmchan = ftdm_queue_dequeue(span->pendingchans))) {
- /* it can happen that someone else processed the chan states
- * but without taking the chan out of the queue, so check th
- * flag before advancing the state */
- ftdm_mutex_lock(ftdmchan->mutex);
- ftdm_channel_advance_states(ftdmchan);
- ftdm_mutex_unlock(ftdmchan->mutex);
- }
- }
- }
-
- if (ftdm_test_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RESTARTING)) {
- if (ftdm_check_state_all(span, FTDM_CHANNEL_STATE_DOWN)) {
- sangomabc_exec_command(&sangoma_boost_data->mcon,
- 0,
- 0,
- -1,
- SIGBOOST_EVENT_SYSTEM_RESTART_ACK,
- 0, 0);
- ftdm_clear_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RESTARTING);
- ftdm_clear_flag_locked(span, FTDM_SPAN_SUSPENDED);
- ftdm_clear_flag((&sangoma_boost_data->mcon), MSU_FLAG_DOWN);
- init_outgoing_array();
- }
- }
-}
-
-
-/**
- * \brief Checks for events on a span
- * \param span Span to check for events
- */
-static __inline__ ftdm_status_t check_events(ftdm_span_t *span, int ms_timeout)
-{
- ftdm_status_t status;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- status = ftdm_span_poll_event(span, ms_timeout, NULL);
-
- switch(status) {
- case FTDM_SUCCESS:
- {
- ftdm_event_t *event;
- while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) {
- switch (event->enum_id) {
- case FTDM_OOB_ALARM_TRAP:
- if (sangoma_boost_data->sigmod) {
- sangoma_boost_data->sigmod->on_hw_link_status_change(event->channel, FTDM_HW_LINK_DISCONNECTED);
- }
- break;
- case FTDM_OOB_ALARM_CLEAR:
- if (sangoma_boost_data->sigmod) {
- sangoma_boost_data->sigmod->on_hw_link_status_change(event->channel, FTDM_HW_LINK_CONNECTED);
- }
- break;
- }
- }
- }
- break;
- case FTDM_FAIL:
- {
- if (!ftdm_running()) {
- break;
- }
- ftdm_log(FTDM_LOG_ERROR, "Boost Check Event Failure Failure: %s\n", span->last_error);
- return FTDM_FAIL;
- }
- break;
- default:
- break;
- }
-
- return FTDM_SUCCESS;
-}
-
-/**
- * \brief Main thread function for sangoma boost span (monitor)
- * \param me Current thread
- * \param obj Span to run in this thread
- */
-static void *ftdm_sangoma_events_run(ftdm_thread_t *me, void *obj)
-{
- ftdm_span_t *span = (ftdm_span_t *) obj;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- unsigned errs = 0;
-
- while (ftdm_test_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_EVENTS_RUNNING) && ftdm_running()) {
- if (check_events(span, 100) != FTDM_SUCCESS) {
- if (errs++ > 50) {
- ftdm_log(FTDM_LOG_ERROR, "Too many event errors, quitting sangoma events thread\n");
- return NULL;
- }
- }
- }
-
- ftdm_log(FTDM_LOG_DEBUG, "Sangoma Boost Events thread ended.\n");
-
- ftdm_clear_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_EVENTS_RUNNING);
-
- return NULL;
-}
-
-static ftdm_status_t ftdm_boost_connection_open(ftdm_span_t *span)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- if (sangoma_boost_data->sigmod) {
- if (sangoma_boost_data->sigmod->start_span(span) != FTDM_SUCCESS) {
- return FTDM_FAIL;
- }
- ftdm_clear_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RESTARTING);
- ftdm_clear_flag_locked(span, FTDM_SPAN_SUSPENDED);
- ftdm_clear_flag((&sangoma_boost_data->mcon), MSU_FLAG_DOWN);
- }
-
- sangoma_boost_data->pcon = sangoma_boost_data->mcon;
-
- /* when sigmod is present, all arguments: local_ip etc, are ignored by sangomabc_connection_open */
- if (sangomabc_connection_open(&sangoma_boost_data->mcon,
- sangoma_boost_data->mcon.cfg.local_ip,
- sangoma_boost_data->mcon.cfg.local_port,
- sangoma_boost_data->mcon.cfg.remote_ip,
- sangoma_boost_data->mcon.cfg.remote_port) < 0) {
- ftdm_log(FTDM_LOG_ERROR, "Error: Opening MCON Socket [%d] %s\n", sangoma_boost_data->mcon.socket, strerror(errno));
- return FTDM_FAIL;
- }
-
- if (sangomabc_connection_open(&sangoma_boost_data->pcon,
- sangoma_boost_data->pcon.cfg.local_ip,
- ++sangoma_boost_data->pcon.cfg.local_port,
- sangoma_boost_data->pcon.cfg.remote_ip,
- ++sangoma_boost_data->pcon.cfg.remote_port) < 0) {
- ftdm_log(FTDM_LOG_ERROR, "Error: Opening PCON Socket [%d] %s\n", sangoma_boost_data->pcon.socket, strerror(errno));
- return FTDM_FAIL;
- }
-
- /* try to create the boost sockets interrupt objects */
- if (ftdm_interrupt_create(&sangoma_boost_data->pcon.sock_interrupt, sangoma_boost_data->pcon.socket) != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_ERROR, "Span %s could not create its boost msock interrupt!\n", span->name);
- return FTDM_FAIL;
- }
-
- if (ftdm_interrupt_create(&sangoma_boost_data->mcon.sock_interrupt, sangoma_boost_data->mcon.socket) != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_ERROR, "Span %s could not create its boost psock interrupt!\n", span->name);
- return FTDM_FAIL;
- }
-
- return FTDM_SUCCESS;
-}
-
-/*!
- \brief wait for a boost event
- \return -1 on error, 0 on timeout, 1 when there are events
- */
-static int ftdm_boost_wait_event(ftdm_span_t *span)
-{
- ftdm_status_t res;
- ftdm_interrupt_t *ints[3];
- int numints;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- ftdm_queue_get_interrupt(span->pendingchans, &ints[0]);
- numints = 1;
- /* if in queue mode wait for both the pendingchans queue and the boost msg queue */
- if (sangoma_boost_data->sigmod) {
- ftdm_queue_get_interrupt(sangoma_boost_data->boost_queue, &ints[1]);
- numints = 2;
- }
-#ifndef __WINDOWS__
- else {
- /* socket mode ... */
- ints[1] = sangoma_boost_data->mcon.sock_interrupt;
- ints[2] = sangoma_boost_data->pcon.sock_interrupt;
- numints = 3;
- sangoma_boost_data->iteration = 0;
- }
-#endif
- res = ftdm_interrupt_multiple_wait(ints, numints, 100);
- if (FTDM_SUCCESS != res && FTDM_TIMEOUT != res) {
- ftdm_log(FTDM_LOG_CRIT, "Unexpected return value from interrupt waiting: %d\n", res);
- return -1;
- }
- return 0;
-}
-
-
-static sangomabc_event_t *ftdm_boost_read_event(ftdm_span_t *span)
-{
- sangomabc_event_t *event = NULL;
- sangomabc_connection_t *mcon, *pcon;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- mcon = &sangoma_boost_data->mcon;
- pcon = &sangoma_boost_data->pcon;
-
- event = sangomabc_connection_readp(pcon, sangoma_boost_data->iteration);
-
- /* if there is no event and this is not a sigmod-driven span it's time to try the other connection for events */
- if (!event && !sangoma_boost_data->sigmod) {
- event = sangomabc_connection_read(mcon, sangoma_boost_data->iteration);
- }
-
- return event;
-}
-
-/**
- * \brief Main thread function for sangoma boost span (monitor)
- * \param me Current thread
- * \param obj Span to run in this thread
- */
-static void *ftdm_sangoma_boost_run(ftdm_thread_t *me, void *obj)
-{
- ftdm_span_t *span = (ftdm_span_t *) obj;
- sangomabc_connection_t *mcon, *pcon;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- mcon = &sangoma_boost_data->mcon;
- pcon = &sangoma_boost_data->pcon;
-
- /* sigmod overrides socket functionality if not null */
- if (sangoma_boost_data->sigmod) {
- mcon->span = span;
- pcon->span = span;
- /* everything could be retrieved through span, but let's use shortcuts */
- mcon->sigmod = sangoma_boost_data->sigmod;
- pcon->sigmod = sangoma_boost_data->sigmod;
- mcon->boost_queue = sangoma_boost_data->boost_queue;
- pcon->boost_queue = sangoma_boost_data->boost_queue;
- }
-
- if (ftdm_boost_connection_open(span) != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_CRIT, "ftdm_boost_connection_open failed\n");
- goto end;
- }
-
- init_outgoing_array();
- if (!sangoma_boost_data->sigmod) {
- sangomabc_exec_commandp(pcon,
- 0,
- 0,
- -1,
- SIGBOOST_EVENT_SYSTEM_RESTART,
- 0);
- ftdm_set_flag(mcon, MSU_FLAG_DOWN);
- }
-
- while (ftdm_test_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RUNNING)) {
- sangomabc_event_t *event = NULL;
-
- if (!ftdm_running()) {
- if (!sangoma_boost_data->sigmod) {
- sangomabc_exec_commandp(pcon,
- 0,
- 0,
- -1,
- SIGBOOST_EVENT_SYSTEM_RESTART,
- 0);
- ftdm_set_flag(mcon, MSU_FLAG_DOWN);
- }
- ftdm_log(FTDM_LOG_DEBUG, "ftdm is no longer running\n");
- break;
- }
-
- if (ftdm_boost_wait_event(span) < 0) {
- ftdm_log(FTDM_LOG_ERROR, "ftdm_boost_wait_event failed\n");
- }
-
- while ((event = ftdm_boost_read_event(span))) {
- parse_sangoma_event(span, pcon, (sangomabc_short_event_t*)event);
- sangoma_boost_data->iteration++;
- }
-
- check_state(span);
- }
-
-end:
- if (!sangoma_boost_data->sigmod) {
- sangomabc_connection_close(&sangoma_boost_data->mcon);
- sangomabc_connection_close(&sangoma_boost_data->pcon);
- }
-
- ftdm_clear_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RUNNING);
-
- ftdm_log(FTDM_LOG_DEBUG, "Sangoma Boost thread ended.\n");
- return NULL;
-}
-
-#if 0
-static int sigmod_ss7box_isup_exec_cmd(ftdm_stream_handle_t *stream, char *cmd)
-{
- FILE *fp;
- int status=0;
- char path[1024];
-
- fp = popen(cmd, "r");
- if (fp == NULL) {
- stream->write_function(stream, "%s: -ERR failed to execute cmd: %s\n",
- __FILE__,cmd);
- return -1;
- }
-
- while (fgets(path, sizeof(path)-1, fp) != NULL) {
- path[sizeof(path)-1]='\0';
- stream->write_function(stream,"%s", path);
- }
-
-
- status = pclose(fp);
- if (status == -1) {
- /* Error reported by pclose() */
- } else {
- /* Use macros described under wait() to inspect `status' in order
- to determine success/failure of command executed by popen() */
- }
-
- return status;
-}
-#endif
-
-static void ftdm_cli_span_state_cmd(ftdm_span_t *span, char *state)
-{
- unsigned int j;
- int cnt=0;
- ftdm_channel_state_t state_e = ftdm_str2ftdm_channel_state(state);
- if (state_e == FTDM_CHANNEL_STATE_INVALID) {
- ftdm_log(FTDM_LOG_CRIT, "Checking for channels not in the INVALID state is probably not what you want\n");
- }
- for(j = 1; j <= span->chan_count; j++) {
- if (span->channels[j]->state != state_e) {
- ftdm_channel_t *ftdmchan = span->channels[j];
- ftdm_log(FTDM_LOG_CRIT, "Channel %i s%dc%d State=%s\n",
- j, ftdmchan->physical_span_id-1, ftdmchan->physical_chan_id-1, ftdm_channel_state2str(ftdmchan->state));
- cnt++;
- }
- }
- ftdm_log(FTDM_LOG_CRIT, "Total Channel Cnt %i\n",cnt);
-}
-
-#define FTDM_BOOST_SYNTAX "list sigmods | | tracelevel "
-/**
- * \brief API function to kill or debug a sangoma_boost span
- * \param stream API stream handler
- * \param data String containing argurments
- * \return Flags
- */
-static FIO_API_FUNCTION(ftdm_sangoma_boost_api)
-{
- char *mycmd = NULL, *argv[10] = { 0 };
- int argc = 0;
-
- if (data) {
- mycmd = ftdm_strdup(data);
- argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
- }
-
- if (argc > 1) {
- if (!strcasecmp(argv[0], "list")) {
- if (!strcasecmp(argv[1], "sigmods")) {
- if (ftdm_sangoma_boost_list_sigmods(stream) != FTDM_SUCCESS) {
- stream->write_function(stream, "-ERR failed to list sigmods\n");
- goto done;
- }
- goto done;
- }
-
- if (!strcasecmp(argv[1], "ids")) {
- print_request_ids();
- goto done;
- }
- } else if (!strcasecmp(argv[0], "tracelevel")) {
- ftdm_status_t status;
- const char *levelname = NULL;
- int dbglevel;
- ftdm_sangoma_boost_data_t *sangoma_boost_data;
- ftdm_span_t *span;
-
- if (argc <= 2) {
- stream->write_function(stream, "-ERR usage: tracelevel \n");
- goto done;
- }
-
- status = ftdm_span_find_by_name(argv[1], &span);
- if (FTDM_SUCCESS != status) {
- stream->write_function(stream, "-ERR failed to find span by name %s\n", argv[1]);
- goto done;
- }
-
- if (span->signal_type != FTDM_SIGTYPE_SANGOMABOOST) {
- stream->write_function(stream, "-ERR span %s is not of boost type\n", argv[1]);
- goto done;
- }
-
- for (dbglevel = 0; (levelname = FTDM_LEVEL_NAMES[dbglevel]); dbglevel++) {
- if (!strcasecmp(levelname, argv[2])) {
- break;
- }
- }
-
- if (!levelname) {
- stream->write_function(stream, "-ERR invalid log level %s\n", argv[2]);
- goto done;
- }
-
- sangoma_boost_data = span->signal_data;
- sangoma_boost_data->pcon.debuglevel = dbglevel;
- sangoma_boost_data->mcon.debuglevel = dbglevel;
- stream->write_function(stream, "+OK span %s has now trace level %s\n", argv[1], FTDM_LEVEL_NAMES[dbglevel]);
- goto done;
-#ifndef __WINDOWS__
-#if 0
-/* NC: This code crashes the kernel due to fork on heavy fs load */
- } else if (!strcasecmp(argv[0], "ss7box_isupd_ckt")) {
-
- if (!strcasecmp(argv[1], "used")) {
- stream->write_function(stream, "ss7box_isupd: in use\n", FTDM_BOOST_SYNTAX);
- sigmod_ss7box_isup_exec_cmd(stream, (char*) "ckt_report.sh inuse");
- } else if (!strcasecmp(argv[1], "reset")) {
- stream->write_function(stream, "ss7box_isupd: in reset\n", FTDM_BOOST_SYNTAX);
- sigmod_ss7box_isup_exec_cmd(stream, (char*) "ckt_report.sh reset");
- } else if (!strcasecmp(argv[1], "ready")) {
- stream->write_function(stream, "ss7box_isupd: ready \n", FTDM_BOOST_SYNTAX);
- sigmod_ss7box_isup_exec_cmd(stream, (char*) "ckt_report.sh free");
- } else {
- stream->write_function(stream, "ss7box_isupd: list\n", FTDM_BOOST_SYNTAX);
- sigmod_ss7box_isup_exec_cmd(stream, (char*) "ckt_report.sh");
- }
-
- goto done;
-#endif
-#endif
-
- } else if (!strcasecmp(argv[0], "span")) {
- int err;
- sangomabc_connection_t *pcon;
- ftdm_sangoma_boost_data_t *sangoma_boost_data;
- ftdm_span_t *span;
-
- if (argc <= 2) {
- stream->write_function(stream, "-ERR invalid span usage: span \n");
- goto done;
- }
-
- err = ftdm_span_find_by_name(argv[1], &span);
- if (FTDM_SUCCESS != err) {
- stream->write_function(stream, "-ERR failed to find span by name %s\n",argv[1]);
- goto done;
- }
-
- if (!strcasecmp(argv[2], "restart")) {
- sangoma_boost_data = span->signal_data;
- pcon = &sangoma_boost_data->pcon;
-
- /* No need to set any span flags because
- our RESTART will generate a RESTART from the sig daemon */
- sangomabc_exec_commandp(pcon,
- 0,
- 0,
- -1,
- SIGBOOST_EVENT_SYSTEM_RESTART,
- 0);
- } else if (!strcasecmp(argv[2], "state")) {
- if (argc <= 3) {
- stream->write_function(stream, "-ERR invalid span state: span state \n");
- goto done;
- }
- ftdm_cli_span_state_cmd(span,argv[3]);
- }
-
- goto done;
-
- } else {
- boost_sigmod_interface_t *sigmod_iface = NULL;
- sigmod_iface = hashtable_search(g_boost_modules_hash, argv[0]);
- if (sigmod_iface) {
- char *p = strchr(data, ' ');
- if (++p) {
- char* mydup = strdup(p);
- if(sigmod_iface->exec_api == NULL) {
- stream->write_function(stream, "%s does not support api functions\n", sigmod_iface->name);
- goto done;
- }
- //stream->write_function(stream, "sigmod:%s command:%s\n", sigmod_iface->name, mydup);
- if (sigmod_iface->exec_api(stream, mydup) != FTDM_SUCCESS) {
- stream->write_function(stream, "-ERR:failed to execute command:%s\n", mydup);
- }
- free(mydup);
- }
-
- goto done;
- } else {
- stream->write_function(stream, "-ERR: Could not find sigmod %s\n", argv[0]);
- }
- }
- }
- stream->write_function(stream, "-ERR: Usage: %s\n", FTDM_BOOST_SYNTAX);
-done:
- ftdm_safe_free(mycmd);
- return FTDM_SUCCESS;
-}
-
-/**
- * \brief Loads sangoma_boost IO module
- * \param fio FreeTDM IO interface
- * \return Success
- */
-static FIO_IO_LOAD_FUNCTION(ftdm_sangoma_boost_io_init)
-{
- ftdm_assert(fio != NULL, "fio is NULL");
- memset(&ftdm_sangoma_boost_interface, 0, sizeof(ftdm_sangoma_boost_interface));
-
- ftdm_sangoma_boost_interface.name = "boost";
- ftdm_sangoma_boost_interface.api = ftdm_sangoma_boost_api;
-
- *fio = &ftdm_sangoma_boost_interface;
-
- return FTDM_SUCCESS;
-}
-
-/**
- * \brief Loads sangoma boost signaling module
- * \param fio FreeTDM IO interface
- * \return Success
- */
-static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_boost_init)
-{
- g_boost_modules_hash = create_hashtable(10, ftdm_hash_hashfromstring, ftdm_hash_equalkeys);
- if (!g_boost_modules_hash) {
- return FTDM_FAIL;
- }
- ftdm_mutex_create(&request_mutex);
- ftdm_mutex_create(&g_boost_modules_mutex);
- memset(&g_trunkgroups[0], 0, sizeof(g_trunkgroups));
- return FTDM_SUCCESS;
-}
-
-static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_boost_destroy)
-{
- ftdm_hash_iterator_t *i = NULL;
- boost_sigmod_interface_t *sigmod = NULL;
- const void *key = NULL;
- void *val = NULL;
- ftdm_dso_lib_t lib;
- ftdm_log(FTDM_LOG_DEBUG, "Destroying sangoma boost module\n");
- for (i = hashtable_first(g_boost_modules_hash); i; i = hashtable_next(i)) {
- hashtable_this(i, &key, NULL, &val);
- if (key && val) {
- sigmod = val;
- lib = sigmod->pvt;
- ftdm_log(FTDM_LOG_DEBUG, "destroying sigmod %s\n", sigmod->name);
- sigmod->on_unload();
- ftdm_dso_destroy(&lib);
- }
- }
-
- hashtable_destroy(g_boost_modules_hash);
- ftdm_mutex_destroy(&request_mutex);
- ftdm_mutex_destroy(&g_boost_modules_mutex);
- return FTDM_SUCCESS;
-}
-
-static ftdm_status_t ftdm_sangoma_boost_start(ftdm_span_t *span)
-{
- int err;
-
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- ftdm_set_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RUNNING);
- err = ftdm_thread_create_detached(ftdm_sangoma_boost_run, span);
- if (err) {
- ftdm_clear_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RUNNING);
- return err;
- }
-
- // launch the events thread to handle HW DTMF and possibly
- // other events in the future
- ftdm_set_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_EVENTS_RUNNING);
- err = ftdm_thread_create_detached(ftdm_sangoma_events_run, span);
- if (err) {
- ftdm_clear_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_EVENTS_RUNNING);
- ftdm_clear_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RUNNING);
- }
-
- return err;
-}
-
-static ftdm_status_t ftdm_sangoma_boost_stop(ftdm_span_t *span)
-{
- int cnt = 50;
- ftdm_status_t status = FTDM_SUCCESS;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
-
- if (sangoma_boost_data->sigmod) {
- /* I think stopping the span before destroying the queue makes sense
- otherwise may be boost events would still arrive when the queue is already destroyed! */
- status = sangoma_boost_data->sigmod->stop_span(span);
- if (status != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_CRIT, "Failed to stop span %s boost signaling\n", span->name);
- return FTDM_FAIL;
- }
- ftdm_queue_enqueue(sangoma_boost_data->boost_queue, NULL);
- }
-
- while (ftdm_test_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_RUNNING) && cnt-- > 0) {
- ftdm_log(FTDM_LOG_DEBUG, "Waiting for boost thread\n");
- ftdm_sleep(100);
- }
-
- if (!cnt) {
- ftdm_log(FTDM_LOG_CRIT, "it seems boost thread in span %s may be stuck, we may segfault :-(\n", span->name);
- return FTDM_FAIL;
- }
-
- cnt = 50;
- while (ftdm_test_flag(sangoma_boost_data, FTDM_SANGOMA_BOOST_EVENTS_RUNNING) && cnt-- > 0) {
- ftdm_log(FTDM_LOG_DEBUG, "Waiting for boost events thread\n");
- ftdm_sleep(100);
- }
-
- if (!cnt) {
- ftdm_log(FTDM_LOG_CRIT, "it seems boost events thread in span %s may be stuck, we may segfault :-(\n", span->name);
- return FTDM_FAIL;
- }
-
- if (sangoma_boost_data->sigmod) {
- ftdm_queue_destroy(&sangoma_boost_data->boost_queue);
- }
-
- return status;
-}
-
-static ftdm_state_map_t boost_state_map = {
- {
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_ANY_STATE},
- {FTDM_CHANNEL_STATE_RESTART, FTDM_END}
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_RESTART, FTDM_END},
- {FTDM_CHANNEL_STATE_DOWN, FTDM_END}
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_DOWN, FTDM_END},
- {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_DIALING, FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_HOLD, FTDM_END}
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_HOLD, FTDM_END},
- {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS,
- FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_HANGUP, FTDM_END}
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_DIALING, FTDM_END},
- {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS, FTDM_END}
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_IDLE, FTDM_CHANNEL_STATE_DIALING, FTDM_END},
- {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_END}
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END},
- {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_HANGUP, FTDM_END}
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_END},
- {FTDM_CHANNEL_STATE_DOWN, FTDM_END},
- },
- {
- ZSD_OUTBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_UP, FTDM_END},
- {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END}
- },
-
- /****************************************/
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_ANY_STATE},
- {FTDM_CHANNEL_STATE_RESTART, FTDM_END}
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_RESTART, FTDM_END},
- {FTDM_CHANNEL_STATE_DOWN, FTDM_END}
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_DOWN},
- {FTDM_CHANNEL_STATE_IN_LOOP, FTDM_END}
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_IN_LOOP},
- {FTDM_CHANNEL_STATE_DOWN, FTDM_END}
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_DOWN, FTDM_END},
- {FTDM_CHANNEL_STATE_RING, FTDM_END}
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_RING, FTDM_END},
- {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA,FTDM_END}
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END},
- {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_HANGUP, FTDM_END},
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END},
- {FTDM_CHANNEL_STATE_DOWN, FTDM_END},
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_END},
- {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_END},
- },
- {
- ZSD_INBOUND,
- ZSM_UNACCEPTABLE,
- {FTDM_CHANNEL_STATE_UP, FTDM_END},
- {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_END},
- },
-
-
- }
-};
-
-static BOOST_WRITE_MSG_FUNCTION(ftdm_boost_write_msg)
-{
- sangomabc_short_event_t *shortmsg = NULL;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = NULL;
- sangomabc_queue_element_t *element = NULL;
-
- ftdm_assert_return(msg != NULL, FTDM_FAIL, "Boost message to write was null");
-
- if (!span) {
- shortmsg = msg;
- ftdm_log(FTDM_LOG_ERROR, "Unexpected boost message %d\n", shortmsg->event_id);
- return FTDM_FAIL;
- }
- /* duplicate the event and enqueue it */
- element = ftdm_calloc(1, sizeof(*element));
- if (!element) {
- return FTDM_FAIL;
- }
- memcpy(element->boostmsg, msg, msglen);
- element->size = msglen;
-
- sangoma_boost_data = span->signal_data;
- return ftdm_queue_enqueue(sangoma_boost_data->boost_queue, element);
-}
-
-static BOOST_SIG_STATUS_CB_FUNCTION(ftdm_boost_sig_status_change)
-{
- ftdm_sigmsg_t sig;
- ftdm_log(FTDM_LOG_NOTICE, "%d:%d Signaling link status changed to %s\n", ftdmchan->span_id, ftdmchan->chan_id, 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;
- ftdm_span_send_signal(ftdmchan->span, &sig);
- return;
-}
-
-static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(sangoma_boost_set_channel_sig_status)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
- if (!sangoma_boost_data->sigmod) {
- ftdm_log(FTDM_LOG_ERROR, "Cannot set signaling status in boost channel with no signaling module configured\n");
- return FTDM_FAIL;
- }
- if (!sangoma_boost_data->sigmod->set_channel_sig_status) {
- ftdm_log(FTDM_LOG_ERROR, "Cannot set signaling status in boost channel: method not implemented\n");
- return FTDM_NOTIMPL;
- }
- return sangoma_boost_data->sigmod->set_channel_sig_status(ftdmchan, status);
-}
-
-static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(sangoma_boost_get_channel_sig_status)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = ftdmchan->span->signal_data;
- if (!sangoma_boost_data->sigmod) {
- return FTDM_FAIL;
- }
- if (!sangoma_boost_data->sigmod->get_channel_sig_status) {
- return FTDM_NOTIMPL;
- }
- return sangoma_boost_data->sigmod->get_channel_sig_status(ftdmchan, status);
-}
-
-static FIO_SPAN_SET_SIG_STATUS_FUNCTION(sangoma_boost_set_span_sig_status)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- if (!sangoma_boost_data->sigmod) {
- ftdm_log(FTDM_LOG_ERROR, "Cannot set signaling status in boost span with no signaling module configured\n");
- return FTDM_FAIL;
- }
- if (!sangoma_boost_data->sigmod->set_span_sig_status) {
- ftdm_log(FTDM_LOG_ERROR, "Cannot set signaling status in boost span: method not implemented\n");
- return FTDM_NOTIMPL;
- }
- return sangoma_boost_data->sigmod->set_span_sig_status(span, status);
-}
-
-static FIO_SPAN_GET_SIG_STATUS_FUNCTION(sangoma_boost_get_span_sig_status)
-{
- ftdm_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- if (!sangoma_boost_data->sigmod) {
- return FTDM_FAIL;
- }
- if (!sangoma_boost_data->sigmod->get_span_sig_status) {
- ftdm_log(FTDM_LOG_ERROR, "Cannot get signaling status in boost span: method not implemented\n");
- return FTDM_NOTIMPL;
- }
- return sangoma_boost_data->sigmod->get_span_sig_status(span, status);
-}
-
-/**
- * \brief Initialises an sangoma boost span from configuration variables
- * \param span Span to configure
- * \param sig_cb Callback function for event signals
- * \param ap List of configuration variables
- * \return Success or failure
- */
-static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_boost_configure_span)
-{
-#define FAIL_CONFIG_RETURN(retstatus) \
- if (sangoma_boost_data) \
- ftdm_safe_free(sangoma_boost_data); \
- if (err) \
- ftdm_safe_free(err) \
- if (hash_locked) \
- ftdm_mutex_unlock(g_boost_modules_mutex); \
- if (lib) \
- ftdm_dso_destroy(&lib); \
- return retstatus;
-
- boost_sigmod_interface_t *sigmod_iface = NULL;
- ftdm_sangoma_boost_data_t *sangoma_boost_data = NULL;
- const char *local_ip = "127.0.0.65", *remote_ip = "127.0.0.66";
- const char *sigmod = NULL;
- int local_port = 53000, remote_port = 53000;
- const char *var = NULL, *val = NULL;
- int hash_locked = 0;
- ftdm_dso_lib_t lib = NULL;
- char path[255] = "";
- char *err = NULL;
- unsigned int j = 0;
- unsigned paramindex = 0;
- ftdm_status_t rc = FTDM_SUCCESS;
-
- for (; ftdm_parameters[paramindex].var; paramindex++) {
- var = ftdm_parameters[paramindex].var;
- val = ftdm_parameters[paramindex].val;
- if (!strcasecmp(var, "sigmod")) {
- sigmod = val;
- } else if (!strcasecmp(var, "local_ip")) {
- local_ip = val;
- } else if (!strcasecmp(var, "remote_ip")) {
- remote_ip = val;
- } else if (!strcasecmp(var, "local_port")) {
- local_port = atoi(val);
- } else if (!strcasecmp(var, "remote_port")) {
- remote_port = atoi(val);
- } else if (!strcasecmp(var, "outbound-called-ton")) {
- ftdm_set_ton(val, &span->default_caller_data.dnis.type);
- } else if (!strcasecmp(var, "outbound-called-npi")) {
- ftdm_set_npi(val, &span->default_caller_data.dnis.plan);
- } else if (!strcasecmp(var, "outbound-calling-ton")) {
- ftdm_set_ton(val, &span->default_caller_data.cid_num.type);
- } else if (!strcasecmp(var, "outbound-calling-npi")) {
- ftdm_set_npi(val, &span->default_caller_data.cid_num.plan);
- } else if (!strcasecmp(var, "outbound-rdnis-ton")) {
- ftdm_set_ton(val, &span->default_caller_data.rdnis.type);
- } else if (!strcasecmp(var, "outbound-rdnis-npi")) {
- ftdm_set_npi(val, &span->default_caller_data.rdnis.plan);
- } else if (!sigmod) {
- snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var);
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
- }
-
- if (!sigmod) {
-#ifndef HAVE_NETINET_SCTP_H
- ftdm_log(FTDM_LOG_CRIT, "No sigmod attribute in span %s, you must either specify a sigmod or re-compile with SCTP available to use socket mode boost!\n", span->name);
- ftdm_set_string(span->last_error, "No sigmod configuration was set and there is no SCTP available!");
- FAIL_CONFIG_RETURN(FTDM_FAIL);
-#else
- if (!local_ip && local_port && remote_ip && remote_port && sig_cb) {
- ftdm_set_string(span->last_error, "missing Sangoma boost IP parameters");
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
-#endif
- }
-
- sangoma_boost_data = ftdm_calloc(1, sizeof(*sangoma_boost_data));
- if (!sangoma_boost_data) {
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
-
- /* WARNING: be sure to release this mutex on errors inside this if() */
- ftdm_mutex_lock(g_boost_modules_mutex);
- hash_locked = 1;
- if (sigmod && !(sigmod_iface = hashtable_search(g_boost_modules_hash, (void *)sigmod))) {
- ftdm_build_dso_path(sigmod, path, sizeof(path));
- lib = ftdm_dso_open(path, &err);
- if (!lib) {
- ftdm_log(FTDM_LOG_ERROR, "Error loading Sangoma boost signaling module '%s': %s\n", path, err);
- snprintf(span->last_error, sizeof(span->last_error), "Failed to load sangoma boost signaling module %s", path);
-
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
- if (!(sigmod_iface = (boost_sigmod_interface_t *)ftdm_dso_func_sym(lib, BOOST_INTERFACE_NAME_STR, &err))) {
- ftdm_log(FTDM_LOG_ERROR, "Failed to read Sangoma boost signaling module interface '%s': %s\n", path, err);
- snprintf(span->last_error, sizeof(span->last_error), "Failed to read Sangoma boost signaling module interface '%s': %s", path, err);
-
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
- rc = sigmod_iface->on_load();
- if (rc != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_ERROR, "Failed to load Sangoma boost signaling module interface '%s': on_load method failed (%d)\n", path, rc);
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
- sigmod_iface->pvt = lib;
- sigmod_iface->set_write_msg_cb(ftdm_boost_write_msg);
- sigmod_iface->set_sig_status_cb(ftdm_boost_sig_status_change);
- hashtable_insert(g_boost_modules_hash, (void *)sigmod_iface->name, sigmod_iface, HASHTABLE_FLAG_NONE);
- lib = NULL; /* destroying the lib will be done when going down and NOT on FAIL_CONFIG_RETURN */
- }
- ftdm_mutex_unlock(g_boost_modules_mutex);
- hash_locked = 0;
-
- if (sigmod_iface) {
- /* try to create the boost queue */
- if (ftdm_queue_create(&sangoma_boost_data->boost_queue, BOOST_QUEUE_SIZE) != FTDM_SUCCESS) {
- ftdm_log(FTDM_LOG_ERROR, "Span %s could not create its boost queue!\n", span->name);
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
- ftdm_log(FTDM_LOG_NOTICE, "Span %s will use Sangoma Boost Signaling Module %s\n", span->name, sigmod_iface->name);
- sangoma_boost_data->sigmod = sigmod_iface;
- sigmod_iface->configure_span(span, ftdm_parameters);
- } else {
- ftdm_log(FTDM_LOG_NOTICE, "Span %s will use boost socket mode\n", span->name);
- ftdm_set_string(sangoma_boost_data->mcon.cfg.local_ip, local_ip);
- sangoma_boost_data->mcon.cfg.local_port = local_port;
- ftdm_set_string(sangoma_boost_data->mcon.cfg.remote_ip, remote_ip);
- sangoma_boost_data->mcon.cfg.remote_port = remote_port;
- }
-
- for (j = 1; j <= span->chan_count; j++) {
- span->channels[j]->call_data = ftdm_calloc(1, sizeof(sangoma_boost_call_t));
- if (!span->channels[j]->call_data) {
- FAIL_CONFIG_RETURN(FTDM_FAIL);
- }
- }
-
- span->signal_cb = sig_cb;
- span->start = ftdm_sangoma_boost_start;
- span->stop = ftdm_sangoma_boost_stop;
- span->signal_data = sangoma_boost_data;
- span->signal_type = FTDM_SIGTYPE_SANGOMABOOST;
- span->outgoing_call = sangoma_boost_outgoing_call;
- span->channel_request = sangoma_boost_channel_request;
- span->get_channel_sig_status = sangoma_boost_get_channel_sig_status;
- span->set_channel_sig_status = sangoma_boost_set_channel_sig_status;
- span->get_span_sig_status = sangoma_boost_get_span_sig_status;
- span->set_span_sig_status = sangoma_boost_set_span_sig_status;
- span->state_map = &boost_state_map;
- span->state_processor = state_advance;
- sangoma_boost_data->mcon.debuglevel = FTDM_LOG_LEVEL_DEBUG;
- sangoma_boost_data->pcon.debuglevel = FTDM_LOG_LEVEL_DEBUG;
- ftdm_clear_flag(span, FTDM_SPAN_SUGGEST_CHAN_ID);
- ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE);
- if (sigmod_iface) {
- /* the core will do the hunting */
- span->channel_request = NULL;
- }
- ftdm_set_flag_locked(span, FTDM_SPAN_SUSPENDED);
- return FTDM_SUCCESS;
-}
-
-static ftdm_status_t ftdm_sangoma_boost_list_sigmods(ftdm_stream_handle_t *stream)
-{
- ftdm_hash_iterator_t *i = NULL;
- boost_sigmod_interface_t *sigmod_iface = NULL;
- const void *key = NULL;
- void *val = NULL;
-
- stream->write_function(stream, "List of loaded sigmod modules:\n");
- for (i = hashtable_first(g_boost_modules_hash); i; i = hashtable_next(i)) {
- hashtable_this(i, &key, NULL, &val);
- if (key && val) {
- sigmod_iface = val;
- stream->write_function(stream, " %s\n", sigmod_iface->name);
- }
- }
- stream->write_function(stream, "\n");
- return FTDM_SUCCESS;
-}
-
-/**
- * \brief FreeTDM sangoma boost signaling module definition
- */
-EX_DECLARE_DATA ftdm_module_t ftdm_module = {
- /*.name =*/ "sangoma_boost",
- /*.io_load =*/ ftdm_sangoma_boost_io_init,
- /*.io_unload =*/ NULL,
- /*.sig_load = */ ftdm_sangoma_boost_init,
- /*.sig_configure =*/ NULL,
- /*.sig_unload = */ftdm_sangoma_boost_destroy,
- /*.configure_span_signaling = */ ftdm_sangoma_boost_configure_span
-};
-
-/* 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:
- */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_client.c b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_client.c
deleted file mode 100644
index 6ddb74d253..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_client.c
+++ /dev/null
@@ -1,589 +0,0 @@
-/*
- * Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
- * 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.
- */
-
-#define _GNU_SOURCE
-
-#if HAVE_NETDB_H
-#include
-#endif
-
-#include "freetdm.h"
-#include "sangoma_boost_client.h"
-
-#ifndef HAVE_GETHOSTBYNAME_R
-extern int gethostbyname_r (const char *__name,
- struct hostent *__result_buf,
- char *__buf, size_t __buflen,
- struct hostent **__result,
- int *__h_errnop);
-#endif
-
-struct sangomabc_map {
- uint32_t event_id;
- const char *name;
-};
-
-static struct sangomabc_map sangomabc_table[] = {
- {SIGBOOST_EVENT_CALL_START, "CALL_START"},
- {SIGBOOST_EVENT_CALL_START_ACK, "CALL_START_ACK"},
- {SIGBOOST_EVENT_CALL_START_NACK, "CALL_START_NACK"},
- {SIGBOOST_EVENT_CALL_PROGRESS, "CALL PROGRESS"},
- {SIGBOOST_EVENT_CALL_START_NACK_ACK, "CALL_START_NACK_ACK"},
- {SIGBOOST_EVENT_CALL_ANSWERED, "CALL_ANSWERED"},
- {SIGBOOST_EVENT_CALL_STOPPED, "CALL_STOPPED"},
- {SIGBOOST_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
- {SIGBOOST_EVENT_CALL_RELEASED, "CALL_RELEASED"},
- {SIGBOOST_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
- {SIGBOOST_EVENT_SYSTEM_RESTART_ACK, "SYSTEM_RESTART_ACK"},
- {SIGBOOST_EVENT_HEARTBEAT, "HEARTBEAT"},
- {SIGBOOST_EVENT_INSERT_CHECK_LOOP, "LOOP START"},
- {SIGBOOST_EVENT_REMOVE_CHECK_LOOP, "LOOP STOP"},
- {SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE, "AUTO_CALL_GAP_ABATE"},
- {SIGBOOST_EVENT_DIGIT_IN, "DIGIT_IN"}
-};
-
-
-
-static void sangomabc_print_event_call(sangomabc_connection_t *mcon, sangomabc_event_t *event, int priority, int dir, const char *file, const char *func, int line)
-{
- if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
- return;
-
- ftdm_log(file, func, line, mcon->debuglevel, "%s EVENT (%s): %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s] Rdnis=[%s]\n",
- dir ? "TX":"RX",
- priority ? "P":"N",
- sangomabc_event_id_name(event->event_id),
- event->event_id,
- BOOST_EVENT_SPAN(mcon->sigmod, event),
- BOOST_EVENT_CHAN(mcon->sigmod, event),
- event->call_setup_id,
- event->fseqno,
- strlen(event->calling_name)?event->calling_name:"N/A",
- (event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
- (event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
- event->isup_in_rdnis);
-
-}
-static void sangomabc_print_event_short(sangomabc_connection_t *mcon, sangomabc_short_event_t *event, int priority, int dir, const char *file, const char *func, int line)
-{
- if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
- return;
- ftdm_log(file, func, line, mcon->debuglevel, "%s EVENT (%s): %s:(%X) [s%dc%d] Rc=%i CSid=%i Seq=%i \n",
- dir ? "TX":"RX",
- priority ? "P":"N",
- sangomabc_event_id_name(event->event_id),
- event->event_id,
- BOOST_EVENT_SPAN(mcon->sigmod, event),
- BOOST_EVENT_CHAN(mcon->sigmod, event),
- event->release_cause,
- event->call_setup_id,
- event->fseqno);
-}
-
-
-static int create_conn_socket(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
-{
-#ifndef WIN32
- int rc;
- struct hostent *result, *local_result;
- char buf[512], local_buf[512];
- int err = 0, local_err = 0;
-
- if (mcon->sigmod) {
- ftdm_log(FTDM_LOG_WARNING, "I should not be called on a sigmod-managed connection!\n");
- return 0;
- }
-
- memset(&mcon->remote_hp, 0, sizeof(mcon->remote_hp));
- memset(&mcon->local_hp, 0, sizeof(mcon->local_hp));
-#ifdef HAVE_NETINET_SCTP_H
- ftdm_log(FTDM_LOG_DEBUG, "Creating SCTP socket L=%s:%d R=%s:%d\n",
- local_ip, local_port, ip, port);
- mcon->socket = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
-#else
- ftdm_log(FTDM_LOG_DEBUG, "Creating UDP socket L=%s:%d R=%s:%d\n",
- local_ip, local_port, ip, port);
- mcon->socket = socket(AF_INET, SOCK_DGRAM, 0);
-#endif
-
- if (mcon->socket >= 0) {
- int flag;
-
- flag = 1;
-#ifdef HAVE_GETHOSTBYNAME_R_FIVE
- gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &err);
- gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_err);
- if (!err && !local_err) {
-#else
- gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &result, &err);
- gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_result, &local_err);
- if (result && local_result) {
-#endif
- mcon->remote_addr.sin_family = mcon->remote_hp.h_addrtype;
- memcpy((char *) &mcon->remote_addr.sin_addr.s_addr, mcon->remote_hp.h_addr_list[0], mcon->remote_hp.h_length);
- mcon->remote_addr.sin_port = htons(port);
-
- mcon->local_addr.sin_family = mcon->local_hp.h_addrtype;
- memcpy((char *) &mcon->local_addr.sin_addr.s_addr, mcon->local_hp.h_addr_list[0], mcon->local_hp.h_length);
- mcon->local_addr.sin_port = htons(local_port);
-
-#ifdef HAVE_NETINET_SCTP_H
- setsockopt(mcon->socket, IPPROTO_SCTP, SCTP_NODELAY,
- (char *)&flag, sizeof(int));
-#endif
-
- if ((rc = bind(mcon->socket,
- (struct sockaddr *) &mcon->local_addr,
- sizeof(mcon->local_addr))) < 0) {
- close(mcon->socket);
- mcon->socket = -1;
- } else {
-#ifdef HAVE_NETINET_SCTP_H
- rc=listen(mcon->socket, 100);
- if (rc) {
- close(mcon->socket);
- mcon->socket = -1;
- }
-#endif
- }
- }
- }
-
- return mcon->socket;
-#else
- return 0;
-#endif // ifndef WIN32
-}
-
-int sangomabc_connection_close(sangomabc_connection_t *mcon)
-{
-#ifndef WIN32
- if (mcon->sigmod) {
- ftdm_log(FTDM_LOG_WARNING, "I should not be called on a sigmod-managed connection!\n");
- return 0;
- }
- if (mcon->socket > -1) {
- close(mcon->socket);
- }
-
- if (mcon->mutex) {
- ftdm_mutex_lock(mcon->mutex);
- ftdm_mutex_unlock(mcon->mutex);
- ftdm_mutex_destroy(&mcon->mutex);
- }
- memset(mcon, 0, sizeof(*mcon));
- mcon->socket = -1;
-#endif
- return 0;
-}
-
-int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
-{
- ftdm_mutex_create(&mcon->mutex);
- if (mcon->sigmod) {
- /*value of mcon->socket will be ignored in sigmod mode */
- return 0;
- }
-#ifndef WIN32
- create_conn_socket(mcon, local_ip, local_port, ip, port);
- return mcon->socket;
-#else
- return 0;
-#endif
-}
-
-
-int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause, int flags)
-{
- sangomabc_event_t *oevent;
- sangomabc_short_event_t sevent;
- sangomabc_event_t fevent;
- int retry = 5;
-
- if (boost_full_event(cmd)) {
- sangomabc_event_init((void *)&fevent, cmd, chan, span);
- oevent = &fevent;
- } else {
- sangomabc_event_init(&sevent, cmd, chan, span);
- sevent.release_cause = (uint8_t)cause;
- oevent = (sangomabc_event_t *)&sevent;
- }
- oevent->flags = flags;
-
- if (cmd == SIGBOOST_EVENT_SYSTEM_RESTART || cmd == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
- mcon->rxseq_reset = 1;
- mcon->txseq = 0;
- mcon->rxseq = 0;
- mcon->txwindow = 0;
- }
-
- if (id >= 0) {
- oevent->call_setup_id = (uint16_t)id;
- }
-
- while (sangomabc_connection_write(mcon, (sangomabc_event_t*)oevent) <= 0) {
- if (--retry <= 0) {
- ftdm_log(FTDM_LOG_CRIT, "Failed to tx on boost socket: %s\n", strerror(errno));
- return -1;
- } else {
- ftdm_log(FTDM_LOG_WARNING, "Failed to tx on boost socket: %s :retry %i\n", strerror(errno), retry);
- ftdm_sleep(1);
- }
- }
-
- return 0;
-}
-
-
-int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause)
-{
- sangomabc_short_event_t oevent;
- int retry = 5;
-
- sangomabc_event_init(&oevent, cmd, chan, span);
- oevent.release_cause = (uint8_t)cause;
-
- if (id >= 0) {
- oevent.call_setup_id = (uint16_t)id;
- }
-
- while (sangomabc_connection_writep(pcon, (sangomabc_event_t*)&oevent) <= 0) {
- if (--retry <= 0) {
- ftdm_log(FTDM_LOG_CRIT, "Failed to tx on boost socket: %s\n", strerror(errno));
- return -1;
- } else {
- ftdm_log(FTDM_LOG_WARNING, "Failed to tx on boost socket: %s :retry %i\n", strerror(errno), retry);
- ftdm_sleep(1);
- }
- }
-
- return 0;
-}
-
-sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
-{
-#ifndef WIN32
- unsigned int fromlen = sizeof(struct sockaddr_in);
-#endif
- int bytes = 0;
- int msg_ok = 0;
- sangomabc_queue_element_t *e = NULL;
-
- if (mcon->sigmod) {
- e = ftdm_queue_dequeue(mcon->boost_queue);
- if (e) {
- bytes = (int)e->size;
- memcpy(&mcon->event, e->boostmsg, bytes);
- ftdm_safe_free(e);
- }
- }
-#ifndef WIN32
- else {
- bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
- (struct sockaddr *) &mcon->local_addr, &fromlen);
- }
-#endif
- if (bytes <= 0) {
- return NULL;
- }
-
- if (mcon->event.version != SIGBOOST_VERSION) {
- ftdm_log(FTDM_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
- }
-
- if ((bytes >= MIN_SIZE_CALLSTART_MSG) && boost_full_event(mcon->event.event_id)) {
- msg_ok=1;
-
- } else if (bytes == sizeof(sangomabc_short_event_t)) {
- msg_ok=1;
-
- } else {
- msg_ok=0;
- }
-
- if (msg_ok) {
- if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
- if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
- mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
- mcon->event.event_id != SIGBOOST_EVENT_HEARTBEAT) {
- ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "Not reading packets when connection is down. [%s]\n",
- sangomabc_event_id_name(mcon->event.event_id));
- return NULL;
- }
- }
-
- if (boost_full_event(mcon->event.event_id)) {
- sangomabc_print_event_call(mcon, &mcon->event, 0, 0, file, func, line);
- } else {
- sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)&mcon->event, 0, 0, file, func, line);
- }
-
-#if 0
-/* NC: NOT USED ANY MORE */
- if (mcon->rxseq_reset) {
- //if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
- ftdm_log(FTDM_LOG_DEBUG, "Rx sync ok\n");
- mcon->rxseq = mcon->event.fseqno;
- return &mcon->event;
- //}
- errno=EAGAIN;
- ftdm_log(FTDM_LOG_DEBUG, "Waiting for rx sync...\n");
- return NULL;
- }
-#endif
-
- mcon->txwindow = mcon->txseq - mcon->event.bseqno;
- mcon->rxseq++;
-
-#if 0
- if (mcon->rxseq != mcon->event.fseqno) {
- ftdm_log(FTDM_LOG_CRIT, "Invalid Sequence Number Expect=%i Rx=%i\n", mcon->rxseq, mcon->event.fseqno);
- return NULL;
- }
-#endif
-
- return &mcon->event;
- } else {
- if (iteration == 0) {
- ftdm_log(FTDM_LOG_CRIT, "NC - Invalid Event length from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
- return NULL;
- }
- }
-
- return NULL;
-}
-
-sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
-{
-#ifndef WIN32
- unsigned int fromlen = sizeof(struct sockaddr_in);
-#endif
- int bytes = 0;
-
- if (mcon->sigmod) {
- /* priority stuff is handled just the same when there is a sigmod */
- return sangomabc_connection_read(mcon, iteration);
- }
-#ifndef WIN32
- else {
- bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT, (struct sockaddr *) &mcon->local_addr, &fromlen);
- }
-#endif
- if (bytes <= 0) {
- return NULL;
- }
-
- if (mcon->event.version != SIGBOOST_VERSION) {
- ftdm_log(FTDM_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
- }
-
- if (bytes == sizeof(sangomabc_short_event_t)) {
-
- if (boost_full_event(mcon->event.event_id)) {
- sangomabc_print_event_call(mcon, &mcon->event, 1, 0, file, func, line);
- } else {
- sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)&mcon->event, 1, 0, file, func, line);
- }
-
- return &mcon->event;
- } else {
- if (iteration == 0) {
- ftdm_log(FTDM_LOG_CRIT, "Critical Error: PQ Invalid Event lenght from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
- return NULL;
- }
- }
-
- return NULL;
-}
-
-
-int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
-{
- int err = 0;
- int event_size=MIN_SIZE_CALLSTART_MSG+event->isup_in_rdnis_size;
-
- ftdm_assert_return(event != NULL, -1, "No event!");
- ftdm_assert_return(mcon->socket >= 0, -1, "No mcon->socket!");
- ftdm_assert_return(mcon->mutex != NULL, -1, "No mcon->mutex!");
-
- ftdm_assert_return(event->span <= FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN, -1, "Invalid span when writing boost event\n");
- ftdm_assert_return(event->chan <= FTDM_MAX_CHANNELS_PHYSICAL_SPAN, -1, "Invalid chan when writing boost event\n");
-
- if (!boost_full_event(event->event_id)) {
- event_size=sizeof(sangomabc_short_event_t);
- }
-
- if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
- if (event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
- event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
- event->event_id != SIGBOOST_EVENT_HEARTBEAT) {
- ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "Not writing packets when connection is down. [%s]\n",
- sangomabc_event_id_name(event->event_id));
- return 0;
- }
- }
-
- ftdm_mutex_lock(mcon->mutex);
- if (event->event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
- mcon->txseq=0;
- mcon->rxseq=0;
- event->fseqno=0;
- } else {
- event->fseqno = mcon->txseq++;
- }
- event->bseqno = mcon->rxseq;
- event->version = SIGBOOST_VERSION;
-
- if (boost_full_event(event->event_id)) {
- sangomabc_print_event_call(mcon, event, 0, 1, file, func, line);
- } else {
- sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)event, 0, 1, file, func, line);
- }
-
- if (mcon->sigmod) {
- mcon->sigmod->write_msg(mcon->span, event, event_size);
- err = event_size;
- }
-#ifndef WIN32
- else {
- err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
- }
-#endif
-
- ftdm_mutex_unlock(mcon->mutex);
-
- ftdm_assert_return(err == event_size, -1, "Failed to send the boost message completely!");
-
- return err;
-}
-
-
-int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
-{
- int err = 0;
- int event_size=sizeof(sangomabc_event_t);
-
- if (!mcon->sigmod) {
- ftdm_assert_return(event != NULL, -1, "No event!");
- ftdm_assert_return(mcon->socket >= 0, -1, "No mcon->socket!");
- ftdm_assert_return(mcon->mutex != NULL, -1, "No mcon->mutex!");
- }
-
- if (!boost_full_event(event->event_id)) {
- event_size=sizeof(sangomabc_short_event_t);
- }
-
- ftdm_mutex_lock(mcon->mutex);
- event->version = SIGBOOST_VERSION;
- if (mcon->sigmod) {
- mcon->sigmod->write_msg(mcon->span, event, event_size);
- err = event_size;
-
- }
-#ifndef WIN32
- else {
- err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
- }
-#endif
- ftdm_mutex_unlock(mcon->mutex);
-
- ftdm_assert_return(err == event_size, -1, "Failed to send boost message completely!");
-
- if (boost_full_event(event->event_id)) {
- sangomabc_print_event_call(mcon, event, 1, 1, file, func, line);
- } else {
- sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)event, 1, 1, file, func, line);
- }
-
- return err;
-}
-
-
-void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id)
-{
- memset(event, 0, sizeof(sangomabc_event_t));
- event->event_id = SIGBOOST_EVENT_CALL_START;
-
- if (calling) {
- strncpy((char*)event->calling_number_digits, calling, sizeof(event->calling_number_digits)-1);
- event->calling_number_digits_count = (uint8_t)strlen(calling);
- }
-
- if (called) {
- strncpy((char*)event->called_number_digits, called, sizeof(event->called_number_digits)-1);
- event->called_number_digits_count = (uint8_t)strlen(called);
- }
-
- event->call_setup_id = (uint16_t)setup_id;
-
-}
-
-void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span)
-{
- if (boost_full_event(event_id)) {
- memset(event, 0, sizeof(sangomabc_event_t));
- } else {
- memset(event, 0, sizeof(sangomabc_short_event_t));
- }
- event->event_id = event_id;
- event->chan = (uint8_t)chan;
- event->span = (uint8_t)span;
-}
-
-const char *sangomabc_event_id_name(uint32_t event_id)
-{
- unsigned int x;
- const char *ret = NULL;
-
- for (x = 0 ; x < sizeof(sangomabc_table)/sizeof(struct sangomabc_map); x++) {
- if (sangomabc_table[x].event_id == event_id) {
- ret = sangomabc_table[x].name;
- break;
- }
- }
-
- return ret;
-}
-
-
-/* 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:
- */
-
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_client.h b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_client.h
deleted file mode 100644
index e333c4aba3..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_client.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
- * 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 _SANGOMABC_H
-#define _SANGOMABC_H
-
-#include "sangoma_boost_interface.h"
-
-#include
-#include
-#ifndef WIN32
-#include
-#include
-#include
-#ifdef HAVE_NETINET_SCTP_H
-#include
-#endif
-#include
-#include
-#include
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include "sigboost.h"
-
-#define sangomabc_test_flag(p,flag) ((p)->flags & (flag))
-
-#define sangomabc_set_flag(p,flag) do { \
- ((p)->flags |= (flag)); \
- } while (0)
-
-#define sangomabc_clear_flag(p,flag) do { \
- ((p)->flags &= ~(flag)); \
- } while (0)
-
-#define sangomabc_copy_flags(dest,src,flagz) do { \
- (dest)->flags &= ~(flagz); \
- (dest)->flags |= ((src)->flags & (flagz)); \
- } while (0)
-
-typedef t_sigboost_callstart sangomabc_event_t;
-typedef t_sigboost_short sangomabc_short_event_t;
-typedef uint32_t sangomabc_event_id_t;
-
-typedef struct sangomabc_ip_cfg
-{
- char local_ip[25];
- int local_port;
- char remote_ip[25];
- int remote_port;
-}sangomabc_ip_cfg_t;
-
-typedef enum {
- MSU_FLAG_EVENT = (1 << 0),
- MSU_FLAG_DOWN = (1 << 1)
-} sangomabc_flag_t;
-
-
-struct sangomabc_connection {
- ftdm_socket_t socket;
- struct sockaddr_in local_addr;
- struct sockaddr_in remote_addr;
- sangomabc_event_t event;
- struct hostent remote_hp;
- struct hostent local_hp;
- unsigned int flags;
- ftdm_mutex_t *mutex;
- FILE *log;
- unsigned int txseq;
- unsigned int rxseq;
- unsigned int txwindow;
- unsigned int rxseq_reset;
- sangomabc_ip_cfg_t cfg;
- /* boost signaling mod interface pointer (if not working in TCP mode) */
- boost_sigmod_interface_t *sigmod;
- ftdm_queue_t *boost_queue;
- ftdm_interrupt_t *sock_interrupt;
- ftdm_span_t *span;
- int debuglevel;
-};
-
-typedef struct sangomabc_connection sangomabc_connection_t;
-
-typedef struct sangomabc_queue_element {
- unsigned char boostmsg[sizeof(sangomabc_event_t)];
- ftdm_size_t size;
-} sangomabc_queue_element_t;
-
-/* disable nagle's algorythm */
-static __inline__ void sctp_no_nagle(int socket)
-{
-#ifdef HAVE_NETINET_SCTP_H
- int flag = 1;
- setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY, (char *) &flag, sizeof(int));
-#endif
-}
-
-int sangomabc_connection_close(sangomabc_connection_t *mcon);
-int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
-sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
-sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
-int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
-int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
-#define sangomabc_connection_write(_m,_e) __sangomabc_connection_write(_m, _e, __FILE__, __FUNCTION__, __LINE__)
-#define sangomabc_connection_writep(_m,_e) __sangomabc_connection_writep(_m, _e, __FILE__, __FUNCTION__, __LINE__)
-#define sangomabc_connection_read(_m,_e) __sangomabc_connection_read(_m, _e, __FILE__, __FUNCTION__, __LINE__)
-#define sangomabc_connection_readp(_m,_e) __sangomabc_connection_readp(_m, _e, __FILE__, __FUNCTION__, __LINE__)
-void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span);
-void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id);
-const char *sangomabc_event_id_name(uint32_t event_id);
-int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause, int flags);
-int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause);
-
-#define BOOST_EVENT_SPAN(sigmod, event) ((sigmod) ? event->span : event->span + 1)
-#define BOOST_EVENT_CHAN(sigmod, event) ((sigmod) ? event->chan : event->chan + 1)
-
-
-#endif
-
-
-/* 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:
- */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_interface.h b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_interface.h
deleted file mode 100644
index f6130db444..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sangoma_boost_interface.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2009, Sangoma Technologies
- * Moises Silva
- * 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 SANGOMA_BOOST_INTERFACE_H
-#define SANGOMA_BOOST_INTERFACE_H
-
-#include "private/ftdm_core.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*!
- \brief Callback used to notify signaling status changes on a channel
- \param ftdmchan The freetdm channel where the signaling status just changed
- \param status The new signaling status
- */
-#define BOOST_SIG_STATUS_CB_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
-typedef void (*boost_sig_status_cb_func_t) BOOST_SIG_STATUS_CB_ARGS;
-#define BOOST_SIG_STATUS_CB_FUNCTION(name) void name BOOST_SIG_STATUS_CB_ARGS
-
-/*!
- \brief Write a boost msg to a boost endpoint
- \param span The freetdm span where this msg was generated
- \param msg The generic message pointer, owned by the caller
- \param msglen The length of the provided structure pointed by msg
- \return FTDM_SUCCESS or FTDM_FAIL
-
- The msg buffer is owned by the caller and it should
- be either t_sigboost_callstart or t_sigboost_short
- the endpoint receiving the msg will first cast to
- t_sigboost_short, check the event type, and if needed.
- */
-#define BOOST_WRITE_MSG_ARGS (ftdm_span_t *span, void *msg, ftdm_size_t msglen)
-typedef ftdm_status_t (*boost_write_msg_func_t) BOOST_WRITE_MSG_ARGS;
-#define BOOST_WRITE_MSG_FUNCTION(name) ftdm_status_t name BOOST_WRITE_MSG_ARGS
-
-/*!
- \brief Set the callback to be used by a signaling module to write boost messages
- \param callback The callback to be used by the signaling module
-
- The provided callback will be used for the signaling boost module to notify the
- user with boost messages.
- */
-#define BOOST_SET_WRITE_MSG_CB_ARGS (boost_write_msg_func_t callback)
-typedef void (*boost_set_write_msg_cb_func_t) BOOST_SET_WRITE_MSG_CB_ARGS;
-#define BOOST_SET_WRITE_MSG_CB_FUNCTION(name) void name BOOST_SET_WRITE_MSG_CB_ARGS
-
-/*!
- \brief Notify hardware status change
- \param ftdmchan The freetdm channel
- \param status The hw status
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS (ftdm_channel_t *ftdmchan, ftdm_channel_hw_link_status_t status)
-typedef void (*boost_on_hw_link_status_change_func_t) BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS;
-#define BOOST_ON_HW_LINK_STATUS_CHANGE_FUNCTION(name) void name BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS
-
-/*!
- \brief Set signaling status callback used by the signaling module to report signaling status changes
- \param callback The callback to be used by the signaling module
-
- The provided callback will be used for the signaling boost module to notify the
- user with signaling link status changes.
- */
-#define BOOST_SET_SIG_STATUS_CB_ARGS (boost_sig_status_cb_func_t callback)
-typedef void (*boost_set_sig_status_cb_func_t) BOOST_SET_SIG_STATUS_CB_ARGS;
-#define BOOST_SET_SIG_STATUS_CB_FUNCTION(name) void name BOOST_SET_SIG_STATUS_CB_ARGS
-
-/*!
- \brief Get the signaling status on the given channel.
- \param ftdmchan The freetdm channel
- \param status The status pointer where the current signaling status will be set
- */
-#define BOOST_GET_CHANNEL_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status)
-typedef ftdm_status_t (*boost_get_channel_sig_status_func_t) BOOST_GET_CHANNEL_SIG_STATUS_ARGS;
-#define BOOST_GET_CHANNEL_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_GET_CHANNEL_SIG_STATUS_ARGS
-
-/*!
- \brief Set the signaling status on the given channel.
- \param ftdmchan The freetdm channel
- \param status The new status for the channel
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_SET_CHANNEL_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
-typedef ftdm_status_t (*boost_set_channel_sig_status_func_t) BOOST_SET_CHANNEL_SIG_STATUS_ARGS;
-#define BOOST_SET_CHANNEL_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_SET_CHANNEL_SIG_STATUS_ARGS
-
-/*!
- \brief Get the signaling status on the given span.
- \param span The freetdm span
- \param status The status pointer where the current signaling status will be set
- */
-#define BOOST_GET_SPAN_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t *status)
-typedef ftdm_status_t (*boost_get_span_sig_status_func_t) BOOST_GET_SPAN_SIG_STATUS_ARGS;
-#define BOOST_GET_SPAN_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_GET_SPAN_SIG_STATUS_ARGS
-
-/*!
- \brief Set the signaling status on the given span.
- \param ftdmchan The freetdm span
- \param status The new status for the span
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_SET_SPAN_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status)
-typedef ftdm_status_t (*boost_set_span_sig_status_func_t) BOOST_SET_SPAN_SIG_STATUS_ARGS;
-#define BOOST_SET_SPAN_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_SET_SPAN_SIG_STATUS_ARGS
-
-/*!
- \brief Configure the given span signaling
- \param span The freetdm span
- \param parameters The array of configuration key,value pairs (must be null terminated)
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_CONFIGURE_SPAN_ARGS (ftdm_span_t *span, ftdm_conf_parameter_t *parameters)
-typedef ftdm_status_t (*boost_configure_span_func_t) BOOST_CONFIGURE_SPAN_ARGS;
-#define BOOST_CONFIGURE_SPAN_FUNCTION(name) ftdm_status_t name BOOST_CONFIGURE_SPAN_ARGS
-
-/*!
- \brief Start the given span
- \param span The freetdm span
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_START_SPAN_ARGS (ftdm_span_t *span)
-typedef ftdm_status_t (*boost_start_span_func_t) BOOST_START_SPAN_ARGS;
-#define BOOST_START_SPAN_FUNCTION(name) ftdm_status_t name BOOST_START_SPAN_ARGS
-
-/*!
- \brief Stop the given span
- \param span The freetdm span
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_STOP_SPAN_ARGS (ftdm_span_t *span)
-typedef ftdm_status_t (*boost_stop_span_func_t) BOOST_START_SPAN_ARGS;
-#define BOOST_STOP_SPAN_FUNCTION(name) ftdm_status_t name BOOST_STOP_SPAN_ARGS
-
-/*!
- \brief Called when the module is being loaded BEFORE calling anything else
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_ON_LOAD_ARGS (void)
-typedef ftdm_status_t (*boost_on_load_func_t) BOOST_ON_LOAD_ARGS;
-#define BOOST_ON_LOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_LOAD_ARGS
-
-/*!
- \brief Called when the module is being unloaded, last chance to stop everything!
- */
-#define BOOST_ON_UNLOAD_ARGS (void)
-typedef ftdm_status_t (*boost_on_unload_func_t) BOOST_ON_UNLOAD_ARGS;
-#define BOOST_ON_UNLOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_UNLOAD_ARGS
-
-/*!
- \brief Called when user wants to execute sigmod api function
- \return FTDM_SUCCESS or FTDM_FAIL
- */
-#define BOOST_API_ARGS (ftdm_stream_handle_t *stream, char *cmd)
-typedef ftdm_status_t (*boost_api_func_t) BOOST_API_ARGS;
-#define BOOST_API_FUNCTION(name) ftdm_status_t name BOOST_API_ARGS
-
-
-/*!
- \brief The boost signaling module interface
- */
-typedef struct boost_sigmod_interface_s {
- /*! \brief Module name */
- const char *name;
- /*! \brief write boost message function */
- boost_write_msg_func_t write_msg;
- /*! \brief set the user write boost message function */
- boost_set_write_msg_cb_func_t set_write_msg_cb;
- /*! \brief set the user signaling status function */
- boost_set_sig_status_cb_func_t set_sig_status_cb;
- /*! \brief get channel signaling status */
- boost_get_channel_sig_status_func_t get_channel_sig_status;
- /*! \brief set channel signaling status */
- boost_set_channel_sig_status_func_t set_channel_sig_status;
- /*! \brief get span signaling status */
- boost_get_span_sig_status_func_t get_span_sig_status;
- /*! \brief set span signaling status */
- boost_set_span_sig_status_func_t set_span_sig_status;
- /*! \brief set notify hardware link status change */
- boost_on_hw_link_status_change_func_t on_hw_link_status_change;
- /*! \brief configure span signaling */
- boost_configure_span_func_t configure_span;
- /*! \brief start freetdm span */
- boost_start_span_func_t start_span;
- /*! \brief stop freetdm span */
- boost_stop_span_func_t stop_span;
- /*! \brief the module was just loaded */
- boost_on_load_func_t on_load;
- /*! \brief the module is about to be unloaded */
- boost_on_unload_func_t on_unload;
- /*! \brief module api function */
- boost_api_func_t exec_api;
- /*! \brief private pointer for the interface user */
- void *pvt;
-} boost_sigmod_interface_t;
-
-#ifdef __cplusplus
-} // extern C
-#endif
-
-#define BOOST_INTERFACE_NAME boost_sigmod_interface
-#define BOOST_INTERFACE_NAME_STR "boost_sigmod_interface"
-/* use this in your sig boost module to declare your interface */
-#ifndef WIN32
-#define BOOST_INTERFACE boost_sigmod_interface_t BOOST_INTERFACE_NAME
-#else
-#define BOOST_INTERFACE __declspec(dllexport) boost_sigmod_interface_t BOOST_INTERFACE_NAME
-#endif
-#endif
-
-
-/* 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:
- */
-
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sigboost.h b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sigboost.h
deleted file mode 100644
index 7975dc5b93..0000000000
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/sigboost.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
- * sigboost.h $Revision: 1.13 $
- *
- * Definitions for the sigboost interface.
- *
- * WARNING WARNING WARNING
- *
- * This file is used by sangoma_mgd and perhaps other programs. Any changes
- * to this file must be coordinated with other user programs,
- *
- * Copyright (C) 2005 Xygnada Technology, Inc.
- *
-****************************************************************************/
-#ifndef _SIGBOOST_H_
-#define _SIGBOOST_H_
-
-#define SIGBOOST_VERSION 103
-
-// handy to define integer types that actually work on both Lin and Win
-#include
-
-enum e_sigboost_event_id_values
-{
- SIGBOOST_EVENT_CALL_START = 0x80, /*128*/
- SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129*/
- SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130*/
- SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131*/
- SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132*/
- SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133*/
- SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134*/
- SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135*/
- SIGBOOST_EVENT_SYSTEM_RESTART_ACK = 0x88, /*136*/
- /* CALL_RELEASED is aimed to fix a race condition that became obvious
- * when the boost socket was replaced by direct function calls
- * and the channel hunting was moved to freetdm, the problem is
- * we can get CALL_STOPPED msg and reply with CALL_STOPPED_ACK
- * but the signaling module will still (in PRI) send RELEASE and
- * wait for RELEASE_COMPLETE from the isdn network before
- * marking the channel as available, therefore freetdm should
- * also not mark the channel as available until CALL_RELEASED
- * is received, for socket mode we can continue working as usual
- * with CALL_STOPPED being the last step because the hunting is
- * done in the signaling module.
- * */
- SIGBOOST_EVENT_CALL_RELEASED = 0x51, /* 81 */
- SIGBOOST_EVENT_CALL_PROGRESS = 0x50, /*decimal 80*/
- /* Following IDs are ss7boost to sangoma_mgd only. */
- SIGBOOST_EVENT_HEARTBEAT = 0x89, /*137*/
- SIGBOOST_EVENT_INSERT_CHECK_LOOP = 0x8a, /*138*/
- SIGBOOST_EVENT_REMOVE_CHECK_LOOP = 0x8b, /*139*/
- SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE = 0x8c, /*140*/
- SIGBOOST_EVENT_DIGIT_IN = 0x8d, /*141*/
-};
-
-#define BOOST_DECODE_EVENT_ID(id) \
- (id==SIGBOOST_EVENT_CALL_START)?"SIGBOOST_EVENT_CALL_START": \
- (id==SIGBOOST_EVENT_CALL_START_ACK)?"SIGBOOST_EVENT_CALL_START_ACK": \
- (id==SIGBOOST_EVENT_CALL_START_NACK)?"SIGBOOST_EVENT_CALL_START_NACK": \
- (id==SIGBOOST_EVENT_CALL_ANSWERED)?"SIGBOOST_EVENT_CALL_ANSWERED": \
- (id==SIGBOOST_EVENT_CALL_STOPPED)?"SIGBOOST_EVENT_CALL_STOPPED": \
- (id==SIGBOOST_EVENT_CALL_STOPPED_ACK)?"SIGBOOST_EVENT_CALL_STOPPED_ACK": \
- (id==SIGBOOST_EVENT_SYSTEM_RESTART)?"SIGBOOST_EVENT_SYSTEM_RESTART": \
- (id==SIGBOOST_EVENT_SYSTEM_RESTART_ACK)?"SIGBOOST_EVENT_SYSTEM_RESTART_ACK": \
- (id==SIGBOOST_EVENT_CALL_RELEASED)?"SIGBOOST_EVENT_CALL_RELEASED": \
- (id==SIGBOOST_EVENT_CALL_PROGRESS)?"SIGBOOST_EVENT_CALL_PROGRESS": \
- (id==SIGBOOST_EVENT_HEARTBEAT)?"SIGBOOST_EVENT_HEARTBEAT": \
- (id==SIGBOOST_EVENT_INSERT_CHECK_LOOP)?"SIGBOOST_EVENT_INSERT_CHECK_LOOP": \
- (id==SIGBOOST_EVENT_REMOVE_CHECK_LOOP)?"SIGBOOST_EVENT_REMOVE_CHECK_LOOP": \
- (id==SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE)?"SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE": \
- (id==SIGBOOST_EVENT_DIGIT_IN)?"SIGBOOST_EVENT_DIGIT_IN": "Unknown"
-
-enum e_sigboost_release_cause_values
-{
- SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0,
- SIGBOOST_RELEASE_CAUSE_NORMAL = 16,
- /* probable elimination */
- //SIGBOOST_RELEASE_CAUSE_BUSY = 0x91, /* 145 */
- //SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92, /* 146 */
- //SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93, /* 147 */
- //SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94, /* 148 */
-};
-
-enum e_sigboost_call_setup_ack_nack_cause_values
-{
- //SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 34, /* Q.850 value - don't use */
- SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 117, /* non Q.850 value indicates local all ckt busy
- causing sangoma_mgd to perform automatic call
- gapping*/
- SIGBOOST_CALL_SETUP_NACK_TEST_CKT_BUSY = 17, /* Q.850 value */
- SIGBOOST_CALL_SETUP_NACK_INVALID_NUMBER = 28, /* Q.850 value */
- SIGBOOST_CALL_SETUP_CSUPID_DBL_USE = 200, /* unused Q.850 value */
-};
-
-
-enum e_sigboost_huntgroup_values
-{
- SIGBOOST_HUNTGRP_SEQ_ASC = 0x00, /* sequential with lowest available first */
- SIGBOOST_HUNTGRP_SEQ_DESC = 0x01, /* sequential with highest available first */
- SIGBOOST_HUNTGRP_RR_ASC = 0x02, /* round-robin with lowest available first */
- SIGBOOST_HUNTGRP_RR_DESC = 0x03, /* round-robin with highest available first */
-};
-
-enum e_sigboost_event_info_par_values
-{
- SIGBOOST_EVI_SPARE = 0x00,
- SIGBOOST_EVI_ALERTING = 0x01,
- SIGBOOST_EVI_PROGRESS = 0x02,
-};
-
-enum e_sigboost_progress_flags
-{
- SIGBOOST_PROGRESS_RING = (1 << 0),
- SIGBOOST_PROGRESS_MEDIA = (1 << 1)
-};
-
-#define MAX_DIALED_DIGITS 31
-
-/* Next two defines are used to create the range of values for call_setup_id
- * in the t_sigboost structure.
- * 0..((CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN) - 1) */
-#define CORE_MAX_SPANS 200
-#define CORE_MAX_CHAN_PER_SPAN 32
-#define MAX_PENDING_CALLS CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN
-/* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
-
-/* Should only be used by server */
-#define MAX_CALL_SETUP_ID 0xFFFF
-
-#define SIZE_CUSTOM 900
-#define SIZE_RDNIS SIZE_CUSTOM
-
-
-#pragma pack(1)
-
-typedef struct
-{
- uint8_t capability;
- uint8_t uil1p;
-} t_sigboost_bearer;
-
-typedef struct
-{
- uint8_t digits_count;
- char digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
- uint8_t npi;
- uint8_t ton;
- uint8_t screening_ind;
- uint8_t presentation_ind;
-}t_sigboost_digits;
-
-typedef struct
-{
- uint16_t version;
- uint32_t event_id;
- /* delete sequence numbers - SCTP does not need them */
- uint32_t fseqno;
- uint32_t bseqno;
- uint16_t call_setup_id;
- uint32_t trunk_group;
- uint8_t span;
- uint8_t chan;
- uint32_t flags;
- /* struct timeval tv; */
- t_sigboost_digits called;
- t_sigboost_digits calling;
- t_sigboost_digits rdnis;
- /* ref. Q.931 Table 4-11 and Q.951 Section 3 */
- char calling_name[MAX_DIALED_DIGITS + 1];
- t_sigboost_bearer bearer;
- uint8_t hunt_group;
- uint16_t custom_data_size;
- char custom_data[SIZE_CUSTOM]; /* it's a null terminated string */
-
-} t_sigboost_callstart;
-
-#define called_number_digits_count called.digits_count
-#define called_number_digits called.digits
-#define calling_number_digits_count calling.digits_count
-#define calling_number_digits calling.digits
-#define calling_number_screening_ind calling.screening_ind
-#define calling_number_presentation calling.presentation_ind
-
-#define isup_in_rdnis_size custom_data_size
-#define isup_in_rdnis custom_data
-
-
-#define MIN_SIZE_CALLSTART_MSG sizeof(t_sigboost_callstart) - SIZE_CUSTOM
-
-typedef struct
-{
- uint16_t version;
- uint32_t event_id;
- /* delete sequence numbers - SCTP does not need them */
- uint32_t fseqno;
- uint32_t bseqno;
- uint16_t call_setup_id;
- uint32_t trunk_group;
- uint8_t span;
- uint8_t chan;
- uint32_t flags;
- /* struct timeval tv; */
- uint8_t release_cause;
-} t_sigboost_short;
-#pragma pack()
-
-
-static __inline__ int boost_full_event(int event_id)
-{
- switch (event_id) {
- case SIGBOOST_EVENT_CALL_START:
- case SIGBOOST_EVENT_DIGIT_IN:
- case SIGBOOST_EVENT_CALL_PROGRESS:
- return 1;
- default:
- break;
- }
-
- return 0;
-}
-
-#endif
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
index e7053c1d43..608b0b6ac0 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
@@ -676,12 +676,15 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
/*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);
+ if (sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY)) {
+ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
+ }
} else {
if (!sngisdn_test_flag(sngisdn_info, FLAG_SENT_PROCEED)) {
/* By default, we do not send a progress indicator in the proceed */
ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_INVALID};
-
sngisdn_set_flag(sngisdn_info, FLAG_SENT_PROCEED);
+
sngisdn_snd_proceed(ftdmchan, prog_ind);
}
}
@@ -797,6 +800,17 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm
/* If we never received a PROCEED/ALERT/PROGRESS/CONNECT on an outgoing call, we need to send release instead of disconnect */
sngisdn_snd_release(ftdmchan, 0);
break;
+ case FTDM_CHANNEL_STATE_PROCEED:
+ if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
+ if (((sngisdn_span_data_t*)(ftdmchan->span->signal_data))->switchtype == SNGISDN_SWITCH_4ESS ||
+ ((sngisdn_span_data_t*)(ftdmchan->span->signal_data))->switchtype == SNGISDN_SWITCH_5ESS) {
+
+ /* When using 5ESS, if the user wants to clear an inbound call, the correct procedure is to send a PROGRESS with in-band info available, and play tones. Then send a DISCONNECT. If we reached this point, it means user did not try to play-tones, so send a RELEASE because remote side does not expect DISCONNECT in state 3 */
+ sngisdn_snd_release(ftdmchan, 0);
+ break;
+ }
+ }
+ /* fall-through */
default:
sngisdn_snd_disconnect(ftdmchan);
break;
@@ -898,9 +912,6 @@ 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;
- /* lock the channel while we check whether it is availble */
- ftdm_channel_lock(ftdmchan);
-
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_DOWN:
@@ -925,10 +936,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_isdn_outgoing_call)
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Outgoing call requested channel in already in use\n");
status = FTDM_BREAK;
}
- break;
+ break;
}
- ftdm_channel_unlock(ftdmchan);
return status;
}
static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_chan_sig_status)
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h
index 58fcc07040..b369deae1f 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h
@@ -80,6 +80,8 @@ typedef enum {
FLAG_ACTIVATING = (1 << 10),
/* Used when we receive an ALERT msg + inband tones ready */
FLAG_MEDIA_READY = (1 << 11),
+ /* Set when we already sent a Channel ID IE */
+ FLAG_SENT_CHAN_ID = (1 << 12),
} sngisdn_flag_t;
@@ -112,6 +114,11 @@ typedef enum {
SNGISDN_OPT_FALSE = 2,
} sngisdn_opt_t;
+typedef enum {
+ SNGISDN_EARLY_MEDIA_ON_PROCEED = (1 << 0),
+ SNGISDN_EARLY_MEDIA_ON_PROGRESS = (1 << 1),
+ SNGISDN_EARLY_MEDIA_ON_ALERT= (1 << 2),
+} sngisdn_early_media_opt_t;
typedef enum {
SNGISDN_AVAIL_DOWN = 1,
@@ -188,7 +195,8 @@ typedef struct sngisdn_span_data {
uint8_t span_id;
uint8_t tei;
uint8_t min_digits;
- uint8_t trace_flags; /* TODO: change to flags, so we can use ftdm_test_flag etc.. */
+ uint8_t trace_flags; /* TODO change to bit map of sngisdn_tracetype_t */
+ uint8_t early_media_flags; /* bit map of ftdm_sngisdn_early_media_opt_t */
uint8_t overlap_dial;
uint8_t setup_arb;
uint8_t facility_ie_decode;
@@ -196,10 +204,10 @@ typedef struct sngisdn_span_data {
int8_t facility_timeout;
uint8_t num_local_numbers;
uint8_t ignore_cause_value;
- uint8_t raw_trace_q931;
- uint8_t raw_trace_q921;
+ uint8_t raw_trace_q931; /* TODO: combine with trace_flags */
+ uint8_t raw_trace_q921; /* TODO: combine with trace_flags */
uint8_t timer_t3;
- uint8_t restart_opt;
+ uint8_t restart_opt;
char* local_numbers[SNGISDN_NUM_LOCAL_NUMBERS];
ftdm_sched_t *sched;
ftdm_queue_t *event_queue;
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c
index aad68e15d1..9fe28190e1 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c
@@ -84,6 +84,8 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span
signal_data->switchtype = SNGISDN_SWITCH_4ESS;
} else if (!strcasecmp(switch_name, "dms100")) {
signal_data->switchtype = SNGISDN_SWITCH_DMS100;
+ } else if (!strcasecmp(switch_name, "qsig")) {
+ signal_data->switchtype = SNGISDN_SWITCH_QSIG;
} else {
ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported switchtype %s for trunktype:%s\n", span->name, switch_name, ftdm_trunk_type2str(span->trunk_type));
return FTDM_FAIL;
@@ -192,6 +194,24 @@ static ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span)
return FTDM_SUCCESS;
}
+static ftdm_status_t parse_early_media(const char* opt, ftdm_span_t *span)
+{
+ sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data;
+ if (!strcasecmp(opt, "on-proceed")) {
+ signal_data->early_media_flags |= SNGISDN_EARLY_MEDIA_ON_PROCEED;
+ } else if (!strcasecmp(opt, "on-progress")) {
+ signal_data->early_media_flags |= SNGISDN_EARLY_MEDIA_ON_PROGRESS;
+ } else if (!strcasecmp(opt, "on-alert")) {
+ signal_data->early_media_flags |= SNGISDN_EARLY_MEDIA_ON_ALERT;
+ } else {
+ ftdm_log(FTDM_LOG_ERROR, "Unsupported early-media option %s\n", opt);
+ return FTDM_FAIL;
+ }
+ ftdm_log(FTDM_LOG_DEBUG, "Early media opt:0x%x\n", signal_data->early_media_flags);
+ return FTDM_SUCCESS;
+}
+
+
static ftdm_status_t set_switchtype_defaults(ftdm_span_t *span)
{
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data;
@@ -249,6 +269,7 @@ static ftdm_status_t set_switchtype_defaults(ftdm_span_t *span)
return FTDM_SUCCESS;
}
+
ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span)
{
unsigned paramindex;
@@ -351,10 +372,14 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
parse_yesno(var, val, &signal_data->raw_trace_q931);
} else if (!strcasecmp(var, "q921-raw-trace")) {
parse_yesno(var, val, &signal_data->raw_trace_q921);
+ } else if (!strcasecmp(var, "early-media-override")) {
+ if (parse_early_media(val, span) != FTDM_SUCCESS) {
+ return FTDM_FAIL;
+ }
} else {
ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var);
}
- }
+ } /* for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) */
if (signal_data->switchtype == SNGISDN_SWITCH_INVALID) {
ftdm_log(FTDM_LOG_ERROR, "%s: switchtype not specified", span->name);
@@ -366,10 +391,11 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
}
if (span->default_caller_data.bearer_layer1 == FTDM_INVALID_INT_PARM) {
- if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN) {
- span->default_caller_data.bearer_layer1 = IN_UIL1_G711ULAW;
- } else {
+ if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN ||
+ signal_data->switchtype == SNGISDN_SWITCH_QSIG) {
span->default_caller_data.bearer_layer1 = IN_UIL1_G711ALAW;
+ } else {
+ span->default_caller_data.bearer_layer1 = IN_UIL1_G711ULAW;
}
}
return FTDM_SUCCESS;
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c
index a52a624dd0..1bd2753e81 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c
@@ -667,25 +667,33 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span)
cfg.t.cfg.s.inDLSAP.maxBSrvCnt = 2;
cfg.t.cfg.s.inDLSAP.maxDSrvCnt = 2;
#endif /* ISDN_SRV */
-
- if (signal_data->signalling == SNGISDN_SIGNALING_NET) {
- cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;
- cfg.t.cfg.s.inDLSAP.intType = NETWORK;
- cfg.t.cfg.s.inDLSAP.clrGlr = FALSE; /* in case of glare, do not clear local call */
- cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE;
- if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN ||
- signal_data->switchtype == SNGISDN_SWITCH_INSNET) {
- cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;
- } else {
- cfg.t.cfg.s.inDLSAP.rstOpt = TRUE;
- }
- } else {
- cfg.t.cfg.s.inDLSAP.ackOpt = FALSE;
- cfg.t.cfg.s.inDLSAP.intType = USER;
+ if (signal_data->switchtype == SNGISDN_SWITCH_QSIG) {
+ cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;
+ cfg.t.cfg.s.inDLSAP.intType = SYM_USER;
cfg.t.cfg.s.inDLSAP.clrGlr = TRUE; /* in case of glare, clear local call */
cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE;
cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;
+ } else {
+ if (signal_data->signalling == SNGISDN_SIGNALING_NET) {
+ cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;
+ cfg.t.cfg.s.inDLSAP.intType = NETWORK;
+ cfg.t.cfg.s.inDLSAP.clrGlr = FALSE; /* in case of glare, do not clear local call */
+ cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE;
+
+ if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN ||
+ signal_data->switchtype == SNGISDN_SWITCH_INSNET) {
+ cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;
+ } else {
+ cfg.t.cfg.s.inDLSAP.rstOpt = TRUE;
+ }
+ } else {
+ cfg.t.cfg.s.inDLSAP.ackOpt = FALSE;
+ cfg.t.cfg.s.inDLSAP.intType = USER;
+ cfg.t.cfg.s.inDLSAP.clrGlr = TRUE; /* in case of glare, clear local call */
+ cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE;
+ cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;
+ }
}
/* Override the restart options if user selected that option */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c
index 7b7c748c7a..bcc7d938b7 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c
@@ -167,12 +167,12 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
char retrieved_str[255];
ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str);
- /*
- return values for "sng_isdn_retrieve_facility_information_following":
- If there will be no information following, or fails to decode IE, returns -1
- 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
- */
+ /*
+ return values for "sng_isdn_retrieve_facility_information_following":
+ If there will be no information following, or fails to decode IE, returns -1
+ 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 (ret_val == 1) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Expecting Caller name in FACILITY\n");
@@ -346,6 +346,7 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event)
sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info;
ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan;
+ sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data;
CnStEvnt *cnStEvnt = &sngisdn_event->event.cnStEvnt;
@@ -385,7 +386,11 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event)
case FTDM_CHANNEL_STATE_PROCEED:
case FTDM_CHANNEL_STATE_PROGRESS:
case FTDM_CHANNEL_STATE_RINGING:
- if (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL) {
+ if ((cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL) ||
+ (cnStEvnt->progInd1.eh.pres && cnStEvnt->progInd1.progDesc.val == IN_PD_IBAVAIL) ||
+ (cnStEvnt->progInd2.eh.pres && cnStEvnt->progInd2.progDesc.val == IN_PD_IBAVAIL) ||
+ (cnStEvnt->progInd3.eh.pres && cnStEvnt->progInd3.progDesc.val == IN_PD_IBAVAIL)) {
+
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media available\n");
sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY);
} else {
@@ -393,16 +398,34 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event)
}
switch (evntType) {
case MI_CALLPROC:
+ if (!sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY) &&
+ (signal_data->early_media_flags & SNGISDN_EARLY_MEDIA_ON_PROCEED)) {
+
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media override on proceed\n");
+ sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY);
+ }
if (ftdmchan->state == FTDM_CHANNEL_STATE_DIALING) {
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROCEED);
}
break;
case MI_ALERTING:
+ if (!sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY) &&
+ (signal_data->early_media_flags & SNGISDN_EARLY_MEDIA_ON_ALERT)) {
+
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media override on alert\n");
+ sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY);
+ }
if (ftdmchan->state == FTDM_CHANNEL_STATE_PROCEED) {
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RINGING);
}
break;
case MI_PROGRESS:
+ if (!sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY) &&
+ (signal_data->early_media_flags & SNGISDN_EARLY_MEDIA_ON_PROGRESS)) {
+
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Early media override on progress\n");
+ sngisdn_set_flag(sngisdn_info, FLAG_MEDIA_READY);
+ }
if (sngisdn_test_flag(sngisdn_info, FLAG_MEDIA_READY)) {
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
} else if (ftdmchan->state != FTDM_CHANNEL_STATE_PROGRESS) {
@@ -778,6 +801,23 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event)
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing FACILITY IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
+ if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) {
+ /* If Facility decoding is disabled, we do not care about current call state, just pass event up to user */
+ ftdm_sigmsg_t sigev;
+ if (facEvnt->facElmt.facStr.pres) {
+ get_facility_ie_str(ftdmchan, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len-2);
+ }
+ memset(&sigev, 0, sizeof(sigev));
+ sigev.chan_id = ftdmchan->chan_id;
+ sigev.span_id = ftdmchan->span_id;
+ sigev.channel = ftdmchan;
+
+ sigev.event_id = FTDM_SIGEVENT_FACILITY;
+ ftdm_span_send_signal(ftdmchan->span, &sigev);
+ ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_GET_CALLERID:
/* Update the caller ID Name */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c
index 9c1b7baf79..08e5984a4f 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c
@@ -821,9 +821,17 @@ ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_s
ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId)
{
+ sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data;
if (!ftdmchan) {
return FTDM_SUCCESS;
}
+
+ if (ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
+ /* Indicate channel ID only in first response */
+ return FTDM_SUCCESS;
+ }
+ ftdm_set_flag(sngisdn_info, FLAG_SENT_CHAN_ID);
+
chanId->eh.pres = PRSNT_NODEF;
chanId->prefExc.pres = PRSNT_NODEF;
chanId->prefExc.val = IN_PE_EXCLSVE;
@@ -873,29 +881,32 @@ ftdm_status_t set_bear_cap_ie(ftdm_channel_t *ftdmchan, BearCap *bearCap)
bearCap->tranMode.pres = PRSNT_NODEF;
bearCap->tranMode.val = IN_TM_CIRCUIT;
- if (!FTDM_SPAN_IS_BRI(ftdmchan->span)) {
- /* Trillium stack rejests lyr1Ident on BRI, but Netbricks always sends it.
- Check with Trillium if this ever causes calls to fail in the field */
+ bearCap->usrInfoLyr1Prot.pres = PRSNT_NODEF;
+ bearCap->usrInfoLyr1Prot.val = sngisdn_get_usrInfoLyr1Prot_from_user(ftdmchan->caller_data.bearer_layer1);
- /* PRI only params */
- bearCap->usrInfoLyr1Prot.pres = PRSNT_NODEF;
- bearCap->usrInfoLyr1Prot.val = sngisdn_get_usrInfoLyr1Prot_from_user(ftdmchan->caller_data.bearer_layer1);
-
- if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN &&
- bearCap->usrInfoLyr1Prot.val == IN_UIL1_G711ULAW) {
-
- /* We are bridging a call from T1 */
- bearCap->usrInfoLyr1Prot.val = IN_UIL1_G711ALAW;
-
- } else if (bearCap->usrInfoLyr1Prot.val == IN_UIL1_G711ALAW) {
-
- /* We are bridging a call from E1 */
- bearCap->usrInfoLyr1Prot.val = IN_UIL1_G711ULAW;
- }
-
- bearCap->lyr1Ident.pres = PRSNT_NODEF;
- bearCap->lyr1Ident.val = IN_L1_IDENT;
+ switch (signal_data->switchtype) {
+ case SNGISDN_SWITCH_NI2:
+ case SNGISDN_SWITCH_4ESS:
+ case SNGISDN_SWITCH_5ESS:
+ case SNGISDN_SWITCH_DMS100:
+ case SNGISDN_SWITCH_INSNET:
+ if (bearCap->usrInfoLyr1Prot.val == IN_UIL1_G711ALAW) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Overriding bearer cap to u-law\n");
+ bearCap->usrInfoLyr1Prot.val = IN_UIL1_G711ULAW;
+ }
+ break;
+ case SNGISDN_SWITCH_EUROISDN:
+ case SNGISDN_SWITCH_QSIG:
+ if (bearCap->usrInfoLyr1Prot.val == IN_UIL1_G711ULAW) {
+ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Overriding bearer cap to a-law\n");
+ bearCap->usrInfoLyr1Prot.val = IN_UIL1_G711ALAW;
+ }
+ break;
}
+
+ bearCap->lyr1Ident.pres = PRSNT_NODEF;
+ bearCap->lyr1Ident.val = IN_L1_IDENT;
+
return FTDM_SUCCESS;
}
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c
index e8b8bdbd9a..a0a7cc681a 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c
@@ -838,8 +838,9 @@ 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);
+ print_hex_dump(tmp, &tmp_len, data, 0, data_len);
ftdm_log(FTDM_LOG_WARNING, "Failed to determine b-channel on SETUP message\n%s\n", tmp);
}
}
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
index e7378bf2ea..df0414a7f5 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
@@ -44,6 +44,7 @@
/* PROTOTYPES *****************************************************************/
int ft_to_sngss7_cfg_all(void);
+int ftmod_ss7_relay_gen_config(void);
int ftmod_ss7_mtp1_gen_config(void);
int ftmod_ss7_mtp2_gen_config(void);
int ftmod_ss7_mtp3_gen_config(void);
@@ -65,68 +66,170 @@ int ftmod_ss7_isup_ckt_config(int id);
int ftmod_ss7_isup_isap_config(int id);
int ftmod_ss7_cc_isap_config(int id);
+
+int ftmod_ss7_relay_chan_config(int id);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
int ft_to_sngss7_cfg_all(void)
{
int x = 0;
+ int ret = 0;
/* check if we have done gen_config already */
if (!(g_ftdm_sngss7_data.gen_config)) {
+ /* start of by checking if the license and sig file are valid */
if (sng_validate_license(g_ftdm_sngss7_data.cfg.license,
- g_ftdm_sngss7_data.cfg.signature,
- g_ftdm_sngss7_data.cfg.spc)) {
+ g_ftdm_sngss7_data.cfg.signature)) {
SS7_CRITICAL("License verification failed..ending!\n");
return 1;
}
- if (ftmod_ss7_mtp1_gen_config()) {
- SS7_CRITICAL("MTP1 General configuration FAILED!\n");
- return 1;
- } else {
- SS7_INFO("MTP1 General configuration DONE\n");
+ /* if the procId is not 0 then we are using relay mode */
+ if (g_ftdm_sngss7_data.cfg.procId != 0) {
+ /* set the desired procID value */
+ sng_set_procId((uint16_t)g_ftdm_sngss7_data.cfg.procId);
}
- if (ftmod_ss7_mtp2_gen_config()) {
- SS7_CRITICAL("MTP2 General configuration FAILED!\n");
+ /* start up the stack manager */
+ if (sng_isup_init_sm()) {
+ SS7_CRITICAL("Failed to start Stack Manager\n");
return 1;
} else {
- SS7_INFO("MTP2 General configuration DONE\n");
+ SS7_INFO("Started Stack Manager!\n");
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM);
}
- if (ftmod_ss7_mtp3_gen_config()) {
- SS7_CRITICAL("MTP3 General configuration FAILED!\n");
- return 1;
- } else {
- SS7_INFO("MTP3 General configuration DONE\n");
- }
+ /* check if the configuration had a Relay Channel */
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) {
+ /* start up the relay task */
+ if (sng_isup_init_relay()) {
+ SS7_CRITICAL("Failed to start Relay\n");
+ return 1;
+ } else {
+ SS7_INFO("Started Relay!\n");
+ }
- if (ftmod_ss7_isup_gen_config()) {
- SS7_CRITICAL("ISUP General configuration FAILED!\n");
- return 1;
- } else {
- SS7_INFO("ISUP General configuration DONE\n");
- }
+ /* run general configuration on the relay task */
+ if (ftmod_ss7_relay_gen_config()) {
+ SS7_CRITICAL("Relay General configuration FAILED!\n");
+ return 1;
+ } else {
+ SS7_INFO("Relay General configuration DONE\n");
+ }
- if (ftmod_ss7_cc_gen_config()) {
- SS7_CRITICAL("CC General configuration FAILED!\n");
- return 1;
- } else {
- SS7_INFO("CC General configuration DONE\n");
- }
+ } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) */
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {
+ if (sng_isup_init_cc()) {
+ SS7_CRITICAL("Failed to start Call-Control\n");
+ return 1;
+ } else {
+ SS7_INFO("Started Call-Control!\n");
+ }
+ if (ftmod_ss7_cc_gen_config()) {
+ SS7_CRITICAL("CC General configuration FAILED!\n");
+ return 1;
+ } else {
+ SS7_INFO("CC General configuration DONE\n");
+ }
+ if (ftmod_ss7_cc_isap_config(1)) {
+ SS7_CRITICAL("CC ISAP configuration FAILED!\n");
+ return 1;
+ } else {
+ SS7_INFO("CC ISAP configuration DONE!\n");
+ }
+ } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) */
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {
+ if (sng_isup_init_isup()) {
+ SS7_CRITICAL("Failed to start ISUP\n");
+ return 1;
+ } else {
+ SS7_INFO("Started ISUP!\n");
+ }
+ if (ftmod_ss7_isup_gen_config()) {
+ SS7_CRITICAL("ISUP General configuration FAILED!\n");
+ return 1;
+ } else {
+ SS7_INFO("ISUP General configuration DONE\n");
+ }
+ } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) {
+ if (sng_isup_init_mtp3()) {
+ SS7_CRITICAL("Failed to start MTP3\n");
+ return 1;
+ } else {
+ SS7_INFO("Started MTP3!\n");
+ }
+
+ if (ftmod_ss7_mtp3_gen_config()) {
+ SS7_CRITICAL("MTP3 General configuration FAILED!\n");
+ return 1;
+ } else {
+ SS7_INFO("MTP3 General configuration DONE\n");
+ }
+ } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) */
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) {
+ if (sng_isup_init_mtp2()) {
+ SS7_CRITICAL("Failed to start MTP2\n");
+ return 1;
+ } else {
+ SS7_INFO("Started MTP2!\n");
+ }
+ if (sng_isup_init_mtp1()) {
+ SS7_CRITICAL("Failed to start MTP2\n");
+ return 1;
+ } else {
+ SS7_INFO("Started MTP1!\n");
+ }
+ if (ftmod_ss7_mtp1_gen_config()) {
+ SS7_CRITICAL("MTP1 General configuration FAILED!\n");
+ return 1;
+ } else {
+ SS7_INFO("MTP1 General configuration DONE\n");
+ }
+ if (ftmod_ss7_mtp2_gen_config()) {
+ SS7_CRITICAL("MTP2 General configuration FAILED!\n");
+ return 1;
+ } else {
+ SS7_INFO("MTP2 General configuration DONE\n");
+ }
+ } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) */
/* update the global gen_config so we don't do it again */
g_ftdm_sngss7_data.gen_config = 1;
- }
+ } /* if (!(g_ftdm_sngss7_data.gen_config)) */
+ /* 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_relay_chan_config(x)) {
+ SS7_CRITICAL("Relay Channel %d configuration FAILED!\n", x);
+ return 1;
+ } else {
+ SS7_INFO("Relay Channel %d configuration 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) */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
+ while (x < (MAX_MTP_LINKS + 1)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtpLink[x].flags & CONFIGURED)) {
+ if (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED) &&
+ (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0)) {
/* configure mtp1 */
if (ftmod_ss7_mtp1_psap_config(x)) {
@@ -136,6 +239,18 @@ int ft_to_sngss7_cfg_all(void)
SS7_INFO("MTP1 PSAP %d configuration DONE!\n", x);
}
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.mtp1Link[x].flags |= SNGSS7_CONFIGURED;
+ }
+ x++;
+ } /* while (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) */
+
+ x = 1;
+ while (x < (MAX_MTP_LINKS + 1)) {
+ /* check if this link has been configured already */
+ if (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED) &&
+ (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0)) {
+
/* configure mtp2 */
if (ftmod_ss7_mtp2_dlsap_config(x)) {
SS7_CRITICAL("MTP2 DLSAP %d configuration FAILED!\n",x);
@@ -144,6 +259,18 @@ int ft_to_sngss7_cfg_all(void)
SS7_INFO("MTP2 DLSAP %d configuration DONE!\n", x);
}
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.mtp2Link[x].flags |= SNGSS7_CONFIGURED;
+ }
+ x++;
+ } /* while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) */
+
+ x = 1;
+ while (x < (MAX_MTP_LINKS + 1)) {
+ /* check if this link has been configured already */
+ if (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED) &&
+ (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0)) {
+
/* configure mtp3 */
if (ftmod_ss7_mtp3_dlsap_config(x)) {
SS7_CRITICAL("MTP3 DLSAP %d configuration FAILED!\n", x);
@@ -152,35 +279,37 @@ int ft_to_sngss7_cfg_all(void)
SS7_INFO("MTP3 DLSAP %d configuration DONE!\n", x);
}
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.mtpLink[x].flags |= CONFIGURED;
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.mtp3Link[x].flags |= SNGSS7_CONFIGURED;
}
x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) */
+ } /* while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) */
x = 1;
while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & CONFIGURED)) {
+ if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED)) {
- if (ftmod_ss7_mtp3_nsap_config(x)) {
- SS7_CRITICAL("MTP3 NSAP %d configuration FAILED!\n", x);
+ ret = ftmod_ss7_mtp3_nsap_config(x);
+ if (ret) {
+ SS7_CRITICAL("MTP3 NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret));
return 1;
} else {
SS7_INFO("MTP3 NSAP %d configuration DONE!\n", x);
}
- if (ftmod_ss7_isup_nsap_config(x)) {
- SS7_CRITICAL("ISUP NSAP %d configuration FAILED!\n", x);
+ ret = ftmod_ss7_isup_nsap_config(x);
+ if (ret) {
+ SS7_CRITICAL("ISUP NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret));
return 1;
} else {
SS7_INFO("ISUP NSAP %d configuration DONE!\n", x);
}
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.nsap[x].flags |= CONFIGURED;
- } /* if !CONFIGURED */
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
x++;
} /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
@@ -188,7 +317,7 @@ int ft_to_sngss7_cfg_all(void)
x = 1;
while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & CONFIGURED)) {
+ if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED)) {
if (ftmod_ss7_mtp3_linkset_config(x)) {
SS7_CRITICAL("MTP3 LINKSET %d configuration FAILED!\n", x);
@@ -197,9 +326,9 @@ int ft_to_sngss7_cfg_all(void)
SS7_INFO("MTP3 LINKSET %d configuration DONE!\n", x);
}
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= CONFIGURED;
- } /* if !CONFIGURED */
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
x++;
} /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
@@ -207,7 +336,7 @@ int ft_to_sngss7_cfg_all(void)
x = 1;
while ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0)) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & CONFIGURED)) {
+ if (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED)) {
if (ftmod_ss7_mtp3_route_config(x)) {
SS7_CRITICAL("MTP3 ROUTE %d configuration FAILED!\n", x);
@@ -216,31 +345,17 @@ int ft_to_sngss7_cfg_all(void)
SS7_INFO("MTP3 ROUTE %d configuration DONE!\n",x);
}
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.mtpRoute[x].flags |= CONFIGURED;
- } /* if !CONFIGURED */
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.mtpRoute[x].flags |= SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
x++;
} /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */
- if (!(g_ftdm_sngss7_data.cfg.mtpRoute[0].flags & CONFIGURED)) {
-
- if (ftmod_ss7_mtp3_route_config(0)) {
- SS7_CRITICAL("MTP3 ROUTE 0 configuration FAILED!\n");
- return 1;
- } else {
- SS7_INFO("MTP3 ROUTE 0 configuration DONE!\n");
- }
-
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.mtpRoute[0].flags |= CONFIGURED;
- } /* if !CONFIGURED */
-
-
x = 1;
while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
/* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & CONFIGURED)) {
+ if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED)) {
if (ftmod_ss7_isup_isap_config(x)) {
SS7_CRITICAL("ISUP ISAP %d configuration FAILED!\n", x);
@@ -249,57 +364,51 @@ int ft_to_sngss7_cfg_all(void)
SS7_INFO("ISUP ISAP %d configuration DONE!\n", x);
}
- if (ftmod_ss7_cc_isap_config(x)) {
- SS7_CRITICAL("CC ISAP %d configuration FAILED!\n", x);
- return 1;
- } else {
- SS7_INFO("CC ISAP %d configuration DONE!\n", x);
- }
-
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.isap[x].flags |= CONFIGURED;
- } /* if !CONFIGURED */
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
x++;
} /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
- x = 1;
- while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {
- /* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & CONFIGURED)) {
-
- if (ftmod_ss7_isup_intf_config(x)) {
- SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x);
- return 1;
- } else {
- SS7_INFO("ISUP INTF %d configuration DONE!\n", x);
- /* set the interface to paused */
- sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[x], SNGSS7_PAUSED);
- }
-
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.isupIntf[x].flags |= CONFIGURED;
- } /* if !CONFIGURED */
-
- x++;
- } /* while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) */
-
- x = 1;
- while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
- /* check if this link has been configured already */
- if (!(g_ftdm_sngss7_data.cfg.isupCkt[x].flags & CONFIGURED)) {
- if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == 0) {
- if (ftmod_ss7_isup_ckt_config(x)) {
- SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {
+ x = 1;
+ while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {
+ /* check if this link has been configured already */
+ if (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED)) {
+
+ if (ftmod_ss7_isup_intf_config(x)) {
+ SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x);
return 1;
} else {
- SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
+ SS7_INFO("ISUP INTF %d configuration DONE!\n", x);
+ /* set the interface to paused */
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[x], SNGSS7_PAUSED);
}
+
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.isupIntf[x].flags |= SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
+
+ x++;
+ } /* while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) */
+ } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */
+
+ 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);
}
- /* set the CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= CONFIGURED;
- } /* if !CONFIGURED */
+ } /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
+
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
x++;
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
@@ -307,6 +416,44 @@ int ft_to_sngss7_cfg_all(void)
return 0;
}
+/******************************************************************************/
+int ftmod_ss7_relay_gen_config(void)
+{
+ RyMngmt cfg; /*configuration structure*/
+ Pst pst; /*post structure*/
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTRY;
+
+ /* clear the configuration structure */
+ memset(&cfg, 0x0, sizeof(RyMngmt));
+
+ /* fill in some general sections of the header */
+ smHdrInit(&cfg.hdr);
+
+ /* fill in the post structure */
+ smPstInit( &cfg.t.cfg.s.ryGenCfg.lmPst );
+
+ /*fill in the specific fields of the header */
+ cfg.hdr.msgType = TCFG;
+ cfg.hdr.entId.ent = ENTRY;
+ cfg.hdr.entId.inst = S_INST;
+ cfg.hdr.elmId.elmnt = STGEN;
+
+ cfg.t.cfg.s.ryGenCfg.lmPst.srcEnt = ENTRY;
+ cfg.t.cfg.s.ryGenCfg.lmPst.dstEnt = ENTSM;
+
+ cfg.t.cfg.s.ryGenCfg.nmbChan = 10;
+ cfg.t.cfg.s.ryGenCfg.tmrRes = RY_PERIOD;
+ cfg.t.cfg.s.ryGenCfg.usta = 1;
+
+
+ return(sng_cfg_relay(&pst, &cfg));
+}
+
/******************************************************************************/
int ftmod_ss7_mtp1_gen_config(void)
{
@@ -413,15 +560,13 @@ int ftmod_ss7_mtp3_gen_config(void)
cfg.t.cfg.s.snGen.typeSP = LSN_TYPE_SP; /* type of signalling postatic int */
- cfg.t.cfg.s.snGen.spCode1 = g_ftdm_sngss7_data.cfg.spc; /* our DPC for CCITT version */
-
+ cfg.t.cfg.s.snGen.spCode1 = 0; /* our DPC for CCITT version */
#if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || SS7_CHINA || defined(TDS_ROLL_UPGRADE_SUPPORT))
- cfg.t.cfg.s.snGen.spCode2 = g_ftdm_sngss7_data.cfg.spc; /* our DPC for ANSI or CHINA version */
+ cfg.t.cfg.s.snGen.spCode2 = 0; /* our DPC for ANSI or CHINA version */
#endif
-
cfg.t.cfg.s.snGen.ssfValid = TRUE; /* ssf validation required */
cfg.t.cfg.s.snGen.nmbDLSap = MAX_SN_LINKS; /* number of MTP Data Link SAPs */
- cfg.t.cfg.s.snGen.nmbNSap = MAX_SN_VARIANTS; /* number of Upper Layer Saps */
+ cfg.t.cfg.s.snGen.nmbNSap = MAX_SN_ROUTES; /* number of Upper Layer Saps */
cfg.t.cfg.s.snGen.nmbRouts = MAX_SN_ROUTES; /* maximum number of routing entries */
cfg.t.cfg.s.snGen.nmbLnkSets = MAX_SN_LINKSETS; /* number of link sets */
cfg.t.cfg.s.snGen.nmbRteInst = MAX_SN_ROUTES*16; /* number of simultaneous Rte instances */
@@ -575,7 +720,7 @@ int ftmod_ss7_mtp1_psap_config(int id)
{
L1Mngmt cfg;
Pst pst;
- sng_mtp_link_t *k = &g_ftdm_sngss7_data.cfg.mtpLink[id];
+ sng_mtp1_link_t *k = &g_ftdm_sngss7_data.cfg.mtp1Link[id];
/* initalize the post structure */
smPstInit(&pst);
@@ -597,8 +742,8 @@ int ftmod_ss7_mtp1_psap_config(int id)
cfg.hdr.elmId.elmntInst1 = k->id;
- cfg.t.cfg.s.l1PSAP.span = k->mtp1.span;
- cfg.t.cfg.s.l1PSAP.chan = k->mtp1.chan;
+ cfg.t.cfg.s.l1PSAP.span = k->span;
+ cfg.t.cfg.s.l1PSAP.chan = k->chan;
cfg.t.cfg.s.l1PSAP.spId = k->id;
return(sng_cfg_mtp1(&pst, &cfg));
@@ -609,7 +754,7 @@ int ftmod_ss7_mtp2_dlsap_config(int id)
{
SdMngmt cfg;
Pst pst;
- sng_mtp_link_t *k = &g_ftdm_sngss7_data.cfg.mtpLink[id];
+ sng_mtp2_link_t *k = &g_ftdm_sngss7_data.cfg.mtp2Link[id];
/* initalize the post structure */
smPstInit( &pst);
@@ -633,10 +778,15 @@ int ftmod_ss7_mtp2_dlsap_config(int id)
cfg.t.cfg.s.sdDLSAP.mem.region = S_REG; /* memory region */
cfg.t.cfg.s.sdDLSAP.mem.pool = S_POOL; /* memory pool */
- cfg.t.cfg.s.sdDLSAP.swtch = k->mtp2.linkType; /* protocol type */
+ cfg.t.cfg.s.sdDLSAP.swtch = k->linkType; /* protocol type */
cfg.t.cfg.s.sdDLSAP.priorDl = PRIOR0; /* priority for data link layer */
cfg.t.cfg.s.sdDLSAP.routeDl = RTESPEC; /* route for data link layer */
cfg.t.cfg.s.sdDLSAP.selectorDl = 0; /* upper interface selector */
+ if (k->mtp1ProcId > 0) {
+ cfg.t.cfg.s.sdDLSAP.dstProcId = k->mtp1ProcId; /* the procid of MAC/L1/MTP1 */
+ } else {
+ cfg.t.cfg.s.sdDLSAP.dstProcId = SFndProcId(); /* the procid of MAC/L1/MTP1 */
+ }
cfg.t.cfg.s.sdDLSAP.dstProcId = SFndProcId(); /* the procid of MAC/L1/MTP1 */
cfg.t.cfg.s.sdDLSAP.entMac = ENTL1; /* entity for MAC */
cfg.t.cfg.s.sdDLSAP.instMac = S_INST; /* instance for MAC */
@@ -646,22 +796,22 @@ int ftmod_ss7_mtp2_dlsap_config(int id)
cfg.t.cfg.s.sdDLSAP.memMac.region = S_REG; /* memory region and pool id for MAC */
cfg.t.cfg.s.sdDLSAP.memMac.pool = S_POOL;
cfg.t.cfg.s.sdDLSAP.maxOutsFrms = MAX_SD_OUTSTANDING; /* maximum outstanding frames */
- cfg.t.cfg.s.sdDLSAP.errType = k->mtp2.errorType;
+ cfg.t.cfg.s.sdDLSAP.errType = k->errorType;
cfg.t.cfg.s.sdDLSAP.t1.enb = TRUE; /* timer 1 - Alignment Ready Timer */
- cfg.t.cfg.s.sdDLSAP.t1.val = k->mtp2.t1;
+ cfg.t.cfg.s.sdDLSAP.t1.val = k->t1;
cfg.t.cfg.s.sdDLSAP.t2.enb = TRUE; /* timer 2 - Not Aligned Timer */
- cfg.t.cfg.s.sdDLSAP.t2.val = k->mtp2.t2;
+ cfg.t.cfg.s.sdDLSAP.t2.val = k->t2;
cfg.t.cfg.s.sdDLSAP.t3.enb = TRUE; /* timer 3 - Aligned Timer */
- cfg.t.cfg.s.sdDLSAP.t3.val = k->mtp2.t3;
+ cfg.t.cfg.s.sdDLSAP.t3.val = k->t3;
cfg.t.cfg.s.sdDLSAP.t5.enb = TRUE; /* timer 5 - Sending SIB timer */
- cfg.t.cfg.s.sdDLSAP.t5.val = k->mtp2.t5;
+ cfg.t.cfg.s.sdDLSAP.t5.val = k->t5;
cfg.t.cfg.s.sdDLSAP.t6.enb = TRUE; /* timer 6 - Remote Congestion Timer */
- cfg.t.cfg.s.sdDLSAP.t6.val = k->mtp2.t6;
+ cfg.t.cfg.s.sdDLSAP.t6.val = k->t6;
cfg.t.cfg.s.sdDLSAP.t7.enb = TRUE; /* timer 7 - Excessive delay of acknowledgement timer */
- cfg.t.cfg.s.sdDLSAP.t7.val = k->mtp2.t7;
- cfg.t.cfg.s.sdDLSAP.provEmrgcy = k->mtp2.t4e; /* emergency proving period */
- cfg.t.cfg.s.sdDLSAP.provNormal = k->mtp2.t4n; /* normal proving period */
- cfg.t.cfg.s.sdDLSAP.lssuLen = k->mtp2.lssuLength; /* one or two byte LSSU length */
+ cfg.t.cfg.s.sdDLSAP.t7.val = k->t7;
+ cfg.t.cfg.s.sdDLSAP.provEmrgcy = k->t4e; /* emergency proving period */
+ cfg.t.cfg.s.sdDLSAP.provNormal = k->t4n; /* normal proving period */
+ cfg.t.cfg.s.sdDLSAP.lssuLen = k->lssuLength; /* one or two byte LSSU length */
cfg.t.cfg.s.sdDLSAP.maxFrmLen = MAX_SD_FRAME_LEN; /* max frame length for MSU */
cfg.t.cfg.s.sdDLSAP.congDisc = FALSE; /* congestion discard TRUE or FALSE */
cfg.t.cfg.s.sdDLSAP.sdT = MAX_SD_SUERM; /* SUERM error rate threshold */
@@ -670,7 +820,7 @@ int ftmod_ss7_mtp2_dlsap_config(int id)
cfg.t.cfg.s.sdDLSAP.sdN1 = MAX_SD_MSU_RETRANS; /* maximum number of MSUs for retransmission */
cfg.t.cfg.s.sdDLSAP.sdN2 = MAX_SD_OCTETS_RETRANS; /* maximum number of MSU octets for retrans */
cfg.t.cfg.s.sdDLSAP.sdCp = MAX_SD_ALIGN_ATTEMPTS; /* maximum number of alignment attempts */
- cfg.t.cfg.s.sdDLSAP.spIdSE = k->mtp2.mtp1Id; /* service provider id */
+ cfg.t.cfg.s.sdDLSAP.spIdSE = k->mtp1Id; /* service provider id */
cfg.t.cfg.s.sdDLSAP.sdtFlcStartTr = 256; /* SDT interface flow control start thresh */
cfg.t.cfg.s.sdDLSAP.sdtFlcEndTr = 512; /* SDT interface flow control end thresh */
@@ -707,7 +857,6 @@ int ftmod_ss7_mtp2_dlsap_config(int id)
#endif /*RUG*/
return(sng_cfg_mtp2(&pst, &cfg));
- return 0;
}
/******************************************************************************/
@@ -715,7 +864,7 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
{
Pst pst;
SnMngmt cfg;
- sng_mtp_link_t *k = &g_ftdm_sngss7_data.cfg.mtpLink[id];
+ sng_mtp3_link_t *k = &g_ftdm_sngss7_data.cfg.mtp3Link[id];
/* initalize the post structure */
@@ -738,14 +887,14 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
cfg.hdr.elmId.elmntInst1 = k->id;
- cfg.t.cfg.s.snDLSAP.lnkSetId = k->mtp3.linkSetId; /* link set ID */
- cfg.t.cfg.s.snDLSAP.opc = k->mtp3.spc; /* Originating Postatic int Code */
- cfg.t.cfg.s.snDLSAP.adjDpc = k->mtp3.apc; /* Adlacent Destination Postatic int Code */
+ cfg.t.cfg.s.snDLSAP.lnkSetId = k->linkSetId; /* link set ID */
+ cfg.t.cfg.s.snDLSAP.opc = k->spc; /* Originating Postatic int Code */
+ cfg.t.cfg.s.snDLSAP.adjDpc = k->apc; /* Adlacent Destination Postatic int Code */
cfg.t.cfg.s.snDLSAP.lnkPrior = 0; /* link priority within the link set */
cfg.t.cfg.s.snDLSAP.msgSize = MAX_SN_MSG_SIZE; /* message length */
cfg.t.cfg.s.snDLSAP.msgPrior = 0; /* management message priority */
- cfg.t.cfg.s.snDLSAP.lnkType = k->mtp3.linkType; /* link type ANSI, ITU, BICI or CHINA */
- cfg.t.cfg.s.snDLSAP.upSwtch = k->mtp3.switchType; /* user part switch type */
+ cfg.t.cfg.s.snDLSAP.lnkType = k->linkType; /* link type ANSI, ITU, BICI or CHINA */
+ cfg.t.cfg.s.snDLSAP.upSwtch = k->switchType; /* user part switch type */
cfg.t.cfg.s.snDLSAP.maxSLTtry = MAX_SLTM_RETRIES; /* maximun times to retry SLTM */
cfg.t.cfg.s.snDLSAP.p0QLen = 32; /* size of the priority 0 Q */
cfg.t.cfg.s.snDLSAP.p1QLen = 32; /* size of the priority 1 Q */
@@ -756,7 +905,7 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
cfg.t.cfg.s.snDLSAP.maxCredit = MAX_SN_CREDIT; /* max credit */
#endif /* SDT2 */
cfg.t.cfg.s.snDLSAP.lnkId = 0; /* signalling link allocation procedure identity */
- cfg.t.cfg.s.snDLSAP.lnkTstSLC = k->mtp3.slc; /* link selection code for link test */
+ cfg.t.cfg.s.snDLSAP.lnkTstSLC = k->slc; /* link selection code for link test */
cfg.t.cfg.s.snDLSAP.tstLen = 6; /* link test pattern length */
cfg.t.cfg.s.snDLSAP.tst[0] = 'K'; /* link test pattern */
cfg.t.cfg.s.snDLSAP.tst[1] = 'O'; /* link test pattern */
@@ -764,8 +913,8 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
cfg.t.cfg.s.snDLSAP.tst[3] = 'R'; /* link test pattern */
cfg.t.cfg.s.snDLSAP.tst[4] = 'A'; /* link test pattern */
cfg.t.cfg.s.snDLSAP.tst[5] = 'D'; /* link test pattern */
- cfg.t.cfg.s.snDLSAP.ssf = k->mtp3.ssf; /* sub service field */
- cfg.t.cfg.s.snDLSAP.dstProcId = SFndProcId(); /* destination processor id */
+ cfg.t.cfg.s.snDLSAP.ssf = k->ssf; /* sub service field */
+ cfg.t.cfg.s.snDLSAP.dstProcId = k->mtp2ProcId; /* destination processor id */
cfg.t.cfg.s.snDLSAP.dstEnt = ENTSD; /* entity */
cfg.t.cfg.s.snDLSAP.dstInst = S_INST; /* instance */
cfg.t.cfg.s.snDLSAP.prior = PRIOR0; /* priority */
@@ -773,9 +922,9 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
cfg.t.cfg.s.snDLSAP.selector = 0; /* lower layer selector */
cfg.t.cfg.s.snDLSAP.mem.region = S_REG; /* memory region id */
cfg.t.cfg.s.snDLSAP.mem.pool = S_POOL; /* memory pool id */
- cfg.t.cfg.s.snDLSAP.spId = k->mtp3.mtp2Id ;/* service provider id */
+ cfg.t.cfg.s.snDLSAP.spId = k->mtp2Id; /* service provider id */
- switch (k->mtp3.linkType) {
+ switch (k->linkType) {
/**************************************************************************/
case (LSN_SW_ANS):
case (LSN_SW_ANS96):
@@ -793,9 +942,9 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
cfg.t.cfg.s.snDLSAP.dpcLen = DPC14; /* dpc length 14 bits */
break;
/**************************************************************************/
- } /* switch (k->mtp3.linkType) */
+ } /* switch (k->linkType) */
- switch (k->mtp3.linkType) {
+ switch (k->linkType) {
/**************************************************************************/
case (LSN_SW_ANS):
case (LSN_SW_ANS96):
@@ -811,51 +960,51 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
cfg.t.cfg.s.snDLSAP.flushContFlag = FALSE; /* flush continue handling */
break;
/**************************************************************************/
- } /* switch (k->mtp3.linkType) */
+ } /* switch (k->linkType) */
cfg.t.cfg.s.snDLSAP.tmr.t1.enb = TRUE; /* t1 - delay to avoid missequencing on changeover */
- cfg.t.cfg.s.snDLSAP.tmr.t1.val = k->mtp3.t1;
+ cfg.t.cfg.s.snDLSAP.tmr.t1.val = k->t1;
cfg.t.cfg.s.snDLSAP.tmr.t2.enb = TRUE; /* t2 - waiting for changeover ack */
- cfg.t.cfg.s.snDLSAP.tmr.t2.val = k->mtp3.t2;
+ cfg.t.cfg.s.snDLSAP.tmr.t2.val = k->t2;
cfg.t.cfg.s.snDLSAP.tmr.t3.enb = TRUE; /* t3 - delay to avoid missequencing on changeback */
- cfg.t.cfg.s.snDLSAP.tmr.t3.val = k->mtp3.t3;
+ cfg.t.cfg.s.snDLSAP.tmr.t3.val = k->t3;
cfg.t.cfg.s.snDLSAP.tmr.t4.enb = TRUE; /* t4 - waiting for first changeback ack */
- cfg.t.cfg.s.snDLSAP.tmr.t4.val = k->mtp3.t4;
+ cfg.t.cfg.s.snDLSAP.tmr.t4.val = k->t4;
cfg.t.cfg.s.snDLSAP.tmr.t5.enb = TRUE; /* t5 - waiting for second changeback ack */
- cfg.t.cfg.s.snDLSAP.tmr.t5.val = k->mtp3.t5;
+ cfg.t.cfg.s.snDLSAP.tmr.t5.val = k->t5;
cfg.t.cfg.s.snDLSAP.tmr.t7.enb = TRUE; /* t7 - waiting for link connection ack */
- cfg.t.cfg.s.snDLSAP.tmr.t7.val = k->mtp3.t7;
+ cfg.t.cfg.s.snDLSAP.tmr.t7.val = k->t7;
cfg.t.cfg.s.snDLSAP.tmr.t12.enb = TRUE; /* t12 - waiting for uninhibit ack */
- cfg.t.cfg.s.snDLSAP.tmr.t12.val = k->mtp3.t12;
+ cfg.t.cfg.s.snDLSAP.tmr.t12.val = k->t12;
cfg.t.cfg.s.snDLSAP.tmr.t13.enb = TRUE; /* t13 - waiting for forced uninhibit */
- cfg.t.cfg.s.snDLSAP.tmr.t13.val = k->mtp3.t13;
+ cfg.t.cfg.s.snDLSAP.tmr.t13.val = k->t13;
cfg.t.cfg.s.snDLSAP.tmr.t14.enb = TRUE; /* t14 - waiting for inhibition ack */
- cfg.t.cfg.s.snDLSAP.tmr.t14.val = k->mtp3.t14;
+ cfg.t.cfg.s.snDLSAP.tmr.t14.val = k->t14;
cfg.t.cfg.s.snDLSAP.tmr.t17.enb = TRUE; /* t17 - delay to avoid oscillation of initial alignment failure */
- cfg.t.cfg.s.snDLSAP.tmr.t17.val = k->mtp3.t17;
+ cfg.t.cfg.s.snDLSAP.tmr.t17.val = k->t17;
cfg.t.cfg.s.snDLSAP.tmr.t22.enb = TRUE; /* t22 - local inhibit test timer */
- cfg.t.cfg.s.snDLSAP.tmr.t22.val = k->mtp3.t22;
+ cfg.t.cfg.s.snDLSAP.tmr.t22.val = k->t22;
cfg.t.cfg.s.snDLSAP.tmr.t23.enb = TRUE; /* t23 - remote inhibit test timer */
- cfg.t.cfg.s.snDLSAP.tmr.t23.val = k->mtp3.t23;
+ cfg.t.cfg.s.snDLSAP.tmr.t23.val = k->t23;
cfg.t.cfg.s.snDLSAP.tmr.t24.enb = TRUE; /* t24 - stabilizing timer */
- cfg.t.cfg.s.snDLSAP.tmr.t24.val = k->mtp3.t24;
+ cfg.t.cfg.s.snDLSAP.tmr.t24.val = k->t24;
cfg.t.cfg.s.snDLSAP.tmr.t31.enb = TRUE; /* t31 - BSN requested timer */
- cfg.t.cfg.s.snDLSAP.tmr.t31.val = k->mtp3.t31;
+ cfg.t.cfg.s.snDLSAP.tmr.t31.val = k->t31;
cfg.t.cfg.s.snDLSAP.tmr.t32.enb = TRUE; /* t32 - SLT timer */
- cfg.t.cfg.s.snDLSAP.tmr.t32.val = k->mtp3.t32;
+ cfg.t.cfg.s.snDLSAP.tmr.t32.val = k->t32;
cfg.t.cfg.s.snDLSAP.tmr.t33.enb = TRUE; /* t33 - connecting timer */
- cfg.t.cfg.s.snDLSAP.tmr.t33.val = k->mtp3.t33;
+ cfg.t.cfg.s.snDLSAP.tmr.t33.val = k->t33;
cfg.t.cfg.s.snDLSAP.tmr.t34.enb = TRUE; /* t34 - periodic signalling link test timer */
- cfg.t.cfg.s.snDLSAP.tmr.t34.val = k->mtp3.t34;
+ cfg.t.cfg.s.snDLSAP.tmr.t34.val = k->t34;
#if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || defined(TDS_ROLL_UPGRADE_SUPPORT))
cfg.t.cfg.s.snDLSAP.tmr.t35.enb = TRUE; /* t35 - false link congestion timer, same as t31 of ANSI'96*/
- cfg.t.cfg.s.snDLSAP.tmr.t35.val = k->mtp3.t35;
+ cfg.t.cfg.s.snDLSAP.tmr.t35.val = k->t35;
cfg.t.cfg.s.snDLSAP.tmr.t36.enb = TRUE; /* t36 - false link congestion timer, same as t33 of ANSI'96*/
- cfg.t.cfg.s.snDLSAP.tmr.t36.val = k->mtp3.t36;
+ cfg.t.cfg.s.snDLSAP.tmr.t36.val = k->t36;
cfg.t.cfg.s.snDLSAP.tmr.t37.enb = TRUE; /* t37 - false link congestion timer, same as t34 of ANSI'96*/
- cfg.t.cfg.s.snDLSAP.tmr.t37.val = k->mtp3.t37;
+ cfg.t.cfg.s.snDLSAP.tmr.t37.val = k->t37;
cfg.t.cfg.s.snDLSAP.tmr.tCraft.enb = TRUE; /* link referral craft timer - T19 in ANSI */
- cfg.t.cfg.s.snDLSAP.tmr.tCraft.val = k->mtp3.tcraft;
+ cfg.t.cfg.s.snDLSAP.tmr.tCraft.val = k->tcraft;
#endif
#ifdef SDT2
cfg.t.cfg.s.snDLSAP.tmr.tFlc.enb = TRUE; /* flow control timer */
@@ -996,10 +1145,10 @@ int ftmod_ss7_mtp3_route_config(int id)
cfg.t.cfg.s.snRout.swtchType = k->linkType; /* switch type */
cfg.t.cfg.s.snRout.upSwtch = k->switchType; /* user part switch type */
cfg.t.cfg.s.snRout.cmbLnkSetId = k->cmbLinkSetId; /* combined link set ID */
- if (k->id == 0) {
- cfg.t.cfg.s.snRout.dir = LSN_RTE_UP; /* direction */
+ if (k->dir == SNG_RTE_UP) {
+ cfg.t.cfg.s.snRout.dir = LSN_RTE_UP; /* direction */
} else {
- cfg.t.cfg.s.snRout.dir = LSN_RTE_DN; /* direction */
+ cfg.t.cfg.s.snRout.dir = LSN_RTE_DN; /* direction */
}
cfg.t.cfg.s.snRout.rteToAdjSp = 0; /* flag indicating this route to adjacent SP */
cfg.t.cfg.s.snRout.ssf = k->ssf; /* sub service field */
@@ -1217,6 +1366,11 @@ int ftmod_ss7_isup_ckt_config(int id)
/* 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;
+ }
+
/*clear the configuration structure*/
memset(&cfg, 0x0, sizeof(SiMngmt));
@@ -1417,11 +1571,11 @@ int ftmod_ss7_isup_isap_config(int id)
}
/******************************************************************************/
-int ftmod_ss7_cc_isap_config(int id)
+int ftmod_ss7_cc_isap_config(int dstProcId)
{
CcMngmt cfg;
Pst pst;
- sng_isap_t *k = &g_ftdm_sngss7_data.cfg.isap[id];
+
/* initalize the post structure */
smPstInit(&pst);
@@ -1441,11 +1595,11 @@ int ftmod_ss7_cc_isap_config(int id)
cfg.hdr.entId.inst = S_INST;
cfg.hdr.elmId.elmnt = STISAP;
- cfg.hdr.elmId.elmntInst1 = k->id;
+ cfg.hdr.elmId.elmntInst1 = 1;
- cfg.t.cfg.s.ccISAP.suId = k->suId;
- cfg.t.cfg.s.ccISAP.spId = k->spId;
- cfg.t.cfg.s.ccISAP.pst.dstProcId = SFndProcId();
+ cfg.t.cfg.s.ccISAP.suId = 1;
+ cfg.t.cfg.s.ccISAP.spId = 1;
+ cfg.t.cfg.s.ccISAP.pst.dstProcId = dstProcId;
cfg.t.cfg.s.ccISAP.pst.dstEnt = ENTSI;
cfg.t.cfg.s.ccISAP.pst.dstInst = S_INST;
cfg.t.cfg.s.ccISAP.pst.srcProcId = SFndProcId();
@@ -1461,6 +1615,70 @@ int ftmod_ss7_cc_isap_config(int id)
}
/******************************************************************************/
+int ftmod_ss7_relay_chan_config(int id)
+{
+ RyMngmt cfg; /*configuration structure*/
+ Pst pst; /*post structure*/
+ sng_relay_t *k = &g_ftdm_sngss7_data.cfg.relay[id];
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTRY;
+
+ /* clear the configuration structure */
+ memset(&cfg, 0x0, sizeof(RyMngmt));
+
+ /* fill in some general sections of the header */
+ smHdrInit(&cfg.hdr);
+
+ /*fill in the specific fields of the header */
+ cfg.hdr.msgType = TCFG;
+ cfg.hdr.entId.ent = ENTRY;
+ cfg.hdr.entId.inst = S_INST;
+ cfg.hdr.elmId.elmnt = STCHCFG;
+
+ cfg.hdr.elmId.elmntInst1 = k->id;
+
+ cfg.t.cfg.s.ryChanCfg.id = k->id; /* channel id */
+ cfg.t.cfg.s.ryChanCfg.type = k->type; /* channel type */
+/* cfg.t.cfg.s.ryChanCfg.msInd =;*/ /* master/slave indicator */
+ if (k->type == LRY_CT_TCP_LISTEN) {
+ cfg.t.cfg.s.ryChanCfg.low = 0; /* low proc id for channel */
+ cfg.t.cfg.s.ryChanCfg.high = 0; /* high proc id for channel */
+ } else {
+ cfg.t.cfg.s.ryChanCfg.low = k->procId; /* low proc id for channel */
+ cfg.t.cfg.s.ryChanCfg.high = k->procId; /* high proc id for channel */
+ }
+ cfg.t.cfg.s.ryChanCfg.nmbScanQ = MAX_RELAY_NMBSCAN; /* number of times to scan the queue */
+ cfg.t.cfg.s.ryChanCfg.flags = LRY_FLG_INTR; /* flags */
+ cfg.t.cfg.s.ryChanCfg.congThrsh = MAX_RELAY_CONGTHRSH; /* congestion threshold */
+ cfg.t.cfg.s.ryChanCfg.dropThrsh = 0; /* drop threshold */
+ cfg.t.cfg.s.ryChanCfg.contThrsh = MAX_RELAY_CONGTHRSH + 1; /* continue threshold */
+ cfg.t.cfg.s.ryChanCfg.kaTxTmr.enb = 1; /* keep alive transmit timer config */
+ cfg.t.cfg.s.ryChanCfg.kaTxTmr.val = RY_TX_KP_ALIVE_TMR;
+ cfg.t.cfg.s.ryChanCfg.kaRxTmr.enb = 1; /* keep alive receive timer config */
+ cfg.t.cfg.s.ryChanCfg.kaRxTmr.val = RY_RX_KP_ALIVE_TMR;
+ cfg.t.cfg.s.ryChanCfg.btTmr.enb = 1; /* boot timer */
+ cfg.t.cfg.s.ryChanCfg.btTmr.val = RY_BT_TMR;
+ cfg.t.cfg.s.ryChanCfg.region = S_REG; /* Relay region */
+ cfg.t.cfg.s.ryChanCfg.pool = S_POOL; /* Relay pool */
+#if (RY_ENBUDPSOCK || RY_ENBTCPSOCK)
+ cfg.t.cfg.s.ryChanCfg.listenPortNo = k->port; /* Listen Port of Rx Relay Channel*/
+ strncpy(cfg.t.cfg.s.ryChanCfg.transmittoHostName, k->hostname, (size_t)RY_REMHOSTNAME_SIZE);
+ cfg.t.cfg.s.ryChanCfg.transmittoPortNo = k->port; /* TransmitTo PortId for Tx Relay Channel */
+ cfg.t.cfg.s.ryChanCfg.targetProcId = k->procId; /* procId of the node present in the other end of this channel */
+# ifdef LRY1
+ cfg.t.cfg.s.ryChanCfg.sockParam =; /* Socket Parameters */
+# endif /* LRY1 */
+# ifdef LRYV2
+ cfg.t.cfg.s.ryChanCfg.selfHostName[RY_REMHOSTNAME_SIZE];
+# endif /* LRY2 */
+#endif /* RY_ENBUDPSOCK || RY_ENBTCPSOCK */
+
+ return(sng_cfg_relay(&pst, &cfg));
+}
/******************************************************************************/
/* For Emacs:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
index dc2d24f42a..280107acd0 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
@@ -46,6 +46,8 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream);
+static ftdm_status_t handle_show_procId(ftdm_stream_handle_t *stream);
+
static ftdm_status_t handle_set_function_trace(ftdm_stream_handle_t *stream, int on, int level);
static ftdm_status_t handle_set_message_trace(ftdm_stream_handle_t *stream, int on, int level);
static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name);
@@ -67,6 +69,8 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c
static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose);
static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose);
+static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name);
+static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name);
static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *name);
static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *name);
@@ -76,9 +80,12 @@ static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, cha
static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name);
static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name);
-static ftdm_status_t handle_status_link(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 extract_span_chan(char *argv[10], int pos, int *span, int *chan);
static ftdm_status_t check_arg_count(int args, int min);
/******************************************************************************/
@@ -111,18 +118,29 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
if (!strcasecmp(argv[c], "status")) {
/**********************************************************************/
+ if (check_arg_count(argc, 3)) goto handle_cli_error_argc;
c++;
- if (!strcasecmp(argv[c], "link")) {
+ if (!strcasecmp(argv[c], "mtp3")) {
/******************************************************************/
c++;
- handle_status_link(stream, argv[c]);
+ handle_status_mtp3link(stream, argv[c]);
+ /******************************************************************/
+ } else if (!strcasecmp(argv[c], "mtp2")) {
+ /******************************************************************/
+ c++;
+ handle_status_mtp2link(stream, argv[c]);
/******************************************************************/
} else if (!strcasecmp(argv[c], "linkset")) {
/******************************************************************/
c++;
handle_status_linkset(stream, argv[c]);
/******************************************************************/
+ } else if (!strcasecmp(argv[c], "relay")) {
+ /******************************************************************/
+ c++;
+ handle_status_relay(stream, argv[c]);
+ /******************************************************************/
} else if (!strcasecmp(argv[c], "span")) {
/******************************************************************/
if (check_arg_count(argc, 6)) goto handle_cli_error_argc;
@@ -256,6 +274,10 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
sts.rx_frm, sts.rx_err, sts.rx_fisu, sts.rx_lssu, sts.rx_msu);
*/
/**********************************************************************/
+ } else if (!strcasecmp(argv[c], "procid")) {
+ /**********************************************************************/
+ handle_show_procId(stream);
+ /**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"show\" command\n");
@@ -534,6 +556,44 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
/**********************************************************************/
}
/**************************************************************************/
+ } else if (!strcasecmp(argv[c], "bind")) {
+ /**************************************************************************/
+ if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
+ c++;
+
+ if (!strcasecmp(argv[c], "link")) {
+ /**********************************************************************/
+ if (check_arg_count(argc, 3)) goto handle_cli_error_argc;
+ c++;
+
+ handle_bind_link(stream, argv[c]);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ stream->write_function(stream, "Unknown \"bind\" command\n");
+ goto handle_cli_error;
+ /**********************************************************************/
+ }
+ /**************************************************************************/
+ } else if (!strcasecmp(argv[c], "unbind")) {
+ /**************************************************************************/
+ if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
+ c++;
+
+ if (!strcasecmp(argv[c], "link")) {
+ /**********************************************************************/
+ if (check_arg_count(argc, 3)) goto handle_cli_error_argc;
+ c++;
+
+ handle_unbind_link(stream, argv[c]);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ stream->write_function(stream, "Unknown \"bind\" command\n");
+ goto handle_cli_error;
+ /**********************************************************************/
+ }
+ /**************************************************************************/
} else if (!strcasecmp(argv[c], "activate")) {
/**************************************************************************/
if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
@@ -620,8 +680,8 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream)
stream->write_function(stream, "ftdm ss7 set mtrace X Y\n");
stream->write_function(stream, "\n");
stream->write_function(stream, "Ftmod_sangoma_ss7 information:\n");
- stream->write_function(stream, "ftdm ss7 show status link X\n");
- stream->write_function(stream, "ftdm ss7 show status linkset X\n");
+ stream->write_function(stream, "ftdm ss7 show status mtp3 X\n");
+ stream->write_function(stream, "ftdm ss7 show status mtp2 X\n");
stream->write_function(stream, "ftdm ss7 show status span X chan Y\n");
stream->write_function(stream, "ftdm ss7 show free span X chan Y\n");
stream->write_function(stream, "ftdm ss7 show inuse span X chan Y\n");
@@ -649,6 +709,16 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream)
return FTDM_SUCCESS;
}
+/******************************************************************************/
+static ftdm_status_t handle_show_procId(ftdm_stream_handle_t *stream)
+{
+ int procId = sng_get_procId();
+
+ stream->write_function(stream, "Local ProcId = %d\n", procId);
+
+ return FTDM_SUCCESS;
+}
+
/******************************************************************************/
static ftdm_status_t handle_set_function_trace(ftdm_stream_handle_t *stream, int on, int level)
{
@@ -693,7 +763,7 @@ static ftdm_status_t handle_show_free(ftdm_stream_handle_t *stream, int span, in
int lspan;
int lchan;
- x=1;
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
free = 0;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
@@ -756,7 +826,7 @@ static ftdm_status_t handle_show_inuse(ftdm_stream_handle_t *stream, int span, i
int lspan;
int lchan;
- x=1;
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
in_use = 0;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
@@ -826,7 +896,7 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,
int lspan;
int lchan;
- x=1;
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
in_reset = 0;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
@@ -848,10 +918,10 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,
}
if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) {
- if ((sngss7_test_flag(ss7_info, FLAG_RESET_RX)) ||
- (sngss7_test_flag(ss7_info, FLAG_RESET_TX)) ||
- (sngss7_test_flag(ss7_info, FLAG_GRP_RESET_RX)) ||
- (sngss7_test_flag(ss7_info, FLAG_GRP_RESET_TX))) {
+ if ((sngss7_test_ckt_flag(ss7_info, FLAG_RESET_RX)) ||
+ (sngss7_test_ckt_flag(ss7_info, FLAG_RESET_TX)) ||
+ (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_RESET_RX)) ||
+ (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_RESET_TX))) {
if (verbose) {
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|in_reset=Y\n",
@@ -862,7 +932,7 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,
/*increment the count of circuits in reset */
in_reset++;
- } /* if ((sngss7_test_flag(ss7_info, FLAG_RESET_RX) ... */
+ } /* if ((sngss7_test_ckt_flag(ss7_info, FLAG_RESET_RX) ... */
} /* if ( span and chan) */
} /* if ( cic != 0) */
@@ -885,7 +955,7 @@ static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, i
int lspan;
int lchan;
- x=1;
+ 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) {
ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
@@ -913,7 +983,7 @@ static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, i
for (bit = 0; bit < 33; bit++) {
stream->write_function(stream, "|");
- if (ss7_info->flags & ( 0x1 << bit)) {
+ if (ss7_info->ckt_flags & ( 0x1 << bit)) {
stream->write_function(stream, "%2d=1", bit);
} else {
stream->write_function(stream, "%2d=0", bit);
@@ -941,7 +1011,7 @@ static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span,
int lspan;
int lchan;
- x=1;
+ 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) {
ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
@@ -967,37 +1037,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_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {
+ if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_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_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {
+ if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_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_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {
+ if(sngss7_test_ckt_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_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {
+ if(sngss7_test_ckt_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_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX)) {
+ if(sngss7_test_ckt_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_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {
+ if(sngss7_test_ckt_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {
stream->write_function(stream, "l_ucic=Y|");
}else {
stream->write_function(stream, "l_ucic=N|");
@@ -1026,7 +1096,7 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN;
sng_isup_ckt_t *ckt;
- x=1;
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
/* extract the circuit to make it easier to work with */
ckt = &g_ftdm_sngss7_data.cfg.isupCkt[x];
@@ -1061,53 +1131,58 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
ftdmchan = ss7_info->ftdmchan;
- /* grab the signaling_status */
- ftdm_channel_get_sig_status(ftdmchan, &sigstatus);
+ if (ftdmchan == NULL) {
+ /* this should never happen!!! */
+ stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|FTDMCHAN DOES NOT EXISTS",
+ ckt->span,
+ ckt->chan,
+ ckt->cic);
+
+ } else {
+ /* 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|",
+ ckt->span,
+ ckt->chan,
+ ckt->cic,
+ 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))) {
+ 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))) {
+ 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)) {
+ 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)) {
+ stream->write_function(stream, "r_hw=Y|");
+ }else {
+ stream->write_function(stream, "r_hw=N|");
+ }
- stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|sig_status=%4s|state=%s|",
- ckt->span,
- ckt->chan,
- ckt->cic,
- ftdm_signaling_status2str(sigstatus),
- ftdm_channel_state2str(ftdmchan->state));
-
- if((sngss7_test_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_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_RELAY_DOWN)) {
+ stream->write_function(stream, "relay=Y|");
+ }else {
+ stream->write_function(stream, "relay=N|");
+ }
}
- if((sngss7_test_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_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_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_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_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_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {
- stream->write_function(stream, "l_ucic=Y|");
- }else {
- stream->write_function(stream, "l_ucic=N|");
- }
-
- stream->write_function(stream, "flags=0x%X",ss7_info->flags);
+ stream->write_function(stream, "flags=0x%X",ss7_info->ckt_flags);
stream->write_function(stream, "\n");
} /* if ( hole, sig, voice) */
@@ -1127,7 +1202,7 @@ static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int c
int lspan;
int lchan;
- x=1;
+ 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) {
ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
@@ -1162,7 +1237,7 @@ 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_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
+ sngss7_set_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -1193,7 +1268,7 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c
int lspan;
int lchan;
- x=1;
+ 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) {
ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
@@ -1228,10 +1303,10 @@ 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_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX);
+ sngss7_set_ckt_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX);
/* clear the block flag */
- sngss7_clear_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
+ sngss7_clear_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -1254,18 +1329,18 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c
}
/******************************************************************************/
-static ftdm_status_t handle_status_link(ftdm_stream_handle_t *stream, char *name)
+static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *name)
{
int x = 0;
SnMngmt sta;
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the status request */
- if (ftmod_ss7_mtplink_sta(x, &sta)) {
+ if (ftmod_ss7_mtp3link_sta(x, &sta)) {
stream->write_function(stream, "Failed to read link=%s status\n", name);
return FTDM_FAIL;
}
@@ -1273,9 +1348,9 @@ static ftdm_status_t handle_status_link(ftdm_stream_handle_t *stream, char *name
/* print the results */
stream->write_function(stream, "%s|span=%d|chan=%d|sap=%d|state=%s|l_blk=%s|r_blk=%s|l_inhbt=%s|r_inhbt=%s\n",
name,
- g_ftdm_sngss7_data.cfg.mtpLink[x].mtp1.span,
- g_ftdm_sngss7_data.cfg.mtpLink[x].mtp1.chan,
- g_ftdm_sngss7_data.cfg.mtpLink[x].id,
+ g_ftdm_sngss7_data.cfg.mtp1Link[x].span,
+ g_ftdm_sngss7_data.cfg.mtp1Link[x].chan,
+ g_ftdm_sngss7_data.cfg.mtp3Link[x].id,
DECODE_LSN_LINK_STATUS(sta.t.ssta.s.snDLSAP.state),
(sta.t.ssta.s.snDLSAP.locBlkd) ? "Y":"N",
(sta.t.ssta.s.snDLSAP.remBlkd) ? "Y":"N",
@@ -1295,6 +1370,50 @@ success:
return FTDM_SUCCESS;
}
+/******************************************************************************/
+static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *name)
+{
+ int x = 0;
+ SdMngmt sta;
+
+ /* find the link request by it's name */
+ x = 1;
+ while(g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) {
+
+ /* send the status request */
+ if (ftmod_ss7_mtp2link_sta(x, &sta)) {
+ stream->write_function(stream, "Failed to read link=%s status\n", name);
+ return FTDM_FAIL;
+ }
+
+ /* print the results */
+ stream->write_function(stream, "%s|span=%d|chan=%d|sap=%d|state=%s|outsFrm=%d|drpdFrm=%d|lclStatus=%s|rmtStatus=%s|fsn=%d|bsn=%d\n",
+ name,
+ g_ftdm_sngss7_data.cfg.mtp1Link[x].span,
+ g_ftdm_sngss7_data.cfg.mtp1Link[x].chan,
+ g_ftdm_sngss7_data.cfg.mtp2Link[x].id,
+ DECODE_LSD_LINK_STATUS(sta.t.ssta.s.sdDLSAP.hlSt),
+ sta.t.ssta.s.sdDLSAP.psOutsFrm,
+ sta.t.ssta.s.sdDLSAP.cntMaDrop,
+ (sta.t.ssta.s.sdDLSAP.lclBsy) ? "Y":"N",
+ (sta.t.ssta.s.sdDLSAP.remBsy) ? "Y":"N",
+ sta.t.ssta.s.sdDLSAP.fsn,
+ sta.t.ssta.s.sdDLSAP.bsn);
+
+ goto success;
+ }
+
+ /* move to the next link */
+ x++;
+ } /* while (id != 0) */
+
+ stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
+
+success:
+ return FTDM_SUCCESS;
+}
+
/******************************************************************************/
static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *name)
{
@@ -1338,17 +1457,17 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the inhibit request */
- if (ftmod_ss7_inhibit_mtplink(x)) {
+ if (ftmod_ss7_inhibit_mtp3link(x)) {
stream->write_function(stream, "Failed to inhibit link=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the link */
- handle_status_link(stream, &name[0]);
+ handle_status_mtp3link(stream, &name[0]);
goto success;
}
@@ -1370,17 +1489,17 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
- if (ftmod_ss7_uninhibit_mtplink(x)) {
+ if (ftmod_ss7_uninhibit_mtp3link(x)) {
stream->write_function(stream, "Failed to uninhibit link=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the link */
- handle_status_link(stream, &name[0]);
+ handle_status_mtp3link(stream, &name[0]);
goto success;
}
@@ -1404,7 +1523,7 @@ static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int c
int lspan;
int lchan;
- x=1;
+ 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) {
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
@@ -1429,7 +1548,7 @@ static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int c
ftdm_mutex_lock(ftdmchan->mutex);
/* throw the reset flag */
- sngss7_set_flag(sngss7_info, FLAG_RESET_TX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
switch (ftdmchan->state) {
/**************************************************************************/
@@ -1476,7 +1595,7 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
return FTDM_SUCCESS;
}
- x=1;
+ 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) {
@@ -1500,9 +1619,9 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
continue;
} else {
/* throw the grp reset flag */
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);
if (ftdmchan->physical_chan_id == chan) {
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_BASE);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE);
sngss7_span->tx_grs.circuit = sngss7_info->circuit->id;
sngss7_span->tx_grs.range = range-1;
}
@@ -1523,7 +1642,7 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
x++;
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */
- x=1;
+ 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) {
@@ -1565,7 +1684,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c
return FTDM_SUCCESS;
}
- x=1;
+ 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) {
@@ -1582,7 +1701,7 @@ 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_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
/* bring the sig status down */
sigev.chan_id = ftdmchan->chan_id;
@@ -1622,7 +1741,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c
/* send the circuit group block */
ft_to_sngss7_cgb(main_chan);
- x=1;
+ 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) {
@@ -1665,7 +1784,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c
return FTDM_SUCCESS;
}
- x=1;
+ 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) {
@@ -1682,7 +1801,7 @@ 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_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
/* bring the sig status up */
sigev.chan_id = ftdmchan->chan_id;
@@ -1722,7 +1841,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c
/* send the circuit group block */
ft_to_sngss7_cgu(main_chan);
- x=1;
+ 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) {
@@ -1745,6 +1864,68 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c
return FTDM_SUCCESS;
}
+/******************************************************************************/
+static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name)
+{
+ int x = 0;
+
+ /* find the link request by it's name */
+ x = 1;
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
+
+ /* send the uninhibit request */
+ if (ftmod_ss7_bind_mtp3link(g_ftdm_sngss7_data.cfg.mtp3Link[x].mtp2Id)) {
+ stream->write_function(stream, "Failed to bind link=%s\n", name);
+ return FTDM_FAIL;
+ }
+
+ /* print the new status of the link */
+ handle_status_mtp3link(stream, &name[0]);
+ goto success;
+ }
+
+ /* move to the next link */
+ x++;
+ } /* while (id != 0) */
+
+ stream->write_function(stream, "Could not find link=%s\n", name);
+
+success:
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name)
+{
+ int x = 0;
+
+ /* find the link request by it's name */
+ x = 1;
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
+
+ /* send the uninhibit request */
+ if (ftmod_ss7_unbind_mtp3link(g_ftdm_sngss7_data.cfg.mtp3Link[x].mtp2Id)) {
+ stream->write_function(stream, "Failed to bind link=%s\n", name);
+ return FTDM_FAIL;
+ }
+
+ /* print the new status of the link */
+ handle_status_mtp3link(stream, &name[0]);
+ goto success;
+ }
+
+ /* move to the next link */
+ x++;
+ } /* while (id != 0) */
+
+ stream->write_function(stream, "Could not find link=%s\n", name);
+
+success:
+ return FTDM_SUCCESS;
+}
+
/******************************************************************************/
static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *name)
{
@@ -1752,17 +1933,17 @@ static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *na
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
- if (ftmod_ss7_activate_mtplink(x)) {
+ if (ftmod_ss7_activate_mtp3link(x)) {
stream->write_function(stream, "Failed to activate link=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the link */
- handle_status_link(stream, &name[0]);
+ handle_status_mtp3link(stream, &name[0]);
goto success;
}
@@ -1783,17 +1964,17 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the deactivate request */
- if (ftmod_ss7_deactivate2_mtplink(x)) {
+ if (ftmod_ss7_deactivate2_mtp3link(x)) {
stream->write_function(stream, "Failed to deactivate link=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the link */
- handle_status_link(stream, &name[0]);
+ handle_status_mtp3link(stream, &name[0]);
goto success;
}
@@ -1877,17 +2058,17 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name)
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
- if (ftmod_ss7_lpo_mtplink(x)) {
+ if (ftmod_ss7_lpo_mtp3link(x)) {
stream->write_function(stream, "Failed set LPO link=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the link */
- handle_status_link(stream, &name[0]);
+ handle_status_mtp3link(stream, &name[0]);
goto success;
}
@@ -1908,17 +2089,17 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name)
/* find the link request by it's name */
x = 1;
- while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
+ while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
/* send the uninhibit request */
- if (ftmod_ss7_lpr_mtplink(x)) {
+ if (ftmod_ss7_lpr_mtp3link(x)) {
stream->write_function(stream, "Failed set LPR link=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the link */
- handle_status_link(stream, &name[0]);
+ handle_status_mtp3link(stream, &name[0]);
goto success;
}
@@ -1932,6 +2113,47 @@ success:
return FTDM_SUCCESS;
}
+/******************************************************************************/
+static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *name)
+{
+ RyMngmt sta;
+ int x = 0;
+
+ memset(&sta, 0x0, sizeof(sta));
+
+
+ /* find the channel request by it's name */
+ x = 1;
+ while(g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
+ if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) {
+
+ if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[x].id, &sta)) {
+ stream->write_function(stream, "Failed to read relay =%s status\n", name);
+ return FTDM_FAIL;
+ }
+
+ /* print the results */
+ stream->write_function(stream, "%s|sap=%d|type=%d|port=%d|hostname=%s|procId=%d|status=%s\n",
+ name,
+ g_ftdm_sngss7_data.cfg.relay[x].id,
+ g_ftdm_sngss7_data.cfg.relay[x].type,
+ g_ftdm_sngss7_data.cfg.relay[x].port,
+ g_ftdm_sngss7_data.cfg.relay[x].hostname,
+ g_ftdm_sngss7_data.cfg.relay[x].procId,
+ DECODE_LRY_CHAN_STATUS(sta.t.ssta.rySta.cStatus));
+
+ goto success;
+ }
+
+ /* move to the next link */
+ x++;
+
+ } /* g_ftdm_sngss7_data.cfg.relay[x].id */
+
+success:
+ return FTDM_SUCCESS;
+}
+
/******************************************************************************/
static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan)
{
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c
index 87733dd594..c1b18e529a 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c
@@ -48,19 +48,31 @@ static int ftmod_ss7_enable_isap(int suId);
static int ftmod_ss7_enable_nsap(int suId);
static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId);
-int ftmod_ss7_inhibit_mtplink(uint32_t id);
-int ftmod_ss7_uninhibit_mtplink(uint32_t id);
+int ftmod_ss7_inhibit_mtp3link(uint32_t id);
+int ftmod_ss7_uninhibit_mtp3link(uint32_t id);
-int ftmod_ss7_activate_mtplink(uint32_t id);
-int ftmod_ss7_deactivate_mtplink(uint32_t id);
-int ftmod_ss7_deactivate2_mtplink(uint32_t id);
+int ftmod_ss7_bind_mtp3link(uint32_t id);
+int ftmod_ss7_unbind_mtp3link(uint32_t id);
+int ftmod_ss7_activate_mtp3link(uint32_t id);
+int ftmod_ss7_deactivate_mtp3link(uint32_t id);
+int ftmod_ss7_deactivate2_mtp3link(uint32_t id);
int ftmod_ss7_activate_mtplinkSet(uint32_t id);
int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
-int ftmod_ss7_lpo_mtplink(uint32_t id);
-int ftmod_ss7_lpr_mtplink(uint32_t id);
+int ftmod_ss7_lpo_mtp3link(uint32_t id);
+int ftmod_ss7_lpr_mtp3link(uint32_t id);
+
+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_grp_mtp3Link(uint32_t procId);
+int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
+
+int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@@ -71,7 +83,7 @@ int ft_to_sngss7_activate_all(void)
x = 1;
while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
/* check if this link has already been actived */
- if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & ACTIVE)) {
+ if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE)) {
if (ftmod_ss7_enable_isap(x)) {
SS7_CRITICAL("ISAP %d Enable: NOT OK\n", x);
@@ -80,9 +92,9 @@ int ft_to_sngss7_activate_all(void)
SS7_INFO("ISAP %d Enable: OK\n", x);
}
- /* set the ACTIVE flag */
- g_ftdm_sngss7_data.cfg.isap[x].flags |= ACTIVE;
- } /* if !ACTIVE */
+ /* set the SNGSS7_ACTIVE flag */
+ g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_ACTIVE;
+ } /* if !SNGSS7_ACTIVE */
x++;
} /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
@@ -90,7 +102,7 @@ int ft_to_sngss7_activate_all(void)
x = 1;
while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
/* check if this link has already been actived */
- if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & ACTIVE)) {
+ if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE)) {
if (ftmod_ss7_enable_nsap(x)) {
SS7_CRITICAL("NSAP %d Enable: NOT OK\n", x);
@@ -99,31 +111,33 @@ int ft_to_sngss7_activate_all(void)
SS7_INFO("NSAP %d Enable: OK\n", x);
}
- /* set the ACTIVE flag */
- g_ftdm_sngss7_data.cfg.nsap[x].flags |= ACTIVE;
- } /* if !ACTIVE */
+ /* set the SNGSS7_ACTIVE flag */
+ g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_ACTIVE;
+ } /* if !SNGSS7_ACTIVE */
x++;
} /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
- x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
- /* check if this link has already been actived */
- if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & ACTIVE)) {
-
- if (ftmod_ss7_enable_mtpLinkSet(x)) {
- SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
- return 1;
- } else {
- SS7_INFO("LinkSet \"%s\" Enable: OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
- }
-
- /* set the ACTIVE flag */
- g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= ACTIVE;
- } /* if !ACTIVE */
-
- x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
+ if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) {
+ x = 1;
+ while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
+ /* check if this link has already been actived */
+ if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE)) {
+
+ if (ftmod_ss7_enable_mtpLinkSet(x)) {
+ SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
+ return 1;
+ } else {
+ SS7_INFO("LinkSet \"%s\" Enable: OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
+ }
+
+ /* set the SNGSS7_ACTIVE flag */
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_ACTIVE;
+ } /* if !SNGSS7_ACTIVE */
+
+ x++;
+ } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
+ }
return 0;
}
@@ -223,7 +237,7 @@ static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId)
}
/******************************************************************************/
-int ftmod_ss7_inhibit_mtplink(uint32_t id)
+int ftmod_ss7_inhibit_mtp3link(uint32_t id)
{
SnMngmt cntrl;
Pst pst;
@@ -253,7 +267,7 @@ int ftmod_ss7_inhibit_mtplink(uint32_t id)
}
/******************************************************************************/
-int ftmod_ss7_uninhibit_mtplink(uint32_t id)
+int ftmod_ss7_uninhibit_mtp3link(uint32_t id)
{
SnMngmt cntrl;
Pst pst;
@@ -283,7 +297,7 @@ int ftmod_ss7_uninhibit_mtplink(uint32_t id)
}
/******************************************************************************/
-int ftmod_ss7_activate_mtplink(uint32_t id)
+int ftmod_ss7_bind_mtp3link(uint32_t id)
{
SnMngmt cntrl;
Pst pst;
@@ -304,7 +318,67 @@ int ftmod_ss7_activate_mtplink(uint32_t id)
cntrl.hdr.entId.ent = ENTSN;
cntrl.hdr.entId.inst = S_INST;
cntrl.hdr.elmId.elmnt = STDLSAP;
- cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
+ cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
+
+ cntrl.t.cntrl.action = ABND; /* Activate */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_mtp3(&pst, &cntrl));
+}
+
+/******************************************************************************/
+int ftmod_ss7_unbind_mtp3link(uint32_t id)
+{
+ SnMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSN;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SnMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSN;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STDLSAP;
+ cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
+
+ cntrl.t.cntrl.action = AUBND_DIS; /* unbind and disable */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_mtp3(&pst, &cntrl));
+}
+
+/******************************************************************************/
+int ftmod_ss7_activate_mtp3link(uint32_t id)
+{
+ SnMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSN;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SnMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSN;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STDLSAP;
+ cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
cntrl.t.cntrl.action = AENA; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
@@ -313,7 +387,7 @@ int ftmod_ss7_activate_mtplink(uint32_t id)
}
/******************************************************************************/
-int ftmod_ss7_deactivate_mtplink(uint32_t id)
+int ftmod_ss7_deactivate_mtp3link(uint32_t id)
{
SnMngmt cntrl;
Pst pst;
@@ -334,7 +408,7 @@ int ftmod_ss7_deactivate_mtplink(uint32_t id)
cntrl.hdr.entId.ent = ENTSN;
cntrl.hdr.entId.inst = S_INST;
cntrl.hdr.elmId.elmnt = STDLSAP;
- cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
+ cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
cntrl.t.cntrl.action = ADISIMM; /* Deactivate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
@@ -343,7 +417,7 @@ int ftmod_ss7_deactivate_mtplink(uint32_t id)
}
/******************************************************************************/
-int ftmod_ss7_deactivate2_mtplink(uint32_t id)
+int ftmod_ss7_deactivate2_mtp3link(uint32_t id)
{
SnMngmt cntrl;
Pst pst;
@@ -364,7 +438,7 @@ int ftmod_ss7_deactivate2_mtplink(uint32_t id)
cntrl.hdr.entId.ent = ENTSN;
cntrl.hdr.entId.inst = S_INST;
cntrl.hdr.elmId.elmnt = STDLSAP;
- cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
+ cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
cntrl.t.cntrl.action = ADISIMM_L2; /* Deactivate...layer 2 only */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
@@ -463,7 +537,7 @@ int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id)
}
/******************************************************************************/
-int ftmod_ss7_lpo_mtplink(uint32_t id)
+int ftmod_ss7_lpo_mtp3link(uint32_t id)
{
SnMngmt cntrl;
Pst pst;
@@ -484,7 +558,7 @@ int ftmod_ss7_lpo_mtplink(uint32_t id)
cntrl.hdr.entId.ent = ENTSN;
cntrl.hdr.entId.inst = S_INST;
cntrl.hdr.elmId.elmnt = STDLSAP;
- cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
+ cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
cntrl.t.cntrl.action = ACTION_LPO; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
@@ -493,7 +567,7 @@ int ftmod_ss7_lpo_mtplink(uint32_t id)
}
/******************************************************************************/
-int ftmod_ss7_lpr_mtplink(uint32_t id)
+int ftmod_ss7_lpr_mtp3link(uint32_t id)
{
SnMngmt cntrl;
Pst pst;
@@ -514,7 +588,7 @@ int ftmod_ss7_lpr_mtplink(uint32_t id)
cntrl.hdr.entId.ent = ENTSN;
cntrl.hdr.entId.inst = S_INST;
cntrl.hdr.elmId.elmnt = STDLSAP;
- cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
+ cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
cntrl.t.cntrl.action = ACTION_LPR; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
@@ -523,6 +597,216 @@ int ftmod_ss7_lpr_mtplink(uint32_t id)
}
/******************************************************************************/
+int ftmod_ss7_shutdown_isup(void)
+{
+ 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 = STGEN;
+
+ cntrl.t.cntrl.action = ASHUTDOWN; /* shutdown */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_isup(&pst, &cntrl));
+}
+
+/******************************************************************************/
+int ftmod_ss7_shutdown_mtp3(void)
+{
+ SnMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSN;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SnMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSN;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STGEN;
+
+ cntrl.t.cntrl.action = ASHUTDOWN; /* Activate */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_mtp3(&pst, &cntrl));
+}
+
+/******************************************************************************/
+int ftmod_ss7_shutdown_mtp2(void)
+{
+ SdMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSD;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SdMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSD;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STGEN;
+
+ cntrl.t.cntrl.action = ASHUTDOWN; /* Activate */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_mtp2(&pst, &cntrl));
+}
+
+/******************************************************************************/
+int ftmod_ss7_shutdown_relay(void)
+{
+ 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.t.cntrl.action = ASHUTDOWN; /* Activate */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_relay(&pst, &cntrl));
+}
+
+/******************************************************************************/
+int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId)
+{
+ SnMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSN;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SnMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSN;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STGRDLSAP; /* group DLSAP */
+
+ cntrl.t.cntrl.ctlType.groupKey.dstProcId = procId; /* all SAPS to this ProcId */
+
+ cntrl.t.cntrl.action = AUBND_DIS; /* disable and unbind */
+ cntrl.t.cntrl.subAction = SAGR_DSTPROCID; /* specificed element */
+
+ return (sng_cntrl_mtp3(&pst, &cntrl));
+
+}
+
+/******************************************************************************/
+int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId)
+{
+ SnMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSN;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SnMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSN;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STGRDLSAP; /* group DLSAP */
+
+ cntrl.t.cntrl.ctlType.groupKey.dstProcId = procId; /* all SAPS to this ProcId */
+
+ cntrl.t.cntrl.action = ABND_ENA; /* bind and enable */
+ cntrl.t.cntrl.subAction = SAGR_DSTPROCID; /* specificed element */
+
+ return (sng_cntrl_mtp3(&pst, &cntrl));
+
+}
+
+/******************************************************************************/
+int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId)
+{
+ SdMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSD;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(cntrl));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSD;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STGRNSAP; /* group NSAP */
+
+ cntrl.t.cntrl.par.dstProcId = procId; /* all SAPS to this ProcId */
+
+ cntrl.t.cntrl.action = AUBND_DIS; /* disable and unbind */
+ cntrl.t.cntrl.subAction = SAGR_DSTPROCID; /* specificed element */
+
+ return (sng_cntrl_mtp2(&pst, &cntrl));
+
+}
/******************************************************************************/
/* For Emacs:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
index dcfb7f79e0..3a6fca7376 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
@@ -99,21 +99,21 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
- if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) {
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx IAM (glare)\n", sngss7_info->circuit->cic);
} else {
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx IAM\n", sngss7_info->circuit->cic);
}
/* check if the circuit has a remote block */
- if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {
+ 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))) {
/* as per Q.764, 2.8.2.3 xiv ... remove the block from this channel */
- sngss7_clear_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
- sngss7_clear_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
- sngss7_clear_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
/* KONRAD FIX ME : check in case there is a ckt and grp block */
}
@@ -134,7 +134,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
ftdmchan->physical_chan_id);
/* set the flag to indicate this hangup is started from the local side */
- sngss7_set_flag(sngss7_info, FLAG_LOCAL_REL);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL);
ftdmchan->caller_data.hangup_cause = 41;
@@ -253,26 +253,26 @@ handle_glare:
sngss7_info->glare.circuit = circuit;
memcpy(&sngss7_info->glare.iam, siConEvnt, sizeof(*siConEvnt));
- if (!(sngss7_test_flag(sngss7_info, FLAG_GLARE))) {
+ if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) {
/* glare, throw the flag */
- sngss7_set_flag(sngss7_info, FLAG_GLARE);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE);
/* setup the hangup cause */
ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */
/* this is a remote hangup request */
- sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);
/* move the state of the channel to Terminating to end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
- } /* if (!(sngss7_test_flag(sngss7_info, FLAG_GLARE))) */
+ } /* if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) */
break;
/**************************************************************************/
default: /* should not have gotten an IAM while in this state */
SS7_ERROR_CHAN(ftdmchan, "Got IAM on channel in invalid state(%s)...reset!\n", ftdm_channel_state2str (ftdmchan->state));
/* reset the cic */
- sngss7_set_flag(sngss7_info, FLAG_RESET_TX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
/* move the state of the channel to RESTART to force a reset */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
@@ -341,7 +341,7 @@ ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circ
ftdm_channel_state2str (ftdmchan->state));
/* reset the cic */
- sngss7_set_flag(sngss7_info, FLAG_RESET_TX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
/* go to RESTART */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
@@ -545,7 +545,7 @@ ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circ
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx ANM/CON\n", sngss7_info->circuit->cic);
/* throw the TX reset flag */
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);
/* go to RESTART */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
@@ -597,7 +597,7 @@ ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
}
/* this is a remote hangup request */
- sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);
ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
/* move the state of the channel to CANCEL to end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
@@ -618,7 +618,7 @@ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
}
/* this is a remote hangup request */
- sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);
/* move the state of the channel to TERMINATING to end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
@@ -631,7 +631,7 @@ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
/* since we need to acknowledge the hang up set the flag for remote release */
- sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);
/* go to hangup complete to send the RLC */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
@@ -645,7 +645,7 @@ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
default:
/* throw the reset flag */
- sngss7_set_flag(sngss7_info, FLAG_RESET_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX);
/* set the state to RESTART */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
@@ -1134,13 +1134,13 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
- if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) {
/* the glare flag is already up so it was caught ... do nothing */
SS7_DEBUG_CHAN(ftdmchan, "Glare flag is already up...nothing to do!%s\n", " ");
} else {
SS7_DEBUG_CHAN(ftdmchan, "Glare flag is not up yet...indicating glare from reattempt!%s\n", " ");
/* glare, throw the flag */
- sngss7_set_flag(sngss7_info, FLAG_GLARE);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE);
/* clear any existing glare data from the channel */
memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t));
@@ -1149,7 +1149,7 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci
ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */
/* this is a remote hangup request */
- sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);
/* move the state of the channel to Terminating to end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
@@ -1179,7 +1179,7 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui
sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[infId], SNGSS7_PAUSED);
/* go through all the circuits now and find any other circuits on this infId */
- i = 1;
+ i = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) {
/* check that the infId matches and that this is not a siglink */
@@ -1200,7 +1200,7 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui
if (ftdm_test_flag(ftdmchan->span, FTDM_SPAN_IN_THREAD)) {
SS7_DEBUG_CHAN(ftdmchan, "Rx PAUSE%s\n", "");
/* set the pause flag on the channel */
- sngss7_set_flag(sngss7_info, FLAG_INFID_PAUSED);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
}
/* unlock the channel again before we exit */
@@ -1234,7 +1234,7 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu
sngss7_clear_flag(&g_ftdm_sngss7_data.cfg.isupIntf[infId], SNGSS7_PAUSED);
/* go through all the circuits now and find any other circuits on this infId */
- i = 1;
+ i = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) {
/* check that the infId matches and that this is not a siglink */
@@ -1252,14 +1252,14 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu
ftdm_mutex_lock(ftdmchan->mutex);
/* only resume if we are paused */
- if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) {
SS7_DEBUG_CHAN(ftdmchan, "Rx RESUME%s\n", "");
/* set the resume flag on the channel */
- sngss7_set_flag(sngss7_info, FLAG_INFID_RESUME);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
/* clear the paused flag */
- sngss7_clear_flag(sngss7_info, FLAG_INFID_PAUSED);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
}
/* unlock the channel again before we exit */
@@ -1421,12 +1421,12 @@ ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
ftdm_mutex_lock(ftdmchan->mutex);
/* check if the circuit is already blocked or not */
- if (sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {
SS7_WARN("Received BLO on circuit that is already blocked!\n");
}
/* throw the ckt block flag */
- sngss7_set_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -1484,15 +1484,15 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
ftdm_mutex_lock(ftdmchan->mutex);
/* check if the channel is blocked */
- if (!(sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX))) {
+ if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX))) {
SS7_WARN("Received UBL on circuit that is not blocked!\n");
}
/* throw the unblock flag */
- sngss7_set_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX);
/* clear the block flag */
- sngss7_clear_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -1550,7 +1550,7 @@ ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
ftdm_mutex_lock(ftdmchan->mutex);
/* throw the reset flag */
- sngss7_set_flag(sngss7_info, FLAG_RESET_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX);
switch (ftdmchan->state) {
/**************************************************************************/
@@ -1595,7 +1595,7 @@ ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_
ftdm_mutex_lock(ftdmchan->mutex);
/* throw the reset flag */
- sngss7_set_flag(sngss7_info, FLAG_RESET_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX);
switch (ftdmchan->state) {
/**************************************************************************/
@@ -1643,9 +1643,9 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/**********************************************************************/
case FTDM_CHANNEL_STATE_RESTART:
- if ( sngss7_test_flag(sngss7_info, FLAG_RESET_TX) ) {
+ if ( sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX) ) {
/* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
- sngss7_set_flag(sngss7_info, FLAG_RESET_TX_RSP);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP);
/* go to DOWN */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
@@ -1667,7 +1667,7 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
/* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
- sngss7_set_flag(sngss7_info, FLAG_RESET_TX_RSP);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP);
/* go to DOWN */
/*ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);*/
@@ -1795,12 +1795,12 @@ ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t ci
ftdm_mutex_lock(ftdmchan->mutex);
/* check if the circuit is already blocked or not */
- if (sngss7_test_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {
SS7_WARN("Received local BLO on circuit that is already blocked!\n");
}
/* throw the ckt block flag */
- sngss7_set_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -1831,12 +1831,12 @@ ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t ci
ftdm_mutex_lock(ftdmchan->mutex);
/* check if the circuit is already blocked or not */
- if (sngss7_test_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
SS7_WARN("Received local UBL on circuit that is already unblocked!\n");
}
/* throw the ckt block flag */
- sngss7_set_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -1878,7 +1878,7 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit
ftdm_mutex_lock(ftdmchan->mutex);
/* throw the ckt block flag */
- sngss7_set_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -1982,11 +1982,11 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
switch (blockType) {
/**********************************************************************/
case 0: /* maintenance oriented */
- sngss7_set_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
break;
/**********************************************************************/
case 1: /* hardware failure oriented */
- sngss7_set_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
break;
/**********************************************************************/
case 2: /* reserved for national use */
@@ -2113,11 +2113,11 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
switch (blockType) {
/**********************************************************************/
case 0: /* maintenance oriented */
- sngss7_clear_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
break;
/**********************************************************************/
case 1: /* hardware failure oriented */
- sngss7_clear_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
break;
/**********************************************************************/
case 2: /* reserved for national use */
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c
index 72bd1c3fb2..76984b907b 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c
@@ -409,13 +409,80 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
sngss7_event_data_t *sngss7_event = NULL;
+ uint32_t intfId;
+ int x;
- /* 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);
- SS7_FUNC_TRACE_EXIT(__FUNCTION__);
- return;
- }
+ /* check if the eventType is a pause/resume */
+ switch (evntType) {
+ /**************************************************************************/
+ 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
+ */
+ intfId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId;
+
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
+ while ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) &&
+ (g_ftdm_sngss7_data.cfg.isupCkt[x].id < ((g_ftdm_sngss7_data.cfg.procId +1) * 1000))) {
+ /**********************************************************************/
+ /* confirm this is a voice channel and not a gap/sig (no ftdmchan there) */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != VOICE) goto move_along;
+
+ /* compare the intfIds */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) {
+ /* we have a match, setup the pointers to the correct values */
+ circuit = x;
+
+ if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
+ /* bounce out of the loop */
+ break;
+ } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].intfId == intfId) */
+
+move_along:
+ /* move along ... nothing to see here */
+ x++;
+
+ /**********************************************************************/
+ } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
+
+ /* check if we found any circuits that are on the intfId, drop the message
+ * if none are found
+ */
+ if (ftdmchan == NULL) goto sta_ind_end;
+
+ break;
+ /**************************************************************************/
+ default:
+sta_ind_local:
+ /* 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);
+ SS7_FUNC_TRACE_EXIT(__FUNCTION__);
+ return;
+ }
+
+ break;
+ /**************************************************************************/
+ } /* switch (evntType) */
/* initalize the sngss7_event */
sngss7_event = ftdm_malloc(sizeof(*sngss7_event));
@@ -440,6 +507,7 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
/* enqueue this event */
ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info->ftdmchan->span->signal_data)->event_queue, sngss7_event);
+sta_ind_end:
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
}
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
index 3f507d6648..f4143fc864 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
@@ -48,6 +48,8 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);
void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta);
void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta);
void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta);
+void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta);
+
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@@ -77,8 +79,8 @@ void handle_sng_log(uint8_t level, char *fmt,...)
ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
break;
/**************************************************************************/
- case SNG_LOGLEVEL_STATS:
- ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
+ case SNG_LOGLEVEL_NOTICE:
+ ftdm_log(FTDM_LOG_NOTICE, "sng_ss7->%s", data);
break;
/**************************************************************************/
case SNG_LOGLEVEL_ERROR:
@@ -132,17 +134,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta->t.usta.evntParm[0]) {
+ while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
x++;
}
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
- sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
+ sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
}
@@ -173,17 +175,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta->t.usta.evntParm[0]) {
+ while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
x++;
}
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
- sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
+ sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n",
@@ -196,17 +198,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta->t.usta.evntParm[0]) {
+ while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
x++;
}
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
- sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
+ sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n",
@@ -220,17 +222,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta->t.usta.evntParm[0]) {
+ while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
x++;
}
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
- sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
+ sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : RTB Queue Len(%d)|Oldest BSN(%d)|Tx Queue Len(%d)|Outstanding Frames(%d)\n",
@@ -246,17 +248,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta->t.usta.evntParm[0]) {
+ while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
x++;
}
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
- sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
+ sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : RTB Queue Len(%d)\n",
@@ -269,17 +271,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta->t.usta.evntParm[0]) {
+ while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
break;
}
x++;
}
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
- sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
+ sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %d\n",
@@ -290,9 +292,11 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/**********************************************************************/
case (LCM_EVENT_UI_INV_EVT):
case (LCM_EVENT_LI_INV_EVT):
- ftdm_log(FTDM_LOG_ERROR,"[MTP2] %s : %s : Primitive (%d)\n",
+ ftdm_log(FTDM_LOG_ERROR,"[MTP2] %s(%d) : %s(%d) : Primitive (%d)\n",
DECODE_LSD_EVENT(sta->t.usta.alarm.event),
+ sta->t.usta.alarm.event,
DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
+ sta->t.usta.alarm.cause,
sta->t.usta.evntParm[0]);
break;
/**********************************************************************/
@@ -362,22 +366,23 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
/* find the name for the sap in question */
x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta->hdr.elmId.elmntInst1) {
+ while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == sta->hdr.elmId.elmntInst1) {
break;
}
x++;
}
- if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->hdr.elmId.elmntInst1);
} else {
- sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
+ sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp3Link[x].name);
}
switch (sta->t.usta.alarm.event) {
/**********************************************************************/
case (LSN_EVENT_INV_OPC_OTHER_END):
+
ftdm_log(FTDM_LOG_ERROR,"[MTP3]%s %s : %s : OPC(0x%X%X%X%X)\n",
buf,
DECODE_LSN_EVENT(sta->t.usta.alarm.event),
@@ -460,7 +465,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
break;
/**********************************************************************/
default:
- ftdm_log(FTDM_LOG_ERROR,"[MTP3][DPC:0x%d%d%d%d] %s : %s\n",
+ ftdm_log(FTDM_LOG_ERROR,"[MTP3][DPC:0x%X%X%X%X] %s : %s\n",
sta->t.usta.evntParm[0],
sta->t.usta.evntParm[1],
sta->t.usta.evntParm[2],
@@ -744,7 +749,63 @@ void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta)
return;
} /* handle_cc_alarm */
+
/******************************************************************************/
+void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)
+{
+
+
+ switch (sta->hdr.elmId.elmnt) {
+ /**************************************************************************/
+ case (LRY_USTA_ERR): /* ERROR */
+ ftdm_log(FTDM_LOG_ERROR,"[RELAY] Error: tx procId %d: err procId %d: channel %d: seq %s: reason %s\n",
+ sta->t.usta.s.ryErrUsta.sendPid,
+ sta->t.usta.s.ryErrUsta.errPid,
+ sta->t.usta.s.ryErrUsta.id,
+ DECODE_LRY_SEQ(sta->t.usta.s.ryErrUsta.sequence),
+ DECODE_LRY_REASON(sta->t.usta.s.ryErrUsta.reason));
+
+ /* process the event */
+ handle_relay_disconnect_on_error(sta);
+
+ break;
+ /**************************************************************************/
+ case (LRY_USTA_CNG): /* Congestion */
+ ftdm_log(FTDM_LOG_ERROR,"[RELAY] Congestion: tx procId %d: rem procId %d: channel %d: %s\n",
+ sta->t.usta.s.ryCongUsta.sendPid,
+ sta->t.usta.s.ryCongUsta.remPid,
+ sta->t.usta.s.ryCongUsta.id,
+ DECODE_LRY_CONG_FLAGS(sta->t.usta.s.ryCongUsta.flags));
+ break;
+ /**************************************************************************/
+ case (LRY_USTA_UP): /* channel up */
+ ftdm_log(FTDM_LOG_ERROR,"[RELAY] Channel UP: tx procId %d: channel %d\n",
+ sta->t.usta.s.ryUpUsta.sendPid,
+ sta->t.usta.s.ryUpUsta.id);
+
+ /* process the event */
+ handle_relay_connect(sta);
+
+ break;
+ /**************************************************************************/
+ case (LRY_USTA_DN): /* channel down */
+ ftdm_log(FTDM_LOG_ERROR,"[RELAY] Channel DOWN: tx procId %d: channel %d\n",
+ sta->t.usta.s.ryUpUsta.sendPid,
+ sta->t.usta.s.ryUpUsta.id);
+
+ /* process the event */
+ handle_relay_disconnect_on_down(sta);
+
+ break;
+ /**************************************************************************/
+ default:
+ ftdm_log(FTDM_LOG_ERROR,"Unknown Relay Alram\n");
+ break;
+ /**************************************************************************/
+ } /* switch (sta->hdr.elmId.elmnt) */
+
+ return;
+}
/******************************************************************************/
/* For Emacs:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
index 9016771671..48579ada85 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
@@ -273,6 +273,7 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
ftdm_interrupt_t *ftdm_sangoma_ss7_int[2];
ftdm_span_t *ftdmspan = (ftdm_span_t *) obj;
ftdm_channel_t *ftdmchan = NULL;
+ ftdm_event_t *event = NULL;
sngss7_event_data_t *sngss7_event = NULL;
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->signal_data;
@@ -363,6 +364,22 @@ 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);
+
+ /* Poll for events, e.g HW DTMF */
+ switch (ftdm_span_poll_event(ftdmspan, 0, NULL)) {
+ /**********************************************************************/
+ case FTDM_SUCCESS:
+ while (ftdm_span_next_event(ftdmspan, &event) == FTDM_SUCCESS);
+ break;
+ /**********************************************************************/
+ case FTDM_TIMEOUT:
+ /* No events pending */
+ break;
+ /**********************************************************************/
+ default:
+ SS7_ERROR("%s:Failed to poll span event\n", ftdmspan->name);
+ /**********************************************************************/
+ } /* switch (ftdm_span_poll_event(span, 0)) */
} /* master while loop */
/* clear the IN_THREAD flag so that we know the thread is done */
@@ -495,8 +512,6 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/**************************************************************************/
case FTDM_CHANNEL_STATE_COLLECT: /* IAM received but wating on digits */
- isup_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
-
if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) {
SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n");
break;
@@ -516,8 +531,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/*now go to the RING state */
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RING);
- } else if (i >= isup_intf->min_digits) {
- SS7_DEBUG_CHAN(ftdmchan, "Received %d digits (min digits = %d)\n", i, isup_intf->min_digits);
+ } 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);
@@ -527,7 +542,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
if (ftdmchan->last_state != FTDM_CHANNEL_STATE_IDLE) {
SS7_INFO_CHAN(ftdmchan,"Received %d out of %d so far: %s...starting T35\n",
i,
- isup_intf->min_digits,
+ sngss7_info->circuit->min_digits,
ftdmchan->caller_data.dnis.digits);
/* start ISUP t35 */
@@ -543,7 +558,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
ftdmchan->caller_data.hangup_cause = 41;
/* set the flag to indicate this hangup is started from the local side */
- sngss7_set_flag (sngss7_info, FLAG_LOCAL_REL);
+ sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL);
/* end the call */
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
@@ -673,7 +688,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
/* set the flag to indicate this hangup is started from the remote side */
- sngss7_set_flag (sngss7_info, FLAG_REMOTE_REL);
+ 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;
@@ -689,15 +704,15 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
/* check for remote hangup flag */
- if (sngss7_test_flag (sngss7_info, FLAG_REMOTE_REL)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) {
/* remote release ...do nothing here */
SS7_DEBUG_CHAN(ftdmchan,"Hanging up remotely requested call!%s\n", "");
- } else if (sngss7_test_flag (sngss7_info, FLAG_GLARE)) {
+ } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_GLARE)) {
/* release due to glare */
SS7_DEBUG_CHAN(ftdmchan,"Hanging up requested call do to glare%s\n", "");
} else {
/* set the flag to indicate this hangup is started from the local side */
- sngss7_set_flag (sngss7_info, FLAG_LOCAL_REL);
+ sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL);
/*this state is set when FS is hanging up...so tell the stack */
ft_to_sngss7_rel (ftdmchan);
@@ -718,16 +733,16 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
break;
}
- if (sngss7_test_flag (sngss7_info, FLAG_REMOTE_REL)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) {
/* check if this hangup is from a tx RSC */
- if (sngss7_test_flag (sngss7_info, FLAG_RESET_TX)) {
+ 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);
} else {
/* if the hangup is from a rx RSC, rx GRS, or glare don't sent RLC */
- if (!(sngss7_test_flag(sngss7_info, FLAG_RESET_RX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_GLARE))) {
+ if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) &&
+ !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) &&
+ !(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) {
/* send out the release complete */
ft_to_sngss7_rlc (ftdmchan);
@@ -738,17 +753,17 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
SS7_DEBUG_CHAN(ftdmchan,"Completing remotely requested hangup!%s\n", "");
- } else if (sngss7_test_flag (sngss7_info, FLAG_LOCAL_REL)) {
+ } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_LOCAL_REL)) {
/* if this hang up is do to a rx RESET we need to sit here till the RSP arrives */
- if (sngss7_test_flag (sngss7_info, FLAG_RESET_TX_RSP)) {
+ 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);
}
/* 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_flag (sngss7_info, FLAG_GLARE)) {
+ } 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);
@@ -767,18 +782,18 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
/* check if there is a reset response that needs to be sent */
- if (sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) {
/* send a RSC-RLC */
ft_to_sngss7_rsca (ftdmchan);
/* clear the reset flag */
clear_rx_rsc_flags(sngss7_info);
- } /* if (sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) */
+ } /* if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) */
/* check if there was a GRS that needs a GRA */
- if ((sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX)) &&
- (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) &&
- (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT))) {
+ if ((sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) &&
+ (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) &&
+ (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT))) {
/* check if this is the base circuit and send out the GRA
* we insure that this is the last circuit to have the state change queued
@@ -794,40 +809,40 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* clear the grp reset flag */
clear_rx_grs_flags(sngss7_info);
- }/* if ( sngss7_test_flag ( sngss7_info, FLAG_GRP_RESET_RX ) ) */
+ }/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_RX ) ) */
/* check if we got the reset response */
- if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX_RSP)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP)) {
/* clear the reset flag */
clear_tx_rsc_flags(sngss7_info);
- } /* if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX_RSP)) */
+ } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP)) */
- if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {
/* clear the reset flag */
clear_tx_grs_flags(sngss7_info);
/* clean out the spans GRA structure */
clear_rx_gra_data(sngss7_info);
- } /* if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) */
+ } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) */
/* check if we came from reset (aka we just processed a reset) */
if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) ||
(ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED)) {
/* check if reset flags are up indicating there is more processing to do yet */
- if (!(sngss7_test_flag (sngss7_info, FLAG_RESET_TX)) &&
- !(sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) &&
- !(sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
- !(sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX))) {
+ 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))) {
/* now check if there is an active block */
- if (!(sngss7_test_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {
+ 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))) {
/* check if the sig status is down, and bring it up if it isn't */
if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
@@ -839,7 +854,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
} /* if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) */
} /* if !blocked */
} else {
- SS7_DEBUG_CHAN(ftdmchan,"Reset flags present (0x%X)\n", sngss7_info->flags);
+ 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);
@@ -858,8 +873,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
sngss7_info->spId = 0;
/* clear any call related flags */
- sngss7_clear_flag (sngss7_info, FLAG_REMOTE_REL);
- sngss7_clear_flag (sngss7_info, FLAG_LOCAL_REL);
+ sngss7_clear_ckt_flag (sngss7_info, FLAG_REMOTE_REL);
+ sngss7_clear_ckt_flag (sngss7_info, FLAG_LOCAL_REL);
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) {
@@ -869,10 +884,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
} /* if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) */
/* check if there is a glared call that needs to be processed */
- if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) {
/* clear the glare flag */
- sngss7_clear_flag (sngss7_info, FLAG_GLARE);
+ sngss7_clear_ckt_flag (sngss7_info, FLAG_GLARE);
/* check if we have an IAM stored...if we don't have one just exit */
if (sngss7_info->glare.circuit != 0) {
@@ -885,23 +900,23 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* clear the glare info */
memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t));
} /* if (sngss7_info->glare.circuit != 0) */
- } /* if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) */
+ } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) */
break;
/**************************************************************************/
case FTDM_CHANNEL_STATE_RESTART: /* CICs needs a Reset */
- if (sngss7_test_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK)) {
- if ((sngss7_test_flag(sngss7_info, FLAG_RESET_RX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX))) {
+ if (sngss7_test_ckt_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_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
/* clear the block flag */
- sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
/* process the flag */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -915,28 +930,28 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
* 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_flag(sngss7_info, FLAG_INFID_PAUSED))) {
+ (!sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED))) {
/* check if this is an outgoing RSC */
- if ((sngss7_test_flag(sngss7_info, FLAG_RESET_TX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_RESET_SENT))) {
+ 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_flag(sngss7_info, FLAG_RESET_SENT);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);
- } /* if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX)) */
+ } /* 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_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
- !(sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &&
- (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {
+ 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))) {
/* send out the grs */
ft_to_sngss7_grs (ftdmchan);
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_SENT);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
- }/* if ( sngss7_test_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
+ }/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
} /* if ( last_state != HANGUP && !PAUSED */
/* if the sig_status is up...bring it down */
@@ -946,10 +961,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
ftdm_span_send_signal (ftdmchan->span, &sigev);
}
- if (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX)) {
/* set the grp reset done flag so we know we have finished this reset */
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);
- } /* if (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX)) */
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);
+ } /* if (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX)) */
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_INUSE)) {
@@ -987,17 +1002,17 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
} /* switch (ftdmchan->last_state) */
} else {
/* check if this an incoming RSC or we have a response already */
- if (sngss7_test_flag (sngss7_info, FLAG_RESET_RX) ||
- sngss7_test_flag (sngss7_info, FLAG_RESET_TX_RSP) ||
- sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX_RSP) ||
- sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX_CMPLT)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX) ||
+ sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX_RSP) ||
+ sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX_RSP) ||
+ sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX_CMPLT)) {
- SS7_DEBUG_CHAN(ftdmchan, "Reset processed moving to DOWN (0x%X)\n", sngss7_info->flags);
+ 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);
} else {
- SS7_DEBUG_CHAN(ftdmchan, "Waiting on Reset Rsp/Grp Reset to move to DOWN (0x%X)\n", sngss7_info->flags);
+ SS7_DEBUG_CHAN(ftdmchan, "Waiting on Reset Rsp/Grp Reset to move to DOWN (0x%X)\n", sngss7_info->ckt_flags);
}
}
@@ -1005,20 +1020,20 @@ 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->flags);
+ SS7_DEBUG_CHAN(ftdmchan,"Current flags: 0x%X\n", sngss7_info->ckt_flags);
/**********************************************************************/
- if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing RESUME%s\n", "");
/* clear the RESUME flag */
- sngss7_clear_flag(sngss7_info, FLAG_INFID_RESUME);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
/* if there are any resets present */
- if ((sngss7_test_flag (sngss7_info, FLAG_RESET_TX)) ||
- (sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) ||
- (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX)) ||
- (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX))) {
+ 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 */
goto suspend_goto_restart;
@@ -1034,7 +1049,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
} /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */
- if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE%s\n", "");
/* bring the sig status down */
@@ -1044,9 +1059,9 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* go back to the last state */
goto suspend_goto_last;
- } /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) { */
+ } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { */
/**********************************************************************/
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_RX flag %s\n", "");
/* bring the sig status down */
@@ -1061,11 +1076,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_RX flag %s\n", "");
/* clear the unblock flag */
- sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
+ sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
/* bring the sig status up */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
@@ -1080,7 +1095,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
/**********************************************************************/
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_TX flag %s\n", "");
/* bring the sig status down */
@@ -1095,11 +1110,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)){
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)){
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_TX flag %s\n", "");
/* clear the unblock flag */
- sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX);
+ sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX);
/* bring the sig status up */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
@@ -1114,7 +1129,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
/**********************************************************************/
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_BLOCK_RX flag %s\n", "");
/* send a BLA */
@@ -1124,11 +1139,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_UNBLK_RX flag %s\n", "");
/* clear the unblock flag */
- sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
+ sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
/* send a uba */
/*ft_to_sngss7_uba(ftdmchan);*/
@@ -1137,7 +1152,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
/**********************************************************************/
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_BLOCK flag %s\n", "");
/* bring the channel signaling status to down */
@@ -1157,17 +1172,17 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
goto suspend_goto_last;
}
- if (sngss7_test_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {
+ if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", "");;
/* remove the UCIC block flag */
- sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
/* remove the UCIC unblock flag */
- sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
/* throw the channel into reset to sync states */
- sngss7_set_flag(sngss7_info, FLAG_RESET_TX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
/* bring the channel into restart again */
goto suspend_goto_restart;
@@ -1232,9 +1247,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
}
/* check if there is a remote block */
- if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {
+ 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))) {
/* the channel is blocked...can't send any calls here */
SS7_ERROR_CHAN(ftdmchan, "Requested channel is remotely blocked, re-hunt channel!%s\n", " ");
@@ -1242,9 +1257,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
}
/* check if there is a local block */
- if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {
+ 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))) {
/* KONRAD FIX ME : we should check if this is a TEST call and allow it */
@@ -1339,48 +1354,6 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
SS7_INFO ("Starting span %s:%u.\n", span->name, span->span_id);
- /* throw the channels in pause */
- for (x = 1; x < (span->chan_count + 1); x++) {
- /* extract the channel structure and sngss7 channel data */
- ftdmchan = span->channels[x];
- if (ftdmchan->call_data == NULL) continue;
- sngss7_info = ftdmchan->call_data;
- sngss7_span = ftdmchan->span->signal_data;
- sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
-
-
- /* lock the channel */
- ftdm_mutex_lock(ftdmchan->mutex);
-
- /* check if the interface is paused or resumed */
- if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
- /* throw the pause flag */
- sngss7_clear_flag(sngss7_info, FLAG_INFID_RESUME);
- sngss7_set_flag(sngss7_info, FLAG_INFID_PAUSED);
- } else {
- /* throw the pause flag */
- sngss7_clear_flag(sngss7_info, FLAG_INFID_PAUSED);
- sngss7_set_flag(sngss7_info, FLAG_INFID_RESUME);
- }
-#if 0
- /* throw the grp reset flag */
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);
- if (x == 1) {
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_BASE);
- sngss7_span->tx_grs.circuit = sngss7_info->circuit->id;
- sngss7_span->tx_grs.range = span->chan_count -1;
- }
-#else
- /* throw the channel into reset */
- sngss7_set_flag(sngss7_info, FLAG_RESET_TX);
-#endif
- /* throw the channel to suspend */
- ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
-
- /* unlock the channel */
- ftdm_mutex_unlock(ftdmchan->mutex);
- }
-
/* clear the monitor thread stop flag */
ftdm_clear_flag (span, FTDM_SPAN_STOP_THREAD);
ftdm_clear_flag (span, FTDM_SPAN_IN_THREAD);
@@ -1397,6 +1370,52 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
return FTDM_FAIL;
}
+ /* confirm the state of all isup interfaces*/
+ check_status_of_all_isup_intf();
+
+ /* throw the channels in pause */
+ for (x = 1; x < (span->chan_count + 1); x++) {
+ /* extract the channel structure and sngss7 channel data */
+ ftdmchan = span->channels[x];
+ if (ftdmchan->call_data == NULL) continue;
+ sngss7_info = ftdmchan->call_data;
+ sngss7_span = ftdmchan->span->signal_data;
+ sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
+
+ /* lock the channel */
+ ftdm_mutex_lock(ftdmchan->mutex);
+
+ /* 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);
+ }
+#if 0
+ /* throw the grp reset flag */
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);
+ if (x == 1) {
+ sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_BASE);
+ sngss7_span->tx_grs.circuit = sngss7_info->circuit->id;
+ sngss7_span->tx_grs.range = span->chan_count -1;
+ }
+#else
+ /* throw the channel into reset */
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);
+#endif
+ /* throw the channel to suspend */
+ ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
+
+ /* unlock the channel */
+ ftdm_mutex_unlock(ftdmchan->mutex);
+ }
+
SS7_DEBUG ("Finished starting span %s:%u.\n", span->name, span->span_id);
return FTDM_SUCCESS;
@@ -1537,7 +1556,6 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init)
sng_event.cc.sng_umsg_ind = sngss7_umsg_ind;
sng_event.cc.sng_susp_ind = sngss7_susp_ind;
sng_event.cc.sng_resm_ind = sngss7_resm_ind;
- sng_event.cc.sng_ssp_sta_cfm = sngss7_ssp_sta_cfm;
sng_event.sm.sng_log = handle_sng_log;
sng_event.sm.sng_mtp1_alarm = handle_sng_mtp1_alarm;
@@ -1545,9 +1563,10 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init)
sng_event.sm.sng_mtp3_alarm = handle_sng_mtp3_alarm;
sng_event.sm.sng_isup_alarm = handle_sng_isup_alarm;
sng_event.sm.sng_cc_alarm = handle_sng_cc_alarm;
+ sng_event.sm.sng_relay_alarm = handle_sng_relay_alarm;
/* initalize sng_ss7 library */
- sng_isup_init (&sng_event);
+ sng_isup_init_gen(&sng_event);
/* print the version of the library being used */
sng_isup_version(&major, &minor, &build);
@@ -1566,7 +1585,41 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
ftdm_log (FTDM_LOG_INFO, "Starting ftmod_sangoma_ss7 unload...\n");
- sng_isup_free();
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {
+ sng_isup_free_cc();
+ sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC);
+ }
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {
+ ftmod_ss7_shutdown_isup();
+ sng_isup_free_isup();
+ sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP);
+ }
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) {
+ ftmod_ss7_shutdown_mtp3();
+ sng_isup_free_mtp3();
+ sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3);
+ }
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) {
+ ftmod_ss7_shutdown_mtp2();
+ sng_isup_free_mtp2();
+ sng_isup_free_mtp1();
+ sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2);
+ }
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) {
+ ftmod_ss7_shutdown_relay();
+ sng_isup_free_relay();
+ sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY);
+ }
+
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM)) {
+ sng_isup_free_sm();
+ }
+
+ sng_isup_free_gen();
ftdm_log (FTDM_LOG_INFO, "Finished ftmod_sangoma_ss7 unload!\n");
return FTDM_SUCCESS;
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
index f28547f9fe..05c63518ec 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
@@ -83,10 +83,9 @@ typedef enum {
} sng_ckt_type_t;
typedef enum {
- CONFIGURED = (1 << 0),
- ACTIVE = (1 << 1),
- SNGSS7_PAUSED = (1 << 7)
-} sng_flag_t;
+ SNG_RTE_UP = 0,
+ SNG_RTE_DN
+} sng_route_direction_t;
typedef enum {
SNGSS7_LPA_FOR_COT = (1 << 0), /* send LPA when COT arrives */
@@ -98,84 +97,124 @@ typedef enum {
SNG_CALLING = 2
} sng_addr_type_t;
-typedef struct sng_mtp_link {
- char name[MAX_NAME_LEN];
- uint32_t id;
- uint32_t flags;
- struct {
- uint32_t span;
- uint32_t chan;
- } mtp1;
- struct {
- uint32_t lssuLength;
- uint32_t errorType;
- uint32_t linkType;
- uint32_t mtp1Id;
- uint32_t t1;
- uint32_t t2;
- uint32_t t3;
- uint32_t t4n;
- uint32_t t4e;
- uint32_t t5;
- uint32_t t6;
- uint32_t t7;
- } mtp2;
- struct {
- uint32_t priority;
- uint32_t linkType;
- uint32_t switchType;
- uint32_t apc;
- uint32_t spc;
- uint32_t ssf;
- uint32_t slc;
- uint32_t linkSetId;
- uint32_t mtp2Id;
- uint32_t t1;
- uint32_t t2;
- uint32_t t3;
- uint32_t t4;
- uint32_t t5;
- uint32_t t6;
- uint32_t t7;
- uint32_t t8;
- uint32_t t9;
- uint32_t t10;
- uint32_t t11;
- uint32_t t12;
- uint32_t t13;
- uint32_t t14;
- uint32_t t15;
- uint32_t t16;
- uint32_t t17;
- uint32_t t18;
- uint32_t t19;
- uint32_t t20;
- uint32_t t21;
- uint32_t t22;
- uint32_t t23;
- uint32_t t24;
- uint32_t t25;
- uint32_t t27;
- uint32_t t28;
- uint32_t t29;
- uint32_t t30;
- uint32_t t31;
- uint32_t t32;
- uint32_t t33;
- uint32_t t34;
- uint32_t t35;
- uint32_t t36;
- uint32_t t37;
- uint32_t tcraft;
- uint32_t tflc;
- uint32_t tbnd;
- } mtp3;
-} sng_mtp_link_t;
+typedef struct sng_mtp2_error_type {
+ int init;
+ char sng_type[MAX_NAME_LEN];
+ uint32_t tril_type;
+} sng_mtp2_error_type_t;
+
+typedef struct sng_link_type {
+ int init;
+ char sng_type[MAX_NAME_LEN];
+ uint32_t tril_mtp2_type;
+ uint32_t tril_mtp3_type;
+} sng_link_type_t;
+
+typedef struct sng_switch_type {
+ int init;
+ char sng_type[MAX_NAME_LEN];
+ uint32_t tril_mtp3_type;
+ uint32_t tril_isup_type;
+} sng_switch_type_t;
+
+typedef struct sng_ssf_type {
+ int init;
+ char sng_type[MAX_NAME_LEN];
+ uint32_t tril_type;
+} sng_ssf_type_t;
+
+typedef struct sng_cic_cntrl_type {
+ int init;
+ char sng_type[MAX_NAME_LEN];
+ uint32_t tril_type;
+} sng_cic_cntrl_type_t;
+
+typedef struct sng_mtp1_link {
+ char name[MAX_NAME_LEN];
+ uint32_t flags;
+ uint32_t id;
+ uint32_t span;
+ uint32_t chan;
+} sng_mtp1_link_t;
+
+typedef struct sng_mtp2_link {
+ char name[MAX_NAME_LEN];
+ uint32_t flags;
+ uint32_t id;
+ uint32_t lssuLength;
+ uint32_t errorType;
+ uint32_t linkType;
+ uint32_t mtp1Id;
+ uint32_t mtp1ProcId;
+ uint32_t t1;
+ uint32_t t2;
+ uint32_t t3;
+ uint32_t t4n;
+ uint32_t t4e;
+ uint32_t t5;
+ uint32_t t6;
+ uint32_t t7;
+} sng_mtp2_link_t;
+
+typedef struct sng_mtp3_link {
+ char name[MAX_NAME_LEN];
+ uint32_t flags;
+ uint32_t id;
+ uint32_t priority;
+ uint32_t linkType;
+ uint32_t switchType;
+ uint32_t apc;
+ uint32_t spc;
+ uint32_t ssf;
+ uint32_t slc;
+ uint32_t linkSetId;
+ uint32_t mtp2Id;
+ uint32_t mtp2ProcId;
+ uint32_t t1;
+ uint32_t t2;
+ uint32_t t3;
+ uint32_t t4;
+ uint32_t t5;
+ uint32_t t6;
+ uint32_t t7;
+ uint32_t t8;
+ uint32_t t9;
+ uint32_t t10;
+ uint32_t t11;
+ uint32_t t12;
+ uint32_t t13;
+ uint32_t t14;
+ uint32_t t15;
+ uint32_t t16;
+ uint32_t t17;
+ uint32_t t18;
+ uint32_t t19;
+ uint32_t t20;
+ uint32_t t21;
+ uint32_t t22;
+ uint32_t t23;
+ uint32_t t24;
+ uint32_t t25;
+ uint32_t t27;
+ uint32_t t28;
+ uint32_t t29;
+ uint32_t t30;
+ uint32_t t31;
+ uint32_t t32;
+ uint32_t t33;
+ uint32_t t34;
+ uint32_t t35;
+ uint32_t t36;
+ uint32_t t37;
+ uint32_t tcraft;
+ uint32_t tflc;
+ uint32_t tbnd;
+} sng_mtp3_link_t;
typedef struct sng_link_set {
- uint32_t id;
char name[MAX_NAME_LEN];
uint32_t flags;
+ uint32_t id;
uint32_t apc;
uint32_t linkType;
uint32_t switchType;
@@ -185,18 +224,24 @@ typedef struct sng_link_set {
uint32_t links[16];
} sng_link_set_t;
+typedef struct sng_link_set_list {
+ uint32_t lsId;
+ struct sng_link_set_list *next;
+} sng_link_set_list_t;
+
typedef struct sng_route {
- uint32_t id;
char name[MAX_NAME_LEN];
uint32_t flags;
+ uint32_t id;
uint32_t dpc;
uint32_t cmbLinkSetId;
- uint32_t linkSetId;
+ struct sng_link_set_list lnkSets;
uint32_t linkType;
uint32_t switchType;
uint32_t ssf;
uint32_t nwId;
uint32_t isSTP;
+ uint32_t dir;
uint32_t t6;
uint32_t t8;
uint32_t t10;
@@ -211,10 +256,10 @@ typedef struct sng_route {
} sng_route_t;
typedef struct sng_isup_intf {
- uint32_t id;
char name[MAX_NAME_LEN];
uint32_t options;
uint32_t flags;
+ uint32_t id;
uint32_t spc;
uint32_t dpc;
uint32_t switchType;
@@ -222,9 +267,6 @@ typedef struct sng_isup_intf {
uint32_t mtpRouteId;
uint32_t ssf;
uint32_t isap;
- uint32_t clg_nadi;
- uint32_t cld_nadi;
- uint32_t min_digits;
uint16_t t4;
uint32_t t10;
uint32_t t11;
@@ -241,7 +283,6 @@ typedef struct sng_isup_intf {
uint32_t t29;
uint32_t t30;
uint32_t t32;
- uint32_t t35;
uint32_t t37;
uint32_t t38;
uint32_t t39;
@@ -251,15 +292,23 @@ typedef struct sng_isup_intf {
} sng_isup_inf_t;
typedef struct sng_isup_ckt {
- uint32_t id;
+ uint32_t options;
uint32_t flags;
+ uint32_t ckt_flags;
+ uint32_t procId;
+ uint32_t id;
+ uint32_t ccSpanId;
uint32_t span;
uint32_t chan;
uint32_t type; /* VOICE/SIG/HOLE */
uint32_t cic;
uint32_t infId;
- uint32_t ssf;
uint32_t typeCntrl;
+ uint32_t ssf;
+ uint32_t switchType;
+ uint32_t clg_nadi;
+ uint32_t cld_nadi;
+ uint32_t min_digits;
void *obj;
uint16_t t3;
uint16_t t12;
@@ -268,12 +317,13 @@ typedef struct sng_isup_ckt {
uint16_t t15;
uint16_t t16;
uint16_t t17;
+ uint32_t t35;
uint16_t tval;
} sng_isup_ckt_t;
typedef struct sng_nsap {
- uint32_t id;
uint32_t flags;
+ uint32_t id;
uint32_t suId;
uint32_t spId;
uint32_t nwId;
@@ -311,15 +361,30 @@ typedef struct sng_isap {
uint32_t tfnlrelrsp;
} sng_isap_t;
+typedef struct sng_relay {
+ uint32_t id;
+ char name[MAX_NAME_LEN];
+ uint32_t flags;
+ uint32_t type;
+ uint32_t port;
+ char hostname[RY_REMHOSTNAME_SIZE];
+ uint32_t procId;
+} sng_relay_t;
+
typedef struct sng_ss7_cfg {
uint32_t spc;
+ uint32_t procId;
char license[MAX_PATH];
char signature[MAX_PATH];
- sng_mtp_link_t mtpLink[MAX_MTP_LINKS+1];
+ uint32_t flags;
+ sng_relay_t relay[MAX_RELAY_CHANNELS+1];
+ sng_mtp1_link_t mtp1Link[MAX_MTP_LINKS+1];
+ sng_mtp2_link_t mtp2Link[MAX_MTP_LINKS+1];
+ sng_mtp3_link_t mtp3Link[MAX_MTP_LINKS+1];
sng_link_set_t mtpLinkSet[MAX_MTP_LINKSETS+1];
sng_route_t mtpRoute[MAX_MTP_ROUTES+1];
sng_isup_inf_t isupIntf[MAX_ISUP_INFS+1];
- sng_isup_ckt_t isupCkt[MAX_ISUP_CKTS+1];
+ sng_isup_ckt_t isupCkt[10000]; /* KONRAD - only need 2000 ( and 0-1000 aren't used) since other servers are registerd else where */
sng_nsap_t nsap[MAX_NSAPS+1];
sng_isap_t isap[MAX_ISAPS+1];
}sng_ss7_cfg_t;
@@ -365,7 +430,7 @@ typedef struct sngss7_chan_data {
uint32_t spInstId;
uint32_t spId;
uint8_t globalFlg;
- uint32_t flags;
+ uint32_t ckt_flags;
sngss7_glare_data_t glare;
sngss7_timer_data_t t35;
}sngss7_chan_data_t;
@@ -407,8 +472,6 @@ typedef struct sngss7_event_data
} sngss7_event_data_t;
-
-
typedef enum {
FLAG_RESET_RX = (1 << 0),
FLAG_RESET_TX = (1 << 1),
@@ -439,15 +502,39 @@ typedef enum {
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_t;
+ FLAG_GRP_MN_UNBLK_TX = (1 << 29),
+ FLAG_RELAY_DOWN = (1 << 30)
+} sng_ckt_flag_t;
+
+/* valid for every cfg array except circuits */
+typedef enum {
+ SNGSS7_CONFIGURED = (1 << 0),
+ SNGSS7_ACTIVE = (1 << 1),
+ SNGSS7_RELAY_INIT = (1 << 3),
+ SNGSS7_PAUSED = (1 << 7) /* for isup interfaces */
+} sng_cfg_flag_t;
+
+typedef enum {
+ SNGSS7_SM = (1 << 0),
+ SNGSS7_RY = (1 << 1),
+ SNGSS7_MTP1 = (1 << 2),
+ SNGSS7_MTP2 = (1 << 3),
+ SNGSS7_MTP3 = (1 << 4),
+ SNGSS7_ISUP = (1 << 5),
+ SNGSS7_CC = (1 << 6)
+} sng_task_flag_t;
/******************************************************************************/
/* GLOBALS ********************************************************************/
-extern ftdm_sngss7_data_t g_ftdm_sngss7_data;
-extern uint32_t sngss7_id;
-extern ftdm_sched_t *sngss7_sched;
-extern int cmbLinkSetId;
+extern ftdm_sngss7_data_t g_ftdm_sngss7_data;
+extern sng_ssf_type_t sng_ssf_type_map[];
+extern sng_switch_type_t sng_switch_type_map[];
+extern sng_link_type_t sng_link_type_map[];
+extern sng_mtp2_error_type_t sng_mtp2_error_type_map[];
+extern sng_cic_cntrl_type_t sng_cic_cntrl_type_map[];
+extern uint32_t sngss7_id;
+extern ftdm_sched_t *sngss7_sched;
+extern int cmbLinkSetId;
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
@@ -461,6 +548,12 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);
void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta);
void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta);
void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta);
+void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta);
+
+/* in ftmod_sangoma_ss7_relay.c */
+ftdm_status_t handle_relay_connect(RyMngmt *sta);
+ftdm_status_t handle_relay_disconnect_on_down(RyMngmt *sta);
+ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta);
/* in ftmod_sangoma_ss7_cfg.c */
int ft_to_sngss7_cfg_all(void);
@@ -484,20 +577,36 @@ int ftmod_ss7_cc_isap_config(int id);
/* in ftmod_sangoma_ss7_cntrl.c */
int ft_to_sngss7_activate_all(void);
-int ftmod_ss7_inhibit_mtplink(uint32_t id);
-int ftmod_ss7_uninhibit_mtplink(uint32_t id);
-int ftmod_ss7_activate_mtplink(uint32_t id);
-int ftmod_ss7_deactivate_mtplink(uint32_t id);
-int ftmod_ss7_deactivate2_mtplink(uint32_t id);
+int ftmod_ss7_inhibit_mtp3link(uint32_t id);
+int ftmod_ss7_uninhibit_mtp3link(uint32_t id);
+int ftmod_ss7_bind_mtp3link(uint32_t id);
+int ftmod_ss7_unbind_mtp3link(uint32_t id);
+int ftmod_ss7_activate_mtp3link(uint32_t id);
+int ftmod_ss7_deactivate_mtp3link(uint32_t id);
+int ftmod_ss7_deactivate2_mtp3link(uint32_t id);
int ftmod_ss7_activate_mtplinkSet(uint32_t id);
int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
-int ftmod_ss7_lpo_mtplink(uint32_t id);
-int ftmod_ss7_lpr_mtplink(uint32_t id);
+int ftmod_ss7_lpo_mtp3link(uint32_t id);
+int ftmod_ss7_lpr_mtp3link(uint32_t id);
+
+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_grp_mtp3Link(uint32_t procId);
+int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
+
+int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
/* in ftmod_sangoma_ss7_sta.c */
-int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm);
+int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm);
+int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm);
+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);
/* in ftmod_sangoma_ss7_out.c */
@@ -607,6 +716,14 @@ ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info);
ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type);
ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type);
+int find_mtp2_error_type_in_map(const char *err_type);
+int find_link_type_in_map(const char *linkType);
+int find_switch_type_in_map(const char *switchType);
+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);
+
/* in ftmod_sangoma_ss7_timers.c */
void handle_isup_t35(void *userdata);
/******************************************************************************/
@@ -739,6 +856,10 @@ void handle_isup_t35(void *userdata);
#define sngss7_clear_flag(obj, flag) ((obj)->flags &= ~(flag))
#define sngss7_set_flag(obj, flag) ((obj)->flags |= (flag))
+#define sngss7_test_ckt_flag(obj, flag) ((obj)->ckt_flags & flag)
+#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_options(obj, option) ((obj)->options & option)
#define sngss7_clear_options(obj, option) ((obj)->options &= ~(option))
#define sngss7_set_options(obj, option) ((obj)->options |= (option))
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c
index ec8d7df12a..918b284de1 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c
@@ -125,9 +125,9 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
iam.txMedReq.trMedReq.pres = PRSNT_NODEF;
iam.txMedReq.trMedReq.val = ftdmchan->caller_data.bearer_capability;
- if ((g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].switchType == LSI_SW_ANS88) ||
- (g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].switchType == LSI_SW_ANS92) ||
- (g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].switchType == LSI_SW_ANS95)) {
+ if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) ||
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) ||
+ (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) {
/* include only if we're running ANSI */
iam.fwdCallInd.transCallNInd.pres = PRSNT_NODEF;
@@ -178,7 +178,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
iam.usrServInfoA.rateMultiplier.pres = PRSNT_NODEF;
iam.usrServInfoA.rateMultiplier.val = 0x1; /* 1x rate multipler */
} /* if ANSI */
-
+
/* copy down the called number information */
copy_cdPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cdPtyNum);
@@ -192,7 +192,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling NADI value \"%s\"\n", clg_nadi);
iam.cgPtyNum.natAddrInd.val = atoi(clg_nadi);
} else {
- iam.cgPtyNum.natAddrInd.val = g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].clg_nadi;
+ iam.cgPtyNum.natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].clg_nadi;
SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLG, using \"%d\"\n", iam.cgPtyNum.natAddrInd.val);
}
@@ -201,7 +201,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called NADI value \"%s\"\n", cld_nadi);
iam.cdPtyNum.natAddrInd.val = atoi(cld_nadi);
} else {
- iam.cdPtyNum.natAddrInd.val = g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].cld_nadi;
+ iam.cdPtyNum.natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cld_nadi;
SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLD, using \"%d\"\n", iam.cdPtyNum.natAddrInd.val);
}
@@ -299,7 +299,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
ftdmchan->caller_data.dnis.digits,
iam.cdPtyNum.natAddrInd.val);
- ftdm_call_clear_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -310,7 +310,6 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
- sng_isup_inf_t *isup_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
SiCnStEvnt acm;
memset (&acm, 0x0, sizeof (acm));
@@ -360,8 +359,8 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
acm.bckCallInd.sccpMethInd.val = SCCPMTH_NOIND;
/* fill in any optional parameters */
- if (sngss7_test_options(isup_intf, SNGSS7_ACM_OBCI_BITA)) {
- SS7_DEBUG_CHAN(ftdmchan, "Found ACM_OBCI_BITA flag:0x%X\n", isup_intf->options);
+ if (sngss7_test_options(&g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id], SNGSS7_ACM_OBCI_BITA)) {
+ SS7_DEBUG_CHAN(ftdmchan, "Found ACM_OBCI_BITA flag:0x%X\n", g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].options);
acm.optBckCalInd.eh.pres = PRSNT_NODEF;
acm.optBckCalInd.inbndInfoInd.pres = PRSNT_NODEF;
acm.optBckCalInd.inbndInfoInd.val = 0x1;
@@ -380,7 +379,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -404,7 +403,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -439,7 +438,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -462,7 +461,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -483,7 +482,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -504,7 +503,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -525,7 +524,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -546,7 +545,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -568,7 +567,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -589,7 +588,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -610,7 +609,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -655,7 +654,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -689,7 +688,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -738,7 +737,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -788,7 +787,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -839,7 +838,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
@@ -890,7 +889,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_vars(&ftdmchan->caller_data);
+ ftdm_call_clear_data(&ftdmchan->caller_data);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
new file mode 100644
index 0000000000..05ea69ea69
--- /dev/null
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2009|Konrad Hammel
+ * 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 ********************************************************************/
+#include "ftmod_sangoma_ss7_main.h"
+/******************************************************************************/
+
+/* DEFINES ********************************************************************/
+/******************************************************************************/
+
+/* GLOBALS ********************************************************************/
+/******************************************************************************/
+
+/* PROTOTYPES *****************************************************************/
+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 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 disable_all_sigs_for_relay(uint32_t procId);
+static ftdm_status_t disble_all_mtp2_sigs_for_relay(void);
+/******************************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+ftdm_status_t handle_relay_connect(RyMngmt *sta)
+{
+ sng_relay_t *sng_relay = &g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryUpUsta.id];
+
+
+ /* 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);
+
+ /* 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);
+
+ /* react based on type of channel */
+ switch (sng_relay->type) {
+ /******************************************************************/
+ case (LRY_CT_TCP_CLIENT):
+ /* 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);*/
+ ftmod_ss7_enable_grp_mtp3Link(sta->t.usta.s.ryUpUsta.id);
+
+ break;
+ /******************************************************************/
+ default:
+ break;
+ /******************************************************************/
+ } /* switch (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryUpUsta.id].type) */
+ } /* intial up? */
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+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();
+
+ disble_all_mtp2_sigs_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);
+
+ disable_all_sigs_for_relay(sta->t.usta.s.ryErrUsta.errPid);
+ }
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+ftdm_status_t handle_relay_disconnect_on_down(RyMngmt *sta)
+{
+
+ /* check if the channel is a server, means we just lost a MGW */
+ if (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryUpUsta.id].type == LRY_CT_TCP_SERVER) {
+ block_all_ckts_for_relay(sta->t.usta.s.ryUpUsta.id);
+
+ disable_all_sigs_for_relay(sta->t.usta.s.ryUpUsta.id);
+ }
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+ftdm_status_t disable_all_ckts_for_relay(void)
+{
+ sngss7_chan_data_t *sngss7_info = NULL;
+ ftdm_channel_t *ftdmchan = NULL;
+ int x;
+
+ SS7_INFO("Disabling all ckts becuase of Relay loss\n");
+
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
+ while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
+ /**********************************************************************/
+ /* make sure this is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
+
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(g_ftdm_sngss7_data.cfg.isupCkt[x].id, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for circuit = %d!\n", g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ x++;
+ continue;
+ }
+
+ /* throw the relay_down flag */
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RELAY_DOWN);
+
+ /* throw the channel infId status flags to PAUSED ... they will be executed next process cycle */
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);
+ } /* 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;
+}
+
+/******************************************************************************/
+ftdm_status_t enable_all_ckts_for_relay(void)
+{
+ sngss7_chan_data_t *sngss7_info = NULL;
+ sng_isup_inf_t *sngIntf = NULL;
+ ftdm_channel_t *ftdmchan = NULL;
+ int x;
+
+ SS7_INFO("Enabling all ckts becuase of Relay connection\n");
+
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
+ while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
+ /**********************************************************************/
+ /* make sure this is voice channel */
+ if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
+
+ /* get the ftdmchan and ss7_chan_data from the circuit */
+ if (extract_chan_data(g_ftdm_sngss7_data.cfg.isupCkt[x].id, &sngss7_info, &ftdmchan)) {
+ SS7_ERROR("Failed to extract channel data for circuit = %d!\n", g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ x++;
+ continue;
+ }
+
+ /* bring the relay_down flag down */
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_RELAY_DOWN);
+
+ sngIntf = &g_ftdm_sngss7_data.cfg.isupIntf[g_ftdm_sngss7_data.cfg.isupCkt[x].infId];
+
+ /* check if the interface is paused or resumed */
+ if (sngss7_test_flag(sngIntf, SNGSS7_PAUSED)) {
+ /* don't bring the channel resume flag up...the interface is down */
+ SS7_DEBUG_CHAN(ftdmchan, "ISUP interface (%d) set to paused, not resuming channel\n", sngIntf->id);
+ } else {
+ 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);
+ }
+ } /* 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;
+}
+
+/******************************************************************************/
+ftdm_status_t reconfig_all_ckts_for_relay(void)
+{
+#if 1
+ int x;
+ int ret;
+
+ 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);
+ }
+
+ } /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
+
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
+
+ x++;
+ } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
+#endif
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+ftdm_status_t block_all_ckts_for_relay(uint32_t procId)
+{
+ int x;
+
+ SS7_INFO("BLOcking all ckts on ProcID = %d\n", procId);
+
+ /* 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);
+
+ } /* 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;
+}
+
+/******************************************************************************/
+ftdm_status_t disable_all_sigs_for_relay(uint32_t procId)
+{
+ SS7_INFO("Disalbing all sig links on ProcID = %d\n", procId);
+
+ ftmod_ss7_disable_grp_mtp3Link(procId);
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+ftdm_status_t disble_all_mtp2_sigs_for_relay(void)
+{
+ /* check if there is a local mtp2 link*/
+ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) {
+ SS7_INFO("Disalbing all mtp2 sig links on local system\n");
+
+ ftmod_ss7_disable_grp_mtp2Link(1);
+ }
+
+ return FTDM_SUCCESS;
+
+}
+
+/******************************************************************************/
+/* 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:
+ */
+/******************************************************************************/
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c
index 1235238452..2f507a2ad4 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c
@@ -42,12 +42,43 @@
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
-int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm);
+int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm);
+int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm);
+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);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
-int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm)
+int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm)
+{
+
+ return 1;
+}
+
+/******************************************************************************/
+int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm)
+{
+ SdMngmt sta;
+ Pst pst;
+
+ memset(&sta, 0x0, sizeof(sta));
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSD;
+
+ sta.hdr.elmId.elmnt = STDLSAP;
+ sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp2Link[id].id;
+
+ return(sng_sta_mtp2(&pst, &sta, cfm));
+}
+
+/******************************************************************************/
+int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm)
{
SnMngmt sta;
Pst pst;
@@ -60,8 +91,13 @@ int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm)
/* insert the destination Entity */
pst.dstEnt = ENTSN;
+ /* 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;
+ }
+
sta.hdr.elmId.elmnt = STDLSAP;
- sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
+ sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;
return(sng_sta_mtp3(&pst, &sta, cfm));
}
@@ -80,13 +116,77 @@ int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm)
/* insert the destination Entity */
pst.dstEnt = ENTSN;
+ /* 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;
+ }
+
sta.hdr.elmId.elmnt = STLNKSET;
sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
sta.hdr.elmId.elmntInst2 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].links[0];
return(sng_sta_mtp3(&pst, &sta, cfm));
}
+
/******************************************************************************/
+int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status)
+{
+ 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_STINTF;
+
+ sta.t.ssta.elmntId.intfId = id;
+
+ ret = sng_sta_isup(&pst, &sta, &cfm);
+
+ *status = cfm.t.ssta.cfm.s.intf.state;
+
+ return(ret);
+}
+
+/******************************************************************************/
+int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm)
+{
+ RyMngmt sta;
+ Pst pst;
+
+ memset(&sta, 0x0, sizeof(sta));
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTRY;
+
+ sta.hdr.entId.ent = ENTRY;
+ sta.hdr.entId.inst = S_INST;
+ sta.hdr.msgType = TSSTA;
+ sta.hdr.elmId.elmnt = STCHSTA;
+ sta.hdr.elmId.elmntInst1 = id;
+
+
+ return(sng_sta_relay(&pst, &sta, cfm));
+}
/******************************************************************************/
/* For Emacs:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
index 23617c9147..683caf2352 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c
@@ -75,6 +75,14 @@ ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info);
ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type);
ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type);
+
+int find_mtp2_error_type_in_map(const char *err_type);
+int find_link_type_in_map(const char *linkType);
+int find_switch_type_in_map(const char *switchType);
+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);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@@ -432,7 +440,7 @@ int check_cics_in_range(sngss7_chan_data_t *sngss7_info)
}
/* check if the channel still has the reset flag done is up */
- if (!sngss7_test_flag(tmp_sngss7_info, FLAG_GRP_RESET_RX_DN)) {
+ if (!sngss7_test_ckt_flag(tmp_sngss7_info, FLAG_GRP_RESET_RX_DN)) {
SS7_DEBUG_CHAN(tmp_ftdmchan, "[CIC:%d] Still processing reset...\n", tmp_sngss7_info->circuit->cic);
return 0;
}
@@ -475,19 +483,19 @@ ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_in
int check_for_reset(sngss7_chan_data_t *sngss7_info)
{
- if (sngss7_test_flag(sngss7_info,FLAG_RESET_RX)) {
+ if (sngss7_test_ckt_flag(sngss7_info,FLAG_RESET_RX)) {
return 1;
}
- if (sngss7_test_flag(sngss7_info,FLAG_RESET_TX)) {
+ if (sngss7_test_ckt_flag(sngss7_info,FLAG_RESET_TX)) {
return 1;
}
- if (sngss7_test_flag(sngss7_info,FLAG_GRP_RESET_RX)) {
+ if (sngss7_test_ckt_flag(sngss7_info,FLAG_GRP_RESET_RX)) {
return 1;
}
- if (sngss7_test_flag(sngss7_info,FLAG_GRP_RESET_TX)) {
+ if (sngss7_test_ckt_flag(sngss7_info,FLAG_GRP_RESET_TX)) {
return 1;
}
@@ -498,11 +506,13 @@ int check_for_reset(sngss7_chan_data_t *sngss7_info)
/******************************************************************************/
unsigned long get_unique_id(void)
{
+ int procId = sng_get_procId();
- if (sngss7_id < 420000000) {
+ /* id values are between (procId * 1,000,000) and ((procId + 1) * 1,000,000) */
+ if (sngss7_id < ((procId + 1) * 1000000) ) {
sngss7_id++;
} else {
- sngss7_id = 1;
+ sngss7_id = procId * 1000000;
}
return(sngss7_id);
@@ -525,7 +535,7 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
}
/* check if the GRP_RESET_RX flag is already up */
- if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) {
/* we have already processed this channel...move along */
continue;
}
@@ -543,7 +553,7 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
(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_flag(sngss7_info, FLAG_GRP_RESET_RX);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX);
switch (ftdmchan->state) {
/**************************************************************************/
@@ -598,10 +608,10 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
/* check if there is a state change pending on the channel */
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
/* check the state to the GRP_RESET_RX_DN flag */
- if (!sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) {
+ if (!sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) {
/* this channel is still resetting...do nothing */
goto GRS_UNLOCK_ALL;
- } /* if (!sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) */
+ } /* if (!sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) */
} else {
/* state change pending */
goto GRS_UNLOCK_ALL;
@@ -625,16 +635,16 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
}
/* throw the GRP reset flag complete flag */
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);
+ 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);
/* update the status map if the ckt is in blocked state */
- if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) ||
- (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {
+ 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))) {
sngss7_span->rx_grs.status[byte] = (sngss7_span->rx_grs.status[byte] | (1 << bit));
} /* if blocked */
@@ -679,7 +689,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
}
/* check if the channel is already procoessing the GRA */
- if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {
/* move along */
continue;
}
@@ -701,7 +711,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
case FTDM_CHANNEL_STATE_RESTART:
/* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
/* go to DOWN */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
@@ -720,7 +730,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
/* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
- sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
break;
/**********************************************************************/
@@ -775,7 +785,7 @@ ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)
sigev.channel = ftdmchan;
/* if we have the PAUSED flag and the sig status is still UP */
- if ((sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) &&
+ if ((sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) &&
(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP))) {
/* clear up any pending state changes */
@@ -790,7 +800,7 @@ ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)
/* if the RESUME flag is up go to SUSPENDED to process the flag */
/* after doing this the flag will be cleared */
- if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) {
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) {
/* clear up any pending state changes */
while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
@@ -839,7 +849,7 @@ ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan)
}
/* throw the ckt block flag */
- sngss7_set_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
@@ -858,9 +868,9 @@ ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan)
ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info)
{
/* clear all the flags related to an incoming GRS */
- sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_RX);
- sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);
- sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);
return FTDM_SUCCESS;
}
@@ -892,10 +902,10 @@ ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info)
ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info)
{
/* clear all the flags related to an outgoing GRS */
- sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_BASE);
- sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_TX);
- sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_SENT);
- sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
return FTDM_SUCCESS;
}
@@ -918,7 +928,7 @@ ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info)
ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info)
{
/* clear all the flags related to an incoming RSC */
- sngss7_clear_flag(sngss7_info, FLAG_RESET_RX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_RX);
return FTDM_SUCCESS;
}
@@ -927,9 +937,9 @@ ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info)
ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info)
{
/* clear all the flags related to an outgoing RSC */
- sngss7_clear_flag(sngss7_info, FLAG_RESET_TX);
- sngss7_clear_flag(sngss7_info, FLAG_RESET_SENT);
- sngss7_clear_flag(sngss7_info, FLAG_RESET_TX_RSP);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_TX);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_SENT);
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP);
return FTDM_SUCCESS;
}
@@ -1147,6 +1157,197 @@ ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int typ
return FTDM_SUCCESS;
}
+/******************************************************************************/
+int find_mtp2_error_type_in_map(const char *err_type)
+{
+ int i = 0;
+
+ while (sng_mtp2_error_type_map[i].init == 1) {
+ /* check if string matches the sng_type name */
+ if (!strcasecmp(err_type, sng_mtp2_error_type_map[i].sng_type)) {
+ /* we've found a match break from the loop */
+ break;
+ } else {
+ /* move on to the next on */
+ i++;
+ }
+ } /* while (sng_mtp2_error_type_map[i].init == 1) */
+
+ /* check how we exited the loop */
+ if (sng_mtp2_error_type_map[i].init == 0) {
+ return -1;
+ } else {
+ return i;
+ } /* if (sng_mtp2_error_type_map[i].init == 0) */
+}
+
+/******************************************************************************/
+int find_link_type_in_map(const char *linkType)
+{
+ int i = 0;
+
+ while (sng_link_type_map[i].init == 1) {
+ /* check if string matches the sng_type name */
+ if (!strcasecmp(linkType, sng_link_type_map[i].sng_type)) {
+ /* we've found a match break from the loop */
+ break;
+ } else {
+ /* move on to the next on */
+ i++;
+ }
+ } /* while (sng_link_type_map[i].init == 1) */
+
+ /* check how we exited the loop */
+ if (sng_link_type_map[i].init == 0) {
+ return -1;
+ } else {
+ return i;
+ } /* if (sng_link_type_map[i].init == 0) */
+}
+
+/******************************************************************************/
+int find_switch_type_in_map(const char *switchType)
+{
+ int i = 0;
+
+ while (sng_switch_type_map[i].init == 1) {
+ /* check if string matches the sng_type name */
+ if (!strcasecmp(switchType, sng_switch_type_map[i].sng_type)) {
+ /* we've found a match break from the loop */
+ break;
+ } else {
+ /* move on to the next on */
+ i++;
+ }
+ } /* while (sng_switch_type_map[i].init == 1) */
+
+ /* check how we exited the loop */
+ if (sng_switch_type_map[i].init == 0) {
+ return -1;
+ } else {
+ return i;
+ } /* if (sng_switch_type_map[i].init == 0) */
+}
+
+/******************************************************************************/
+int find_ssf_type_in_map(const char *ssfType)
+{
+ int i = 0;
+
+ while (sng_ssf_type_map[i].init == 1) {
+ /* check if string matches the sng_type name */
+ if (!strcasecmp(ssfType, sng_ssf_type_map[i].sng_type)) {
+ /* we've found a match break from the loop */
+ break;
+ } else {
+ /* move on to the next on */
+ i++;
+ }
+ } /* while (sng_ssf_type_map[i].init == 1) */
+
+ /* check how we exited the loop */
+ if (sng_ssf_type_map[i].init == 0) {
+ return -1;
+ } else {
+ return i;
+ } /* if (sng_ssf_type_map[i].init == 0) */
+}
+
+/******************************************************************************/
+int find_cic_cntrl_in_map(const char *cntrlType)
+{
+ int i = 0;
+
+ while (sng_cic_cntrl_type_map[i].init == 1) {
+ /* check if string matches the sng_type name */
+ if (!strcasecmp(cntrlType, sng_cic_cntrl_type_map[i].sng_type)) {
+ /* we've found a match break from the loop */
+ break;
+ } else {
+ /* move on to the next on */
+ i++;
+ }
+ } /* while (sng_cic_cntrl_type_map[i].init == 1) */
+
+ /* check how we exited the loop */
+ if (sng_cic_cntrl_type_map[i].init == 0) {
+ return -1;
+ } else {
+ return i;
+ } /* if (sng_cic_cntrl_type_map[i].init == 0) */
+}
+
+/******************************************************************************/
+ftdm_status_t check_status_of_all_isup_intf(void)
+{
+ sng_isup_inf_t *sngss7_intf = NULL;
+ uint8_t status = 0xff;
+ int x;
+
+ /* go through all the isupIntfs and ask the stack to give their current state */
+ x = 1;
+ for (x = 1; x < (MAX_ISUP_INFS + 1); x++) {
+ /**************************************************************************/
+
+ if (g_ftdm_sngss7_data.cfg.isupIntf[x].id == 0) continue;
+
+ sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[x];
+
+ if (ftmod_ss7_isup_intf_sta(sngss7_intf->id, &status)) {
+ SS7_ERROR("Failed to get status of ISUP intf %d\n", sngss7_intf->id);
+ continue;
+ }
+
+ switch (status){
+ /**********************************************************************/
+ case (SI_INTF_AVAIL):
+ SS7_DEBUG("State of ISUP intf %d = AVAIL\n", sngss7_intf->id);
+
+ /* check the current state for interface that we know */
+ if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
+ /* we thing the intf is paused...put into resume */
+ sngss7_clear_flag(sngss7_intf, SNGSS7_PAUSED);
+ } else {
+ /* nothing to since we already know that interface is active */
+ }
+ break;
+ /**********************************************************************/
+ case (SI_INTF_UNAVAIL):
+ SS7_DEBUG("State of ISUP intf %d = UNAVAIL\n", sngss7_intf->id);
+ /* check the current state for interface that we know */
+ if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
+ /* nothing to since we already know that interface is active */
+ } else {
+ /* put the interface into pause */
+ sngss7_set_flag(sngss7_intf, SNGSS7_PAUSED);
+ }
+ break;
+ /**********************************************************************/
+ case (SI_INTF_CONG1):
+ SS7_DEBUG("State of ISUP intf %d = Congestion 1\n", sngss7_intf->id);
+ break;
+ /**********************************************************************/
+ case (SI_INTF_CONG2):
+ SS7_DEBUG("State of ISUP intf %d = Congestion 2\n", sngss7_intf->id);
+ break;
+ /**********************************************************************/
+ case (SI_INTF_CONG3):
+ SS7_DEBUG("State of ISUP intf %d = Congestion 3\n", sngss7_intf->id);
+ break;
+ /**********************************************************************/
+ default:
+ /* should do something here to handle the possiblity of an unknown case */
+ SS7_ERROR("Unknown ISUP intf Status code (%d) for Intf = %d\n", status, sngss7_intf->id);
+ break;
+ /**********************************************************************/
+ } /* switch (status) */
+
+ /**************************************************************************/
+ } /* for (x = 1; x < MAX_ISUP_INFS + 1); i++) */
+
+ return FTDM_SUCCESS;
+}
+
/******************************************************************************/
/* For Emacs:
* Local Variables:
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c
index 75b32d6892..c2d493f34e 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c
@@ -61,7 +61,7 @@ void handle_isup_t35(void *userdata)
SS7_ERROR("[Call-Control] Timer 35 expired on CIC = %d\n", sngss7_info->circuit->cic);
/* set the flag to indicate this hangup is started from the local side */
- sngss7_set_flag(sngss7_info, FLAG_LOCAL_REL);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL);
/* hang up on timer expiry */
ftdmchan->caller_data.hangup_cause = 28;
diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c
index d4fd1ca9b3..166fe5dc04 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c
@@ -39,6 +39,60 @@
/******************************************************************************/
/* GLOBALS ********************************************************************/
+sng_ssf_type_t sng_ssf_type_map[] =
+{
+ { 1, "nat" , SSF_NAT },
+ { 1, "int" , SSF_INTL },
+ { 1, "spare" , SSF_SPARE },
+ { 1, "res" , SSF_RES },
+ { 0, "", 0 },
+};
+
+sng_switch_type_t sng_switch_type_map[] =
+{
+ { 1, "itu88" , LSI_SW_ITU , LSI_SW_ITU },
+ { 1, "itu92" , LSI_SW_ITU , LSI_SW_ITU },
+ { 1, "itu97" , LSI_SW_ITU97 , LSI_SW_ITU97 },
+ { 1, "itu00" , LSI_SW_ITU2000 , LSI_SW_ITU2000 },
+ { 1, "ansi88" , LSI_SW_ANS88 , LSI_SW_ANS88 },
+ { 1, "ansi92" , LSI_SW_ANS92 , LSI_SW_ANS92 },
+ { 1, "ansi95" , LSI_SW_ANS92 , LSI_SW_ANS92 },
+ { 1, "etsiv2" , LSI_SW_ETSI , LSI_SW_ETSI },
+ { 1, "etsiv3" , LSI_SW_ETSIV3 , LSI_SW_ETSIV3 },
+ { 1, "india" , LSI_SW_INDIA , LSI_SW_INDIA },
+ { 1, "uk" , LSI_SW_UK , LSI_SW_UK },
+ { 1, "russia" , LSI_SW_RUSSIA , LSI_SW_RUSSIA },
+ { 0, "", 0, 0 },
+};
+
+sng_link_type_t sng_link_type_map[] =
+{
+ { 1, "itu88" , LSD_SW_ITU88 , LSN_SW_ITU },
+ { 1, "itu92" , LSD_SW_ITU92 , LSN_SW_ITU },
+ { 1, "etsi" , LSD_SW_ITU92 , LSN_SW_ITU },
+ { 1, "ansi88" , LSD_SW_ANSI88, LSN_SW_ANS },
+ { 1, "ansi92" , LSD_SW_ANSI92, LSN_SW_ANS },
+ { 1, "ansi96" , LSD_SW_ANSI92, LSN_SW_ANS96 },
+ { 0, "", 0, 0 },
+};
+
+sng_mtp2_error_type_t sng_mtp2_error_type_map[] =
+{
+ { 1, "basic", SD_ERR_NRM },
+ { 1, "pcr" , SD_ERR_CYC },
+ { 0, "", 0 },
+};
+
+sng_cic_cntrl_type_t sng_cic_cntrl_type_map[] =
+{
+ { 1, "bothway" , BOTHWAY },
+ { 1, "incoming" , INCOMING },
+ { 1, "outgoing" , OUTGOING },
+ { 1, "controlling" , CONTROLLING },
+ { 1, "controlled" , CONTROLLED },
+ { 0, "", 0 },
+};
+
typedef struct sng_timeslot
{
int channel;
@@ -47,13 +101,28 @@ typedef struct sng_timeslot
int hole;
}sng_timeslot_t;
-typedef struct sng_isupCkt
+typedef struct sng_span
{
+ char name[MAX_NAME_LEN];
ftdm_span_t *span;
- uint32_t cicbase;
- uint32_t typeCntrl;
- char ch_map[MAX_CIC_MAP_LENGTH];
+ uint32_t ccSpanId;
+} sng_span_t;
+
+typedef struct sng_ccSpan
+{
+ char name[MAX_NAME_LEN];
+ uint32_t options;
+ uint32_t id;
+ uint32_t procId;
uint32_t isupInf;
+ uint32_t cicbase;
+ char ch_map[MAX_CIC_MAP_LENGTH];
+ uint32_t typeCntrl;
+ uint32_t switchType;
+ uint32_t ssf;
+ uint32_t clg_nadi;
+ uint32_t cld_nadi;
+ uint32_t min_digits;
uint32_t t3;
uint32_t t12;
uint32_t t13;
@@ -61,8 +130,9 @@ typedef struct sng_isupCkt
uint32_t t15;
uint32_t t16;
uint32_t t17;
+ uint32_t t35;
uint32_t tval;
-} sng_isupCkt_t;
+} sng_ccSpan_t;
int cmbLinkSetId;
/******************************************************************************/
@@ -72,9 +142,22 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa
static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup);
+static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen);
+
+static int ftmod_ss7_parse_sng_relay(ftdm_conf_node_t *sng_relay);
+static int ftmod_ss7_parse_relay_channel(ftdm_conf_node_t *relay_chan);
+
+static int ftmod_ss7_parse_mtp1_links(ftdm_conf_node_t *mtp1_links);
+static int ftmod_ss7_parse_mtp1_link(ftdm_conf_node_t *mtp1_link);
+
+static int ftmod_ss7_parse_mtp2_links(ftdm_conf_node_t *mtp2_links);
+static int ftmod_ss7_parse_mtp2_link(ftdm_conf_node_t *mtp2_link);
+
+static int ftmod_ss7_parse_mtp3_links(ftdm_conf_node_t *mtp3_links);
+static int ftmod_ss7_parse_mtp3_link(ftdm_conf_node_t *mtp3_link);
+
static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets);
static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset);
-static int ftmod_ss7_parse_mtp_link(ftdm_conf_node_t *mtp_link, sng_mtp_link_t *mtpLink);
static int ftmod_ss7_parse_mtp_routes(ftdm_conf_node_t *mtp_routes);
static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route);
@@ -82,19 +165,22 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route);
static int ftmod_ss7_parse_isup_interfaces(ftdm_conf_node_t *isup_interfaces);
static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface);
-static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink);
+static int ftmod_ss7_parse_cc_spans(ftdm_conf_node_t *cc_spans);
+static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span);
+static int ftmod_ss7_fill_in_relay_channel(sng_relay_t *relay_channel);
+static int ftmod_ss7_fill_in_mtp1_link(sng_mtp1_link_t *mtp1Link);
+static int ftmod_ss7_fill_in_mtp2_link(sng_mtp2_link_t *mtp1Link);
+static int ftmod_ss7_fill_in_mtp3_link(sng_mtp3_link_t *mtp1Link);
static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet);
-
static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route);
static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route);
-
static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup);
static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap);
-
+static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan);
static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf);
+static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan);
-static int ftmod_ss7_fill_in_circuits(sng_isupCkt_t *isupCkt);
static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot);
/******************************************************************************/
@@ -103,18 +189,17 @@ static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot);
int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span)
{
int i = 0;
- int x = 0;
const char *var = NULL;
const char *val = NULL;
ftdm_conf_node_t *ptr = NULL;
sng_route_t self_route;
- sng_isupCkt_t isupCkt;
+ sng_span_t sngSpan;
/* clean out the isup ckt */
- memset(&isupCkt, 0x0, sizeof(sng_isupCkt_t));
+ memset(&sngSpan, 0x0, sizeof(sngSpan));
/* clean out the self route */
- memset(&self_route, 0x0, sizeof(sng_route_t));
+ memset(&self_route, 0x0, sizeof(self_route));
var = ftdm_parameters[i].var;
val = ftdm_parameters[i].val;
@@ -136,92 +221,23 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa
i++;
while (ftdm_parameters[i].var != NULL) {
+ /**************************************************************************/
var = ftdm_parameters[i].var;
val = ftdm_parameters[i].val;
- if (!strcasecmp(var, "ch_map")) {
+ if (!strcasecmp(var, "dialplan")) {
/**********************************************************************/
- strncpy(isupCkt.ch_map, val, MAX_CIC_MAP_LENGTH-1);
- SS7_DEBUG("\tFound channel map \"%s\"\n", isupCkt.ch_map);
- /**********************************************************************/
- } else if (!strcasecmp(var, "typeCntrl")) {
- if (!strcasecmp(val, "bothway")) {
- isupCkt.typeCntrl = BOTHWAY;
- SS7_DEBUG("\tFound control type \"bothway\"\n");
- } else if (!strcasecmp(val, "incoming")) {
- isupCkt.typeCntrl = INCOMING;
- SS7_DEBUG("\tFound control type \"incoming\"\n");
- } else if (!strcasecmp(val, "outgoing")) {
- isupCkt.typeCntrl = OUTGOING;
- SS7_DEBUG("\tFound control type \"outgoing\"\n");
- } else if (!strcasecmp(val, "controlled")) {
- isupCkt.typeCntrl = CONTROLLED;
- SS7_DEBUG("\tFound control type \"controlled\"\n");
- } else if (!strcasecmp(val, "controlling")) {
- isupCkt.typeCntrl = CONTROLLING;
- SS7_DEBUG("\tFound control type \"controlling\"\n");
- } else {
- SS7_ERROR("Found invalid circuit control type \"%s\"!", val);
- goto ftmod_ss7_parse_xml_error;
- }
- /**********************************************************************/
- } else if (!strcasecmp(var, "cicbase")) {
- isupCkt.cicbase = atoi(val);
- SS7_DEBUG("\tFound cicbase = %d\n", isupCkt.cicbase);
- /**********************************************************************/
- } else if (!strcasecmp(var, "dialplan")) {
/* do i give a shit about this??? */
/**********************************************************************/
} else if (!strcasecmp(var, "context")) {
+ /**********************************************************************/
/* do i give a shit about this??? */
/**********************************************************************/
- } else if (!strcasecmp(var, "isup_interface")) {
- /* go through all the existing interfaces and see if we find a match */
- x = 1;
- while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.isupIntf[x].name, val)) {
- /* we have a match so break out of this loop */
- break;
- }
- /* move on to the next one */
- x++;
- }
-
- isupCkt.isupInf = x;
- SS7_DEBUG("\tFound isup_interface = %s\n",g_ftdm_sngss7_data.cfg.isupIntf[x].name);
+ } else if (!strcasecmp(var, "ccSpanId")) {
/**********************************************************************/
- } else if (!strcasecmp(var, "isup.t3")) {
- isupCkt.t3 = atoi(val);
- SS7_DEBUG("\tFound isup t3 = \"%d\"\n", isupCkt.t3);
- /**********************************************************************/
- } else if (!strcasecmp(var, "isup.t12")) {
- isupCkt.t12 = atoi(val);
- SS7_DEBUG("\tFound isup t12 = \"%d\"\n", isupCkt.t12);
- /**********************************************************************/
- } else if (!strcasecmp(var, "isup.t13")) {
- isupCkt.t13 = atoi(val);
- SS7_DEBUG("\tFound isup t13 = \"%d\"\n", isupCkt.t13);
- /**********************************************************************/
- } else if (!strcasecmp(var, "isup.t14")) {
- isupCkt.t14 = atoi(val);
- SS7_DEBUG("\tFound isup t14 = \"%d\"\n", isupCkt.t14);
- /**********************************************************************/
- } else if (!strcasecmp(var, "isup.t15")) {
- isupCkt.t15 = atoi(val);
- SS7_DEBUG("\tFound isup t15 = \"%d\"\n", isupCkt.t15);
- /**********************************************************************/
- } else if (!strcasecmp(var, "isup.t16")) {
- isupCkt.t16 = atoi(val);
- SS7_DEBUG("\tFound isup t16 = \"%d\"\n", isupCkt.t16);
- /**********************************************************************/
- } else if (!strcasecmp(var, "isup.t17")) {
- isupCkt.t17 = atoi(val);
- SS7_DEBUG("\tFound isup t17 = \"%d\"\n", isupCkt.t17);
- /**********************************************************************/
- } else if (!strcasecmp(var, "isup.tval")) {
- isupCkt.tval = atoi(val);
- SS7_DEBUG("\tFound isup tval = \"%d\"\n", isupCkt.tval);
+ sngSpan.ccSpanId = atoi(val);
+ SS7_DEBUG("Found an ccSpanId = %d\n",sngSpan.ccSpanId);
/**********************************************************************/
} else {
SS7_ERROR("Unknown parameter found =\"%s\"...ignoring it!\n", var);
@@ -231,24 +247,11 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa
i++;
} /* while (ftdm_parameters[i].var != NULL) */
- /* setup the self mtp3 route */
- i = g_ftdm_sngss7_data.cfg.isupIntf[x].mtpRouteId;
-
- if(ftmod_ss7_fill_in_self_route(g_ftdm_sngss7_data.cfg.isupIntf[x].spc,
- g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType,
- g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType,
- g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf)) {
-
- SS7_ERROR("Failed to fill in self route structure!\n");
- goto ftmod_ss7_parse_xml_error;
-
- }
-
/* fill the pointer to span into isupCkt */
- isupCkt.span = span;
+ sngSpan.span = span;
/* setup the circuits structure */
- if(ftmod_ss7_fill_in_circuits(&isupCkt)) {
+ if(ftmod_ss7_fill_in_circuits(&sngSpan)) {
SS7_ERROR("Failed to fill in circuits structure!\n");
goto ftmod_ss7_parse_xml_error;
}
@@ -262,9 +265,15 @@ ftmod_ss7_parse_xml_error:
/******************************************************************************/
static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup)
{
+ ftdm_conf_node_t *gen_config = NULL;
+ ftdm_conf_node_t *relay_channels = NULL;
+ ftdm_conf_node_t *mtp1_links = NULL;
+ ftdm_conf_node_t *mtp2_links = NULL;
+ ftdm_conf_node_t *mtp3_links = NULL;
ftdm_conf_node_t *mtp_linksets = NULL;
ftdm_conf_node_t *mtp_routes = NULL;
ftdm_conf_node_t *isup_interfaces = NULL;
+ ftdm_conf_node_t *cc_spans = NULL;
ftdm_conf_node_t *tmp_node = NULL;
/* confirm that we are looking at sng_isup */
@@ -275,51 +284,145 @@ static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup)
SS7_DEBUG("Parsing \"sng_isup\"...\n");
}
- /* extract the 3 main sections of the sng_isup block */
+ /* extract the main sections of the sng_isup block */
tmp_node = sng_isup->child;
- while (tmp_node != NULL) {
- if (!strcasecmp(tmp_node->name, "mtp_linksets")) {
+ while (tmp_node != NULL) {
+ /**************************************************************************/
+ /* check the type of structure */
+ if (!strcasecmp(tmp_node->name, "sng_gen")) {
+ /**********************************************************************/
+ if (gen_config == NULL) {
+ gen_config = tmp_node;
+ SS7_DEBUG("Found a \"sng_gen\" section!\n");
+ } else {
+ SS7_ERROR("Found a second \"sng_gen\" section\n!");
+ return FTDM_FAIL;
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(tmp_node->name, "sng_relay")) {
+ /**********************************************************************/
+ if (relay_channels == NULL) {
+ relay_channels = tmp_node;
+ SS7_DEBUG("Found a \"sng_relay\" section!\n");
+ } else {
+ SS7_ERROR("Found a second \"sng_relay\" section\n!");
+ return FTDM_FAIL;
+ }
+ /**********************************************************************/
+ }else if (!strcasecmp(tmp_node->name, "mtp1_links")) {
+ /**********************************************************************/
+ if (mtp1_links == NULL) {
+ mtp1_links = tmp_node;
+ SS7_DEBUG("Found a \"mtp1_links\" section!\n");
+ } else {
+ SS7_ERROR("Found a second \"mtp1_links\" section!\n");
+ return FTDM_FAIL;
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(tmp_node->name, "mtp2_links")) {
+ /**********************************************************************/
+ if (mtp2_links == NULL) {
+ mtp2_links = tmp_node;
+ SS7_DEBUG("Found a \"mtp2_links\" section!\n");
+ } else {
+ SS7_ERROR("Found a second \"mtp2_links\" section!\n");
+ return FTDM_FAIL;
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(tmp_node->name, "mtp3_links")) {
+ /**********************************************************************/
+ if (mtp3_links == NULL) {
+ mtp3_links = tmp_node;
+ SS7_DEBUG("Found a \"mtp3_links\" section!\n");
+ } else {
+ SS7_ERROR("Found a second \"mtp3_links\" section!\n");
+ return FTDM_FAIL;
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(tmp_node->name, "mtp_linksets")) {
+ /**********************************************************************/
if (mtp_linksets == NULL) {
mtp_linksets = tmp_node;
- SS7_DEBUG("\tFound a \"mtp_linksets section!\n");
+ SS7_DEBUG("Found a \"mtp_linksets\" section!\n");
} else {
- SS7_ERROR("\tFound a second \"mtp_linksets\" section!\n");
+ SS7_ERROR("Found a second \"mtp_linksets\" section!\n");
return FTDM_FAIL;
}
+ /**********************************************************************/
} else if (!strcasecmp(tmp_node->name, "mtp_routes")) {
+ /**********************************************************************/
if (mtp_routes == NULL) {
mtp_routes = tmp_node;
- SS7_DEBUG("\tFound a \"mtp_routes\" section!\n");
+ SS7_DEBUG("Found a \"mtp_routes\" section!\n");
} else {
- SS7_ERROR("\tFound a second \"mtp_routes\" section!\n");
+ SS7_ERROR("Found a second \"mtp_routes\" section!\n");
return FTDM_FAIL;
}
+ /**********************************************************************/
} else if (!strcasecmp(tmp_node->name, "isup_interfaces")) {
+ /**********************************************************************/
if (isup_interfaces == NULL) {
isup_interfaces = tmp_node;
- SS7_DEBUG("\tFound a \"isup_interfaces\" section!\n");
+ SS7_DEBUG("Found a \"isup_interfaces\" section!\n");
} else {
- SS7_ERROR("\tFound a second \"isup_interfaces\" section\n!");
+ SS7_ERROR("Found a second \"isup_interfaces\" section\n!");
return FTDM_FAIL;
}
+ /**********************************************************************/
+ } else if (!strcasecmp(tmp_node->name, "cc_spans")) {
+ /**********************************************************************/
+ if (cc_spans == NULL) {
+ cc_spans = tmp_node;
+ SS7_DEBUG("Found a \"cc_spans\" section!\n");
+ } else {
+ SS7_ERROR("Found a second \"cc_spans\" section\n!");
+ return FTDM_FAIL;
+ }
+ /**********************************************************************/
} else {
+ /**********************************************************************/
SS7_ERROR("\tFound an unknown section \"%s\"!\n", tmp_node->name);
return FTDM_FAIL;
- }
+ /**********************************************************************/
+ }
/* go to the next sibling */
tmp_node = tmp_node->next;
-
} /* while (tmp_node != NULL) */
/* now try to parse the sections */
+ if (ftmod_ss7_parse_sng_gen(gen_config)) {
+ SS7_ERROR("Failed to parse \"gen_config\"!\n");
+ return FTDM_FAIL;
+ }
+
+ if (ftmod_ss7_parse_sng_relay(relay_channels)) {
+ SS7_ERROR("Failed to parse \"relay_channels\"!\n");
+ return FTDM_FAIL;
+ }
+
+ if (ftmod_ss7_parse_mtp1_links(mtp1_links)) {
+ SS7_ERROR("Failed to parse \"mtp1_links\"!\n");
+ return FTDM_FAIL;
+ }
+
+ if (ftmod_ss7_parse_mtp2_links(mtp2_links)) {
+ SS7_ERROR("Failed to parse \"mtp2_links\"!\n");
+ return FTDM_FAIL;
+ }
+
+ if (ftmod_ss7_parse_mtp3_links(mtp3_links)) {
+ SS7_ERROR("Failed to parse \"mtp3_links\"!\n");
+ return FTDM_FAIL;
+ }
+
if (ftmod_ss7_parse_mtp_linksets(mtp_linksets)) {
SS7_ERROR("Failed to parse \"mtp_linksets\"!\n");
return FTDM_FAIL;
}
- if (ftmod_ss7_parse_mtp_routes(mtp_routes)) {
+ if (ftmod_ss7_parse_mtp_routes(mtp_routes)) {
SS7_ERROR("Failed to parse \"mtp_routes\"!\n");
return FTDM_FAIL;
}
@@ -329,6 +432,695 @@ static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup)
return FTDM_FAIL;
}
+ if (ftmod_ss7_parse_cc_spans(cc_spans)) {
+ SS7_ERROR("Failed to parse \"cc_spans\"!\n");
+ return FTDM_FAIL;
+ }
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen)
+{
+ ftdm_conf_parameter_t *parm = sng_gen->parameters;
+ int num_parms = sng_gen->n_parameters;
+ int i = 0;
+
+ /* extract all the information from the parameters */
+ for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+
+ if (!strcasecmp(parm->var, "procId")) {
+ /**********************************************************************/
+ g_ftdm_sngss7_data.cfg.procId = atoi(parm->val);
+ SS7_DEBUG("Found a procId = %d\n", g_ftdm_sngss7_data.cfg.procId);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "license")) {
+ /**********************************************************************/
+ strcpy(g_ftdm_sngss7_data.cfg.license, parm->val);
+ strcpy(g_ftdm_sngss7_data.cfg.signature, parm->val);
+ strcat(g_ftdm_sngss7_data.cfg.signature, ".sig");
+ SS7_DEBUG("Found license file = %s\n", g_ftdm_sngss7_data.cfg.license);
+ SS7_DEBUG("Found signature file = %s\n", g_ftdm_sngss7_data.cfg.signature);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val);
+ return FTDM_FAIL;
+ /**********************************************************************/
+ }
+
+ /* move to the next parmeter */
+ parm = parm + 1;
+ } /* for (i = 0; i < num_parms; i++) */
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_sng_relay(ftdm_conf_node_t *sng_relay)
+{
+ ftdm_conf_node_t *relay_chan = NULL;
+
+ /* confirm that we are looking at sng_relay */
+ if (strcasecmp(sng_relay->name, "sng_relay")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"sng_relay\"!\n",sng_relay->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"sng_relay\"...\n");
+ }
+
+ relay_chan = sng_relay->child;
+
+ if (relay_chan != NULL) {
+ while (relay_chan != NULL) {
+ /* try to the parse relay_channel */
+ if (ftmod_ss7_parse_relay_channel(relay_chan)) {
+ SS7_ERROR("Failed to parse \"relay_channels\"!\n");
+ return FTDM_FAIL;
+ }
+
+ /* move on to the next linkset */
+ relay_chan = relay_chan->next;
+ } /* while (relay_chan != NULL) */
+ } /* if (relay_chan != NULL) */
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_relay_channel(ftdm_conf_node_t *relay_chan)
+{
+ sng_relay_t tmp_chan;
+ ftdm_conf_parameter_t *parm = relay_chan->parameters;
+ int num_parms = relay_chan->n_parameters;
+ int i = 0;
+
+ /* confirm that we are looking at relay_channel */
+ if (strcasecmp(relay_chan->name, "relay_channel")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"relay_channel\"!\n",relay_chan->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"relay_channel\"...\n");
+ }
+
+ /* initalize the tmp_chan structure */
+ memset(&tmp_chan, 0x0, sizeof(tmp_chan));
+
+ /* extract all the information from the parameters */
+ for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+
+ if (!strcasecmp(parm->var, "name")) {
+ /**********************************************************************/
+ strcpy((char *)tmp_chan.name, parm->val);
+ SS7_DEBUG("Found an relay_channel named = %s\n", tmp_chan.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "type")) {
+ /**********************************************************************/
+ if (!strcasecmp(parm->val, "listen")) {
+ tmp_chan.type = LRY_CT_TCP_LISTEN;
+ SS7_DEBUG("Found a type = LISTEN\n");
+ } else if (!strcasecmp(parm->val, "server")) {
+ tmp_chan.type = LRY_CT_TCP_SERVER;
+ SS7_DEBUG("Found a type = SERVER\n");
+ } else if (!strcasecmp(parm->val, "client")) {
+ tmp_chan.type = LRY_CT_TCP_CLIENT;
+ SS7_DEBUG("Found a type = CLIENT\n");
+ } else {
+ SS7_ERROR("Found an invalid \"type\" = %s\n", parm->var);
+ return FTDM_FAIL;
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "hostname")) {
+ /**********************************************************************/
+ strcpy((char *)tmp_chan.hostname, parm->val);
+ SS7_DEBUG("Found a hostname = %s\n", tmp_chan.hostname);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "port")) {
+ /**********************************************************************/
+ tmp_chan.port = atoi(parm->val);
+ SS7_DEBUG("Found a port = %d\n", tmp_chan.port);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "procId")) {
+ /**********************************************************************/
+ tmp_chan.procId = atoi(parm->val);
+ SS7_DEBUG("Found a procId = %d\n", tmp_chan.procId);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val);
+ return FTDM_FAIL;
+ /**********************************************************************/
+ }
+
+ /* move to the next parmeter */
+ parm = parm + 1;
+ } /* for (i = 0; i < num_parms; i++) */
+
+ /* store the channel in the global structure */
+ ftmod_ss7_fill_in_relay_channel(&tmp_chan);
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_mtp1_links(ftdm_conf_node_t *mtp1_links)
+{
+ ftdm_conf_node_t *mtp1_link = NULL;
+
+ /* confirm that we are looking at mtp1_links */
+ if (strcasecmp(mtp1_links->name, "mtp1_links")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp1_links\"!\n",mtp1_links->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"mtp1_links\"...\n");
+ }
+
+ /* extract the mtp_links */
+ mtp1_link = mtp1_links->child;
+
+ /* run through all of the links found */
+ while (mtp1_link != NULL) {
+ /* try to the parse mtp_link */
+ if (ftmod_ss7_parse_mtp1_link(mtp1_link)) {
+ SS7_ERROR("Failed to parse \"mtp1_link\"!\n");
+ return FTDM_FAIL;
+ }
+
+ /* move on to the next link */
+ mtp1_link = mtp1_link->next;
+
+ } /* while (mtp_linkset != NULL) */
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_mtp1_link(ftdm_conf_node_t *mtp1_link)
+{
+ sng_mtp1_link_t mtp1Link;
+ ftdm_conf_parameter_t *parm = mtp1_link->parameters;
+ int num_parms = mtp1_link->n_parameters;
+ int i;
+
+ /* initalize the mtp1Link structure */
+ memset(&mtp1Link, 0x0, sizeof(mtp1Link));
+
+ /* confirm that we are looking at an mtp_link */
+ if (strcasecmp(mtp1_link->name, "mtp1_link")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp1_link\"!\n",mtp1_link->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"mtp1_link\"...\n");
+ }
+
+ for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+
+ if (!strcasecmp(parm->var, "name")) {
+ /**********************************************************************/
+ strcpy((char *)mtp1Link.name, parm->val);
+ SS7_DEBUG("Found an mtp1_link named = %s\n", mtp1Link.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "id")) {
+ /**********************************************************************/
+ mtp1Link.id = atoi(parm->val);
+ SS7_DEBUG("Found an mtp1_link id = %d\n", mtp1Link.id);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "span")) {
+ /**********************************************************************/
+ mtp1Link.span = atoi(parm->val);
+ SS7_DEBUG("Found an mtp1_link span = %d\n", mtp1Link.span);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "chan")) {
+ /**********************************************************************/
+ mtp1Link.chan = atoi(parm->val);
+ SS7_DEBUG("Found an mtp1_link chan = %d\n", mtp1Link.chan);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val);
+ return FTDM_FAIL;
+ /**********************************************************************/
+ }
+
+ /* move to the next parmeter */
+ parm = parm + 1;
+
+ /**************************************************************************/
+ } /* for (i = 0; i < num_parms; i++) */
+
+ /* store the link in global structure */
+ ftmod_ss7_fill_in_mtp1_link(&mtp1Link);
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_mtp2_links(ftdm_conf_node_t *mtp2_links)
+{
+ ftdm_conf_node_t *mtp2_link = NULL;
+
+ /* confirm that we are looking at mtp2_links */
+ if (strcasecmp(mtp2_links->name, "mtp2_links")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp2_links\"!\n",mtp2_links->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"mtp2_links\"...\n");
+ }
+
+ /* extract the mtp_links */
+ mtp2_link = mtp2_links->child;
+
+ /* run through all of the links found */
+ while (mtp2_link != NULL) {
+ /* try to the parse mtp_linkset */
+ if (ftmod_ss7_parse_mtp2_link(mtp2_link)) {
+ SS7_ERROR("Failed to parse \"mtp2_link\"!\n");
+ return FTDM_FAIL;
+ }
+
+ /* move on to the next link */
+ mtp2_link = mtp2_link->next;
+
+ } /* while (mtp_linkset != NULL) */
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_mtp2_link(ftdm_conf_node_t *mtp2_link)
+{
+ sng_mtp2_link_t mtp2Link;
+ ftdm_conf_parameter_t *parm = mtp2_link->parameters;
+ int num_parms = mtp2_link->n_parameters;
+ int i;
+ int ret;
+
+ /* initalize the mtp1Link structure */
+ memset(&mtp2Link, 0x0, sizeof(mtp2Link));
+
+ /* confirm that we are looking at an mtp2_link */
+ if (strcasecmp(mtp2_link->name, "mtp2_link")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp2_link\"!\n",mtp2_link->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"mtp2_link\"...\n");
+ }
+
+ for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+
+ if (!strcasecmp(parm->var, "name")) {
+ /**********************************************************************/
+ strcpy((char *)mtp2Link.name, parm->val);
+ SS7_DEBUG("Found an mtp2_link named = %s\n", mtp2Link.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "id")) {
+ /**********************************************************************/
+ mtp2Link.id = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2_link id = %d\n", mtp2Link.id);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "mtp1Id")) {
+ /**********************************************************************/
+ mtp2Link.mtp1Id = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2_link mtp1Id = %d\n", mtp2Link.mtp1Id);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "errorType")) {
+ /**********************************************************************/
+ ret = find_mtp2_error_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid mtp2_link errorType = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ mtp2Link.errorType = sng_mtp2_error_type_map[ret].tril_type;
+ SS7_DEBUG("Found an mtp2_link errorType = %s\n", sng_mtp2_error_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "lssuLength")) {
+ /**********************************************************************/
+ mtp2Link.lssuLength = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2_link lssuLength = %d\n", mtp2Link.lssuLength);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "linkType")) {
+ /**********************************************************************/
+ ret = find_link_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid mtp2_link linkType = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ mtp2Link.linkType = sng_link_type_map[ret].tril_mtp2_type;
+ SS7_DEBUG("Found an mtp2_link linkType = %s\n", sng_link_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t1")) {
+ /**********************************************************************/
+ mtp2Link.t1 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t1 = \"%d\"\n",mtp2Link.t1);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t2")) {
+ /**********************************************************************/
+ mtp2Link.t2 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t2 = \"%d\"\n",mtp2Link.t2);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t3")) {
+ /**********************************************************************/
+ mtp2Link.t3 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t3 = \"%d\"\n",mtp2Link.t3);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t4n")) {
+ /**********************************************************************/
+ mtp2Link.t4n = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t4n = \"%d\"\n",mtp2Link.t4n);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t4e")) {
+ /**********************************************************************/
+ mtp2Link.t4e = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t4e = \"%d\"\n",mtp2Link.t4e);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t5")) {
+ /**********************************************************************/
+ mtp2Link.t5 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t5 = \"%d\"\n",mtp2Link.t5);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t6")) {
+ /**********************************************************************/
+ mtp2Link.t6 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t6 = \"%d\"\n",mtp2Link.t6);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t7")) {
+ /**********************************************************************/
+ mtp2Link.t7 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp2 t7 = \"%d\"\n",mtp2Link.t7);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val);
+ return FTDM_FAIL;
+ /**********************************************************************/
+ }
+
+ /* move to the next parmeter */
+ parm = parm + 1;
+
+ /**************************************************************************/
+ } /* for (i = 0; i < num_parms; i++) */
+
+ /* store the link in global structure */
+ ftmod_ss7_fill_in_mtp2_link(&mtp2Link);
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_mtp3_links(ftdm_conf_node_t *mtp3_links)
+{
+ ftdm_conf_node_t *mtp3_link = NULL;
+
+ /* confirm that we are looking at mtp3_links */
+ if (strcasecmp(mtp3_links->name, "mtp3_links")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp3_links\"!\n",mtp3_links->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"mtp3_links\"...\n");
+ }
+
+ /* extract the mtp_links */
+ mtp3_link = mtp3_links->child;
+
+ /* run through all of the links found */
+ while (mtp3_link != NULL) {
+ /* try to the parse mtp_linkset */
+ if (ftmod_ss7_parse_mtp3_link(mtp3_link)) {
+ SS7_ERROR("Failed to parse \"mtp3_link\"!\n");
+ return FTDM_FAIL;
+ }
+
+ /* move on to the next link */
+ mtp3_link = mtp3_link->next;
+
+ } /* while (mtp_linkset != NULL) */
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_mtp3_link(ftdm_conf_node_t *mtp3_link)
+{
+ sng_mtp3_link_t mtp3Link;
+ ftdm_conf_parameter_t *parm = mtp3_link->parameters;
+ int num_parms = mtp3_link->n_parameters;
+ int i;
+ int ret;
+
+ /* initalize the mtp3Link structure */
+ memset(&mtp3Link, 0x0, sizeof(mtp3Link));
+
+ /* confirm that we are looking at an mtp_link */
+ if (strcasecmp(mtp3_link->name, "mtp3_link")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp3_link\"!\n",mtp3_link->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"mtp3_link\"...\n");
+ }
+
+ for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+ if (!strcasecmp(parm->var, "name")) {
+ /**********************************************************************/
+ strcpy((char *)mtp3Link.name, parm->val);
+ SS7_DEBUG("Found an mtp3_link named = %s\n", mtp3Link.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "id")) {
+ /**********************************************************************/
+ mtp3Link.id = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3_link id = %d\n", mtp3Link.id);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "mtp2Id")) {
+ /**********************************************************************/
+ mtp3Link.mtp2Id = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3_link mtp2Id = %d\n", mtp3Link.mtp2Id);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "mtp2ProcId")) {
+ /**********************************************************************/
+ mtp3Link.mtp2ProcId = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3_link mtp2ProcId = %d\n", mtp3Link.mtp2ProcId);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "priority")) {
+ /**********************************************************************/
+ mtp3Link.priority = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 Link priority = %d\n",mtp3Link.priority);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "linkType")) {
+ /**********************************************************************/
+ ret = find_link_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid mtp3_link linkType = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ mtp3Link.linkType = sng_link_type_map[ret].tril_mtp3_type;
+ SS7_DEBUG("Found an mtp3_link linkType = %s\n", sng_link_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "switchType")) {
+ /**********************************************************************/
+ ret = find_switch_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid mtp3_link switchType = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ mtp3Link.switchType = sng_switch_type_map[ret].tril_mtp3_type;
+ SS7_DEBUG("Found an mtp3_link switchType = %s\n", sng_switch_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "ssf")) {
+ /**********************************************************************/
+ ret = find_ssf_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid mtp3_link ssf = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ mtp3Link.ssf = sng_ssf_type_map[ret].tril_type;
+ SS7_DEBUG("Found an mtp3_link ssf = %s\n", sng_ssf_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "slc")) {
+ /**********************************************************************/
+ mtp3Link.slc = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 Link slc = %d\n",mtp3Link.slc);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "linkset")) {
+ /**********************************************************************/
+ mtp3Link.linkSetId = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 Link linkset = %d\n",mtp3Link.linkSetId);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t1")) {
+ /**********************************************************************/
+ mtp3Link.t1 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t1 = %d\n",mtp3Link.t1);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t2")) {
+ /**********************************************************************/
+ mtp3Link.t2 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t2 = %d\n",mtp3Link.t2);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t3")) {
+ /**********************************************************************/
+ mtp3Link.t3 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t3 = %d\n",mtp3Link.t3);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t4")) {
+ /**********************************************************************/
+ mtp3Link.t4 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t4 = %d\n",mtp3Link.t4);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t5")) {
+ /**********************************************************************/
+ mtp3Link.t5 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t5 = %d\n",mtp3Link.t5);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t7")) {
+ /**********************************************************************/
+ mtp3Link.t7 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t7 = %d\n",mtp3Link.t7);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t12")) {
+ /**********************************************************************/
+ mtp3Link.t12 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t12 = %d\n",mtp3Link.t12);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t13")) {
+ /**********************************************************************/
+ mtp3Link.t13 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t13 = %d\n",mtp3Link.t13);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t14")) {
+ /**********************************************************************/
+ mtp3Link.t14 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t14 = %d\n",mtp3Link.t14);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t17")) {
+ /**********************************************************************/
+ mtp3Link.t17 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t17 = %d\n",mtp3Link.t17);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t22")) {
+ /**********************************************************************/
+ mtp3Link.t22 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t22 = %d\n",mtp3Link.t22);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t23")) {
+ /**********************************************************************/
+ mtp3Link.t23 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t23 = %d\n",mtp3Link.t23);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t24")) {
+ /**********************************************************************/
+ mtp3Link.t24 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t24 = %d\n",mtp3Link.t24);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t31")) {
+ mtp3Link.t31 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t31 = %d\n",mtp3Link.t31);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t32")) {
+ /**********************************************************************/
+ mtp3Link.t32 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t32 = %d\n",mtp3Link.t32);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t33")) {
+ /**********************************************************************/
+ mtp3Link.t33 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t33 = %d\n",mtp3Link.t33);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t34")) {
+ /**********************************************************************/
+ mtp3Link.t34 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t34 = %d\n",mtp3Link.t34);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t35")) {
+ /**********************************************************************/
+ mtp3Link.t35 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t35 = %d\n",mtp3Link.t35);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t36")) {
+ /**********************************************************************/
+ mtp3Link.t36 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t36 = %d\n",mtp3Link.t36);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "t37")) {
+ /**********************************************************************/
+ mtp3Link.t37 = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 t37 = %d\n",mtp3Link.t37);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "tcraft")) {
+ /**********************************************************************/
+ mtp3Link.tcraft = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 tcraft = %d\n",mtp3Link.tcraft);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "tflc")) {
+ /**********************************************************************/
+ mtp3Link.tflc = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 tflc = %d\n",mtp3Link.tflc);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "tbnd")) {
+ /**********************************************************************/
+ mtp3Link.tbnd = atoi(parm->val);
+ SS7_DEBUG("Found an mtp3 tbnd = %d\n",mtp3Link.tbnd);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter %s!\n", parm->val);
+ return FTDM_FAIL;
+ /**********************************************************************/
+ }
+
+ /* move to the next parmeter */
+ parm = parm + 1;
+
+ /**************************************************************************/
+ } /* for (i = 0; i < num_parms; i++) */
+
+ /* store the link in global structure */
+ ftmod_ss7_fill_in_mtp3_link(&mtp3Link);
+
+ /* move the linktype, switchtype and ssf to the linkset */
+ if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType == 0) {
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType = mtp3Link.linkType;
+ } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType != mtp3Link.linkType) {
+ SS7_ERROR("Trying to add an MTP3 Link to a Linkset with a different linkType: mtp3.id=%d, mtp3.name=%s, mtp3.linktype=%d, linkset.id=%d, linkset.linktype=%d\n",
+ mtp3Link.id, mtp3Link.name, mtp3Link.linkType,
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType);
+ return FTDM_FAIL;
+ } else {
+ /* should print that all is ok...*/
+ }
+
+ if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType == 0) {
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType = mtp3Link.switchType;
+ } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType != mtp3Link.switchType) {
+ SS7_ERROR("Trying to add an MTP3 Link to a Linkset with a different switchType: mtp3.id=%d, mtp3.name=%s, mtp3.switchtype=%d, linkset.id=%d, linkset.switchtype=%d\n",
+ mtp3Link.id, mtp3Link.name, mtp3Link.switchType,
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType);
+ return FTDM_FAIL;
+ } else {
+ /* should print that all is ok...*/
+ }
+
+ if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf == 0) {
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf = mtp3Link.ssf;
+ } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf != mtp3Link.ssf) {
+ SS7_ERROR("Trying to add an MTP3 Link to a Linkset with a different ssf: mtp3.id=%d, mtp3.name=%s, mtp3.ssf=%d, linkset.id=%d, linkset.ssf=%d\n",
+ mtp3Link.id, mtp3Link.name, mtp3Link.ssf,
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf);
+ return FTDM_FAIL;
+ } else {
+ /* should print that all is ok...*/
+ }
+
+
return FTDM_SUCCESS;
}
@@ -367,18 +1159,12 @@ static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets)
/******************************************************************************/
static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
{
+ sng_link_set_t mtpLinkSet;
ftdm_conf_parameter_t *parm = mtp_linkset->parameters;
- int num_parms = mtp_linkset->n_parameters;
- ftdm_conf_node_t *mtp_link = NULL;
- sng_mtp_link_t mtpLink[MAX_MTP_LINKS+1];
- sng_link_set_t mtpLinkSet;
- int count;
- int i;
+ int num_parms = mtp_linkset->n_parameters;
+ int i;
- /* initialize the mtp_link structures */
- for (i = 0; i < (MAX_MTP_LINKS + 1); i++) {
- memset(&mtpLink[i], 0x0, sizeof(mtpLink[i]));
- }
+ /* initalize the mtpLinkSet structure */
memset(&mtpLinkSet, 0x0, sizeof(mtpLinkSet));
/* confirm that we are looking at mtp_linkset */
@@ -391,387 +1177,52 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
/* extract all the information from the parameters */
for (i = 0; i < num_parms; i++) {
- /**********************************************************************/
+ /**************************************************************************/
+
if (!strcasecmp(parm->var, "name")) {
- strncpy((char *)mtpLinkSet.name, parm->val, MAX_NAME_LEN-1);
- SS7_DEBUG("\tFound an \"mtp_linkset\" named = %s\n", mtpLinkSet.name);
+ /**********************************************************************/
+ strcpy((char *)mtpLinkSet.name, parm->val);
+ SS7_DEBUG("Found an mtpLinkSet named = %s\n", mtpLinkSet.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "id")) {
+ /**********************************************************************/
+ mtpLinkSet.id = atoi(parm->val);
+ SS7_DEBUG("Found mtpLinkSet id = %d\n", mtpLinkSet.id);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "apc")) {
+ /**********************************************************************/
mtpLinkSet.apc = atoi(parm->val);
- SS7_DEBUG("\tFound mtpLinkSet->apc = %d\n", mtpLinkSet.apc);
+ SS7_DEBUG("Found mtpLinkSet apc = %d\n", mtpLinkSet.apc);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "minActive")) {
+ /**********************************************************************/
mtpLinkSet.minActive = atoi(parm->val);
- SS7_DEBUG("\tFound mtpLinkSet->minActive = %d\n", mtpLinkSet.minActive);
+ SS7_DEBUG("Found mtpLinkSet minActive = %d\n", mtpLinkSet.minActive);
/**********************************************************************/
} else {
- SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val);
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val);
return FTDM_FAIL;
+ /**********************************************************************/
}
/* move to the next parmeter */
parm = parm + 1;
-
+ /**************************************************************************/
} /* for (i = 0; i < num_parms; i++) */
- /* grab the first mtp-link (which sits below the mtp_links section) */
- mtp_link = mtp_linkset->child->child;
-
- /* initalize the link counter */
- count = 0;
-
- /* run through all of the mtp_links found */
- while (mtp_link != NULL) {
- /* try to the parse mtp_linkset */
- if (ftmod_ss7_parse_mtp_link(mtp_link, &mtpLink[count] )) {
- SS7_ERROR("Failed to parse \"mtp_link\"!\n");
- return FTDM_FAIL;
- }
-
- /* incremenet the link counter */
- count++;
-
- /* move on to the next link */
- mtp_link = mtp_link->next;
-
- } /* while (mtp_link != NULL) */
-
- /* confirm we have the right number of links */
- if (count < 1 || count > 15 ) {
- SS7_ERROR("Invalid number of mtp_links found (%d)\n", count);
- return FTDM_FAIL;
- }
-
- /* now we need to see if this linkset exists already or not and grab an Id */
- i = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLinkSet[i].id != 0) {
- if (!strcasecmp((const char *)g_ftdm_sngss7_data.cfg.mtpLinkSet[i].name, (const char *)mtpLinkSet.name)) {
- /* we've found the linkset...so it has already been configured */
- break;
- }
- i++;
- /* add in error check to make sure we don't go out-of-bounds */
- }
-
- /* if the id value is 0 that means we didn't find the linkset */
- if (g_ftdm_sngss7_data.cfg.mtpLinkSet[i].id == 0) {
- mtpLinkSet.id = i;
- SS7_DEBUG("found new mtpLinkSet, id is = %d\n", mtpLinkSet.id);
- } else {
- mtpLinkSet.id = i;
- SS7_DEBUG("found existing mtpLinkSet, id is = %d\n", mtpLinkSet.id);
- }
-
- /* we now have all the information to fill in the Libsng_ss7 structures */
- i = 0;
- count = 0;
- while (mtpLink[i].mtp1.span != 0 ){
-
- /* have to grab a couple of values from the linkset */
- mtpLink[i].mtp3.apc = mtpLinkSet.apc;
- mtpLink[i].mtp3.linkSetId = mtpLinkSet.id;
-
- ftmod_ss7_fill_in_mtpLink(&mtpLink[i]);
-
- /* increment the links counter */
- count++;
-
- /* increment the index value */
- i++;
- }
-
- mtpLinkSet.linkType = mtpLink[0].mtp3.linkType;
- mtpLinkSet.switchType = mtpLink[0].mtp3.switchType;
- mtpLinkSet.ssf = mtpLink[0].mtp3.ssf;
-
ftmod_ss7_fill_in_mtpLinkSet(&mtpLinkSet);
- return FTDM_SUCCESS;
-}
-
-/******************************************************************************/
-static int ftmod_ss7_parse_mtp_link(ftdm_conf_node_t *mtp_link, sng_mtp_link_t *mtpLink)
-{
- ftdm_conf_parameter_t *parm = mtp_link->parameters;
- int num_parms = mtp_link->n_parameters;
- int i;
-
- /* confirm that we are looking at an mtp_link */
- if (strcasecmp(mtp_link->name, "mtp_link")) {
- SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"mtp_link\"!\n",mtp_link->name);
- return FTDM_FAIL;
- } else {
- SS7_DEBUG("Parsing \"mtp_link\"...\n");
- }
-
- for (i = 0; i < num_parms; i++) {
- /* try to match the parameter to what we expect */
- /**********************************************************************/
- if (!strcasecmp(parm->var, "name")) {
- strncpy((char *)mtpLink->name, parm->val, MAX_NAME_LEN-1);
- SS7_DEBUG("\tFound an \"mtp_link\" named = %s\n", mtpLink->name);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "span")) {
- mtpLink->mtp1.span = atoi(parm->val);
- SS7_DEBUG("\tFound mtpLink->span = %d\n", mtpLink->mtp1.span);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "chan")) {
- mtpLink->mtp1.chan = atoi(parm->val);
- SS7_DEBUG("\tFound mtpLink->chan = %d\n", mtpLink->mtp1.chan);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "errorType")) {
- if (!strcasecmp(parm->val, "basic")) {
- mtpLink->mtp2.errorType = SD_ERR_NRM;
- } else if (!strcasecmp(parm->val, "pcr")) {
- mtpLink->mtp2.errorType = SD_ERR_CYC;
- } else {
- SS7_ERROR("\tFound an invalid \"errorType\" = %s\n", parm->var);
- return FTDM_FAIL;
- }
- SS7_DEBUG("\tFound mtpLink->errorType=%s\n", parm->val);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "lssuLength")) {
- mtpLink->mtp2.lssuLength = atoi(parm->val);
- if ((mtpLink->mtp2.lssuLength != 1) && (mtpLink->mtp2.lssuLength != 2)) {
- SS7_ERROR("\tFound an invalid \"lssuLength\" = %d\n", mtpLink->mtp2.lssuLength);
- return FTDM_FAIL;
- } else {
- SS7_DEBUG("\tFound mtpLink->lssuLength=%d\n", mtpLink->mtp2.lssuLength);
- }
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "priority")) {
- mtpLink->mtp3.priority = atoi(parm->val);
- if ((mtpLink->mtp3.priority == 0) || (mtpLink->mtp3.priority == 1) ||
- (mtpLink->mtp3.priority == 2) || (mtpLink->mtp3.priority == 3)) {
- SS7_DEBUG("\tFound mtpLink->priority = %d\n",mtpLink->mtp3.priority);
- } else {
- SS7_ERROR("\tFound an invalid \"priority\"=%d\n",mtpLink->mtp3.priority);
- return FTDM_FAIL;
- }
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "linkType")) {
- if (!strcasecmp(parm->val, "itu92")) {
- mtpLink->mtp2.linkType = LSD_SW_ITU92;
- mtpLink->mtp3.linkType = LSN_SW_ITU;
- SS7_DEBUG("\tFound mtpLink->linkType = \"ITU92\"\n");
- } else if (!strcasecmp(parm->val, "itu88")) {
- mtpLink->mtp2.linkType = LSD_SW_ITU88;
- mtpLink->mtp3.linkType = LSN_SW_ITU;
- SS7_DEBUG("\tFound mtpLink->linkType = \"ITU88\"\n");
- } else if (!strcasecmp(parm->val, "ansi96")) {
- mtpLink->mtp2.linkType = LSD_SW_ANSI92;
- mtpLink->mtp3.linkType = LSN_SW_ANS96;
- SS7_DEBUG("\tFound mtpLink->linkType = \"ANSI96\"\n");
- } else if (!strcasecmp(parm->val, "ansi92")) {
- mtpLink->mtp2.linkType = LSD_SW_ANSI92;
- mtpLink->mtp3.linkType = LSN_SW_ANS;
- SS7_DEBUG("\tFound mtpLink->linkType = \"ANSI92\"\n");
- } else if (!strcasecmp(parm->val, "ansi88")) {
- mtpLink->mtp2.linkType = LSD_SW_ANSI88;
- mtpLink->mtp3.linkType = LSN_SW_ANS;
- SS7_DEBUG("\tFound mtpLink->linkType = \"ANSI88\"\n");
- } else if (!strcasecmp(parm->val, "etsi")) {
- mtpLink->mtp2.linkType = LSD_SW_ITU92;
- mtpLink->mtp3.linkType = LSN_SW_ITU;
- SS7_DEBUG("\tFound mtpLink->linkType = \"ETSI\"\n");
- } else {
- SS7_ERROR("\tFound an invalid linktype of \"%s\"!\n", parm->val);
- return FTDM_FAIL;
- }
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "switchType")) {
- if (!strcasecmp(parm->val, "itu97")) {
- mtpLink->mtp3.switchType = LSI_SW_ITU97;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ITU97\"\n");
- } else if (!strcasecmp(parm->val, "itu88")) {
- mtpLink->mtp3.switchType = LSI_SW_ITU;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ITU88\"\n");
- } else if (!strcasecmp(parm->val, "itu92")) {
- mtpLink->mtp3.switchType = LSI_SW_ITU;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ITU92\"\n");
- } else if (!strcasecmp(parm->val, "itu00")) {
- mtpLink->mtp3.switchType = LSI_SW_ITU2000;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ITU00\"\n");
- } else if (!strcasecmp(parm->val, "ETSIV2")) {
- mtpLink->mtp3.switchType = LSI_SW_ETSI;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ETSIV2\"\n");
- } else if (!strcasecmp(parm->val, "ETSIV3")) {
- mtpLink->mtp3.switchType = LSI_SW_ETSIV3;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ETSIV3\"\n");
- } else if (!strcasecmp(parm->val, "UK")) {
- mtpLink->mtp3.switchType = LSI_SW_UK;
- SS7_DEBUG("\tFound mtpLink->switchType = \"UK\"\n");
- } else if (!strcasecmp(parm->val, "RUSSIA")) {
- mtpLink->mtp3.switchType = LSI_SW_RUSSIA;
- SS7_DEBUG("\tFound mtpLink->switchType = \"RUSSIA\"\n");
- } else if (!strcasecmp(parm->val, "INDIA")) {
- mtpLink->mtp3.switchType = LSI_SW_INDIA;
- SS7_DEBUG("\tFound mtpLink->switchType = \"INDIA\"\n");
- } else if (!strcasecmp(parm->val, "ansi88")) {
- mtpLink->mtp3.switchType = LSI_SW_ANS88;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ANSI88\"\n");
- } else if (!strcasecmp(parm->val, "ansi92")) {
- mtpLink->mtp3.switchType = LSI_SW_ANS92;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ANSI92\"\n");
- } else if (!strcasecmp(parm->val, "ansi95")) {
- mtpLink->mtp3.switchType = LSI_SW_ANS95;
- SS7_DEBUG("\tFound mtpLink->switchType = \"ANSI95\"\n");
- } else {
- SS7_ERROR("\tFound an invalid linktype of \"%s\"!\n", parm->val);
- return FTDM_FAIL;
- }
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "ssf")) {
- if (!strcasecmp(parm->val, "nat")) {
- mtpLink->mtp3.ssf = SSF_NAT;
- } else if (!strcasecmp(parm->val, "int")) {
- mtpLink->mtp3.ssf = SSF_INTL;
- } else if (!strcasecmp(parm->val, "spare")) {
- mtpLink->mtp3.ssf = SSF_SPARE;
- } else if (!strcasecmp(parm->val, "res")) {
- mtpLink->mtp3.ssf = SSF_RES;
- } else {
- SS7_ERROR("\tFound an invalid ssf of \"%s\"!\n", parm->val);
- return FTDM_FAIL;
- }
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "slc")) {
- mtpLink->mtp3.slc = atoi(parm->val);
- SS7_DEBUG("\tFound mtpLink->slc = \"%d\"\n",mtpLink->mtp3.slc);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t1")) {
- mtpLink->mtp2.t1 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t1 = \"%d\"\n",mtpLink->mtp2.t1);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t2")) {
- mtpLink->mtp2.t2 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t2 = \"%d\"\n",mtpLink->mtp2.t2);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t3")) {
- mtpLink->mtp2.t3 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t3 = \"%d\"\n",mtpLink->mtp2.t3);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t4n")) {
- mtpLink->mtp2.t4n = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t4n = \"%d\"\n",mtpLink->mtp2.t4n);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t4e")) {
- mtpLink->mtp2.t4e = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t4e = \"%d\"\n",mtpLink->mtp2.t4e);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t5")) {
- mtpLink->mtp2.t5 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t5 = \"%d\"\n",mtpLink->mtp2.t5);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t6")) {
- mtpLink->mtp2.t6 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t6 = \"%d\"\n",mtpLink->mtp2.t6);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp2.t7")) {
- mtpLink->mtp2.t7 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp2 t7 = \"%d\"\n",mtpLink->mtp2.t7);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t1")) {
- mtpLink->mtp3.t1 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t1 = \"%d\"\n",mtpLink->mtp3.t1);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t2")) {
- mtpLink->mtp3.t2 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t2 = \"%d\"\n",mtpLink->mtp3.t2);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t3")) {
- mtpLink->mtp3.t3 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t3 = \"%d\"\n",mtpLink->mtp3.t3);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t4")) {
- mtpLink->mtp3.t4 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t4 = \"%d\"\n",mtpLink->mtp3.t4);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t5")) {
- mtpLink->mtp3.t5 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t5 = \"%d\"\n",mtpLink->mtp3.t5);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t7")) {
- mtpLink->mtp3.t7 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t7 = \"%d\"\n",mtpLink->mtp3.t7);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t12")) {
- mtpLink->mtp3.t12 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t12 = \"%d\"\n",mtpLink->mtp3.t12);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t13")) {
- mtpLink->mtp3.t13 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t13 = \"%d\"\n",mtpLink->mtp3.t13);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t14")) {
- mtpLink->mtp3.t14 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t14 = \"%d\"\n",mtpLink->mtp3.t14);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t17")) {
- mtpLink->mtp3.t17 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t17 = \"%d\"\n",mtpLink->mtp3.t17);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t22")) {
- mtpLink->mtp3.t22 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t22 = \"%d\"\n",mtpLink->mtp3.t22);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t23")) {
- mtpLink->mtp3.t23 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t23 = \"%d\"\n",mtpLink->mtp3.t23);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t24")) {
- mtpLink->mtp3.t24 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t24 = \"%d\"\n",mtpLink->mtp3.t24);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t31")) {
- mtpLink->mtp3.t31 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t31 = \"%d\"\n",mtpLink->mtp3.t31);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t32")) {
- mtpLink->mtp3.t32 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t32 = \"%d\"\n",mtpLink->mtp3.t32);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t33")) {
- mtpLink->mtp3.t33 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t33 = \"%d\"\n",mtpLink->mtp3.t33);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t34")) {
- mtpLink->mtp3.t34 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t34 = \"%d\"\n",mtpLink->mtp3.t34);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t35")) {
- mtpLink->mtp3.t35 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t35 = \"%d\"\n",mtpLink->mtp3.t35);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t36")) {
- mtpLink->mtp3.t36 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t36 = \"%d\"\n",mtpLink->mtp3.t36);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.t37")) {
- mtpLink->mtp3.t37 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t37 = \"%d\"\n",mtpLink->mtp3.t37);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.tcraft")) {
- mtpLink->mtp3.tcraft = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 tcraft = \"%d\"\n",mtpLink->mtp3.tcraft);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.tflc")) {
- mtpLink->mtp3.tflc = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 tflc = \"%d\"\n",mtpLink->mtp3.tflc);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp3.tbnd")) {
- mtpLink->mtp3.tbnd = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 tbnd = \"%d\"\n",mtpLink->mtp3.tbnd);
- /**********************************************************************/
- } else {
- SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val);
- return FTDM_FAIL;
+ /* go through all the mtp3 links and fill in the apc */
+ i = 1;
+ while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == mtpLinkSet.id) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtpLinkSet.apc;
}
-
- /* move to the next parameter */
- parm = parm + 1;
+
+ i++;
}
-
+
return FTDM_SUCCESS;
}
@@ -812,7 +1263,12 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)
ftdm_conf_parameter_t *parm = mtp_route->parameters;
int num_parms = mtp_route->n_parameters;
int i;
+ sng_link_set_list_t *lnkSet;
+ ftdm_conf_node_t *linkset;
+ int numLinks;
+
+ /* initalize the mtpRoute structure */
memset(&mtpRoute, 0x0, sizeof(mtpRoute));
/* confirm that we are looking at an mtp_link */
@@ -824,119 +1280,155 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)
}
for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+
/* try to match the parameter to what we expect */
- /**********************************************************************/
if (!strcasecmp(parm->var, "name")) {
- strncpy((char *)mtpRoute.name, parm->val, MAX_NAME_LEN-1);
- SS7_DEBUG("\tFound an \"mtp_route\" named = %s\n", mtpRoute.name);
+ /**********************************************************************/
+ strcpy((char *)mtpRoute.name, parm->val);
+ SS7_DEBUG("Found an mtpRoute named = %s\n", mtpRoute.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "id")) {
+ /**********************************************************************/
+ mtpRoute.id = atoi(parm->val);
+ SS7_DEBUG("Found an mtpRoute id = %d\n", mtpRoute.id);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "dpc")) {
- mtpRoute.dpc = atoi(parm->val);
- SS7_DEBUG("\tFound mtpRoute->dpc = %d\n", mtpRoute.dpc);
/**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp_linkset")) {
-
- /* find the linkset by it's name */
- int x = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
- /* check if the name matches */
- if (!strcasecmp((char *)g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, parm->val)) {
-
- /* now, harvest the required infomormation from the global structure */
- mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].linkType;
- mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].switchType;
- mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].ssf;
- mtpRoute.linkSetId = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id;
- cmbLinkSetId++;
- mtpRoute.cmbLinkSetId = cmbLinkSetId;
-
- /* update the linkset with the new cmbLinkSet value */
- g_ftdm_sngss7_data.cfg.mtpLinkSet[x].numLinks++;
- g_ftdm_sngss7_data.cfg.mtpLinkSet[x].links[g_ftdm_sngss7_data.cfg.mtpLinkSet[x].numLinks-1] = mtpRoute.cmbLinkSetId;
- break;
- }
- x++;
- }
-
- /* check why we exited the wile loop ... and react accordingly */
- if (mtpRoute.cmbLinkSetId == 0) {
- SS7_ERROR("\tFailed to find the linkset = \"%s\"!\n", parm->val);
- return FTDM_FAIL;
- } else {
- SS7_DEBUG("\tFound mtp3_route->linkset = %s\n", parm->val);
- }
+ mtpRoute.dpc = atoi(parm->val);
+ SS7_DEBUG("Found an mtpRoute dpc = %d\n", mtpRoute.dpc);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isSTP")) {
+ /**********************************************************************/
if (!strcasecmp(parm->val, "no")) {
mtpRoute.isSTP = 0;
- SS7_DEBUG("\tFound mtpRoute->isSTP = no\n");
+ SS7_DEBUG("Found an mtpRoute isSTP = no\n");
} else if (!strcasecmp(parm->val, "yes")) {
mtpRoute.isSTP = 1;
- SS7_DEBUG("\tFound mtpRoute->isSTP = yes\n");
+ SS7_DEBUG("Found an mtpRoute isSTP = yes\n");
} else {
- SS7_ERROR("\tFound an invalid parameter for isSTP \"%s\"!\n", parm->val);
+ SS7_ERROR("Found an invalid parameter for isSTP %s!\n", parm->val);
return FTDM_FAIL;
}
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t6")) {
+ /**********************************************************************/
mtpRoute.t6 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t6 = \"%d\"\n",mtpRoute.t6);
+ SS7_DEBUG("Found an mtp3 t6 = %d\n",mtpRoute.t6);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t8")) {
+ /**********************************************************************/
mtpRoute.t8 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t8 = \"%d\"\n",mtpRoute.t8);
+ SS7_DEBUG("Found an mtp3 t8 = %d\n",mtpRoute.t8);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t10")) {
+ /**********************************************************************/
mtpRoute.t10 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t10 = \"%d\"\n",mtpRoute.t10);
+ SS7_DEBUG("Found an mtp3 t10 = %d\n",mtpRoute.t10);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t11")) {
+ /**********************************************************************/
mtpRoute.t11 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t11 = \"%d\"\n",mtpRoute.t11);
+ SS7_DEBUG("Found an mtp3 t11 = %d\n",mtpRoute.t11);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t15")) {
+ /**********************************************************************/
mtpRoute.t15 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t15 = \"%d\"\n",mtpRoute.t15);
+ SS7_DEBUG("Found an mtp3 t15 = %d\n",mtpRoute.t15);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t16")) {
+ /**********************************************************************/
mtpRoute.t16 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t16 = \"%d\"\n",mtpRoute.t16);
+ SS7_DEBUG("Found an mtp3 t16 = %d\n",mtpRoute.t16);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t18")) {
+ /**********************************************************************/
mtpRoute.t18 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t18 = \"%d\"\n",mtpRoute.t18);
+ SS7_DEBUG("Found an mtp3 t18 = %d\n",mtpRoute.t18);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t19")) {
+ /**********************************************************************/
mtpRoute.t19 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t19 = \"%d\"\n",mtpRoute.t19);
+ SS7_DEBUG("Found an mtp3 t19 = %d\n",mtpRoute.t19);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t21")) {
+ /**********************************************************************/
mtpRoute.t21 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t21 = \"%d\"\n",mtpRoute.t21);
+ SS7_DEBUG("Found an mtp3 t21 = %d\n",mtpRoute.t21);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t25")) {
+ /**********************************************************************/
mtpRoute.t25 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t25 = \"%d\"\n",mtpRoute.t25);
+ SS7_DEBUG("Found an mtp3 t25 = %d\n",mtpRoute.t25);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "mtp3.t26")) {
+ /**********************************************************************/
mtpRoute.t26 = atoi(parm->val);
- SS7_DEBUG("\tFound mtp3 t26 = \"%d\"\n",mtpRoute.t26);
+ SS7_DEBUG("Found an mtp3 t26 = %d\n",mtpRoute.t26);
/**********************************************************************/
} else {
- SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val);
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val);
return FTDM_FAIL;
-
+ /**********************************************************************/
}
/* move to the next parameter */
parm = parm + 1;
}
- ftmod_ss7_fill_in_nsap(&mtpRoute);
+ /* fill in the rest of the values in the mtpRoute struct */
+ mtpRoute.nwId = 0;
+ mtpRoute.cmbLinkSetId = mtpRoute.id;
+
+ /* parse in the list of linksets this route is reachable by */
+ linkset = mtp_route->child->child;
+
+ /* initalize the link-list of linkSet Ids */
+ lnkSet = &mtpRoute.lnkSets;
+
+ while (linkset != NULL) {
+ /**************************************************************************/
+ /* extract the linkset Id */
+ lnkSet->lsId = atoi(linkset->parameters->val);
+
+ if (g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].id != 0) {
+ SS7_DEBUG("Found mtpRoute linkset id = %d that is valid\n",lnkSet->lsId);
+ } else {
+ SS7_ERROR("Found mtpRoute linkset id = %d that is invalid\n",lnkSet->lsId);
+ goto move_along;
+ }
+
+ /* pull up the linktype, switchtype, and SSF from the linkset */
+ mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].linkType;
+ mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].switchType;
+ mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].ssf;
+
+ /* extract the number of cmbLinkSetId aleady on this linkset */
+ numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks;
+
+ /* add this routes cmbLinkSetId to the list */
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[numLinks] = mtpRoute.cmbLinkSetId;
+
+ /* increment the number of cmbLinkSets on this linkset */
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++;
+
+ /* update the linked list */
+ lnkSet->next = ftdm_malloc(sizeof(sng_link_set_list_t));
+ lnkSet = lnkSet->next;
+ lnkSet->lsId = 0;
+ lnkSet->next = NULL;
+
+move_along:
+ /* move to the next linkset element */
+ linkset = linkset->next;
+ /**************************************************************************/
+ } /* while (linkset != null) */
+
ftmod_ss7_fill_in_mtp3_route(&mtpRoute);
-
+ ftmod_ss7_fill_in_nsap(&mtpRoute);
return FTDM_SUCCESS;
}
@@ -976,13 +1468,13 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
{
sng_isup_inf_t sng_isup;
sng_isap_t sng_isap;
+ sng_link_set_list_t *lnkSet;
ftdm_conf_parameter_t *parm = isup_interface->parameters;
int num_parms = isup_interface->n_parameters;
int i;
- int linkSetId;
- int flag_cld_nadi = 0;
- int flag_clg_nadi = 0;
+ int ret;
+ /* initalize the isup intf and isap structure */
memset(&sng_isup, 0x0, sizeof(sng_isup));
memset(&sng_isap, 0x0, sizeof(sng_isap));
@@ -996,357 +1488,579 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+
/* try to match the parameter to what we expect */
- /**********************************************************************/
if (!strcasecmp(parm->var, "name")) {
- strncpy((char *)sng_isup.name, parm->val, MAX_NAME_LEN-1);
- SS7_DEBUG("\tFound an \"isup_interface\" named = %s\n", sng_isup.name);
+ /**********************************************************************/
+ strcpy((char *)sng_isup.name, parm->val);
+ SS7_DEBUG("Found an isup_interface named = %s\n", sng_isup.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "id")) {
+ /**********************************************************************/
+ sng_isup.id = atoi(parm->val);
+ SS7_DEBUG("Found an isup id = %d\n", sng_isup.id);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "spc")) {
+ /**********************************************************************/
sng_isup.spc = atoi(parm->val);
- g_ftdm_sngss7_data.cfg.spc = sng_isup.spc;
- SS7_DEBUG("\tFound SPC = %d\n", sng_isup.spc);
+ SS7_DEBUG("Found an isup SPC = %d\n", sng_isup.spc);
/**********************************************************************/
- } else if (!strcasecmp(parm->var, "mtp_route")) {
- /* find the route by it's name */
- int x = 1;
-
- while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) {
-
- /* check if the name matches */
- if (!strcasecmp((char *)g_ftdm_sngss7_data.cfg.mtpRoute[x].name, parm->val)) {
- /* now, harvest the required information from the global structure */
- sng_isup.mtpRouteId = g_ftdm_sngss7_data.cfg.mtpRoute[x].id;
- sng_isup.dpc = g_ftdm_sngss7_data.cfg.mtpRoute[x].dpc;
- sng_isup.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[x].switchType;
- sng_isap.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[x].switchType;
-
- /* find the NSAP corresponding to this switchType and SSF */
- int z = 1;
- while (g_ftdm_sngss7_data.cfg.nsap[z].id != 0) {
- if ((g_ftdm_sngss7_data.cfg.nsap[z].linkType == g_ftdm_sngss7_data.cfg.mtpRoute[x].linkType) &&
- (g_ftdm_sngss7_data.cfg.nsap[z].switchType == g_ftdm_sngss7_data.cfg.mtpRoute[x].switchType) &&
- (g_ftdm_sngss7_data.cfg.nsap[z].ssf == g_ftdm_sngss7_data.cfg.mtpRoute[x].ssf)) {
- sng_isup.nwId = g_ftdm_sngss7_data.cfg.nsap[z].nwId;
- /* we have a match so break out of this loop */
- break;
- }
- /* move on to the next one */
- z++;
- }
- break;
- }
- x++;
- } /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */
-
- /* check why we exited the while loop ... and react accordingly */
- if (sng_isup.mtpRouteId == 0) {
- SS7_ERROR("\tFailed to find the MTP3 Route = \"%s\"!\n", parm->val);
- return FTDM_FAIL;
- } else {
- SS7_DEBUG("\tFound MTP3 Route = %s\n", parm->val);
- }
+ } else if (!strcasecmp(parm->var, "mtprouteId")) {
/**********************************************************************/
- } else if (!strcasecmp(parm->var, "min_digits")) {
- sng_isup.min_digits = atoi(parm->val);
+ sng_isup.mtpRouteId=atoi(parm->val);
- SS7_DEBUG("\tFound min_digits = %d\n", sng_isup.min_digits);
+ SS7_DEBUG("Found an isup mptRouteId = %d\n", sng_isup.mtpRouteId);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "ssf")) {
- if (!strcasecmp(parm->val, "nat")) {
- sng_isup.ssf = SSF_NAT;
- sng_isap.ssf = SSF_NAT;
- } else if (!strcasecmp(parm->val, "int")) {
- sng_isup.ssf = SSF_INTL;
- sng_isap.ssf = SSF_INTL;
- } else if (!strcasecmp(parm->val, "spare")) {
- sng_isup.ssf = SSF_SPARE;
- sng_isap.ssf = SSF_SPARE;
- } else if (!strcasecmp(parm->val, "res")) {
- sng_isup.ssf = SSF_RES;
- sng_isap.ssf = SSF_RES;
- } else {
- SS7_ERROR("\tFound an invalid ssf of \"%s\"!\n", parm->val);
+ /**********************************************************************/
+ ret = find_ssf_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid isup ssf = %s\n", parm->var);
return FTDM_FAIL;
+ } else {
+ sng_isup.ssf = sng_ssf_type_map[ret].tril_type;
+ sng_isap.ssf = sng_ssf_type_map[ret].tril_type;
+ SS7_DEBUG("Found an isup ssf = %s\n", sng_ssf_type_map[ret].sng_type);
}
/**********************************************************************/
- } else if (!strcasecmp(parm->var, "license")) {
- /**********************************************************************/
- strncpy(g_ftdm_sngss7_data.cfg.license, parm->val, MAX_PATH-1);
- strncpy(g_ftdm_sngss7_data.cfg.signature, parm->val, MAX_PATH-1);
- strcat(g_ftdm_sngss7_data.cfg.signature, ".sig");
- SS7_DEBUG("\tFound license file = %s\n", g_ftdm_sngss7_data.cfg.license);
- SS7_DEBUG("\tFound signature file = %s\n", g_ftdm_sngss7_data.cfg.signature);
- /**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t1")) {
+ /**********************************************************************/
sng_isap.t1 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t1 = \"%d\"\n",sng_isap.t1);
+ SS7_DEBUG("Found isup t1 = %d\n",sng_isap.t1);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t2")) {
+ /**********************************************************************/
sng_isap.t2 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t2 = \"%d\"\n",sng_isap.t2);
+ SS7_DEBUG("Found isup t2 = %d\n",sng_isap.t2);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t4")) {
+ /**********************************************************************/
sng_isup.t4 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t4 = \"%d\"\n",sng_isup.t4);
+ SS7_DEBUG("Found isup t4 = %d\n",sng_isup.t4);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t5")) {
+ /**********************************************************************/
sng_isap.t5 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t5 = \"%d\"\n",sng_isap.t5);
+ SS7_DEBUG("Found isup t5 = %d\n",sng_isap.t5);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t6")) {
+ /**********************************************************************/
sng_isap.t6 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t6 = \"%d\"\n",sng_isap.t6);
+ SS7_DEBUG("Found isup t6 = %d\n",sng_isap.t6);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t7")) {
+ /**********************************************************************/
sng_isap.t7 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t7 = \"%d\"\n",sng_isap.t7);
+ SS7_DEBUG("Found isup t7 = %d\n",sng_isap.t7);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t8")) {
+ /**********************************************************************/
sng_isap.t8 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t8 = \"%d\"\n",sng_isap.t8);
+ SS7_DEBUG("Found isup t8 = %d\n",sng_isap.t8);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t9")) {
+ /**********************************************************************/
sng_isap.t9 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t9 = \"%d\"\n",sng_isap.t9);
+ SS7_DEBUG("Found isup t9 = %d\n",sng_isap.t9);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t10")) {
+ /**********************************************************************/
sng_isup.t10 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t10 = \"%d\"\n",sng_isup.t10);
+ SS7_DEBUG("Found isup t10 = %d\n",sng_isup.t10);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t11")) {
+ /**********************************************************************/
sng_isup.t11 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t11 = \"%d\"\n",sng_isup.t11);
+ SS7_DEBUG("Found isup t11 = %d\n",sng_isup.t11);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t18")) {
+ /**********************************************************************/
sng_isup.t18 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t18 = \"%d\"\n",sng_isup.t18);
+ SS7_DEBUG("Found isup t18 = %d\n",sng_isup.t18);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t19")) {
+ /**********************************************************************/
sng_isup.t19 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t19 = \"%d\"\n",sng_isup.t19);
+ SS7_DEBUG("Found isup t19 = %d\n",sng_isup.t19);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t20")) {
+ /**********************************************************************/
sng_isup.t20 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t20 = \"%d\"\n",sng_isup.t20);
+ SS7_DEBUG("Found isup t20 = %d\n",sng_isup.t20);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t21")) {
+ /**********************************************************************/
sng_isup.t21 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t21 = \"%d\"\n",sng_isup.t21);
+ SS7_DEBUG("Found isup t21 = %d\n",sng_isup.t21);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t22")) {
+ /**********************************************************************/
sng_isup.t22 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t22 = \"%d\"\n",sng_isup.t22);
+ SS7_DEBUG("Found isup t22 = %d\n",sng_isup.t22);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t23")) {
+ /**********************************************************************/
sng_isup.t23 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t23 = \"%d\"\n",sng_isup.t23);
+ SS7_DEBUG("Found isup t23 = %d\n",sng_isup.t23);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t24")) {
+ /**********************************************************************/
sng_isup.t24 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t24 = \"%d\"\n",sng_isup.t24);
+ SS7_DEBUG("Found isup t24 = %d\n",sng_isup.t24);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t25")) {
+ /**********************************************************************/
sng_isup.t25 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t25 = \"%d\"\n",sng_isup.t25);
+ SS7_DEBUG("Found isup t25 = %d\n",sng_isup.t25);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t26")) {
+ /**********************************************************************/
sng_isup.t26 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t26 = \"%d\"\n",sng_isup.t26);
+ SS7_DEBUG("Found isup t26 = %d\n",sng_isup.t26);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t28")) {
+ /**********************************************************************/
sng_isup.t28 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t28 = \"%d\"\n",sng_isup.t28);
+ SS7_DEBUG("Found isup t28 = %d\n",sng_isup.t28);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t29")) {
+ /**********************************************************************/
sng_isup.t29 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t29 = \"%d\"\n",sng_isup.t29);
+ SS7_DEBUG("Found isup t29 = %d\n",sng_isup.t29);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t30")) {
+ /**********************************************************************/
sng_isup.t30 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t30 = \"%d\"\n",sng_isup.t30);
+ SS7_DEBUG("Found isup t30 = %d\n",sng_isup.t30);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t31")) {
+ /**********************************************************************/
sng_isap.t31 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t31 = \"%d\"\n",sng_isap.t31);
+ SS7_DEBUG("Found isup t31 = %d\n",sng_isap.t31);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t32")) {
+ /**********************************************************************/
sng_isup.t32 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t32 = \"%d\"\n",sng_isup.t32);
+ SS7_DEBUG("Found isup t32 = %d\n",sng_isup.t32);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t33")) {
+ /**********************************************************************/
sng_isap.t33 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t33 = \"%d\"\n",sng_isap.t33);
+ SS7_DEBUG("Found isup t33 = %d\n",sng_isap.t33);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t34")) {
- sng_isap.t34 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t34 = \"%d\"\n",sng_isap.t34);
/**********************************************************************/
- } else if (!strcasecmp(parm->var, "isup.t35")) {
- sng_isup.t35 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t35 = \"%d\"\n",sng_isup.t35);
+ sng_isap.t34 = atoi(parm->val);
+ SS7_DEBUG("Found isup t34 = %d\n",sng_isap.t34);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t36")) {
+ /**********************************************************************/
sng_isap.t36 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t36 = \"%d\"\n",sng_isap.t36);
+ SS7_DEBUG("Found isup t36 = %d\n",sng_isap.t36);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t37")) {
+ /**********************************************************************/
sng_isup.t37 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t37 = \"%d\"\n",sng_isup.t37);
+ SS7_DEBUG("Found isup t37 = %d\n",sng_isup.t37);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t38")) {
+ /**********************************************************************/
sng_isup.t38 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t38 = \"%d\"\n",sng_isup.t38);
+ SS7_DEBUG("Found isup t38 = %d\n",sng_isup.t38);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.t39")) {
+ /**********************************************************************/
sng_isup.t39 = atoi(parm->val);
- SS7_DEBUG("\tFound isup t39 = \"%d\"\n",sng_isup.t39);
+ SS7_DEBUG("Found isup t39 = %d\n",sng_isup.t39);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tccr")) {
+ /**********************************************************************/
sng_isap.tccr = atoi(parm->val);
- SS7_DEBUG("\tFound isup tccr = \"%d\"\n",sng_isap.tccr);
+ SS7_DEBUG("Found isup tccr = %d\n",sng_isap.tccr);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tccrt")) {
+ /**********************************************************************/
sng_isap.tccrt = atoi(parm->val);
- SS7_DEBUG("\tFound isup tccrt = \"%d\"\n",sng_isap.tccrt);
+ SS7_DEBUG("Found isup tccrt = %d\n",sng_isap.tccrt);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tex")) {
+ /**********************************************************************/
sng_isap.tex = atoi(parm->val);
- SS7_DEBUG("\tFound isup tex = \"%d\"\n",sng_isap.tex);
+ SS7_DEBUG("Found isup tex = %d\n",sng_isap.tex);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tect")) {
+ /**********************************************************************/
sng_isap.tect = atoi(parm->val);
- SS7_DEBUG("\tFound isup tect = \"%d\"\n",sng_isap.tect);
+ SS7_DEBUG("Found isup tect = %d\n",sng_isap.tect);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tcrm")) {
+ /**********************************************************************/
sng_isap.tcrm = atoi(parm->val);
- SS7_DEBUG("\tFound isup tcrm = \"%d\"\n",sng_isap.tcrm);
+ SS7_DEBUG("Found isup tcrm = %d\n",sng_isap.tcrm);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tcra")) {
+ /**********************************************************************/
sng_isap.tcra = atoi(parm->val);
- SS7_DEBUG("\tFound isup tcra = \"%d\"\n",sng_isap.tcra);
+ SS7_DEBUG("Found isup tcra = %d\n",sng_isap.tcra);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tfgr")) {
+ /**********************************************************************/
sng_isup.tfgr = atoi(parm->val);
- SS7_DEBUG("\tFound isup tfgr = \"%d\"\n",sng_isup.tfgr);
+ SS7_DEBUG("Found isup tfgr = %d\n",sng_isup.tfgr);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.trelrsp")) {
+ /**********************************************************************/
sng_isap.trelrsp = atoi(parm->val);
- SS7_DEBUG("\tFound isup trelrsp = \"%d\"\n",sng_isap.trelrsp);
+ SS7_DEBUG("Found isup trelrsp = %d\n",sng_isap.trelrsp);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tfnlrelrsp")) {
+ /**********************************************************************/
sng_isap.tfnlrelrsp = atoi(parm->val);
- SS7_DEBUG("\tFound isup tfnlrelrsp = \"%d\"\n",sng_isap.tfnlrelrsp);
+ SS7_DEBUG("Found isup tfnlrelrsp = %d\n",sng_isap.tfnlrelrsp);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tfnlrelrsp")) {
+ /**********************************************************************/
sng_isap.tfnlrelrsp = atoi(parm->val);
- SS7_DEBUG("\tFound isup tfnlrelrsp = \"%d\"\n",sng_isap.tfnlrelrsp);
+ SS7_DEBUG("Found isup tfnlrelrsp = %d\n",sng_isap.tfnlrelrsp);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tpause")) {
+ /**********************************************************************/
sng_isup.tpause = atoi(parm->val);
- SS7_DEBUG("\tFound isup tpause = \"%d\"\n",sng_isup.tpause);
+ SS7_DEBUG("Found isup tpause = %d\n",sng_isup.tpause);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "isup.tstaenq")) {
+ /**********************************************************************/
sng_isup.tstaenq = atoi(parm->val);
- SS7_DEBUG("\tFound isup tstaenq = \"%d\"\n",sng_isup.tstaenq);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "clg_nadi")) {
- /**********************************************************************/
- /* throw the flag so that we know we got this optional parameter */
- flag_clg_nadi = 1;
- sng_isup.clg_nadi = atoi(parm->val);
- SS7_DEBUG("\tFound default CLG_NADI value = %d\n", sng_isup.clg_nadi);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "cld_nadi")) {
- /**********************************************************************/
- /* throw the flag so that we know we got this optional parameter */
- flag_cld_nadi = 1;
- sng_isup.cld_nadi = atoi(parm->val);
- SS7_DEBUG("\tFound default CLD_NADI value = %d\n", sng_isup.cld_nadi);
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "obci_bita")) {
- /**********************************************************************/
- if (*parm->val == '1') {
- sngss7_set_options(&sng_isup, SNGSS7_ACM_OBCI_BITA);
- SS7_DEBUG("\tFound Optional Backwards Indicator: Bit A (early media) enable option\n");
- } else if (*parm->val == '0') {
- sngss7_clear_options(&sng_isup, SNGSS7_ACM_OBCI_BITA);
- SS7_DEBUG("\tFound Optional Backwards Indicator: Bit A (early media) disable option\n");
- } else {
- SS7_DEBUG("\tInvalid value for \"obci_bita\" option\n");
- }
- /**********************************************************************/
- } else if (!strcasecmp(parm->var, "lpa_on_cot")) {
- /**********************************************************************/
- if (*parm->val == '1') {
- sngss7_set_options(&sng_isup, SNGSS7_LPA_FOR_COT);
- SS7_DEBUG("\tFound Tx LPA on COT enable option\n");
- } else if (*parm->val == '0') {
- sngss7_clear_options(&sng_isup, SNGSS7_LPA_FOR_COT);
- SS7_DEBUG("\tFound Tx LPA on COT disable option\n");
- } else {
- SS7_DEBUG("\tInvalid value for \"lpa_on_cot\" option\n");
- }
+ SS7_DEBUG("Found isup tstaenq = %d\n",sng_isup.tstaenq);
/**********************************************************************/
} else {
- SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val);
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter %s!\n", parm->val);
return FTDM_FAIL;
-
+ /**********************************************************************/
}
/* move to the next parameter */
parm = parm + 1;
- }
+ /**************************************************************************/
+ } /* for (i = 0; i < num_parms; i++) */
- /* check if the user filled in a nadi value by looking at flag */
- if (!flag_cld_nadi) {
- /* default the nadi value to national */
- sng_isup.cld_nadi = 0x03;
- }
+ /* default the interface to paused state */
+ sngss7_set_flag(&sng_isup, SNGSS7_PAUSED);
- if (!flag_clg_nadi) {
- /* default the nadi value to national */
- sng_isup.clg_nadi = 0x03;
- }
- /* check if the user requested min_digits value */
- if (sng_isup.min_digits == 0) {
- /* default to 7 */
- sng_isup.min_digits = 7;
- }
-
/* trickle down the SPC to all sub entities */
- linkSetId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].linkSetId;
-
- i = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[i].id != 0) {
- if (g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.linkSetId == linkSetId) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.spc = g_ftdm_sngss7_data.cfg.spc;
+ lnkSet = &g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].lnkSets;
+ while (lnkSet->next != NULL) {
+ /**************************************************************************/
+ /* go through all the links and check if they belong to this linkset*/
+ i = 1;
+ while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {
+ /* check if this link is in the linkset */
+ if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == lnkSet->lsId) {
+ /* fill in the spc */
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].spc = sng_isup.spc;
+ }
+
+ i++;
}
+
+ /* move to the next lnkSet */
+ lnkSet = lnkSet->next;
+ /**************************************************************************/
+ } /* while (lnkSet->next != NULL) */
- i++;
- }
+ /* pull values from the lower levels */
+ sng_isap.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].switchType;
+ /* fill in the isap */
ftmod_ss7_fill_in_isap(&sng_isap);
- sng_isup.isap = sng_isap.id;
+ /* pull values from the lower levels */
+ sng_isup.isap = sng_isap.id;
+ sng_isup.dpc = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].dpc;
+ sng_isup.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].switchType;
+ sng_isup.nwId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].nwId;
+ /* fill in the isup interface */
ftmod_ss7_fill_in_isup_interface(&sng_isup);
+ /* setup the self mtp3 route */
+ i = sng_isup.mtpRouteId;
+ if(ftmod_ss7_fill_in_self_route(sng_isup.spc,
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType,
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType,
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf)) {
+
+ SS7_ERROR("Failed to fill in self route structure!\n");
+ return FTDM_FAIL;
+
+ }
+
return FTDM_SUCCESS;
}
/******************************************************************************/
-static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink)
+static int ftmod_ss7_parse_cc_spans(ftdm_conf_node_t *cc_spans)
+{
+ ftdm_conf_node_t *cc_span = NULL;
+
+ /* confirm that we are looking at cc_spans */
+ if (strcasecmp(cc_spans->name, "cc_spans")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"cc_spans\"!\n",cc_spans->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"cc_spans\"...\n");
+ }
+
+ /* extract the cc_spans */
+ cc_span = cc_spans->child;
+
+ while (cc_span != NULL) {
+ /* parse the found cc_span */
+ if (ftmod_ss7_parse_cc_span(cc_span)) {
+ SS7_ERROR("Failed to parse \"cc_span\"\n");
+ return FTDM_FAIL;
+ }
+
+ /* go to the next cc_span */
+ cc_span = cc_span->next;
+ }
+
+ return FTDM_SUCCESS;
+
+}
+
+/******************************************************************************/
+static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
+{
+ sng_ccSpan_t sng_ccSpan;
+ ftdm_conf_parameter_t *parm = cc_span->parameters;
+ int num_parms = cc_span->n_parameters;
+ int flag_clg_nadi = 0;
+ int flag_cld_nadi = 0;
+ int i;
+ int ret;
+
+ /* initalize the ccSpan structure */
+ memset(&sng_ccSpan, 0x0, sizeof(sng_ccSpan));
+
+ /* confirm that we are looking at an mtp_link */
+ if (strcasecmp(cc_span->name, "cc_span")) {
+ SS7_ERROR("We're looking at \"%s\"...but we're supposed to be looking at \"cc_span\"!\n",cc_span->name);
+ return FTDM_FAIL;
+ } else {
+ SS7_DEBUG("Parsing \"cc_span\"...\n");
+ }
+
+
+ for (i = 0; i < num_parms; i++) {
+ /**************************************************************************/
+
+ /* try to match the parameter to what we expect */
+ if (!strcasecmp(parm->var, "name")) {
+ /**********************************************************************/
+ strcpy((char *)sng_ccSpan.name, parm->val);
+ SS7_DEBUG("Found an ccSpan named = %s\n", sng_ccSpan.name);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "id")) {
+ /**********************************************************************/
+ sng_ccSpan.id = atoi(parm->val);
+ SS7_DEBUG("Found an ccSpan id = %d\n", sng_ccSpan.id);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "procid")) {
+ /**********************************************************************/
+ sng_ccSpan.procId = atoi(parm->val);
+ SS7_DEBUG("Found an ccSpan procId = %d\n", sng_ccSpan.procId);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "ch_map")) {
+ /**********************************************************************/
+ strcpy(sng_ccSpan.ch_map, parm->val);
+ SS7_DEBUG("Found channel map %s\n", sng_ccSpan.ch_map);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "typeCntrl")) {
+ /**********************************************************************/
+ ret = find_cic_cntrl_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid ccSpan typeCntrl = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ sng_ccSpan.typeCntrl = sng_cic_cntrl_type_map[ret].tril_type;
+ SS7_DEBUG("Found an ccSpan typeCntrl = %s\n", sng_cic_cntrl_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "ssf")) {
+ /**********************************************************************/
+ ret = find_ssf_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid ccSpan ssf = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ sng_ccSpan.ssf = sng_ssf_type_map[ret].tril_type;
+ SS7_DEBUG("Found an ccSpan ssf = %s\n", sng_ssf_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "switchType")) {
+ /**********************************************************************/
+ ret = find_switch_type_in_map(parm->val);
+ if (ret == -1) {
+ SS7_ERROR("Found an invalid ccSpan switchType = %s\n", parm->var);
+ return FTDM_FAIL;
+ } else {
+ sng_ccSpan.switchType = sng_switch_type_map[ret].tril_isup_type;
+ SS7_DEBUG("Found an ccSpan switchType = %s\n", sng_switch_type_map[ret].sng_type);
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "cicbase")) {
+ /**********************************************************************/
+ sng_ccSpan.cicbase = atoi(parm->val);
+ SS7_DEBUG("Found a cicbase = %d\n", sng_ccSpan.cicbase);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup_interface")) {
+ /**********************************************************************/
+ sng_ccSpan.isupInf = atoi(parm->val);
+ SS7_DEBUG("Found an isup_interface = %d\n",sng_ccSpan.isupInf);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "min_digits")) {
+ /**********************************************************************/
+ sng_ccSpan.min_digits = atoi(parm->val);
+ SS7_DEBUG("Found a min_digits = %d\n",sng_ccSpan.min_digits);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "clg_nadi")) {
+ /**********************************************************************/
+ /* throw the flag so that we know we got this optional parameter */
+ flag_clg_nadi = 1;
+ sng_ccSpan.clg_nadi = atoi(parm->val);
+ SS7_DEBUG("Found default CLG_NADI parm->value = %d\n", sng_ccSpan.clg_nadi);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "cld_nadi")) {
+ /**********************************************************************/
+ /* throw the flag so that we know we got this optional parameter */
+ flag_cld_nadi = 1;
+ sng_ccSpan.cld_nadi = atoi(parm->val);
+ SS7_DEBUG("Found default CLD_NADI parm->value = %d\n", sng_ccSpan.cld_nadi);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "obci_bita")) {
+ /**********************************************************************/
+ if (*parm->val == '1') {
+ sngss7_set_options(&sng_ccSpan, SNGSS7_ACM_OBCI_BITA);
+ SS7_DEBUG("Found Optional Backwards Indicator: Bit A (early media) enable option\n");
+ } else if (*parm->val == '0') {
+ sngss7_clear_options(&sng_ccSpan, SNGSS7_ACM_OBCI_BITA);
+ SS7_DEBUG("Found Optional Backwards Indicator: Bit A (early media) disable option\n");
+ } else {
+ SS7_DEBUG("Invalid parm->value for obci_bita option\n");
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "lpa_on_cot")) {
+ /**********************************************************************/
+ if (*parm->val == '1') {
+ sngss7_set_options(&sng_ccSpan, SNGSS7_LPA_FOR_COT);
+ SS7_DEBUG("Found Tx LPA on COT enable option\n");
+ } else if (*parm->val == '0') {
+ sngss7_clear_options(&sng_ccSpan, SNGSS7_LPA_FOR_COT);
+ SS7_DEBUG("Found Tx LPA on COT disable option\n");
+ } else {
+ SS7_DEBUG("Invalid parm->value for lpa_on_cot option\n");
+ }
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t3")) {
+ /**********************************************************************/
+ sng_ccSpan.t3 = atoi(parm->val);
+ SS7_DEBUG("Found isup t3 = %d\n", sng_ccSpan.t3);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t12")) {
+ /**********************************************************************/
+ sng_ccSpan.t12 = atoi(parm->val);
+ SS7_DEBUG("Found isup t12 = %d\n", sng_ccSpan.t12);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t13")) {
+ /**********************************************************************/
+ sng_ccSpan.t13 = atoi(parm->val);
+ SS7_DEBUG("Found isup t13 = %d\n", sng_ccSpan.t13);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t14")) {
+ /**********************************************************************/
+ sng_ccSpan.t14 = atoi(parm->val);
+ SS7_DEBUG("Found isup t14 = %d\n", sng_ccSpan.t14);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t15")) {
+ /**********************************************************************/
+ sng_ccSpan.t15 = atoi(parm->val);
+ SS7_DEBUG("Found isup t15 = %d\n", sng_ccSpan.t15);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t16")) {
+ /**********************************************************************/
+ sng_ccSpan.t16 = atoi(parm->val);
+ SS7_DEBUG("Found isup t16 = %d\n", sng_ccSpan.t16);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t17")) {
+ /**********************************************************************/
+ sng_ccSpan.t17 = atoi(parm->val);
+ SS7_DEBUG("Found isup t17 = %d\n", sng_ccSpan.t17);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.t35")) {
+ /**********************************************************************/
+ sng_ccSpan.t35 = atoi(parm->val);
+ SS7_DEBUG("Found isup t35 = %d\n",sng_ccSpan.t35);
+ /**********************************************************************/
+ } else if (!strcasecmp(parm->var, "isup.tval")) {
+ /**********************************************************************/
+ sng_ccSpan.tval = atoi(parm->val);
+ SS7_DEBUG("Found isup tval = %d\n", sng_ccSpan.tval);
+ /**********************************************************************/
+ } else {
+ /**********************************************************************/
+ SS7_ERROR("Found an invalid parameter %s!\n", parm->var);
+ return FTDM_FAIL;
+ /**********************************************************************/
+ }
+
+ /* move to the next parameter */
+ parm = parm + 1;
+ /**************************************************************************/
+ } /* for (i = 0; i < num_parms; i++) */
+
+ /* check if the user filled in a nadi value by looking at flag */
+ if (!flag_cld_nadi) {
+ /* default the nadi value to national */
+ sng_ccSpan.cld_nadi = 0x03;
+ }
+
+ if (!flag_clg_nadi) {
+ /* default the nadi value to national */
+ sng_ccSpan.clg_nadi = 0x03;
+ }
+
+ /* add this span to our global listing */
+ ftmod_ss7_fill_in_ccSpan(&sng_ccSpan);
+
+ /* make sure the isup interface structure has something in it */
+ if (g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].id == 0) {
+ /* fill in the id, so that we know it exists */
+ g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].id = sng_ccSpan.isupInf;
+
+ /* default the status to PAUSED */
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf], SNGSS7_PAUSED);
+ }
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_fill_in_relay_channel(sng_relay_t *relay_channel)
{
int i;
- /* go through all the existing links and see if we find a match */
+ /* go through all the existing channels and see if we find a match */
i = 1;
- while (g_ftdm_sngss7_data.cfg.mtpLink[i].id != 0) {
- if ((g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.span == mtpLink->mtp1.span) &&
- (g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.chan == mtpLink->mtp1.chan)) {
+ while (g_ftdm_sngss7_data.cfg.relay[i].id != 0) {
+ if ((g_ftdm_sngss7_data.cfg.relay[i].type == relay_channel->type) &&
+ (g_ftdm_sngss7_data.cfg.relay[i].port == relay_channel->port) &&
+ (g_ftdm_sngss7_data.cfg.relay[i].procId == relay_channel->procId) &&
+ (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[i].hostname, relay_channel->hostname))) {
/* we have a match so break out of this loop */
break;
@@ -1355,178 +2069,272 @@ static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink)
i++;
}
- /* if the id value is 0 that means we didn't find the link */
- if (g_ftdm_sngss7_data.cfg.mtpLink[i].id == 0) {
- mtpLink->id = i;
- SS7_DEBUG("found new mtpLink on span=%d, chan=%d, id = %d\n",
- mtpLink->mtp1.span,
- mtpLink->mtp1.chan,
- mtpLink->id);
+ /* if the id value is 0 that means we didn't find the relay channel */
+ if (g_ftdm_sngss7_data.cfg.relay[i].id == 0) {
+ relay_channel->id = i;
+ SS7_DEBUG("found new relay channel on type:%d, hostname:%s, port:%d, procId:%d, id = %d\n",
+ relay_channel->type,
+ relay_channel->hostname,
+ relay_channel->port,
+ relay_channel->procId,
+ relay_channel->id);
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY);
} else {
- mtpLink->id = i;
- SS7_DEBUG("found existing mtpLink on span=%d, chan=%d, id = %d\n",
- mtpLink->mtp1.span,
- mtpLink->mtp1.chan,
- mtpLink->id);
+ relay_channel->id = i;
+ SS7_DEBUG("found existing relay channel on type:%d, hostname:%s, port:%d, procId:%d, id = %d\n",
+ relay_channel->type,
+ relay_channel->hostname,
+ relay_channel->port,
+ relay_channel->procId,
+ relay_channel->id);
}
- /* fill in the information */
- strncpy((char *)g_ftdm_sngss7_data.cfg.mtpLink[i].name, (char *)mtpLink->name, MAX_NAME_LEN-1);
+ g_ftdm_sngss7_data.cfg.relay[i].id = relay_channel->id;
+ g_ftdm_sngss7_data.cfg.relay[i].type = relay_channel->type;
+ g_ftdm_sngss7_data.cfg.relay[i].port = relay_channel->port;
+ g_ftdm_sngss7_data.cfg.relay[i].procId = relay_channel->procId;
+ strcpy(g_ftdm_sngss7_data.cfg.relay[i].hostname, relay_channel->hostname);
+ strcpy(g_ftdm_sngss7_data.cfg.relay[i].name, relay_channel->name);
- g_ftdm_sngss7_data.cfg.mtpLink[i].id = mtpLink->id;
-
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.span = mtpLink->mtp1.span;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.chan = mtpLink->mtp1.chan;
-
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.linkType = mtpLink->mtp2.linkType;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.errorType = mtpLink->mtp2.errorType;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.lssuLength = mtpLink->mtp2.lssuLength;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.mtp1Id = mtpLink->id;
-
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.priority = mtpLink->mtp3.priority;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.linkType = mtpLink->mtp3.linkType;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.switchType = mtpLink->mtp3.switchType;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.apc = mtpLink->mtp3.apc;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.spc = g_ftdm_sngss7_data.cfg.spc;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.ssf = mtpLink->mtp3.ssf;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.slc = mtpLink->mtp3.slc;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.linkSetId = mtpLink->mtp3.linkSetId;
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.mtp2Id = mtpLink->id;
-
- if ( mtpLink->mtp2.t1 != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t1 = mtpLink->mtp2.t1;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t1 = 500;
- }
- if ( mtpLink->mtp2.t2 != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t2 = mtpLink->mtp2.t2;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t2 = 250;
- }
- if ( mtpLink->mtp2.t3 != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t3 = mtpLink->mtp2.t3;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t3 = 20;
- }
- if ( mtpLink->mtp2.t4n != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4n = mtpLink->mtp2.t4n;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4n = 80;
- }
- if ( mtpLink->mtp2.t4e != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4e = mtpLink->mtp2.t4e;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4e = 5;
- }
- if ( mtpLink->mtp2.t5 != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t5 = mtpLink->mtp2.t5;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t5 = 1;
- }
- if ( mtpLink->mtp2.t6 != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t6 = mtpLink->mtp2.t6;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t6 = 60;
- }
- if ( mtpLink->mtp2.t7 != 0 ) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t7 = mtpLink->mtp2.t7;
- }else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t7 = 40;
+ /* if this is THE listen channel grab the procId and use it */
+ if (relay_channel->type == LRY_CT_TCP_LISTEN) {
+ g_ftdm_sngss7_data.cfg.procId = relay_channel->procId;
}
- if (mtpLink->mtp3.t1 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t1 = mtpLink->mtp3.t1;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t1 = 8;
- }
- if (mtpLink->mtp3.t2 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t2 = mtpLink->mtp3.t2;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t2 = 14;
- }
- if (mtpLink->mtp3.t3 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t3 = mtpLink->mtp3.t3;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t3 = 8;
- }
- if (mtpLink->mtp3.t4 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t4 = mtpLink->mtp3.t4;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t4 = 8;
- }
- if (mtpLink->mtp3.t5 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t5 = mtpLink->mtp3.t5;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t5 = 8;
- }
- if (mtpLink->mtp3.t7 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t7 = mtpLink->mtp3.t7;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t7 = 15;
- }
- if (mtpLink->mtp3.t12 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t12 = mtpLink->mtp3.t12;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t12 = 15;
- }
- if (mtpLink->mtp3.t13 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t13 = mtpLink->mtp3.t13;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t13 = 15;
- }
- if (mtpLink->mtp3.t14 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t14 = mtpLink->mtp3.t14;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t14 = 30;
- }
- if (mtpLink->mtp3.t17 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t17 = mtpLink->mtp3.t17;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t17 = 15;
- }
- if (mtpLink->mtp3.t22 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t22 = mtpLink->mtp3.t22;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t22 = 1800;
- }
- if (mtpLink->mtp3.t23 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t23 = mtpLink->mtp3.t23;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t23 = 1800;
- }
- if (mtpLink->mtp3.t24 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t24 = mtpLink->mtp3.t24;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t24 = 5;
- }
- if (mtpLink->mtp3.t31 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t31 = mtpLink->mtp3.t31;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t31 = 50;
- }
- if (mtpLink->mtp3.t32 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t32 = mtpLink->mtp3.t32;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t32 = 120;
- }
- if (mtpLink->mtp3.t33 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t33 = mtpLink->mtp3.t33;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t33 = 3000;
- }
- if (mtpLink->mtp3.t34 != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t34 = mtpLink->mtp3.t34;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t34 = 600;
- }
- if (mtpLink->mtp3.tflc != 0) {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.tflc = mtpLink->mtp3.tflc;
- } else {
- g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.tflc = 300;
- }
- return (mtpLink->id);
+ return FTDM_SUCCESS;
}
+/******************************************************************************/
+static int ftmod_ss7_fill_in_mtp1_link(sng_mtp1_link_t *mtp1Link)
+{
+ int i = mtp1Link->id;
+
+ /* check if this id value has been used already */
+ if (g_ftdm_sngss7_data.cfg.mtp1Link[i].id == 0) {
+ SS7_DEBUG("Found new MTP1 Link: id=%d, name=%s\n", mtp1Link->id, mtp1Link->name);
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP1);
+ } else {
+ SS7_DEBUG("Found an existing MTP1 Link: id=%d, name=%s (old name=%s)\n",
+ mtp1Link->id,
+ mtp1Link->name,
+ g_ftdm_sngss7_data.cfg.mtp1Link[i].name);
+ }
+
+ /* copy over the values */
+ strcpy((char *)g_ftdm_sngss7_data.cfg.mtp1Link[i].name, (char *)mtp1Link->name);
+
+ g_ftdm_sngss7_data.cfg.mtp1Link[i].id = mtp1Link->id;
+ g_ftdm_sngss7_data.cfg.mtp1Link[i].span = mtp1Link->span;
+ g_ftdm_sngss7_data.cfg.mtp1Link[i].chan = mtp1Link->chan;
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_fill_in_mtp2_link(sng_mtp2_link_t *mtp2Link)
+{
+ int i = mtp2Link->id;
+
+ /* check if this id value has been used already */
+ if (g_ftdm_sngss7_data.cfg.mtp2Link[i].id == 0) {
+ SS7_DEBUG("Found new MTP2 Link: id=%d, name=%s\n", mtp2Link->id, mtp2Link->name);
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2);
+ } else {
+ SS7_DEBUG("Found an existing MTP2 Link: id=%d, name=%s (old name=%s)\n",
+ mtp2Link->id,
+ mtp2Link->name,
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].name);
+ }
+
+ /* copy over the values */
+ strcpy((char *)g_ftdm_sngss7_data.cfg.mtp2Link[i].name, (char *)mtp2Link->name);
+
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].id = mtp2Link->id;
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].lssuLength = mtp2Link->lssuLength;
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].errorType = mtp2Link->errorType;
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].linkType = mtp2Link->linkType;
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].mtp1Id = mtp2Link->mtp1Id;
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].mtp1ProcId = mtp2Link->mtp1ProcId;
+
+ if ( mtp2Link->t1 != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t1 = mtp2Link->t1;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t1 = 500;
+ }
+
+ if ( mtp2Link->t2 != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t2 = mtp2Link->t2;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t2 = 250;
+ }
+
+ if ( mtp2Link->t3 != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t3 = mtp2Link->t3;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t3 = 20;
+ }
+
+ if ( mtp2Link->t4n != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t4n = mtp2Link->t4n;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t4n = 80;
+ }
+
+ if ( mtp2Link->t4e != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t4e = mtp2Link->t4e;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t4e = 5;
+ }
+
+ if ( mtp2Link->t5 != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t5 = mtp2Link->t5;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t5 = 1;
+ }
+
+ if ( mtp2Link->t6 != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t6 = mtp2Link->t6;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t6 = 60;
+ }
+
+ if ( mtp2Link->t7 != 0 ) {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t7 = mtp2Link->t7;
+ }else {
+ g_ftdm_sngss7_data.cfg.mtp2Link[i].t7 = 40;
+ }
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_fill_in_mtp3_link(sng_mtp3_link_t *mtp3Link)
+{
+ int i = mtp3Link->id;
+
+ /* check if this id value has been used already */
+ if (g_ftdm_sngss7_data.cfg.mtp3Link[i].id == 0) {
+ SS7_DEBUG("Found new MTP3 Link: id=%d, name=%s\n", mtp3Link->id, mtp3Link->name);
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3);
+ } else {
+ SS7_DEBUG("Found an existing MTP3 Link: id=%d, name=%s (old name=%s)\n",
+ mtp3Link->id,
+ mtp3Link->name,
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].name);
+ }
+
+ /* copy over the values */
+ strcpy((char *)g_ftdm_sngss7_data.cfg.mtp3Link[i].name, (char *)mtp3Link->name);
+
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].id = mtp3Link->id;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].priority = mtp3Link->priority;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].linkType = mtp3Link->linkType;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].switchType = mtp3Link->switchType;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtp3Link->apc;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].spc = mtp3Link->spc; /* unknown at this time */
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].ssf = mtp3Link->ssf;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].slc = mtp3Link->slc;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId = mtp3Link->linkSetId;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].mtp2Id = mtp3Link->mtp2Id;
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].mtp2ProcId = mtp3Link->mtp2ProcId;
+
+ if (mtp3Link->t1 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t1 = mtp3Link->t1;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t1 = 8;
+ }
+ if (mtp3Link->t2 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t2 = mtp3Link->t2;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t2 = 14;
+ }
+ if (mtp3Link->t3 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t3 = mtp3Link->t3;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t3 = 8;
+ }
+ if (mtp3Link->t4 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t4 = mtp3Link->t4;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t4 = 8;
+ }
+ if (mtp3Link->t5 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t5 = mtp3Link->t5;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t5 = 8;
+ }
+ if (mtp3Link->t7 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t7 = mtp3Link->t7;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t7 = 15;
+ }
+ if (mtp3Link->t12 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t12 = mtp3Link->t12;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t12 = 15;
+ }
+ if (mtp3Link->t13 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t13 = mtp3Link->t13;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t13 = 15;
+ }
+ if (mtp3Link->t14 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t14 = mtp3Link->t14;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t14 = 30;
+ }
+ if (mtp3Link->t17 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t17 = mtp3Link->t17;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t17 = 15;
+ }
+ if (mtp3Link->t22 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t22 = mtp3Link->t22;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t22 = 1800;
+ }
+ if (mtp3Link->t23 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t23 = mtp3Link->t23;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t23 = 1800;
+ }
+ if (mtp3Link->t24 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t24 = mtp3Link->t24;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t24 = 5;
+ }
+ if (mtp3Link->t31 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t31 = mtp3Link->t31;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t31 = 50;
+ }
+ if (mtp3Link->t32 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t32 = mtp3Link->t32;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t32 = 120;
+ }
+ if (mtp3Link->t33 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t33 = mtp3Link->t33;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t33 = 3000;
+ }
+ if (mtp3Link->t34 != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t34 = mtp3Link->t34;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].t34 = 600;
+ }
+ if (mtp3Link->tbnd != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].tbnd = mtp3Link->tbnd;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].tbnd = 30000;
+ }
+ if (mtp3Link->tflc != 0) {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].tflc = mtp3Link->tflc;
+ } else {
+ g_ftdm_sngss7_data.cfg.mtp3Link[i].tflc = 300;
+ }
+ return FTDM_SUCCESS;
+}
/******************************************************************************/
static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)
@@ -1537,9 +2345,6 @@ static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)
g_ftdm_sngss7_data.cfg.mtpLinkSet[i].id = mtpLinkSet->id;
g_ftdm_sngss7_data.cfg.mtpLinkSet[i].apc = mtpLinkSet->apc;
- g_ftdm_sngss7_data.cfg.mtpLinkSet[i].linkType = mtpLinkSet->linkType;
- g_ftdm_sngss7_data.cfg.mtpLinkSet[i].switchType = mtpLinkSet->switchType;
- g_ftdm_sngss7_data.cfg.mtpLinkSet[i].ssf = mtpLinkSet->ssf;
/* these values are filled in as we find routes and start allocating cmbLinkSetIds */
g_ftdm_sngss7_data.cfg.mtpLinkSet[i].minActive = mtpLinkSet->minActive;
@@ -1550,28 +2355,37 @@ static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)
/******************************************************************************/
static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
{
- int i;
+ sng_link_set_list_t *lnkSet = NULL;
+ int i = mtp3_route->id;
+ int tmp = 0;
- /* go through all the existing routes and see if we find a match */
- i = 1;
- while (g_ftdm_sngss7_data.cfg.mtpRoute[i].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpRoute[i].name, mtp3_route->name)) {
- /* we have a match so break out of this loop */
- break;
- }
- /* move on to the next one */
- i++;
- }
+ /* check if this id value has been used already */
if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
- mtp3_route->id = i;
- SS7_DEBUG("found new mtp3_route, id is = %d\n", mtp3_route->id);
+ SS7_DEBUG("Found new MTP3 Link: id=%d, name=%s\n", mtp3_route->id, mtp3_route->name);
} else {
- mtp3_route->id = i;
- SS7_DEBUG("found existing mtp3_route, id is = %d\n", mtp3_route->id);
+ SS7_DEBUG("Found an existing MTP3 Link: id=%d, name=%s (old name=%s)\n",
+ mtp3_route->id,
+ mtp3_route->name,
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].name);
}
- strncpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, (char *)mtp3_route->name, MAX_NAME_LEN-1);
+ /* fill in the cmbLinkSet in the linkset structure */
+ lnkSet = &mtp3_route->lnkSets;
+
+ tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks;
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[tmp] = mtp3_route->cmbLinkSetId;
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++;
+
+ while (lnkSet->next != NULL) {
+ tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks;
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[tmp] = mtp3_route->cmbLinkSetId;
+ g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++;
+
+ lnkSet = lnkSet->next;
+ }
+
+ strcpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, (char *)mtp3_route->name);
g_ftdm_sngss7_data.cfg.mtpRoute[i].id = mtp3_route->id;
g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc = mtp3_route->dpc;
@@ -1580,8 +2394,9 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId = mtp3_route->cmbLinkSetId;
g_ftdm_sngss7_data.cfg.mtpRoute[i].isSTP = mtp3_route->isSTP;
g_ftdm_sngss7_data.cfg.mtpRoute[i].nwId = mtp3_route->nwId;
- g_ftdm_sngss7_data.cfg.mtpRoute[i].linkSetId = mtp3_route->linkSetId;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].lnkSets = mtp3_route->lnkSets;
g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf = mtp3_route->ssf;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].dir = SNG_RTE_DN;
if (mtp3_route->t6 != 0) {
g_ftdm_sngss7_data.cfg.mtpRoute[i].t6 = mtp3_route->t6;
} else {
@@ -1641,6 +2456,52 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
return 0;
}
+/******************************************************************************/
+static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf)
+{
+ int i = 1;
+
+ while (g_ftdm_sngss7_data.cfg.mtpRoute[i].id != 0) {
+ if (g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc == spc) {
+ /* we have a match so break out of this loop */
+ break;
+ }
+ /* move on to the next one */
+ i++;
+ }
+
+ if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i;
+ SS7_DEBUG("found new mtp3 self route\n");
+ } else {
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i;
+ SS7_DEBUG("found existing mtp3 self route\n");
+ }
+
+ strncpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, "self-route", MAX_NAME_LEN-1);
+
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc = spc;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType = linkType;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType = switchType;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId = i;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].isSTP = 0;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf = ssf;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].dir = SNG_RTE_UP;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t6 = 8;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t8 = 12;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t10 = 300;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t11 = 300;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t15 = 30;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t16 = 20;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t18 = 200;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t19 = 690;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t21 = 650;
+ g_ftdm_sngss7_data.cfg.mtpRoute[i].t25 = 100;
+
+ return 0;
+}
+
/******************************************************************************/
static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)
{
@@ -1650,8 +2511,7 @@ static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)
i = 1;
while (g_ftdm_sngss7_data.cfg.nsap[i].id != 0) {
if ((g_ftdm_sngss7_data.cfg.nsap[i].linkType == mtp3_route->linkType) &&
- (g_ftdm_sngss7_data.cfg.nsap[i].switchType == mtp3_route->switchType) &&
- (g_ftdm_sngss7_data.cfg.nsap[i].ssf == mtp3_route->ssf)) {
+ (g_ftdm_sngss7_data.cfg.nsap[i].switchType == mtp3_route->switchType)) {
/* we have a match so break out of this loop */
break;
@@ -1662,11 +2522,9 @@ static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)
if (g_ftdm_sngss7_data.cfg.nsap[i].id == 0) {
g_ftdm_sngss7_data.cfg.nsap[i].id = i;
- mtp3_route->nwId = i;
SS7_DEBUG("found new mtp3_isup interface, id is = %d\n", g_ftdm_sngss7_data.cfg.nsap[i].id);
} else {
g_ftdm_sngss7_data.cfg.nsap[i].id = i;
- mtp3_route->nwId = i;
SS7_DEBUG("found existing mtp3_isup interface, id is = %d\n", g_ftdm_sngss7_data.cfg.nsap[i].id);
}
@@ -1683,26 +2541,17 @@ static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)
/******************************************************************************/
static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
{
- int i;
-
- /* go through all the existing interfaces and see if we find a match */
- i = 1;
- while (g_ftdm_sngss7_data.cfg.isupIntf[i].id != 0) {
- if (!strcasecmp(g_ftdm_sngss7_data.cfg.isupIntf[i].name, sng_isup->name)) {
-
- /* we have a match so break out of this loop */
- break;
- }
- /* move on to the next one */
- i++;
- }
+ int i = sng_isup->id;
+ /* check if this id value has been used already */
if (g_ftdm_sngss7_data.cfg.isupIntf[i].id == 0) {
- sng_isup->id = i;
- SS7_DEBUG("found new isup interface, id is = %d\n", sng_isup->id);
+ SS7_DEBUG("Found new ISUP Interface: id=%d, name=%s\n", sng_isup->id, sng_isup->name);
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP);
} else {
- sng_isup->id = i;
- SS7_DEBUG("found existing isup interface, id is = %d\n", sng_isup->id);
+ SS7_DEBUG("Found an existing ISUP Interface: id=%d, name=%s (old name=%s)\n",
+ sng_isup->id,
+ sng_isup->name,
+ g_ftdm_sngss7_data.cfg.isupIntf[i].name);
}
strncpy((char *)g_ftdm_sngss7_data.cfg.isupIntf[i].name, (char *)sng_isup->name, MAX_NAME_LEN-1);
@@ -1715,9 +2564,6 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
g_ftdm_sngss7_data.cfg.isupIntf[i].switchType = sng_isup->switchType;
g_ftdm_sngss7_data.cfg.isupIntf[i].ssf = sng_isup->ssf;
g_ftdm_sngss7_data.cfg.isupIntf[i].isap = sng_isup->isap;
- g_ftdm_sngss7_data.cfg.isupIntf[i].cld_nadi = sng_isup->cld_nadi;
- g_ftdm_sngss7_data.cfg.isupIntf[i].clg_nadi = sng_isup->clg_nadi;
- g_ftdm_sngss7_data.cfg.isupIntf[i].min_digits = sng_isup->min_digits;
g_ftdm_sngss7_data.cfg.isupIntf[i].options = sng_isup->options;
if (sng_isup->t4 != 0) {
g_ftdm_sngss7_data.cfg.isupIntf[i].t4 = sng_isup->t4;
@@ -1799,11 +2645,6 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
} else {
g_ftdm_sngss7_data.cfg.isupIntf[i].t32 = 30;
}
- if (sng_isup->t35 != 0) {
- g_ftdm_sngss7_data.cfg.isupIntf[i].t35 = sng_isup->t35;
- } else {
- g_ftdm_sngss7_data.cfg.isupIntf[i].t35 = 170;
- }
if (sng_isup->t37 != 0) {
g_ftdm_sngss7_data.cfg.isupIntf[i].t37 = sng_isup->t37;
} else {
@@ -1857,10 +2698,10 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap)
if (g_ftdm_sngss7_data.cfg.isap[i].id == 0) {
sng_isap->id = i;
- SS7_DEBUG("found new isup to cc interface, id is = %d\n", g_ftdm_sngss7_data.cfg.isap[i].id);
+ SS7_DEBUG("found new isup to cc interface, id is = %d\n", sng_isap->id);
} else {
sng_isap->id = i;
- SS7_DEBUG("found existing isup to cc interface, id is = %d\n", g_ftdm_sngss7_data.cfg.isap[i].id);
+ SS7_DEBUG("found existing isup to cc interface, id is = %d\n", sng_isap->id);
}
g_ftdm_sngss7_data.cfg.isap[i].id = sng_isap->id;
@@ -1974,265 +2815,247 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap)
}
/******************************************************************************/
-static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf)
+static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)
{
-
- if (g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc == 0){
- SS7_DEBUG("found new mtp3 self route\n");
- } else if (g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc == spc) {
- SS7_DEBUG("found existing mtp3 self route\n");
- return FTDM_SUCCESS;
- } else {
- SS7_ERROR("found new mtp3 self route but it does not match the route already configured (dpc=%d:spc=%d)\n",
- g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc,
- spc);
- return FTDM_FAIL;
- }
-
- strncpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[0].name, "self-route", MAX_NAME_LEN-1);
-
- g_ftdm_sngss7_data.cfg.mtpRoute[0].id = 0;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc = spc;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].linkType = linkType;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].switchType = switchType;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].cmbLinkSetId = 0;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].isSTP = 0;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].ssf = ssf;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t6 = 8;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t8 = 12;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t10 = 300;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t11 = 300;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t15 = 30;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t16 = 20;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t18 = 200;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t19 = 690;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t21 = 650;
- g_ftdm_sngss7_data.cfg.mtpRoute[0].t25 = 100;
-
- return 0;
-}
-
-/******************************************************************************/
-static int ftmod_ss7_fill_in_circuits(sng_isupCkt_t *isupCkt)
-{
- sngss7_chan_data_t *ss7_info = NULL;
- ftdm_channel_t *ftdmchan = NULL;
sng_timeslot_t timeslot;
- int count;
- int i;
+ sngss7_chan_data_t *ss7_info = NULL;
int x;
+ int count = 1;
+ int flag;
- count = 1;
+ while (ccSpan->ch_map[0] != '\0') {
+ /**************************************************************************/
- while (isupCkt->ch_map[0] != '\0') {
-
- /* pull out the next timeslot */
- if (ftmod_ss7_next_timeslot(isupCkt->ch_map, ×lot)) {
+ /* pull out the next timeslot */
+ if (ftmod_ss7_next_timeslot(ccSpan->ch_map, ×lot)) {
SS7_ERROR("Failed to parse the channel map!\n");
return FTDM_FAIL;
}
- if ((timeslot.siglink) || (timeslot.gap)) {
- /* try to find the channel in the circuits structure*/
- x = 1;
- while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
- if ((g_ftdm_sngss7_data.cfg.isupCkt[x].chan == count) &&
- (g_ftdm_sngss7_data.cfg.isupCkt[x].span == isupCkt->span->channels[1]->physical_span_id)) {
-
- SS7_DEVEL_DEBUG("Circuit for span=%d, chan=%d is already exists...id=%d\n",
- isupCkt->span->channels[1]->physical_span_id,
- count,
- x);
-
- /* we have a match so this circuit already exists in the structure */
- break;
- }
- /* move to the next circuit */
- x++;
- } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
-
- /* check why we exited the while loop */
+ /* find a spot for this circuit in the global structure */
+ x = (ccSpan->procId * 1000) + 1;
+ flag = 0;
+ while (flag == 0) {
+ /**********************************************************************/
+ /* check the id value ( 0 = new, 0 > circuit can be existing) */
if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) {
- SS7_DEVEL_DEBUG("Circuit for span=%d, chan=%d is new...id=%d\n",
- isupCkt->span->channels[1]->physical_span_id,
- count,
- x);
+ /* we're at the end of the list of circuitsl aka this is new */
+ SS7_DEBUG("Found a new circuit %d, ccSpanId=%d, chan=%d\n",
+ x,
+ ccSpan->id,
+ count);
- /* prepare the global info sturcture */
- ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));
- ss7_info->ftdmchan = NULL;
- ss7_info->circuit = &g_ftdm_sngss7_data.cfg.isupCkt[x];
-
- /* circuit is new so fill in the needed information */
- g_ftdm_sngss7_data.cfg.isupCkt[x].id = x;
- g_ftdm_sngss7_data.cfg.isupCkt[x].span = isupCkt->span->channels[1]->physical_span_id;
- g_ftdm_sngss7_data.cfg.isupCkt[x].chan = count;
- if (timeslot.siglink) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].type = SIG;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].type = HOLE;
- }
-
- if (timeslot.channel) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].cic = isupCkt->cicbase;
- isupCkt->cicbase++;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].cic = 0;
- }
- g_ftdm_sngss7_data.cfg.isupCkt[x].infId = isupCkt->isupInf;
- g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl = isupCkt->typeCntrl;
- g_ftdm_sngss7_data.cfg.isupCkt[x].ssf = g_ftdm_sngss7_data.cfg.isupIntf[isupCkt->isupInf].ssf;
- g_ftdm_sngss7_data.cfg.isupCkt[x].obj = ss7_info;
-
- } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) */
-
- /* increment the span channel count */
- count++;
-
- } else { /* if ((timeslot.siglink) || (timeslot.gap)) */
- /* find the ftdm the channel structure for this channel*/
- i = 1;
- while (isupCkt->span->channels[i] != NULL) {
- if (isupCkt->span->channels[i]->physical_chan_id == timeslot.channel) {
- break;
- }
- i++;
- } /* while (span->channels[i] != NULL) */
-
- if (isupCkt->span->channels[i] == NULL) {
- /* we weren't able to find the channel in the ftdm channels */
- SS7_ERROR("Unable to find the requested channel %d in the FreeTDM channels!\n", timeslot.channel);
- return FTDM_FAIL;
+ /* throw the flag to end the loop */
+ flag = 1;
} else {
- ftdmchan = isupCkt->span->channels[i];
+ /* check the ccspan.id and chan to see if the circuit already exists */
+ if ((g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId == ccSpan->id) &&
+ (g_ftdm_sngss7_data.cfg.isupCkt[x].chan == count)) {
+
+ /* we are processing a circuit that already exists */
+ SS7_DEBUG("Found an existing circuit %d, ccSpanId=%d, chan%d\n",
+ x,
+ ccSpan->id,
+ count);
+
+ /* throw the flag to end the loop */
+ flag = 1;
+
+ /* not supporting reconfig at this time */
+ SS7_DEBUG("Not supporting ckt reconfig at this time!\n");
+ goto move_along;
+ } else {
+ /* this is not the droid you are looking for */
+ x++;
+ }
+ }
+ /**********************************************************************/
+ } /* while (flag == 0) */
+
+ /* prepare the global info sturcture */
+ ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));
+ ss7_info->ftdmchan = NULL;
+ ss7_info->circuit = &g_ftdm_sngss7_data.cfg.isupCkt[x];
+
+ g_ftdm_sngss7_data.cfg.isupCkt[x].obj = ss7_info;
+
+ /* fill in the rest of the global structure */
+ g_ftdm_sngss7_data.cfg.isupCkt[x].procId = ccSpan->procId;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id = x;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId = ccSpan->id;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].span = 0;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].chan = count;
+
+ if (timeslot.siglink) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].type = SIG;
+ } else if (timeslot.gap) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].type = HOLE;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].type = VOICE;
+
+ /* throw the flag to indicate that we need to start call control */
+ sngss7_set_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC);
+ }
+
+ if (timeslot.channel) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic = ccSpan->cicbase;
+ ccSpan->cicbase++;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic = 0;
+ }
+
+ g_ftdm_sngss7_data.cfg.isupCkt[x].infId = ccSpan->isupInf;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl = ccSpan->typeCntrl;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].ssf = ccSpan->ssf;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cld_nadi = ccSpan->cld_nadi;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].clg_nadi = ccSpan->clg_nadi;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].options = ccSpan->options;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].switchType = ccSpan->switchType;
+ g_ftdm_sngss7_data.cfg.isupCkt[x].min_digits = ccSpan->min_digits;
+
+ if (ccSpan->t3 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = 1200;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = ccSpan->t3;
+ }
+ if (ccSpan->t12 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t12 = 300;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t12 = ccSpan->t12;
+ }
+ if (ccSpan->t13 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t13 = 3000;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t13 = ccSpan->t13;
+ }
+ if (ccSpan->t14 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t14 = 300;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t14 = ccSpan->t14;
+ }
+ if (ccSpan->t15 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t15 = 3000;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t15 = ccSpan->t15;
+ }
+ if (ccSpan->t16 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t16 = 300;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t16 = ccSpan->t16;
+ }
+ if (ccSpan->t17 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = 3000;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = ccSpan->t17;
+ }
+ if (ccSpan->t35 == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = 170;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = ccSpan->t35;
+ }
+ if (ccSpan->tval == 0) {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].tval = 10;
+ } else {
+ g_ftdm_sngss7_data.cfg.isupCkt[x].tval = ccSpan->tval;
+ }
+
+ SS7_INFO("Added procId=%d, spanId = %d, chan = %d, cic = %d, ISUP cirId = %d\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[x].procId,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].chan,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+
+move_along:
+ /* increment the span channel count */
+ count++;
+
+ /**************************************************************************/
+ } /* while (ccSpan->ch_map[0] != '\0') */
+
+
+ return FTDM_SUCCESS;
+}
+
+/******************************************************************************/
+static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan)
+{
+ ftdm_channel_t *ftdmchan = NULL;
+ ftdm_span_t *ftdmspan = sngSpan->span;
+ sng_isup_ckt_t *isupCkt = NULL;
+ sngss7_chan_data_t *ss7_info = NULL;
+ int flag;
+ int i;
+ int x;
+
+ /* go through all the channels on ftdm span */
+ for (i = 1; i < (ftdmspan->chan_count+1); i++) {
+ /**************************************************************************/
+
+ /* extract the ftdmchan pointer */
+ ftdmchan = ftdmspan->channels[i];
+
+ /* find the equivalent channel in the global structure */
+ x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
+ flag = 0;
+ while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
+ /**********************************************************************/
+ /* pull out the circuit to make it easier to work with */
+ isupCkt = &g_ftdm_sngss7_data.cfg.isupCkt[x];
+
+ /* if the ccSpanId's match fill in the span value...this is for sigs
+ * because they will never have a channel that matches since they
+ * have a ftdmchan at this time */
+ if (sngSpan->ccSpanId == isupCkt->ccSpanId) {
+ isupCkt->span = ftdmchan->physical_span_id;
}
- /* try to find a match for the physical span and chan */
- x = 1;
- while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
- if ((g_ftdm_sngss7_data.cfg.isupCkt[x].chan == ftdmchan->physical_chan_id) &&
- (g_ftdm_sngss7_data.cfg.isupCkt[x].span == ftdmchan->physical_span_id)) {
+ /* check if the ccSpanId matches and the physical channel # match */
+ if ((sngSpan->ccSpanId == isupCkt->ccSpanId) &&
+ (ftdmchan->physical_chan_id == isupCkt->chan)) {
- /* we have a match so this circuit already exists in the structure */
- break;
- }
- /* move to the next circuit */
- x++;
- } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
+ /* we've found the channel in the ckt structure...raise the flag */
+ flag = 1;
- /* check why we exited the while loop */
- if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) {
- SS7_DEVEL_DEBUG("Circuit for span=%d, chan=%d is new...id=%d\n",
- ftdmchan->physical_span_id,
- ftdmchan->physical_chan_id,
- x);
+ /* now get out of the loop */
+ break;
+ }
- /* prepare the global info sturcture */
- ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));
- ss7_info->ftdmchan = ftdmchan;
- ss7_info->circuit = &g_ftdm_sngss7_data.cfg.isupCkt[x];
- ftdmchan->call_data = ss7_info;
+ /* move to the next ckt */
+ x++;
- /* prepare the timer structures */
- ss7_info->t35.sched = ((sngss7_span_data_t *)isupCkt->span->signal_data)->sched;
- ss7_info->t35.counter = 1;
- ss7_info->t35.beat = g_ftdm_sngss7_data.cfg.isupIntf[isupCkt->isupInf].t35*100; /* beat is in ms, t35 is in 100ms */
- ss7_info->t35.callback = handle_isup_t35;
- ss7_info->t35.sngss7_info = ss7_info;
+ /* check if we are outside of the range of possible indexes */
+ if (x == ((g_ftdm_sngss7_data.cfg.procId + 1) * 1000)) {
+ break;
+ }
+ /**********************************************************************/
+ } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
- /* circuit is new so fill in the needed information */
- g_ftdm_sngss7_data.cfg.isupCkt[x].id = x;
- g_ftdm_sngss7_data.cfg.isupCkt[x].span = ftdmchan->physical_span_id;
- g_ftdm_sngss7_data.cfg.isupCkt[x].chan = ftdmchan->physical_chan_id;
- g_ftdm_sngss7_data.cfg.isupCkt[x].type = VOICE;
- g_ftdm_sngss7_data.cfg.isupCkt[x].cic = isupCkt->cicbase;
- g_ftdm_sngss7_data.cfg.isupCkt[x].infId = isupCkt->isupInf;
- g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl = isupCkt->typeCntrl;
- if (isupCkt->t3 == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = 1200;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = isupCkt->t3;
- }
- if (isupCkt->t12 == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t12 = 300;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t12 = isupCkt->t12;
- }
- if (isupCkt->t13 == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t13 = 3000;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t13 = isupCkt->t13;
- }
- if (isupCkt->t14 == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t14 = 300;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t14 = isupCkt->t14;
- }
- if (isupCkt->t15 == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t15 = 3000;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t15 = isupCkt->t15;
- }
- if (isupCkt->t16 == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t16 = 300;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t16 = isupCkt->t16;
- }
- if (isupCkt->t17 == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = 3000;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].t17 = isupCkt->t17;
- }
- if (isupCkt->tval == 0) {
- g_ftdm_sngss7_data.cfg.isupCkt[x].tval = 10;
- } else {
- g_ftdm_sngss7_data.cfg.isupCkt[x].tval = isupCkt->tval;
- }
- g_ftdm_sngss7_data.cfg.isupCkt[x].obj = ss7_info;
- g_ftdm_sngss7_data.cfg.isupCkt[x].ssf = g_ftdm_sngss7_data.cfg.isupIntf[isupCkt->isupInf].ssf;
-
- /* increment the cicbase */
- isupCkt->cicbase++;
- } else { /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) */
- SS7_DEBUG("Circuit for span=%d, chan=%d is new...id=%d\n",
- ftdmchan->physical_span_id,
- ftdmchan->physical_chan_id,
- x);
-
- /* for now make sure ss7_info is set to null */
- ss7_info = NULL;
-
- /* KONRAD FIX ME -> confirm that it is the same circuit */
- } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) */
-
- /* increment the span channel count */
- count++;
- } /* if ((timeslot.siglink) || (timeslot.gap)) */
-
- if (ss7_info == NULL) {
- SS7_ERROR("KONRAD -> circuit was not configured !\n");
+ /* check we found the ckt or not */
+ if (!flag) {
+ SS7_ERROR_CHAN(ftdmchan, "Failed to find this channel in the global ckts!%s\n","");
return FTDM_FAIL;
}
- if (ss7_info->ftdmchan == NULL) {
- SS7_INFO("Added span = %d, chan = %d, cic = %d, FTDM chan = %d, ISUP cirId = %d\n",
- g_ftdm_sngss7_data.cfg.isupCkt[x].span,
- g_ftdm_sngss7_data.cfg.isupCkt[x].chan,
- g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
- 0,
- g_ftdm_sngss7_data.cfg.isupCkt[x].id);
- } else {
- SS7_INFO("Added span = %d, chan = %d, cic = %d, FTDM chan = %d, ISUP cirId = %d\n",
- g_ftdm_sngss7_data.cfg.isupCkt[x].span,
- g_ftdm_sngss7_data.cfg.isupCkt[x].chan,
- g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
- ss7_info->ftdmchan->chan_id,
- g_ftdm_sngss7_data.cfg.isupCkt[x].id);
- }
+ /* fill in the rest of the global sngss7_chan_data_t structure */
+ ss7_info = (sngss7_chan_data_t *)isupCkt->obj;
+ ss7_info->ftdmchan = ftdmchan;
- } /* while (ch_map[0] != '\0') */
+ /* attach the sngss7_chan_data_t to the freetdm channel structure */
+ ftdmchan->call_data = ss7_info;
- return 0;
+ /* prepare the timer structures */
+ ss7_info->t35.sched = ((sngss7_span_data_t *)(ftdmspan->signal_data))->sched;
+ ss7_info->t35.counter = 1;
+ ss7_info->t35.beat = (isupCkt->t35) * 100; /* beat is in ms, t35 is in 100ms */
+ ss7_info->t35.callback = handle_isup_t35;
+ ss7_info->t35.sngss7_info = ss7_info;
+
+
+ /**************************************************************************/
+ } /* for (i == 1; i < ftdmspan->chan_count; i++) */
+
+ return FTDM_SUCCESS;
}
/******************************************************************************/
diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2010.vcxproj b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2010.vcxproj
index 40d0a73a5b..a21be2232f 100644
--- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2010.vcxproj
+++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.2010.vcxproj
@@ -61,14 +61,14 @@
<_ProjectFileVersion>10.0.30319.1
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
+ $(SolutionDir)$(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
true
$(SolutionDir)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\
true
- $(SolutionDir)$(Configuration)\
- $(Configuration)\
+ $(SolutionDir)$(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
false
$(SolutionDir)$(Platform)\$(Configuration)\
$(Platform)\$(Configuration)\
diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
index 3b384cdf32..b648daadaf 100644
--- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
+++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
@@ -664,6 +664,8 @@ static FIO_COMMAND_FUNCTION(wanpipe_command)
}
}
break;
+ case FTDM_COMMAND_DISABLE_ECHOTRAIN: { err = 0; }
+ break;
case FTDM_COMMAND_ENABLE_DTMF_DETECT:
{
#ifdef WP_API_FEATURE_DTMF_EVENTS
@@ -1242,7 +1244,7 @@ static FIO_GET_ALARMS_FUNCTION(wanpipe_get_alarms)
/* there is a bug in wanpipe where alarms were not properly set when they should be
* on at application startup, until that is fixed we check the link status here too */
ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_LINK_STATUS, &sangoma_status);
- ftdmchan->alarm_flags = sangoma_status == FTDM_HW_LINK_DISCONNECTED ? 1 : 0;
+ ftdmchan->alarm_flags = sangoma_status == FTDM_HW_LINK_DISCONNECTED ? FTDM_ALARM_RED : FTDM_ALARM_NONE;
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Link status is %d\n", sangoma_status);
}
}
diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h
index aed40541a3..ef7843e5cc 100644
--- a/libs/freetdm/src/include/freetdm.h
+++ b/libs/freetdm/src/include/freetdm.h
@@ -554,6 +554,7 @@ struct ftdm_sigmsg {
uint32_t chan_id; /*!< easy access to chan id */
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 */
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 */
@@ -838,11 +839,11 @@ typedef enum {
/*! \brief FreeTDM supported hardware alarms. */
typedef enum {
FTDM_ALARM_NONE = 0,
- FTDM_ALARM_RED = (1 << 1),
- FTDM_ALARM_YELLOW = (1 << 2),
- FTDM_ALARM_RAI = (1 << 3),
- FTDM_ALARM_BLUE = (1 << 4),
- FTDM_ALARM_AIS = (1 << 5),
+ FTDM_ALARM_RED = (1 << 0),
+ FTDM_ALARM_YELLOW = (1 << 1),
+ FTDM_ALARM_RAI = (1 << 2),
+ FTDM_ALARM_BLUE = (1 << 3),
+ FTDM_ALARM_AIS = (1 << 4),
FTDM_ALARM_GENERAL = (1 << 30)
} ftdm_alarm_flag_t;
@@ -1368,34 +1369,12 @@ 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 Add a custom variable to the channel
- * \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_channel_add_var(ftdm_channel_t *ftdmchan, const char *var_name, const char *value);
-
-/*! \brief Get a custom variable from the channel.
- * \note The variable pointer returned is only valid while the channel is open and it'll be destroyed when the channel is closed. */
-FT_DECLARE(const char *) ftdm_channel_get_var(ftdm_channel_t *ftdmchan, const char *var_name);
-
-/*! \brief Get an iterator to iterate over the channel variables
- * \param ftdmchan The channel 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_channel_get_var_iterator(const ftdm_channel_t *ftdmchan, ftdm_iterator_t *iter);
-
/*! \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_channel_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);
@@ -1426,23 +1405,6 @@ FT_DECLARE(ftdm_iterator_t *) ftdm_call_get_var_iterator(const ftdm_caller_data_
/*! \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);
-/*! \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.
- * \todo Document which signaling variables are available
- * */
-FT_DECLARE(ftdm_status_t) ftdm_call_clear_vars(ftdm_caller_data_t *caller_data);
-
-/*! \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 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 Get the span pointer associated to the channel */
FT_DECLARE(ftdm_span_t *) ftdm_channel_get_span(const ftdm_channel_t *ftdmchan);
diff --git a/libs/freetdm/src/include/ftdm_declare.h b/libs/freetdm/src/include/ftdm_declare.h
index 88a76930f7..b443f2d5f5 100644
--- a/libs/freetdm/src/include/ftdm_declare.h
+++ b/libs/freetdm/src/include/ftdm_declare.h
@@ -178,18 +178,20 @@ typedef int ftdm_socket_t;
/*! \brief FreeTDM APIs possible return codes */
typedef enum {
FTDM_SUCCESS, /*!< Success */
- FTDM_FAIL, /*!< Failure, generic error return code, use ftdm_channel_get_last_error or ftdm_span_get_last_error for details */
- FTDM_MEMERR, /*!< Memory error, most likely allocation failure */
+ FTDM_FAIL, /*!< Failure, generic error return code when no more specific return code can be used */
+
+ FTDM_MEMERR, /*!< Allocation failure */
+ FTDM_ENOMEM = FTDM_MEMERR,
+
FTDM_TIMEOUT, /*!< Operation timed out (ie: polling on a device)*/
+ FTDM_ETIMEDOUT = FTDM_TIMEOUT,
+
FTDM_NOTIMPL, /*!< Operation not implemented */
+ FTDM_ENOSYS = FTDM_NOTIMPL, /*!< The function is not implemented */
+
FTDM_BREAK, /*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */
/*!< Any new return codes should try to mimc unix style error codes, no need to reinvent */
- /* Remapping some of the codes that were before */
- FTDM_ENOMEM = FTDM_MEMERR, /*!< Memory error */
- FTDM_ETIMEDOUT = FTDM_TIMEOUT, /*!< Operation timedout */
- FTDM_ENOSYS = FTDM_NOTIMPL, /*!< The function is not implemented */
-
FTDM_EINVAL, /*!< Invalid argument */
FTDM_ECANCELED, /*!< Operation cancelled */
FTDM_EBUSY, /*!< Device busy */
diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h
index 7cf0934f57..0de52727da 100644
--- a/libs/freetdm/src/include/private/ftdm_core.h
+++ b/libs/freetdm/src/include/private/ftdm_core.h
@@ -94,7 +94,10 @@
!strcasecmp(expr, "active") || \
atoi(expr))) ? 1 : 0
-
+#ifdef WIN32_LEAN_AND_MEAN
+#include
+#include
+#endif
#include
#ifndef __WINDOWS__
@@ -448,7 +451,6 @@ struct ftdm_channel {
struct ftdm_caller_data caller_data;
struct ftdm_span *span;
struct ftdm_io_interface *fio;
- ftdm_hash_t *variable_hash;
unsigned char rx_cas_bits;
uint32_t pre_buffer_size;
uint8_t rxgain_table[FTDM_GAINS_TABLE_SIZE];
@@ -626,6 +628,24 @@ FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan);
FT_DECLARE(void) ftdm_set_echocancel_call_begin(ftdm_channel_t *chan);
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.
+ * \todo Document which signaling variables are available
+ * */
+FT_DECLARE(ftdm_status_t) ftdm_call_clear_vars(ftdm_caller_data_t *caller_data);
+
+/*! \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 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 Assert condition
*/
@@ -685,6 +705,9 @@ FT_DECLARE(void) ftdm_set_echocancel_call_end(ftdm_channel_t *chan);
if (!ftdm_test_flag((fchan), FTDM_CHANNEL_MEDIA)) { \
ftdm_set_flag((fchan), FTDM_CHANNEL_MEDIA); \
ftdm_set_echocancel_call_begin((fchan)); \
+ if ((fchan)->dtmfdbg.requested) { \
+ ftdm_channel_command((fchan), FTDM_COMMAND_ENABLE_DEBUG_DTMF, NULL); \
+ } \
} \
} while (0);
diff --git a/libs/iksemel/configure.ac b/libs/iksemel/configure.ac
index 1b8af13683..403725a80d 100644
--- a/libs/iksemel/configure.ac
+++ b/libs/iksemel/configure.ac
@@ -83,11 +83,18 @@ AC_ARG_ENABLE(64,
if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
if test "${enable_64}" = "yes"; then
- CFLAGS="$CFLAGS -m64"
- CXXFLAGS="$CXXFLAGS -m64 -lgpg-error"
+ CFLAGS="$CFLAGS -mt -m64 -lgpg-error"
+ CXXFLAGS="$CXXFLAGS -mt -m64 -lgpg-error"
+ SUNFLAGS="-xc99=all -mt -m64 -lgpg-error"
+ else
+ CFLAGS="$CFLAGS -mt -lgpg-error"
+ CXXFLAGS="$CXXFLAGS -mt -lgpg-error"
+ SUNFLAGS="-xc99=all -mt -lgpg-error"
fi
fi
+AC_SUBST(SUNCFLAGS)
+
dnl Generating makefiles
AC_CONFIG_FILES([
Makefile
diff --git a/libs/iksemel/src/Makefile.am b/libs/iksemel/src/Makefile.am
index 20ca2630aa..9d3da69df2 100644
--- a/libs/iksemel/src/Makefile.am
+++ b/libs/iksemel/src/Makefile.am
@@ -25,5 +25,5 @@ libiksemel_la_SOURCES = \
base64.c
libiksemel_la_LDFLAGS = -version-info 4:0:1 -no-undefined
-libiksemel_la_CFLAGS = $(CFLAGS) $(LIBGNUTLS_CFLAGS)
-libiksemel_la_LIBADD = $(LIBGNUTLS_LIBS)
+libiksemel_la_CFLAGS = $(CFLAGS) $(LIBGNUTLS_CFLAGS)
+libiksemel_la_LIBADD = $(LIBGNUTLS_LIBS)
diff --git a/libs/iksemel/tools/Makefile.am b/libs/iksemel/tools/Makefile.am
index ab81e66888..b7d80e9b05 100644
--- a/libs/iksemel/tools/Makefile.am
+++ b/libs/iksemel/tools/Makefile.am
@@ -8,11 +8,11 @@ bin_PROGRAMS = ikslint iksroster iksperf
noinst_HEADERS = perf.h
-ikslint_LDADD = $(top_builddir)/src/libiksemel.la
+ikslint_LDADD = $(top_builddir)/src/libiksemel.la @SUNCFLAGS@
ikslint_SOURCES = ikslint.c hash.c
-iksroster_LDADD = $(top_builddir)/src/libiksemel.la
+iksroster_LDADD = $(top_builddir)/src/libiksemel.la @SUNCFLAGS@
iksroster_SOURCES = iksroster.c
-iksperf_LDADD = $(top_builddir)/src/libiksemel.la
+iksperf_LDADD = $(top_builddir)/src/libiksemel.la @SUNCFLAGS@
iksperf_SOURCES = iksperf.c perf.c
diff --git a/libs/ilbc/src/iLBC_decode.c b/libs/ilbc/src/iLBC_decode.c
index fc46fe408c..9fc7a24bb4 100644
--- a/libs/ilbc/src/iLBC_decode.c
+++ b/libs/ilbc/src/iLBC_decode.c
@@ -47,7 +47,9 @@
{
fld dbl
frndint
+ fstp dbl
}
+ return (long int) dbl;
}
#elif defined (_WIN64)
#include
diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c
index 3e5227ea90..ef346b8eea 100644
--- a/libs/openzap/mod_openzap/mod_openzap.c
+++ b/libs/openzap/mod_openzap/mod_openzap.c
@@ -135,7 +135,9 @@ void dump_chan_xml(zap_span_t *span, uint32_t chan_id, switch_stream_handle_t *s
static void zap_set_npi(const char *npi_string, uint8_t *target)
{
- if (!strcasecmp(npi_string, "isdn") || !strcasecmp(npi_string, "e164")) {
+ if (switch_is_number(npi_string)) {
+ *target = (uint8_t)atoi(npi_string);
+ } else if (!strcasecmp(npi_string, "isdn") || !strcasecmp(npi_string, "e164")) {
*target = ZAP_NPI_ISDN;
} else if (!strcasecmp(npi_string, "data")) {
*target = ZAP_NPI_DATA;
@@ -157,7 +159,9 @@ static void zap_set_npi(const char *npi_string, uint8_t *target)
static void zap_set_ton(const char *ton_string, uint8_t *target)
{
- if (!strcasecmp(ton_string, "national")) {
+ if (switch_is_number(ton_string)) {
+ *target = (uint8_t)atoi(ton_string);
+ } else if (!strcasecmp(ton_string, "national")) {
*target = ZAP_TON_NATIONAL;
} else if (!strcasecmp(ton_string, "international")) {
*target = ZAP_TON_INTERNATIONAL;
@@ -1230,27 +1234,25 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
zap_set_string(caller_data.ani.digits, dest);
}
- if ((var = switch_event_get_header(var_event, "openzap_outbound_ton")) || (var = switch_core_get_variable("openzap_outbound_ton"))) {
- if (!strcasecmp(var, "national")) {
- caller_data.ani.type = ZAP_TON_NATIONAL;
- } else if (!strcasecmp(var, "international")) {
- caller_data.ani.type = ZAP_TON_INTERNATIONAL;
- } else if (!strcasecmp(var, "local")) {
- caller_data.ani.type = ZAP_TON_SUBSCRIBER_NUMBER;
- } else if (!strcasecmp(var, "unknown")) {
- caller_data.ani.type = ZAP_TON_UNKNOWN;
- }
+ if ((var = switch_event_get_header(var_event, "openzap_outbound_ton"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting TON to: %s\n", var);
+ zap_set_ton(var, &caller_data.ani.type);
} else {
caller_data.ani.type = outbound_profile->destination_number_ton;
}
- if ((var = switch_event_get_header(var_event, "openzap_custom_call_data")) || (var = switch_core_get_variable("openzap_custom_call_data"))) {
+ if ((var = switch_event_get_header(var_event, "openzap_custom_call_data"))) {
zap_set_string((char *)caller_data.raw_data, var);
caller_data.raw_data_len = strlen(var);
}
-
- caller_data.ani.plan = outbound_profile->destination_number_numplan;
-
+
+ if ((var = switch_event_get_header(var_event, "openzap_outbound_npi"))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting NPI to: %s\n", var);
+ zap_set_npi(var, &caller_data.ani.plan);
+ } else {
+ caller_data.ani.plan = outbound_profile->destination_number_numplan;
+ }
+
/* blindly copy data from outbound_profile. They will be overwritten
* by calling zap_caller_data if needed after */
caller_data.cid_num.type = outbound_profile->caller_ton;
diff --git a/libs/portaudio/build/msvc/portaudio.2010.vcxproj b/libs/portaudio/build/msvc/portaudio.2010.vcxproj
index b4eca56713..10b4c25fd9 100644
--- a/libs/portaudio/build/msvc/portaudio.2010.vcxproj
+++ b/libs/portaudio/build/msvc/portaudio.2010.vcxproj
@@ -41,11 +41,11 @@
- DynamicLibrary
+ StaticLibrary
false
- DynamicLibrary
+ StaticLibrary
false
@@ -57,11 +57,11 @@
false
- DynamicLibrary
+ StaticLibrary
false
- DynamicLibrary
+ StaticLibrary
false
@@ -77,9 +77,11 @@
+
+
@@ -92,10 +94,12 @@
+
+
@@ -110,18 +114,6 @@
<_ProjectFileVersion>10.0.30319.1
- $(Configuration)\
- $(Configuration)\
- true
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- true
- $(Configuration)\
- $(Configuration)\
- false
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- false
@@ -231,45 +223,23 @@
true
true
Win32
- .\Debug_x86/portaudio.tlb
-
-
Disabled
..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)
true
EnableFastChecks
MultiThreadedDebugDLL
- $(Platform)\$(Configuration)/portaudio.pch
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
Level3
true
- ProgramDatabase
_DEBUG;%(PreprocessorDefinitions)
0x0409
-
- ksuser.lib;%(AdditionalDependencies)
- $(Platform)\$(Configuration)\portaudio_x86.dll
- true
- .\portaudio.def
- true
- $(Platform)\$(Configuration)\portaudio_x86.pdb
- false
-
-
- $(Platform)\$(Configuration)\portaudio_x86.lib
- MachineX86
-
true
- $(Platform)\$(Configuration)\portaudio.bsc
@@ -278,45 +248,23 @@
true
true
X64
- .\Debug_x86/portaudio.tlb
-
-
Disabled
..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)
+ WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)
true
EnableFastChecks
MultiThreadedDebugDLL
- $(Platform)\$(Configuration)\portaudio.pch
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
Level3
true
- ProgramDatabase
_DEBUG;%(PreprocessorDefinitions)
0x0409
-
- ksuser.lib;%(AdditionalDependencies)
- $(Platform)\$(Configuration)\portaudio_x64.dll
- true
- .\portaudio.def
- true
- $(Platform)\$(Configuration)/portaudio_x64.pdb
- false
-
-
- $(Platform)\$(Configuration)\portaudio_x64.lib
- MachineX64
-
true
- $(Platform)\$(Configuration)/portaudio_x64.bsc
@@ -325,22 +273,15 @@
true
true
Win32
- .\Release_x86/portaudio.tlb
-
-
MaxSpeed
- OnlyExplicitInline
+ Default
..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
- $(Platform)\$(Configuration)/portaudio.pch
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
Level3
true
@@ -348,20 +289,8 @@
NDEBUG;%(PreprocessorDefinitions)
0x0409
-
- $(Platform)\$(Configuration)\portaudio_x86.dll
- true
- .\portaudio.def
- $(Platform)\$(Configuration)\portaudio_x86.pdb
- false
-
-
- $(Platform)\$(Configuration)\portaudio_x86.lib
- MachineX86
-
true
- $(Platform)\$(Configuration)\portaudio.bsc
@@ -370,22 +299,15 @@
true
true
X64
- .\Release_x86/portaudio.tlb
-
-
MaxSpeed
- OnlyExplicitInline
- ..\..\src\common;..\..\include;.\;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)
+ Default
+ ..\..\src\common;..\..\include;.\;..\..\src\os\win;%(AdditionalIncludeDirectories)
+ WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PA_NO_ASIO;PA_NO_WMME;%(PreprocessorDefinitions)
true
MultiThreadedDLL
true
- $(Platform)\$(Configuration)\portaudio.pch
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
- $(Platform)\$(Configuration)\
Level3
true
@@ -393,20 +315,8 @@
NDEBUG;%(PreprocessorDefinitions)
0x0409
-
- $(Platform)\$(Configuration)\portaudio_x64.dll
- true
- .\portaudio.def
- $(Platform)\$(Configuration)/portaudio_x64.pdb
- false
-
-
- $(Platform)\$(Configuration)/portaudio_x64.lib
- MachineX64
-
true
- $(Platform)\$(Configuration)\portaudio_x64.bsc
@@ -594,6 +504,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -605,6 +516,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -618,6 +530,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -629,6 +542,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -642,6 +556,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -653,6 +568,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -666,6 +582,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -677,6 +594,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -690,6 +608,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -701,6 +620,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -714,6 +634,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -725,6 +646,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -738,6 +660,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -749,6 +672,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -762,6 +686,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
@@ -773,6 +698,7 @@
true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
+ true
..\..\src\hostapi\asio\ASIOSDK\host;..\..\src\hostapi\asio\ASIOSDK\host\pc;..\..\src\hostapi\asio\ASIOSDK\common;%(AdditionalIncludeDirectories)
%(PreprocessorDefinitions)
true
diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
index f77cdd3afa..13454c1a8e 100644
--- a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
+++ b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
@@ -8665,10 +8665,6 @@ void outgoing_destroy(nta_outgoing_t *orq)
orq->orq_destroyed = 1;
orq->orq_callback = outgoing_default_cb;
orq->orq_magic = NULL;
-
- if (orq->orq_method != sip_method_invite &&
- orq->orq_method != sip_method_ack)
- outgoing_terminate(orq);
}
/** @internal Outgoing transaction timer routine.
diff --git a/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c b/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
index f104274ef4..e00d3912d8 100644
--- a/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
+++ b/libs/sofia-sip/libsofia-sip-ua/soa/soa_static.c
@@ -1036,13 +1036,15 @@ int soa_sdp_mode_set(sdp_session_t const *user,
assert(s2u);
- for (j = 0, um = user->sdp_media; j != s2u[i]; um = um->m_next, j++)
- assert(um);
+ for (j = 0, um = user->sdp_media; j != s2u[i]; um = um->m_next, j++) {
+ if (!um) break;
+ }
+
if (um == NULL) {
if (dryrun)
- return 1;
+ return 1;
else
- retval = 1;
+ retval = 1;
sm->m_rejected = 1;
sm->m_mode = sdp_inactive;
sm->m_port = 0;
diff --git a/libs/spandsp/spandsp.pc.in b/libs/spandsp/spandsp.pc.in
index 86a50ff62a..1a91ba04e1 100644
--- a/libs/spandsp/spandsp.pc.in
+++ b/libs/spandsp/spandsp.pc.in
@@ -1,5 +1,5 @@
prefix=@prefix@
-exec_prefix=@exec_prefix@
+exec_prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
diff --git a/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj b/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj
index d841b89c0a..be91504cc2 100644
--- a/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj
+++ b/libs/win32/sofia/libsofia_sip_ua_static.2010.vcxproj
@@ -508,6 +508,12 @@ if not exist "$(ProjectDir)$(IntDir)\auth_client.obj" "autogen.cmd"
{8b3b4c4c-13c2-446c-beb0-f412cc2cfb9a}
false
+
+ {d331904d-a00a-4694-a5a3-fcff64ab5dbe}
+
+
+ {b4b62169-5ad4-4559-8707-3d933ac5db39}
+
{df018947-0fff-4eb3-bdee-441dc81da7a4}
false
diff --git a/scripts/perl/dhcp-inform.pl b/scripts/perl/dhcp-inform.pl
index 3f977ca58b..2ca4bb8732 100644
--- a/scripts/perl/dhcp-inform.pl
+++ b/scripts/perl/dhcp-inform.pl
@@ -61,12 +61,7 @@ while ($sock->recv($newmsg, 1024)) {
}
print "Sending option 66 as $opt_u\n";
- $handle = IO::Socket::INET->new(Proto => 'udp',
- PeerPort => '68',
- LocalPort => '67',
- ReuseAddr => 1,
- PeerAddr => $dhcpreq->ciaddr(),
- ) or die "socket: $@";
- $handle->send($dhcpresp->serialize())
+
+ $sock->send($dhcpresp->serialize())
}
}
diff --git a/scripts/perl/randomize-passwords.pl b/scripts/perl/randomize-passwords.pl
new file mode 100755
index 0000000000..d792f2b293
--- /dev/null
+++ b/scripts/perl/randomize-passwords.pl
@@ -0,0 +1,179 @@
+#!/usr/bin/perl
+#
+# randomize-passwords.pl
+#
+# Randomizes the auth passwords for any file in the file spec given by the user
+# Randomizes the vm passwords for the same files
+# Creates a backup copy of each file altered; optionally will remove backups
+#
+# This program uses only pure Perl modules so it should be portable.
+#
+# Michael S. Collins
+# 2009-11-11
+#
+# Freely contributed to the FreeSWITCH project for use as the developers and community see fit
+
+use strict;
+use warnings;
+use Getopt::Long;
+use File::Basename;
+use File::Copy;
+
+$|++;
+
+## 'CHARACTERS' contains punctuation marks
+use constant CHARACTERS => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=+?> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
+my $numalphas = length(ALPHACHARS);
+
+my $vmlen = 4; # Length of VM password
+my $authlen = 10; # Length of auth password
+my $filespec; # File specification
+my $delbak; # Flag - delete backups (default = keep backups)
+my $nopunct; # Flag - set to true to disable punction marks (i.e. alphanumerics only) in auth passwords
+
+my $opts_ok = GetOptions ("h" => \&usage,
+ "help" => \&usage,
+ "vmlen=i" => \$vmlen,
+ "authlen=i" => \$authlen,
+ "files=s" => \$filespec,
+ "D" => \$delbak,
+ "nopunct" => \$nopunct,
+ );
+
+## Confirm that a file spec was provided
+if ( ! $filespec ) {
+ warn "\nPlease provide a file specification.\n";
+ die "Example: --files=/usr/local/freeswitch/conf/directory/default/1*.xml\n\n";
+}
+
+## Collect the files
+my @FILELIST = glob($filespec);
+if ( ! @FILELIST ) {
+ print "\nNo files found matching this spec:\n$filespec\n";
+ exit(0);
+} else {
+ print "\nFound " . @FILELIST . " file(s).\n\n";
+}
+
+## Iterate through the list, process each file
+foreach my $file ( @FILELIST ) {
+ print "Processing file: $file\n";
+ my $bakfile = $file . '.bak';
+
+ if ( move($file,$bakfile) ) {
+ print " $file ===> $bakfile\n";
+ } else {
+ print " Unable to backup $file to $bakfile. Skipping...\n";
+ next;
+ }
+
+ ## FILEIN is the backup file, FILEOUT is the updated file
+ open(FILEIN ,'<',$bakfile) or die "Could not open $bakfile - aborting operation.\n";
+ open(FILEOUT,'>',$file ) or die "Could not open $file - aborting operation.\n";
+
+ ## Retrieve new passwords from random generators
+ my $newauth = &get_random_chars($authlen);
+ my $newvm = &get_random_digits($vmlen);
+
+ ## Loop through "bak" file, replace passwords, write out to original file
+ while() {
+ ## Check for passwords; if found swap
+ if ( m/param name="password"/ ) {
+ # Found auth password, swap it
+ s/value="(.*?)"/value="$newauth"/;
+ print " Old/new auth pass: $1 ==> $newauth\n";
+ }
+
+ if ( m/param name="vm-password"/ ) {
+ # Found vm password, swap it
+ s/value="(.*?)"/value="$newvm"/;
+ print " Old/new vm pass: $1 ==> $newvm\n";
+ }
+
+ print FILEOUT $_;
+
+ } ## while()
+
+ close(FILEIN);
+ close(FILEOUT);
+
+ ## Clear out the backup file if user asked for it
+ if ( $delbak ) {
+ print " Removing $bakfile...\n";
+ unlink $bakfile;
+ }
+ print " Finished with $file.\n\n";
+
+} ## foreach my $file ( @FILELIST )
+
+exit(0);
+
+## Return random chars for auth password
+sub get_random_chars () {
+ my $length = shift;
+ if ( ! $length ) { $length = $authlen; }
+ my $chars;
+
+ if ( $nopunct ) {
+ foreach my $i (1 .. $length) {
+ my $nextchar = substr( ALPHACHARS,int(rand $numalphas),1 );
+ $chars .= $nextchar;
+ }
+
+ } else {
+ foreach my $i (1 .. $length) {
+ my $nextchar = substr( CHARACTERS,int(rand $numchars),1 );
+ $chars .= $nextchar;
+ }
+ }
+ return $chars;
+}
+
+## Return only digits for vm password
+sub get_random_digits () {
+ my $length = shift;
+ if ( ! $length ) { $length = $vmlen; }
+ my $digits;
+ foreach my $i (1 .. $length) {
+ my $nextdigit = int(rand 10);
+ $digits .= $nextdigit;
+ }
+ return $digits;
+
+}
+
+sub usage () {
+print < [-D] [--vmlen=] [--authlen=]
+
+Options:
+
+ -h, --help Display this help page
+
+ -D Delete backups (default is to save backups)
+
+ --files Specify files to process. Use typical file globs. On a standard Linux install it would look like:
+ --files=/usr/local/freeswitch/conf/directory/default/1*.xml
+
+ --vmlen Set length of voice mail password. (Default is 4 digits)
+
+ --authlen Set length of auth password. (Default is 10 characters)
+
+ --nopunct Disable punction marks in auth passwords, i.e. alphanumerics only
+
+Example:
+ To randomize all the passwords for a default Linux install, with 6 digit VM passwords, use this command:
+
+ ./randomize-passwords.pl --files=/usr/local/freeswitch/conf/directory/default/1*.xml -D --vmlen=6
+
+END_USAGE
+;
+exit(0);
+}
diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h
index 30690b1848..ab0777ed3b 100644
--- a/src/include/private/switch_core_pvt.h
+++ b/src/include/private/switch_core_pvt.h
@@ -236,6 +236,7 @@ struct switch_runtime {
char *odbc_dsn;
char *odbc_user;
char *odbc_pass;
+ char *dbname;
uint32_t debug_level;
uint32_t runlevel;
uint32_t tipping_point;
@@ -246,6 +247,8 @@ struct switch_runtime {
int sql_buffer_len;
int max_sql_buffer_len;
switch_dbtype_t odbc_dbtype;
+ char hostname[256];
+ int multiple_registrations;
};
extern struct switch_runtime runtime;
diff --git a/src/include/switch_core.h b/src/include/switch_core.h
index 29e8b43526..984b54fac7 100644
--- a/src/include/switch_core.h
+++ b/src/include/switch_core.h
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II
+ * Luke Dashjr (OpenMethods, LLC)
*
*
* switch_core.h -- Core Library
@@ -758,6 +759,9 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_force_locate(_In_z_
\return the value of the desired variable
*/
SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname);
+SWITCH_DECLARE(char *) switch_core_get_variable_dup(_In_z_ const char *varname);
+SWITCH_DECLARE(char *) switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool);
+SWITCH_DECLARE(const char *) switch_core_get_hostname(void);
/*!
\brief Add a global variable to the core
@@ -1734,6 +1738,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_close(switch_asr_handle_t *ah, s
*/
SWITCH_DECLARE(switch_status_t) switch_core_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags);
+/*!
+ \brief Feed DTMF to an asr handle
+ \param ah the handle to feed data to
+ \param dtmf a string of DTMF digits
+ \param flags flags to influence behaviour
+ \return SWITCH_STATUS_SUCCESS
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_asr_feed_dtmf(switch_asr_handle_t *ah, const switch_dtmf_t *dtmf, switch_asr_flag_t *flags);
+
/*!
\brief Check an asr handle for results
\param ah the handle to check
@@ -1768,6 +1781,29 @@ SWITCH_DECLARE(switch_status_t) switch_core_asr_load_grammar(switch_asr_handle_t
*/
SWITCH_DECLARE(switch_status_t) switch_core_asr_unload_grammar(switch_asr_handle_t *ah, const char *name);
+/*!
+ \brief Enable a grammar from an asr handle
+ \param ah the handle to enable the grammar from
+ \param name the name of the grammar to enable
+ \return SWITCH_STATUS_SUCCESS
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_asr_enable_grammar(switch_asr_handle_t *ah, const char *name);
+
+/*!
+ \brief Disable a grammar from an asr handle
+ \param ah the handle to disable the grammar from
+ \param name the name of the grammar to disable
+ \return SWITCH_STATUS_SUCCESS
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_asr_disable_grammar(switch_asr_handle_t *ah, const char *name);
+
+/*!
+ \brief Disable all grammars from an asr handle
+ \param ah the handle to disable the grammars from
+ \return SWITCH_STATUS_SUCCESS
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_asr_disable_all_grammars(switch_asr_handle_t *ah);
+
/*!
\brief Pause detection on an asr handle
\param ah the handle to pause
@@ -2191,6 +2227,11 @@ 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);
+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);
+SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, const char *realm, const char *token);
+SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force);
+
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h
index 0bd2a8b2b0..f4a0922e58 100644
--- a/src/include/switch_cpp.h
+++ b/src/include/switch_cpp.h
@@ -68,6 +68,10 @@ Note that the first parameter to the new operator is implicitly handled by c++..
SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg);
SWITCH_DECLARE(void) consoleCleanLog(char *msg);
+SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *body = NULL,
+ char *file = NULL, char *convert_cmd = NULL, char *convert_ext = NULL);
+
+
class CoreSession;
class IVRMenu {
diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h
index 46c9c91670..9b353f3ded 100644
--- a/src/include/switch_ivr.h
+++ b/src/include/switch_ivr.h
@@ -26,6 +26,7 @@
* Anthony Minessale II
* Neal Horman
* Bret McDanel
+ * Luke Dashjr (OpenMethods, LLC)
*
* switch_ivr.h -- IVR Library
*
@@ -198,8 +199,38 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_cor
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_core_session_t *session, const char *name);
+/*!
+ \brief Enable a grammar on a background speech detection handle
+ \param session The session to change the grammar on
+ \param name the grammar name
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_enable_grammar(switch_core_session_t *session, const char *name);
+
+/*!
+ \brief Disable a grammar on a background speech detection handle
+ \param session The session to change the grammar on
+ \param name the grammar name
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_grammar(switch_core_session_t *session, const char *name);
+
+/*!
+ \brief Disable all grammars on a background speech detection handle
+ \param session The session to change the grammar on
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_all_grammars(switch_core_session_t *session);
+
SWITCH_DECLARE(switch_status_t) switch_ivr_set_param_detect_speech(switch_core_session_t *session, const char *name, const char *val);
+/*!
+ \brief Start input timers on a background speech detection handle
+ \param session The session to start the timers on
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_start_input_timers(switch_core_session_t *session);
+
/*!
\brief Record a session to disk
\param session the session to record
diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h
index 114e594c0c..90d7342ef4 100644
--- a/src/include/switch_module_interfaces.h
+++ b/src/include/switch_module_interfaces.h
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II
+ * Luke Dashjr (OpenMethods, LLC)
*
*
* switch_module_interfaces.h -- Module Interface Definitions
@@ -396,6 +397,14 @@ struct switch_asr_interface {
switch_mutex_t *reflock;
switch_loadable_module_interface_t *parent;
struct switch_asr_interface *next;
+ /*! function to enable a grammar to the asr interface */
+ switch_status_t (*asr_enable_grammar) (switch_asr_handle_t *ah, const char *name);
+ /*! function to disable a grammar to the asr interface */
+ switch_status_t (*asr_disable_grammar) (switch_asr_handle_t *ah, const char *name);
+ /*! function to disable all grammars to the asr interface */
+ switch_status_t (*asr_disable_all_grammars) (switch_asr_handle_t *ah);
+ /*! function to feed DTMF to the ASR */
+ switch_status_t (*asr_feed_dtmf) (switch_asr_handle_t *ah, const switch_dtmf_t *dtmf, switch_asr_flag_t *flags);
};
/*! an abstract representation of an asr speech interface. */
diff --git a/src/include/switch_nat.h b/src/include/switch_nat.h
index bdbd51b592..9e40546345 100644
--- a/src/include/switch_nat.h
+++ b/src/include/switch_nat.h
@@ -49,7 +49,7 @@ typedef enum {
SWITCH_NAT_TCP
} switch_nat_ip_proto_t;
-
+SWITCH_DECLARE(const char *) switch_nat_get_type(void);
/*!
\brief Initilize the NAT Traversal System
diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h
index 27dacc7c18..2870bba3af 100644
--- a/src/include/switch_rtp.h
+++ b/src/include/switch_rtp.h
@@ -437,6 +437,8 @@ SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *pri
*/
SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te);
SWITCH_DECLARE(void) switch_rtp_set_telephony_recv_event(switch_rtp_t *rtp_session, switch_payload_t te);
+SWITCH_DECLARE(void) switch_rtp_set_recv_pt(switch_rtp_t *rtp_session, switch_payload_t pt);
+
/*!
\brief Set the payload type for comfort noise
\param rtp_session the RTP session to modify
diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h
index 2c4de14334..a1a93c6ac8 100644
--- a/src/include/switch_utils.h
+++ b/src/include/switch_utils.h
@@ -192,7 +192,7 @@ static inline char switch_itodtmf(char i)
r = i + 55;
}
- return r;
+ return r + 48;
}
static inline int switch_dtmftoi(char *s)
diff --git a/src/mod/Makefile.am b/src/mod/Makefile.am
index e655cf7f05..5af782d12d 100644
--- a/src/mod/Makefile.am
+++ b/src/mod/Makefile.am
@@ -21,7 +21,7 @@ $(OUR_MODULES) $(OUR_CLEAN_MODULES) $(OUR_INSTALL_MODULES) $(OUR_UNINSTALL_MODUL
fi ; \
fi ; \
if test -z "$$target" ; then target="all" ; fi ; \
- if ! test -f $$moddir/$$modname.c && ! test -f $$moddir/$$modname.cpp ; \
+ if ! test -f $$moddir/$$modname.c && ! test -f $$moddir/$$modname.cpp && test $$modname != "mod_com_g729" ; \
then echo ; echo "WARNING $$modname is not a valid FreeSWITCH module dir, skipping it..." ; else \
echo ;\
echo making $$target $$modname ;\
@@ -35,6 +35,9 @@ $(OUR_MODULES) $(OUR_CLEAN_MODULES) $(OUR_INSTALL_MODULES) $(OUR_UNINSTALL_MODUL
fi; \
test -z "$$fail" ;
+mod_com_g729-activate:
+ cd $(switch_builddir)/src/mod/codecs/mod_com_g729 && $(MAKE) $(AM_MAKEFLAGS) activate
+
.DEFAULT:
@if test -z "`echo $@ | grep all`"; then $(MAKE) $(AM_MAKEFLAGS) $@-all ; else echo Unknown target `echo $@ | sed -e 's|-all||'`; exit 1; fi
diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c
index d1de632ee6..9d9feed0aa 100644
--- a/src/mod/applications/mod_callcenter/mod_callcenter.c
+++ b/src/mod/applications/mod_callcenter/mod_callcenter.c
@@ -1384,6 +1384,8 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa
switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "cc_agent", "%s", h->agent_name);
switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "cc_agent_type", "%s", h->agent_type);
switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "ignore_early_media", "true");
+ /* Force loopback to remain live, if not, the loop will detect the actual channel to gone */
+ switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "loopback_bowout", "false");
t_agent_called = switch_epoch_time_now(NULL);
dialstr = switch_mprintf("%s", h->originate_string);
@@ -2080,6 +2082,32 @@ void *SWITCH_THREAD_FUNC cc_member_thread_run(switch_thread_t *thread, void *obj
return NULL;
}
+struct moh_dtmf_helper {
+ const char *queue_name;
+ char dtmf;
+};
+
+static switch_status_t moh_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) {
+ struct moh_dtmf_helper *h = (struct moh_dtmf_helper *) buf;
+
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF:
+ {
+ /* Just laywork for people who want to get some DTMF actions */
+ switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
+ if (strchr("#", dtmf->digit)) {
+ h->dtmf = dtmf->digit;
+ return SWITCH_STATUS_BREAK;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
#define CC_DESC "callcenter"
#define CC_USAGE "queue_name"
@@ -2226,8 +2254,6 @@ SWITCH_STANDARD_APP(callcenter_function)
switch_thread_create(&thread, thd_attr, cc_member_thread_run, h, h->pool);
/* Playback MOH */
- /* TODO Add DTMF callback support */
- /* TODO add MOH infitite loop */
if (cc_moh_override) {
cur_moh = switch_core_session_strdup(member_session, cc_moh_override);
} else {
@@ -2237,6 +2263,12 @@ SWITCH_STANDARD_APP(callcenter_function)
while (switch_channel_ready(member_channel)) {
switch_input_args_t args = { 0 };
+ struct moh_dtmf_helper ht;
+
+ ht.dtmf = '\0';
+ args.input_callback = moh_on_dtmf;
+ args.buf = (void *) &ht;
+ args.buflen = sizeof(h);
/* An agent was found, time to exit and let the bridge do it job */
if ((agent_uuid = switch_channel_get_variable(member_channel, "cc_agent_uuid"))) {
@@ -2260,6 +2292,8 @@ SWITCH_STANDARD_APP(callcenter_function)
switch_ivr_collect_digits_callback(session, &args, 0, 0);
}
+ switch_yield(1000);
+
}
/* Stop Member Thread */
@@ -2625,8 +2659,10 @@ SWITCH_STANDARD_API(cc_config_api_function)
cc_queue_t *queue = NULL;
if ((queue = get_queue(queue_name))) {
queue_rwunlock(queue);
+ stream->write_function(stream, "%s", "+OK\n");
+ } else {
+ stream->write_function(stream, "%s", "-ERR Invalid Queue not found!\n");
}
- stream->write_function(stream, "%s", "+OK\n");
}
} else if (action && !strcasecmp(action, "unload")) {
if (argc-initial_argc < 1) {
@@ -2648,8 +2684,10 @@ SWITCH_STANDARD_API(cc_config_api_function)
destroy_queue(queue_name, SWITCH_FALSE);
if ((queue = get_queue(queue_name))) {
queue_rwunlock(queue);
+ stream->write_function(stream, "%s", "+OK\n");
+ } else {
+ stream->write_function(stream, "%s", "-ERR Invalid Queue not found!\n");
}
- stream->write_function(stream, "%s", "+OK\n");
}
} else if (action && !strcasecmp(action, "list")) {
if (argc-initial_argc < 1) {
@@ -2671,7 +2709,6 @@ SWITCH_STANDARD_API(cc_config_api_function)
goto done;
} else {
const char *queue_name = argv[0 + initial_argc];
-
struct list_result cbt;
cbt.row_process = 0;
cbt.stream = stream;
diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c
index 15ac8ecd2a..517134d2e1 100644
--- a/src/mod/applications/mod_commands/mod_commands.c
+++ b/src/mod/applications/mod_commands/mod_commands.c
@@ -45,6 +45,149 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_commands_shutdown);
SWITCH_MODULE_DEFINITION(mod_commands, mod_commands_load, mod_commands_shutdown, NULL);
+
+struct cb_helper {
+ uint32_t row_process;
+ switch_stream_handle_t *stream;
+};
+
+static int url_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+ struct cb_helper *cb = (struct cb_helper *) pArg;
+
+ cb->row_process++;
+
+ if (!zstr(argv[0])) {
+ cb->stream->write_function(cb->stream, "%s,", argv[0]);
+ }
+
+ return 0;
+}
+
+static switch_status_t select_url(const char *user,
+ const char *domain,
+ const char *concat,
+ const char *exclude_contact,
+ switch_stream_handle_t *stream)
+{
+ struct cb_helper cb;
+ char *sql, *errmsg = NULL;
+ switch_core_flag_t cflags = switch_core_flags();
+ switch_cache_db_handle_t *db = NULL;
+
+ if (!(cflags & SCF_USE_SQL)) {
+ stream->write_function(stream, "-ERR SQL DISABLED NO DATA AVAILABLE!\n");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
+ stream->write_function(stream, "%s", "-ERR Databse Error!\n");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ cb.row_process = 0;
+ cb.stream = stream;
+
+ if (exclude_contact) {
+ sql = switch_mprintf("select url, '%q' "
+ "from registrations where 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'",
+ (concat != NULL) ? concat : "", user, domain);
+ }
+
+ switch_assert(sql);
+ switch_cache_db_execute_sql_callback(db, sql, url_callback, &cb, &errmsg);
+
+ if (errmsg) {
+ stream->write_function(stream, "-ERR SQL Error [%s]\n", errmsg);
+ free(errmsg);
+ errmsg = NULL;
+ }
+
+ switch_safe_free(sql);
+
+ if (db) {
+ switch_cache_db_release_db_handle(&db);
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_STANDARD_API(reg_url_function)
+{
+ char *data;
+ char *user = NULL;
+ char *domain = NULL, *dup_domain = NULL;
+ char *concat = NULL;
+ const char *exclude_contact = NULL;
+ char *reply = "error/facility_not_subscribed";
+ switch_stream_handle_t mystream = { 0 };
+
+
+ if (!cmd) {
+ stream->write_function(stream, "%s", "");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if (session) {
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ exclude_contact = switch_channel_get_variable(channel, "sip_exclude_contact");
+ }
+
+
+ data = strdup(cmd);
+ switch_assert(data);
+
+ user = data;
+
+ if ((domain = strchr(user, '@'))) {
+ *domain++ = '\0';
+ if ((concat = strchr(domain, '/'))) {
+ *concat++ = '\0';
+ }
+ } else {
+ if ((concat = strchr(user, '/'))) {
+ *concat++ = '\0';
+ }
+ }
+
+ if (zstr(domain)) {
+ dup_domain = switch_core_get_variable_dup("domain");
+ domain = dup_domain;
+ }
+
+ if (!user) goto end;
+
+
+ SWITCH_STANDARD_STREAM(mystream);
+ switch_assert(mystream.data);
+
+ select_url(user, domain, concat, exclude_contact, &mystream);
+ reply = mystream.data;
+
+
+ end:
+
+ if (zstr(reply)) {
+ reply = "error/user_not_registered";
+ } else if (end_of(reply) == ',') {
+ end_of(reply) = '\0';
+ }
+
+ stream->write_function(stream, "%s", reply);
+ reply = NULL;
+
+ switch_safe_free(mystream.data);
+
+ switch_safe_free(data);
+ switch_safe_free(dup_domain);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
SWITCH_STANDARD_API(banner_function)
{
stream->write_function(stream, "%s", switch_core_banner());
@@ -349,7 +492,7 @@ SWITCH_STANDARD_API(timer_test_function)
SWITCH_STANDARD_API(group_call_function)
{
- char *domain;
+ char *domain, *dup_domain = NULL;
char *group_name = NULL;
char *flags;
int ok = 0;
@@ -392,7 +535,9 @@ SWITCH_STANDARD_API(group_call_function)
if (domain) {
*domain++ = '\0';
} else {
- domain = switch_core_get_variable("domain");
+ if ((dup_domain = switch_core_get_variable_dup("domain"))) {
+ domain = dup_domain;
+ }
}
if (!zstr(domain)) {
@@ -544,13 +689,14 @@ SWITCH_STANDARD_API(group_call_function)
}
end:
-
+
switch_safe_free(group_name);
+ switch_safe_free(dup_domain);
if (!ok) {
stream->write_function(stream, "error/NO_ROUTE_DESTINATION");
}
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -559,7 +705,7 @@ SWITCH_STANDARD_API(in_group_function)
{
switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group;
int argc;
- char *mydata = NULL, *argv[2], *user, *domain;
+ char *mydata = NULL, *argv[2], *user, *domain, *dup_domain = NULL;
char delim = ',';
switch_event_t *params = NULL;
const char *rval = "false";
@@ -579,7 +725,9 @@ SWITCH_STANDARD_API(in_group_function)
if ((domain = strchr(user, '@'))) {
*domain++ = '\0';
} else {
- domain = switch_core_get_variable("domain");
+ if ((dup_domain = switch_core_get_variable_dup("domain"))) {
+ domain = dup_domain;
+ }
}
switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
@@ -601,6 +749,7 @@ SWITCH_STANDARD_API(in_group_function)
switch_xml_free(xml);
switch_safe_free(mydata);
+ switch_safe_free(dup_domain);
switch_event_destroy(¶ms);
return SWITCH_STATUS_SUCCESS;
@@ -610,7 +759,7 @@ SWITCH_STANDARD_API(user_data_function)
{
switch_xml_t x_domain, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
int argc;
- char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain;
+ char *mydata = NULL, *argv[3], *key = NULL, *type = NULL, *user, *domain, *dup_domain = NULL;
char delim = ' ';
const char *container = "params", *elem = "param";
const char *result = NULL;
@@ -631,7 +780,9 @@ SWITCH_STANDARD_API(user_data_function)
if ((domain = strchr(user, '@'))) {
*domain++ = '\0';
} else {
- if (!(domain = switch_core_get_variable("domain"))) {
+ if ((dup_domain = switch_core_get_variable_dup("domain"))) {
+ domain = dup_domain;
+ } else {
domain = "cluecon.com";
}
}
@@ -694,6 +845,7 @@ SWITCH_STANDARD_API(user_data_function)
}
switch_xml_free(xml);
switch_safe_free(mydata);
+ switch_safe_free(dup_domain);
switch_event_destroy(¶ms);
return SWITCH_STATUS_SUCCESS;
@@ -2372,7 +2524,7 @@ SWITCH_STANDARD_API(uuid_media_function)
return SWITCH_STATUS_SUCCESS;
}
-#define BROADCAST_SYNTAX " [aleg|bleg|both]"
+#define BROADCAST_SYNTAX " [aleg|bleg|holdb|both]"
SWITCH_STANDARD_API(uuid_broadcast_function)
{
char *mycmd = NULL, *argv[4] = { 0 };
@@ -2389,15 +2541,26 @@ SWITCH_STANDARD_API(uuid_broadcast_function)
switch_media_flag_t flags = SMF_NONE;
if (argv[2]) {
- if (!strcasecmp(argv[2], "both")) {
+ if (switch_stristr("both", (argv[2]))) {
flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG);
- } else if (!strcasecmp(argv[2], "aleg")) {
+ }
+
+ if (switch_stristr("aleg", argv[2])) {
flags |= SMF_ECHO_ALEG;
- } else if (!strcasecmp(argv[2], "bleg")) {
+ }
+
+ if (switch_stristr("bleg", argv[2])) {
+ flags &= ~SMF_HOLD_BLEG;
flags |= SMF_ECHO_BLEG;
}
+
+ if (switch_stristr("holdb", argv[2])) {
+ flags &= ~SMF_ECHO_BLEG;
+ flags |= SMF_HOLD_BLEG;
+ }
+
} else {
- flags |= SMF_ECHO_ALEG;
+ flags = SMF_ECHO_ALEG | SMF_HOLD_BLEG;
}
status = switch_ivr_broadcast(argv[0], argv[1], flags);
@@ -3718,6 +3881,14 @@ SWITCH_STANDARD_API(show_function)
as = argv[3];
}
}
+ } else if (!strcasecmp(command, "registrations")) {
+ sprintf(sql, "select * from registrations where hostname='%s'", hostname);
+ if (argv[1] && !strcasecmp(argv[1], "count")) {
+ holder.justcount = 1;
+ if (argv[3] && !strcasecmp(argv[2], "as")) {
+ as = argv[3];
+ }
+ }
} else if (!strcasecmp(command, "channels") && argv[1] && !strcasecmp(argv[1], "like")) {
if (argv[2]) {
char *p;
@@ -4364,7 +4535,9 @@ SWITCH_STANDARD_API(global_getvar_function)
if (zstr(cmd)) {
switch_core_dump_variables(stream);
} else {
- stream->write_function(stream, "%s", switch_str_nil(switch_core_get_variable(cmd)));
+ char *var = switch_core_get_variable_dup(cmd);
+ stream->write_function(stream, "%s", switch_str_nil(var));
+ switch_safe_free(var);
}
return SWITCH_STATUS_SUCCESS;
}
@@ -4417,19 +4590,23 @@ SWITCH_STANDARD_API(strftime_tz_api_function)
if ((format = strchr(mycmd, ' '))) {
*format++ = '\0';
- }
- if ((p = strchr(format, '|'))) {
- *p++ = '\0';
- when = atol(format);
- format = p;
+ if (format && (p = strchr(format, '|'))) {
+ *p++ = '\0';
+ when = atol(format);
+ format = p;
+ }
}
}
- if (switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) { /* The lookup of the zone may fail. */
+ if (zstr(format)) {
+ format = "%Y-%m-%d";
+ }
+
+ if (format && switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) { /* The lookup of the zone may fail. */
stream->write_function(stream, "%s", date);
} else {
- stream->write_function(stream, "-ERR Invalid Timezone\n");
+ stream->write_function(stream, "-ERR Invalid Timezone/Format\n");
}
switch_safe_free(mycmd);
@@ -4864,6 +5041,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
SWITCH_ADD_API(commands_api_interface, "tone_detect", "Start Tone Detection on a channel", tone_detect_session_function, TONE_DETECT_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "unload", "Unload Module", unload_function, UNLOAD_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "unsched_api", "Unschedule an api command", unsched_api_function, UNSCHED_SYNTAX);
+ SWITCH_ADD_API(commands_api_interface, "reg_url", "", reg_url_function, "@");
SWITCH_ADD_API(commands_api_interface, "url_decode", "url decode a string", url_decode_function, "");
SWITCH_ADD_API(commands_api_interface, "url_encode", "url encode a string", url_encode_function, "");
SWITCH_ADD_API(commands_api_interface, "user_data", "find user data", user_data_function, "@ [var|param|attr] ");
@@ -4974,6 +5152,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
switch_console_set_complete("add show management");
switch_console_set_complete("add show modules");
switch_console_set_complete("add show nat_map");
+ switch_console_set_complete("add show registrations");
switch_console_set_complete("add show say");
switch_console_set_complete("add show timer");
switch_console_set_complete("add shutdown");
diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c
index 2d9341a598..5eeae5c781 100644
--- a/src/mod/applications/mod_conference/mod_conference.c
+++ b/src/mod/applications/mod_conference/mod_conference.c
@@ -152,7 +152,8 @@ typedef enum {
CFLAG_BRIDGE_TO = (1 << 6),
CFLAG_WAIT_MOD = (1 << 7),
CFLAG_VID_FLOOR = (1 << 8),
- CFLAG_WASTE_BANDWIDTH = (1 << 9)
+ CFLAG_WASTE_BANDWIDTH = (1 << 9),
+ CFLAG_OUTCALL = (1 << 10)
} conf_flag_t;
typedef enum {
@@ -265,6 +266,7 @@ typedef struct conference_obj {
switch_thread_rwlock_t *rwlock;
uint32_t count;
int32_t energy_level;
+ int32_t agc_energy_level;
uint8_t min;
switch_speech_handle_t lsh;
switch_speech_handle_t *sh;
@@ -288,6 +290,8 @@ typedef struct conference_obj {
uint32_t avg_tally;
switch_time_t run_time;
char *uuid_str;
+ uint32_t originating;
+ switch_call_cause_t cancel_cause;
} conference_obj_t;
/* Relationship with another member */
@@ -323,6 +327,7 @@ struct conference_member {
uint32_t frame_size;
uint8_t *mux_frame;
uint32_t read;
+ uint32_t vol_period;
int32_t energy_level;
int32_t agc_volume_in_level;
int32_t volume_in_level;
@@ -342,7 +347,7 @@ struct conference_member {
uint32_t verbose_events;
uint32_t avg_score;
uint32_t avg_itt;
- uint32_t avg_tally;
+ uint32_t avg_tally;
struct conference_member *next;
switch_ivr_dmachine_t *dmachine;
};
@@ -395,11 +400,17 @@ SWITCH_STANDARD_API(conf_api_main);
static switch_status_t conference_outcall(conference_obj_t *conference,
char *conference_name,
switch_core_session_t *session,
- char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause);
+ char *bridgeto, uint32_t timeout,
+ char *flags,
+ char *cid_name,
+ char *cid_num,
+ char *profile,
+ switch_call_cause_t *cause,
+ switch_call_cause_t *cancel_cause);
static switch_status_t conference_outcall_bg(conference_obj_t *conference,
char *conference_name,
switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
- const char *cid_num, const char *call_uuid);
+ const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause);
SWITCH_STANDARD_APP(conference_function);
static void launch_conference_thread(conference_obj_t *conference);
static void launch_conference_video_thread(conference_obj_t *conference);
@@ -477,6 +488,7 @@ static switch_status_t conference_add_event_member_data(conference_member_t *mem
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Mute-Detect", "%s", switch_test_flag(member, MFLAG_MUTE_DETECT) ? "true" : "false" );
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-Type", "%s", switch_test_flag(member, MFLAG_MOD) ? "moderator" : "member");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Energy-Level", "%d", member->energy_level);
return status;
}
@@ -1380,6 +1392,14 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
/* Rinse ... Repeat */
end:
+ if (switch_test_flag(conference, CFLAG_OUTCALL)) {
+ conference->cancel_cause = SWITCH_CAUSE_ORIGINATOR_CANCEL;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Ending pending outcall channels for Conference: '%s'\n", conference->name);
+ while(conference->originating) {
+ switch_yield(200000);
+ }
+ }
+
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
@@ -1922,6 +1942,17 @@ static void conference_loop_fn_hangup(conference_member_t *member, caller_contro
switch_clear_flag_locked(member, MFLAG_RUNNING);
}
+static void clear_avg(conference_member_t *member)
+{
+
+ member->agc_volume_in_level = 0;
+ member->avg_score = 0;
+ member->avg_itt = 0;
+ member->avg_tally = 0;
+ member->nt_tally = 0;
+}
+
+
/* marshall frames from the call leg to the conference thread for muxing to other call legs */
static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj)
{
@@ -1930,7 +1961,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
switch_channel_t *channel;
switch_status_t status;
switch_frame_t *read_frame = NULL;
- uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400;
+ uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400;
switch_codec_implementation_t read_impl = { 0 };
switch_core_session_t *session = member->session;
int check_floor_change;
@@ -1973,6 +2004,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
if (++hangover_hits >= hangover) {
hangover_hits = hangunder_hits = 0;
switch_clear_flag_locked(member, MFLAG_TALKING);
+ clear_avg(member);
if (test_eflag(member->conference, EFLAG_STOP_TALKING) &&
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
@@ -1988,19 +2020,9 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
/* Check for input volume adjustments */
if (!member->conference->agc_level) {
- member->agc_volume_in_level = 0;
- member->avg_score = 0;
- member->avg_itt = 0;
- member->avg_tally = 0;
- }
-
- if (member->conference->agc_level && member->agc_volume_in_level) {
- switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, member->agc_volume_in_level);
- } else if (member->volume_in_level) {
- switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, member->volume_in_level);
+ clear_avg(member);
}
-
energy_level = member->energy_level;
/* if the member can speak, compute the audio energy level and */
@@ -2009,7 +2031,8 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
uint32_t energy = 0, i = 0, samples = 0, j = 0;
int16_t *data;
int divisor = 0;
- int one_sec = (read_impl.actual_samples_per_second / read_impl.samples_per_packet);
+ int agc_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) / 2;
+ int combined_vol = 0;
data = read_frame->data;
@@ -2019,77 +2042,62 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
member->score = 0;
+ combined_vol = member->agc_volume_in_level;
+ if (member->conference->agc_level) {
+ combined_vol += member->agc_volume_in_level;
+ }
+
+ if (combined_vol) {
+ switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, combined_vol);
+ }
+
if ((samples = read_frame->datalen / sizeof(*data))) {
for (i = 0; i < samples; i++) {
energy += abs(data[j]);
j += read_impl.number_of_channels;
}
member->score = energy / (samples / divisor);
- member->avg_tally += member->score;
- member->avg_score = member->avg_tally / ++member->avg_itt;
- if (!member->avg_itt) member->avg_tally = member->score;
}
+ if (member->vol_period) {
+ member->vol_period--;
+ }
+
if (member->conference->agc_level && member->score &&
- switch_test_flag(member, MFLAG_TALKING) &&
switch_test_flag(member, MFLAG_CAN_SPEAK) &&
- member->score > member->energy_level
+ member->score > member->conference->agc_energy_level
) {
- int diff = member->conference->agc_level - member->score;
- if (abs(diff) >= 200) {
- member->agc_concur++;
- } else {
- member->agc_concur = 0;
- }
-
-#if 0
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG8,
- "conf %s FOO %d %d %d %d %d\n",
- member->conference->name,
- member->id, diff, member->conference->agc_level,
- member->score, member->agc_volume_in_level);
-#endif
+ member->avg_tally += member->score;
+ member->avg_itt++;
+ if (!member->avg_itt) member->avg_itt++;
+ member->avg_score = member->avg_tally / member->avg_itt;
- if (member->agc_concur >= one_sec) {
- if (member->score < member->conference->agc_level) {
- member->agc_volume_in_level++;
-
- switch_normalize_volume(member->agc_volume_in_level);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7,
- "conf %s AGC +++ %d %d %d %d %d\n",
- member->conference->name,
- member->id, diff, member->conference->agc_level,
- member->score, member->agc_volume_in_level);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7,
+ "conf %s AGC %d %d %d %d %d %d\n",
+ member->conference->name,
+ member->id, member->conference->agc_level - member->avg_score, member->conference->agc_level,
+ member->score, member->avg_score, member->agc_volume_in_level);
- } else {
- member->agc_volume_in_level--;
-
- switch_normalize_volume(member->agc_volume_in_level);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7,
- "conf %s AGC --- %d %d %d %d %d\n",
- member->conference->name,
- member->id, diff, member->conference->agc_level,
- member->score, member->agc_volume_in_level);
+
+ if (++member->nt_tally >= agc_period) {
+ if (!member->vol_period) {
+ if (member->avg_score < member->conference->agc_level) {
+ member->agc_volume_in_level++;
+ switch_normalize_volume(member->agc_volume_in_level);
+ member->vol_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) * 2;
+ }
+
+ if (member->avg_score > member->conference->agc_level) {
+ member->agc_volume_in_level--;
+ switch_normalize_volume(member->agc_volume_in_level);
+ member->vol_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) * 2;
+ }
}
- member->agc_concur = 0;
- }
- member->nt_tally = 0;
- } else {
- member->nt_tally++;
- member->agc_concur = 0;
-
- if (member->nt_tally > one_sec * 5) {
- member->agc_volume_in_level = 0;
member->nt_tally = 0;
- member->avg_itt = 0;
- member->avg_tally = 0;
- member->avg_score = member->score;
}
-
-
}
member->score_iir = (int) (((1.0 - SCORE_DECAY) * (float) member->score) + (SCORE_DECAY * (float) member->score_iir));
@@ -2144,6 +2152,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
if (++hangover_hits >= hangover) {
hangover_hits = hangunder_hits = 0;
switch_clear_flag_locked(member, MFLAG_TALKING);
+ clear_avg(member);
if (test_eflag(member->conference, EFLAG_STOP_TALKING) &&
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
@@ -2393,6 +2402,7 @@ static void conference_loop_output(conference_member_t *member)
const char *cid_num = switch_channel_get_variable(channel, "conference_auto_outcall_caller_id_number");
const char *toval = switch_channel_get_variable(channel, "conference_auto_outcall_timeout");
const char *flags = switch_channel_get_variable(channel, "conference_auto_outcall_flags");
+ const char *profile = switch_channel_get_variable(channel, "conference_auto_outcall_profile");
const char *ann = switch_channel_get_variable(channel, "conference_auto_outcall_announce");
const char *prefix = switch_channel_get_variable(channel, "conference_auto_outcall_prefix");
int to = 60;
@@ -2403,6 +2413,8 @@ static void conference_loop_output(conference_member_t *member)
switch_channel_set_private(channel, "_conference_autocall_list_", NULL);
+ switch_set_flag(member->conference, CFLAG_OUTCALL);
+
if (toval) {
to = atoi(toval);
if (to < 10 || to > 500) {
@@ -2421,7 +2433,8 @@ static void conference_loop_output(conference_member_t *member)
for (x = 0; x < argc; x++) {
char *dial_str = switch_mprintf("%s%s", switch_str_nil(prefix), argv[x]);
switch_assert(dial_str);
- conference_outcall_bg(member->conference, NULL, NULL, dial_str, to, switch_str_nil(flags), cid_name, cid_num, NULL);
+ conference_outcall_bg(member->conference, NULL, NULL, dial_str, to, switch_str_nil(flags), cid_name, cid_num, NULL,
+ profile, &member->conference->cancel_cause);
switch_safe_free(dial_str);
}
switch_safe_free(cpstr);
@@ -3399,7 +3412,7 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str
static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv)
{
- int level;
+ int level, energy_level;
int on = 0;
if (argc == 2) {
@@ -3417,7 +3430,13 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str
if (argc > 3) {
level = atoi(argv[3]);
} else {
- level = 2000;
+ level = 650;
+ }
+
+ if (argc > 4) {
+ energy_level = atoi(argv[4]);
+ } else {
+ energy_level = 100;
}
if (level > conference->energy_level) {
@@ -3425,9 +3444,10 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str
conference->avg_itt = 0;
conference->avg_tally = 0;
conference->agc_level = level;
-
+ conference->agc_energy_level = energy_level;
+
if (stream) {
- stream->write_function(stream, "OK AGC ENABLED %d\n", conference->agc_level);
+ stream->write_function(stream, "OK AGC ENABLED %d %d\n", conference->agc_level, conference->agc_energy_level);
}
} else {
@@ -3758,6 +3778,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer
switch_xml_set_attr_d(x_conference, "member-count", ival);
switch_snprintf(i, sizeof(i), "%u", conference->rate);
switch_xml_set_attr_d(x_conference, "rate", ival);
+ switch_xml_set_attr_d(x_conference, "uuid", conference->uuid_str);
if (switch_test_flag(conference, CFLAG_LOCKED)) {
switch_xml_set_attr_d(x_conference, "locked", "true");
@@ -3800,7 +3821,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer
if (conference->agc_level) {
char tmp[30] = "";
- switch_snprintf(tmp, sizeof(tmp), "%d", conference->agc_level);
+ switch_snprintf(tmp, sizeof(tmp), "%d:%d", conference->agc_level, conference->agc_energy_level);
switch_xml_set_attr_d_buf(x_conference, "agc", tmp);
}
@@ -4243,9 +4264,9 @@ static switch_status_t conf_api_sub_dial(conference_obj_t *conference, switch_st
}
if (conference) {
- conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
+ conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &cause, NULL);
} else {
- conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], &cause);
+ conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &cause, NULL);
}
stream->write_function(stream, "Call Requested: result: [%s]\n", switch_channel_cause2str(cause));
@@ -4268,9 +4289,9 @@ static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_
switch_uuid_format(uuid_str, &uuid);
if (conference) {
- conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str);
+ conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL);
} else {
- conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str);
+ conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL);
}
stream->write_function(stream, "OK Job-UUID: %s\n", uuid_str);
@@ -4784,7 +4805,12 @@ SWITCH_STANDARD_API(conf_api_main)
static switch_status_t conference_outcall(conference_obj_t *conference,
char *conference_name,
switch_core_session_t *session,
- char *bridgeto, uint32_t timeout, char *flags, char *cid_name, char *cid_num, switch_call_cause_t *cause)
+ char *bridgeto, uint32_t timeout,
+ char *flags, char *cid_name,
+ char *cid_num,
+ char *profile,
+ switch_call_cause_t *cause,
+ switch_call_cause_t *cancel_cause)
{
switch_core_session_t *peer_session = NULL;
switch_channel_t *peer_channel;
@@ -4792,6 +4818,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
switch_channel_t *caller_channel = NULL;
char appdata[512];
int rdlock = 0;
+ switch_bool_t have_flags = SWITCH_FALSE;
*cause = SWITCH_CAUSE_NORMAL_CLEARING;
@@ -4830,8 +4857,15 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
/* establish an outbound call leg */
- if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NO_LIMITS, NULL) !=
- SWITCH_STATUS_SUCCESS) {
+ switch_mutex_lock(conference->mutex);
+ conference->originating++;
+ switch_mutex_unlock(conference->mutex);
+ status = switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NO_LIMITS, cancel_cause);
+ switch_mutex_lock(conference->mutex);
+ conference->originating--;
+ switch_mutex_unlock(conference->mutex);
+
+ if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n",
switch_channel_cause2str(*cause));
if (caller_channel) {
@@ -4842,7 +4876,6 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
rdlock = 1;
peer_channel = switch_core_session_get_channel(peer_session);
- switch_channel_set_state(peer_channel, CS_SOFT_EXECUTE);
/* make sure the conference still exists */
if (!switch_test_flag(conference, CFLAG_RUNNING)) {
@@ -4870,13 +4903,16 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
status = SWITCH_STATUS_MEMERR;
goto done;
}
- /* add them to the conference */
+
if (flags && strcasecmp(flags, "none")) {
- switch_snprintf(appdata, sizeof(appdata), "%s+flags{%s}", conference_name, flags);
- switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
- } else {
- switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);
+ have_flags = SWITCH_TRUE;
}
+ /* add them to the conference */
+
+ switch_snprintf(appdata, sizeof(appdata), "%s%s%s%s%s%s", conference_name,
+ profile?"@":"", profile?profile:"",
+ have_flags?"+flags{":"", have_flags?flags:"", have_flags?"}":"");
+ switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
switch_channel_set_caller_extension(peer_channel, extension);
switch_channel_set_state(peer_channel, CS_EXECUTE);
@@ -4908,6 +4944,8 @@ struct bg_call {
char *cid_num;
char *conference_name;
char *uuid;
+ char *profile;
+ switch_call_cause_t *cancel_cause;
switch_memory_pool_t *pool;
};
@@ -4920,7 +4958,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,
switch_event_t *event;
conference_outcall(call->conference, call->conference_name,
- call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause);
+ call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, call->profile, &cause, call->cancel_cause);
if (call->conference && test_eflag(call->conference, EFLAG_BGDIAL_RESULT) &&
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
@@ -4936,6 +4974,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,
switch_safe_free(call->cid_num);
switch_safe_free(call->conference_name);
switch_safe_free(call->uuid);
+ switch_safe_free(call->profile);
if (call->pool) {
switch_core_destroy_memory_pool(&call->pool);
}
@@ -4948,7 +4987,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,
static switch_status_t conference_outcall_bg(conference_obj_t *conference,
char *conference_name,
switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
- const char *cid_num, const char *call_uuid)
+ const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause)
{
struct bg_call *call = NULL;
switch_thread_t *thread;
@@ -4962,6 +5001,7 @@ static switch_status_t conference_outcall_bg(conference_obj_t *conference,
call->conference = conference;
call->session = session;
call->timeout = timeout;
+ call->cancel_cause = cancel_cause;
if (conference) {
pool = conference->pool;
@@ -4991,6 +5031,10 @@ static switch_status_t conference_outcall_bg(conference_obj_t *conference,
call->uuid = strdup(call_uuid);
}
+ if (profile) {
+ call->profile = strdup(profile);
+ }
+
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -5664,8 +5708,9 @@ SWITCH_STANDARD_APP(conference_function)
/* more friendliness */
if (conference->bad_pin_sound) {
- conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf, sizeof(pin_buf));
+ conference_local_play_file(conference, session, conference->bad_pin_sound, 20, NULL, 0);
}
+ switch_channel_flush_dtmf(channel);
}
pin_retries--;
}
@@ -5715,7 +5760,7 @@ SWITCH_STANDARD_APP(conference_function)
/* if we're using "bridge:" make an outbound call and bridge it in */
if (!zstr(bridgeto) && strcasecmp(bridgeto, "none")) {
switch_call_cause_t cause;
- if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &cause) != SWITCH_STATUS_SUCCESS) {
+ if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, NULL, &cause, NULL) != SWITCH_STATUS_SUCCESS) {
goto done;
}
} else {
@@ -6344,16 +6389,30 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
if (!zstr(auto_gain_level)) {
int level = 0;
+ int energy_level = 100;
if (switch_true(auto_gain_level)) {
- level = 2000;
+ level = 650;
} else {
+ char *p;
+ int tmp = 0;
+
level = atoi(auto_gain_level);
+ if ((p = strchr(auto_gain_level, ':'))) {
+ p++;
+ if (p) tmp = atoi(p);
+ if (tmp > 0) {
+ energy_level = tmp;
+ }
+ }
}
if (level > 0 && level > conference->energy_level) {
conference->agc_level = level;
}
+
+ conference->agc_energy_level = energy_level;
+
}
if (!zstr(maxmember_sound)) {
diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c
index 41417255bb..9a1258a5b6 100755
--- a/src/mod/applications/mod_dptools/mod_dptools.c
+++ b/src/mod/applications/mod_dptools/mod_dptools.c
@@ -28,6 +28,7 @@
* Michael Murdock
* Neal Horman
* Bret McDanel
+ * Luke Dashjr (OpenMethods, LLC)
*
* mod_dptools.c -- Raw Audio File Streaming Application Module
*
@@ -269,7 +270,7 @@ SWITCH_STANDARD_APP(bind_digit_action_function)
}
-#define DETECT_SPEECH_SYNTAX " [] OR grammar [] OR nogrammar OR pause OR resume OR stop OR param "
+#define DETECT_SPEECH_SYNTAX " [] OR grammar [] OR nogrammar OR grammaron/grammaroff OR grammarsalloff OR pause OR resume OR start_input_timers OR stop OR param "
SWITCH_STANDARD_APP(detect_speech_function)
{
char *argv[4];
@@ -282,6 +283,12 @@ SWITCH_STANDARD_APP(detect_speech_function)
switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]);
} else if (!strcasecmp(argv[0], "nogrammar")) {
switch_ivr_detect_speech_unload_grammar(session, argv[1]);
+ } else if (!strcasecmp(argv[0], "grammaron")) {
+ switch_ivr_detect_speech_enable_grammar(session, argv[1]);
+ } else if (!strcasecmp(argv[0], "grammaroff")) {
+ switch_ivr_detect_speech_disable_grammar(session, argv[1]);
+ } else if (!strcasecmp(argv[0], "grammarsalloff")) {
+ switch_ivr_detect_speech_disable_all_grammars(session);
} else if (!strcasecmp(argv[0], "pause")) {
switch_ivr_pause_detect_speech(session);
} else if (!strcasecmp(argv[0], "resume")) {
@@ -290,6 +297,8 @@ SWITCH_STANDARD_APP(detect_speech_function)
switch_ivr_stop_detect_speech(session);
} else if (!strcasecmp(argv[0], "param")) {
switch_ivr_set_param_detect_speech(session, argv[1], argv[2]);
+ } else if (!strcasecmp(argv[0], "start_input_timers")) {
+ switch_ivr_detect_speech_start_input_timers(session);
} else if (argc >= 3) {
switch_ivr_detect_speech(session, argv[0], argv[1], argv[2], argv[3], NULL);
}
@@ -1855,6 +1864,7 @@ SWITCH_STANDARD_APP(att_xfer_function)
if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)
!= SWITCH_STATUS_SUCCESS || !peer_session) {
+ switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);
goto end;
}
@@ -1869,6 +1879,7 @@ SWITCH_STANDARD_APP(att_xfer_function)
if (zstr(bond) && switch_channel_down(peer_channel)) {
switch_core_session_rwunlock(peer_session);
+ switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);
goto end;
}
@@ -2765,7 +2776,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session
switch_originate_flag_t myflags = SOF_NONE;
char *cid_name_override = NULL;
char *cid_num_override = NULL;
- char *domain = NULL;
+ char *domain = NULL, *dup_domain = NULL;
switch_channel_t *new_channel = NULL;
unsigned int timelimit = 60;
const char *skip, *var;
@@ -2778,7 +2789,8 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session
if ((domain = strchr(group, '@'))) {
*domain++ = '\0';
} else {
- domain = switch_core_get_variable("domain");
+ domain = switch_core_get_variable_pdup("domain", switch_core_session_get_pool(session));
+ dup_domain = domain;
}
if (!domain) {
@@ -2850,6 +2862,7 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session
switch_safe_free(template);
switch_safe_free(group);
+ switch_safe_free(dup_domain);
if (cause == SWITCH_CAUSE_NONE) {
cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
@@ -2878,7 +2891,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
switch_call_cause_t *cancel_cause)
{
switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
- char *user = NULL, *domain = NULL;
+ char *user = NULL, *domain = NULL, *dup_domain = NULL;
const char *dest = NULL;
static switch_call_cause_t cause = SWITCH_CAUSE_NONE;
unsigned int timelimit = 60;
@@ -2899,7 +2912,8 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
if ((domain = strchr(user, '@'))) {
*domain++ = '\0';
} else {
- domain = switch_core_get_variable("domain");
+ domain = switch_core_get_variable_dup("domain");
+ dup_domain = domain;
}
if (!domain) {
@@ -2982,6 +2996,8 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
}
}
}
+ switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_user", user);
+ switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
if (!dest) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No dial-string available, please check your user directory.\n");
@@ -3104,6 +3120,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
}
switch_safe_free(user);
+ switch_safe_free(dup_domain);
return cause;
}
@@ -3182,10 +3199,11 @@ static switch_status_t event_chat_send(const char *proto, const char *from, cons
if (body)
switch_event_add_body(event, "%s", body);
if (to) {
- const char *v;
+ char *v;
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "To", to);
- if ((v = switch_core_get_variable(to))) {
+ if ((v = switch_core_get_variable_dup(to))) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Command", v);
+ free(v);
}
}
@@ -3203,15 +3221,15 @@ static switch_status_t api_chat_send(const char *proto, const char *from, const
const char *body, const char *type, const char *hint)
{
if (to) {
- const char *v;
+ char *v = NULL;
switch_stream_handle_t stream = { 0 };
char *cmd = NULL, *arg;
- if (!(v = switch_core_get_variable(to))) {
- v = to;
+ if (!(v = switch_core_get_variable_dup(to))) {
+ v = strdup(to);
}
- cmd = strdup(v);
+ cmd = v;
switch_assert(cmd);
switch_url_decode(cmd);
diff --git a/src/mod/applications/mod_easyroute/mod_easyroute.c b/src/mod/applications/mod_easyroute/mod_easyroute.c
index 481df958cf..75b4712f2d 100644
--- a/src/mod/applications/mod_easyroute/mod_easyroute.c
+++ b/src/mod/applications/mod_easyroute/mod_easyroute.c
@@ -65,6 +65,7 @@ static struct {
switch_mutex_t *mutex;
char *custom_query;
switch_odbc_handle_t *master_odbc;
+ int odbc_num_retries;
} globals;
SWITCH_MODULE_LOAD_FUNCTION(mod_easyroute_load);
@@ -120,6 +121,8 @@ static switch_status_t load_config(void)
set_global_default_gateway(val);
} else if (!strcasecmp(var, "custom-query")) {
set_global_custom_query(val);
+ } else if (!strcasecmp(var, "odbc-retries")) {
+ globals.odbc_num_retries = atoi(val);
}
}
}
@@ -143,6 +146,9 @@ static switch_status_t load_config(void)
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opened ODBC Database!\n");
}
+ if (globals.odbc_num_retries) {
+ switch_odbc_set_num_retries(globals.master_odbc, globals.odbc_num_retries);
+ }
if (switch_odbc_handle_connect(globals.master_odbc) != SWITCH_ODBC_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
status = SWITCH_STATUS_FALSE;
@@ -205,7 +211,7 @@ static switch_status_t route_lookup(char *dn, easyroute_results_t *results, int
switch_mutex_lock(globals.mutex);
}
/* Do the Query */
- if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, route_callback, &pdata, NULL) == SWITCH_ODBC_SUCCESS) {
+ if (globals.master_odbc && switch_odbc_handle_callback_exec(globals.master_odbc, sql, route_callback, &pdata, NULL) == SWITCH_ODBC_SUCCESS) {
char tmp_profile[129];
char tmp_gateway[129];
@@ -418,7 +424,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_easyroute_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_easyroute_shutdown)
{
- switch_odbc_handle_disconnect(globals.master_odbc);
+ if (globals.master_odbc) {
+ switch_odbc_handle_disconnect(globals.master_odbc);
+ switch_odbc_handle_destroy(&globals.master_odbc);
+ }
switch_safe_free(globals.db_username);
switch_safe_free(globals.db_password);
switch_safe_free(globals.db_dsn);
diff --git a/src/mod/applications/mod_fsk/mod_fsk.c b/src/mod/applications/mod_fsk/mod_fsk.c
index 9802353075..0291707c62 100644
--- a/src/mod/applications/mod_fsk/mod_fsk.c
+++ b/src/mod/applications/mod_fsk/mod_fsk.c
@@ -220,6 +220,7 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat
char *sp;
switch_event_t *event;
const char *app_var;
+ int total = 0;
switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA);
@@ -255,6 +256,7 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat
}
if (varname && val) {
+ total++;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s setting FSK var [%s][%s]\n",
switch_channel_get_name(channel), varname, val);
switch_channel_set_variable(channel, varname, val);
@@ -270,7 +272,7 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat
}
}
- if ((app_var = switch_channel_get_variable(channel, "execute_on_fsk"))) {
+ if (total && (app_var = switch_channel_get_variable(channel, "execute_on_fsk"))) {
char *app_arg;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s processing execute_on_fsk [%s]\n",
diff --git a/src/mod/applications/mod_redis/mod_redis.c b/src/mod/applications/mod_redis/mod_redis.c
index 1e999675b1..ebf2a9e324 100755
--- a/src/mod/applications/mod_redis/mod_redis.c
+++ b/src/mod/applications/mod_redis/mod_redis.c
@@ -89,7 +89,7 @@ SWITCH_LIMIT_INCR(limit_incr_redis)
}
/* Get the keys for redis server */
- uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_variable("hostname"), realm, resource);
+ uuid_rediskey = switch_core_session_sprintf(session,"%s_%s_%s", switch_core_get_hostname(), realm, resource);
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
if ((pvt = switch_channel_get_private(channel, "limit_redis"))) {
@@ -179,7 +179,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", (char *)p_key);
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
- p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_variable("hostname"), (char *)p_key);
+ p_uuid_key = switch_core_session_sprintf(session, "%s_%s", switch_core_get_hostname(), (char *)p_key);
if (credis_decr(redis,p_uuid_key,&uuid_val) != 0) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", p_uuid_key);
switch_goto_status(SWITCH_STATUS_FALSE, end);
@@ -193,7 +193,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
} else {
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
- uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_variable("hostname"), realm, resource);
+ uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_hostname(), realm, resource);
switch_core_hash_delete(pvt->hash, (const char *) rediskey);
if (credis_decr(redis, rediskey, &val) != 0) {
@@ -249,13 +249,13 @@ SWITCH_LIMIT_RESET(limit_reset_redis)
{
REDIS redis;
if (redis_factory(&redis) == SWITCH_STATUS_SUCCESS) {
- char *rediskey = switch_mprintf("%s_*", switch_core_get_variable("hostname"));
+ char *rediskey = switch_mprintf("%s_*", switch_core_get_hostname());
int dec = 0, val = 0, keyc;
char *uuids[2000];
if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) > 0) {
int i = 0;
- int hostnamelen = strlen(switch_core_get_variable("hostname"))+1;
+ int hostnamelen = strlen(switch_core_get_hostname())+1;
for (i = 0; i < keyc && uuids[i]; i++){
const char *key = uuids[i] + hostnamelen;
diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c
index 21c6a68a0e..4dd936b8c6 100644
--- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c
+++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c
@@ -40,6 +40,9 @@
#define MAX_FEC_ENTRIES 4
#define MAX_FEC_SPAN 4
+#define SPANDSP_EVENT_TXFAXRESULT "spandsp::txfaxresult"
+#define SPANDSP_EVENT_RXFAXRESULT "spandsp::rxfaxresult"
+
/*****************************************************************************
OUR DEFINES AND STRUCTS
*****************************************************************************/
@@ -305,7 +308,14 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_core_session_t *session;
switch_channel_t *channel;
pvt_t *pvt;
- char *tmp;
+ char *fax_document_transferred_pages = NULL;
+ char *fax_document_total_pages = NULL;
+ char *fax_image_resolution = NULL;
+ char *fax_image_size = NULL;
+ char *fax_bad_rows = NULL;
+ char *fax_transfer_rate = NULL;
+ char *fax_result_code = NULL;
+ switch_event_t *event;
pvt = (pvt_t *) user_data;
switch_assert(pvt);
@@ -353,13 +363,12 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n");
/*
- Set our channel variables
+ Set our channel variables, variables are also used in event
*/
- tmp = switch_mprintf("%i", result);
- if (tmp) {
- switch_channel_set_variable(channel, "fax_result_code", tmp);
- switch_safe_free(tmp);
+ fax_result_code = switch_core_session_sprintf(session, "%i", result);
+ if (fax_result_code) {
+ switch_channel_set_variable(channel, "fax_result_code", fax_result_code);
}
switch_channel_set_variable(channel, "fax_result_text", t30_completion_code_to_str(result));
@@ -368,49 +377,56 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_channel_set_variable(channel, "fax_local_station_id", local_ident);
switch_channel_set_variable(channel, "fax_remote_station_id", far_ident);
- tmp = switch_mprintf("%i", pvt->app_mode == FUNCTION_TX ? t.pages_tx : t.pages_rx);
- if (tmp) {
- switch_channel_set_variable(channel, "fax_document_transferred_pages", tmp);
- switch_safe_free(tmp);
+ fax_document_transferred_pages = switch_core_session_sprintf(session, "%i", pvt->app_mode == FUNCTION_TX ? t.pages_tx : t.pages_rx);
+ if (fax_document_transferred_pages) {
+ switch_channel_set_variable(channel, "fax_document_transferred_pages", fax_document_transferred_pages);
}
- tmp = switch_mprintf("%i", t.pages_in_file);
- if (tmp) {
- switch_channel_set_variable(channel, "fax_document_total_pages", tmp);
- switch_safe_free(tmp);
+ fax_document_total_pages = switch_core_session_sprintf(session, "%i", t.pages_in_file);
+ if (fax_document_total_pages) {
+ switch_channel_set_variable(channel, "fax_document_total_pages", fax_document_total_pages);
}
- tmp = switch_mprintf("%ix%i", t.x_resolution, t.y_resolution);
- if (tmp) {
- switch_channel_set_variable(channel, "fax_image_resolution", tmp);
- switch_safe_free(tmp);
+ fax_image_resolution = switch_core_session_sprintf(session, "%ix%i", t.x_resolution, t.y_resolution);
+ if (fax_image_resolution) {
+ switch_channel_set_variable(channel, "fax_image_resolution", fax_image_resolution);
}
- tmp = switch_mprintf("%d", t.image_size);
- if (tmp) {
- switch_channel_set_variable(channel, "fax_image_size", tmp);
- switch_safe_free(tmp);
+ fax_image_size = switch_core_session_sprintf(session, "%d", t.image_size);
+ if (fax_image_size) {
+ switch_channel_set_variable(channel, "fax_image_size", fax_image_size);
}
- tmp = switch_mprintf("%d", t.bad_rows);
- if (tmp) {
- switch_channel_set_variable(channel, "fax_bad_rows", tmp);
- switch_safe_free(tmp);
+ fax_bad_rows = switch_core_session_sprintf(session, "%d", t.bad_rows);
+ if (fax_bad_rows) {
+ switch_channel_set_variable(channel, "fax_bad_rows", fax_bad_rows);
}
- tmp = switch_mprintf("%i", t.bit_rate);
- if (tmp) {
- switch_channel_set_variable(channel, "fax_transfer_rate", tmp);
- switch_safe_free(tmp);
+ fax_transfer_rate = switch_core_session_sprintf(session, "%i", t.bit_rate);
+ if (fax_transfer_rate) {
+ switch_channel_set_variable(channel, "fax_transfer_rate", fax_transfer_rate);
}
/* switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); */
pvt->done = 1;
- /*
- TODO Fire events
- */
+ /* Fire event */
+
+ if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, pvt->app_mode == FUNCTION_TX ? SPANDSP_EVENT_TXFAXRESULT : SPANDSP_EVENT_RXFAXRESULT) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-document-transferred-pages", fax_document_transferred_pages);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-document-total-pages", fax_document_total_pages);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-image-resolution", fax_image_resolution);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-image-size", fax_image_size);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-bad-rows", fax_bad_rows);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-transfer-rate", fax_transfer_rate);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-result-code", fax_result_code);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-result-text", t30_completion_code_to_str(result));
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-ecm-used", (t.error_correcting_mode) ? "on" : "off");
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-local-station-id", local_ident);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-remote-station-id", far_ident);
+ switch_core_session_queue_private_event(session, &event, SWITCH_FALSE);
+ }
}
static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)
@@ -1026,7 +1042,6 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Fax TX filename not set.\n");
goto done;
} else if (pvt->app_mode == FUNCTION_RX) {
- char *fname;
const char *prefix;
switch_time_t time;
@@ -1036,11 +1051,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
prefix = globals.prepend_string;
}
- fname = switch_mprintf("%s/%s-%ld-%ld.tif", globals.spool, prefix, globals.total_sessions, time);
- if (fname) {
- pvt->filename = switch_core_session_strdup(session, fname);
- switch_safe_free(fname);
- } else {
+ if (!(pvt->filename = switch_core_session_sprintf(session, "%s/%s-%ld-%ld.tif", globals.spool, prefix, globals.total_sessions, time))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot automatically set fax RX destination file\n");
goto done;
}
diff --git a/src/mod/applications/mod_spy/mod_spy.c b/src/mod/applications/mod_spy/mod_spy.c
index 9986703f66..1797539cf0 100644
--- a/src/mod/applications/mod_spy/mod_spy.c
+++ b/src/mod/applications/mod_spy/mod_spy.c
@@ -201,14 +201,14 @@ static void event_handler(switch_event_t *event)
}
if (!(peer_session = switch_core_session_locate(peer_uuid))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant locate peer session for uuid %s\n", peer_uuid);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't locate peer session for uuid %s\n", peer_uuid);
return;
}
peer_channel = switch_core_session_get_channel(peer_session);
if (switch_event_create(&peer_event, SWITCH_EVENT_CHANNEL_BRIDGE) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cant create bridge event for peer channel %s\n", peer_uuid);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't create bridge event for peer channel %s\n", peer_uuid);
goto end;
}
@@ -249,7 +249,7 @@ SWITCH_STANDARD_APP(userspy_function)
status = switch_core_hash_insert(globals.spy_hash, argv[0], (void *) uuid);
if ((status != SWITCH_STATUS_SUCCESS)) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cant insert to spy hash\n");
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't insert to spy hash\n");
switch_channel_hangup(channel, SWITCH_CAUSE_SERVICE_NOT_IMPLEMENTED);
switch_thread_rwlock_unlock(globals.spy_hash_lock);
return;
diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c
index 76870f75b9..5515f76b72 100644
--- a/src/mod/applications/mod_voicemail/mod_voicemail.c
+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c
@@ -1011,6 +1011,11 @@ typedef struct msg_cnt_callback msg_cnt_callback_t;
static int message_count_callback(void *pArg, int argc, char **argv, char **columnNames)
{
msg_cnt_callback_t *cbt = (msg_cnt_callback_t *) pArg;
+
+ if (argc < 3 || zstr(argv[0]) || zstr(argv[1]) || zstr(argv[2])) {
+ return -1;
+ }
+
if (atoi(argv[0]) == 1) { /* UnRead */
if (!strcasecmp(argv[1], "A_URGENT")) { /* Urgent */
cbt->total_new_urgent_messages = atoi(argv[2]);
@@ -1263,7 +1268,7 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *
{
char msg_count[80] = "";
msg_cnt_callback_t cbt = { 0 };
- char sql[256];
+ char *sql;
char *myid = NULL;
@@ -1277,11 +1282,20 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *
myid = resolve_id(id_in, domain_name, "message-count");
- switch_snprintf(sql, sizeof(sql),
- "select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' group by read_epoch=0,read_flags;",
- myid, domain_name, myfolder);
+ sql = switch_mprintf(
+ "select 1, read_flags, count(read_epoch) from voicemail_msgs where "
+ "username='%q' and domain='%q' and in_folder='%q' and read_epoch=0 "
+ "group by read_flags "
+ "union "
+ "select 0, read_flags, count(read_epoch) from voicemail_msgs where "
+ "username='%q' and domain='%q' and in_folder='%q' and read_epoch<>0 "
+ "group by read_flags;",
+
+ myid, domain_name, myfolder,
+ myid, domain_name, myfolder);
vm_execute_sql_callback(profile, profile->mutex, sql, message_count_callback, &cbt);
+ free(sql);
*total_new_messages = cbt.total_new_messages + cbt.total_new_urgent_messages;
*total_new_urgent_messages = cbt.total_new_urgent_messages;
@@ -1711,8 +1725,7 @@ static void update_mwi(vm_profile_t *profile, const char *id, const char *domain
#define FREE_DOMAIN_ROOT() if (x_user) switch_xml_free(x_user); x_user = NULL
-
-static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *profile, const char *domain_name, const char *id, int auth)
+static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *profile, const char *domain_name, const char *id, int auth, const char *uuid_in)
{
vm_check_state_t vm_check_state = VM_CHECK_START;
switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -1886,6 +1899,9 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
cbt.type = play_msg_type;
cbt.move = VM_MOVE_NEXT;
vm_execute_sql_callback(profile, profile->mutex, sql, listen_callback, &cbt);
+ if (!zstr(uuid_in) && strcmp(cbt.uuid, uuid_in)) {
+ continue;
+ }
status = listen_file(session, profile, &cbt);
if (cbt.move == VM_MOVE_PREV) {
if (cur_message <= 0) {
@@ -2734,6 +2750,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
switch_memory_pool_t *pool = NULL;
char *forwarded_by = NULL;
char *read_flags = NORMAL_FLAG_STRING;
+ char *dup_domain = NULL;
if (zstr(data)) {
status = SWITCH_STATUS_FALSE;
@@ -2781,7 +2798,9 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
}
if (zstr(domain)) {
- domain = switch_core_get_variable("domain");
+ if ((dup_domain = switch_core_get_variable_dup("domain"))) {
+ domain = dup_domain;
+ }
profile_name = domain;
}
@@ -2915,6 +2934,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
end:
switch_safe_free(dup);
+ switch_safe_free(dup_domain);
return status;
}
@@ -2999,6 +3019,8 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
vm_email = switch_core_session_strdup(session, val);
} else if (!strcasecmp(var, "vm-notify-mailto")) {
vm_notify_email = switch_core_session_strdup(session, val);
+ } else if (!strcasecmp(var, "vm-skip-instructions")) {
+ skip_instructions = switch_true(val);
} else if (!strcasecmp(var, "email-addr")) {
email_addr = switch_core_session_strdup(session, val);
} else if (!strcasecmp(var, "vm-email-all-messages") && (send_main = switch_true(val))) {
@@ -3136,12 +3158,12 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
if (*buf != '\0') {
greet_key_press:
if (switch_stristr(buf, profile->login_keys)) {
- voicemail_check_main(session, profile, domain_name, id, 0);
+ voicemail_check_main(session, profile, domain_name, id, 0, NULL);
} else if ((!zstr(profile->operator_ext) || !zstr(operator_ext)) && !zstr(profile->operator_key) && !strcasecmp(buf, profile->operator_key) ) {
int argc;
char *argv[4];
char *mycmd;
-
+
if ((!zstr(operator_ext) && (mycmd = switch_core_session_strdup(session, operator_ext))) ||
(!zstr(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext)))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
@@ -3274,7 +3296,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
#define VM_DESC "voicemail"
-#define VM_USAGE "[check] [auth] []"
+#define VM_USAGE "[check] [auth] [] [uuid]"
SWITCH_STANDARD_APP(voicemail_function)
{
@@ -3286,6 +3308,7 @@ SWITCH_STANDARD_APP(voicemail_function)
const char *domain_name = NULL;
const char *id = NULL;
const char *auth_var = NULL;
+ const char *uuid = NULL;
int x = 0, check = 0, auth = 0;
switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -3345,7 +3368,10 @@ SWITCH_STANDARD_APP(voicemail_function)
}
if (check) {
- voicemail_check_main(session, profile, domain_name, id, auth);
+ if (argv[x]) {
+ uuid = argv[x++];
+ }
+ voicemail_check_main(session, profile, domain_name, id, auth, uuid);
} else {
voicemail_leave_main(session, profile, domain_name, id);
}
diff --git a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c
index 6b261f1d96..0f3bc41f14 100644
--- a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c
+++ b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c
@@ -120,6 +120,11 @@ static switch_status_t tts_commandline_speech_close(switch_speech_handle_t *sh,
tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
assert(info != NULL);
+ if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
+ switch_core_file_close(info->fh);
+ unlink(info->file);
+ }
+
return SWITCH_STATUS_SUCCESS;
}
@@ -130,6 +135,11 @@ static switch_status_t tts_commandline_speech_feed_tts(switch_speech_handle_t *s
assert(info != NULL);
+ if (switch_test_flag(info->fh, SWITCH_FILE_OPEN)) {
+ switch_core_file_close(info->fh);
+ unlink(info->file);
+ }
+
message = switch_core_strdup(sh->memory_pool, globals.command);
tmp = switch_util_quote_shell_arg(text);
@@ -152,7 +162,7 @@ static switch_status_t tts_commandline_speech_feed_tts(switch_speech_handle_t *s
}
if (switch_core_file_open(info->fh, info->file, 0, //number_of_channels,
- 0, //samples_per_second,
+ info->rate, //samples_per_second,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file: %s\n", info->file);
return SWITCH_STATUS_FALSE;
@@ -171,11 +181,14 @@ static switch_status_t tts_commandline_speech_read_tts(switch_speech_handle_t *s
assert(info != NULL);
if (switch_core_file_read(info->fh, data, &my_datalen) != SWITCH_STATUS_SUCCESS) {
- *datalen = my_datalen * 2;
+ switch_core_file_close(info->fh);
+ unlink(info->file);
return SWITCH_STATUS_FALSE;
}
*datalen = my_datalen * 2;
if (datalen == 0) {
+ switch_core_file_close(info->fh);
+ unlink(info->file);
return SWITCH_STATUS_BREAK;
} else {
return SWITCH_STATUS_SUCCESS;
diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
index 4b36e1435e..d5bac5f7f4 100644
--- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
+++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c
@@ -26,6 +26,7 @@
*
* Brian West
* Christopher M. Rienzo
+ * Luke Dashjr (OpenMethods, LLC)
*
* mod_unimrcp.c -- UniMRCP module (MRCP client)
*
@@ -48,6 +49,7 @@
#include "mrcp_resource_loader.h"
#include "mpf_engine.h"
#include "mpf_codec_manager.h"
+#include "mpf_dtmf_generator.h"
#include "mpf_rtp_termination_factory.h"
#include "mrcp_sofiasip_client_agent.h"
#include "mrcp_unirtsp_client_agent.h"
@@ -258,6 +260,7 @@ static switch_status_t audio_queue_create(audio_queue_t ** queue, const char *na
static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len);
static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch_size_t *data_len, int block);
static switch_status_t audio_queue_clear(audio_queue_t *queue);
+static switch_status_t audio_queue_signal(audio_queue_t *queue);
static switch_status_t audio_queue_destroy(audio_queue_t *queue);
/*********************************************************************************************************************************************
@@ -285,6 +288,8 @@ enum speech_channel_state {
SPEECH_CHANNEL_READY,
/** processing speech request */
SPEECH_CHANNEL_PROCESSING,
+ /** finished processing speech request */
+ SPEECH_CHANNEL_DONE,
/** error opening channel */
SPEECH_CHANNEL_ERROR
};
@@ -433,14 +438,20 @@ static const char *grammar_type_to_mime(grammar_type_t type, profile_t *profile)
struct recognizer_data {
/** the available grammars */
switch_hash_t *grammars;
- /** the last grammar used (for pause/resume) */
- grammar_t *last_grammar;
+ /** the enabled grammars */
+ switch_hash_t *enabled_grammars;
/** recognize result */
char *result;
/** true, if voice has started */
int start_of_input;
/** true, if input timers have started */
int timers_started;
+ /** UniMRCP mpf stream */
+ mpf_audio_stream_t *unimrcp_stream;
+ /** DTMF generator */
+ mpf_dtmf_generator_t *dtmf_generator;
+ /** true, if presently transmitting DTMF */
+ char dtmf_generator_active;
};
typedef struct recognizer_data recognizer_data_t;
@@ -451,8 +462,12 @@ static switch_status_t recog_shutdown();
static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags);
static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const char *grammar, const char *name);
static switch_status_t recog_asr_unload_grammar(switch_asr_handle_t *ah, const char *name);
+static switch_status_t recog_asr_enable_grammar(switch_asr_handle_t *ah, const char *name);
+static switch_status_t recog_asr_disable_grammar(switch_asr_handle_t *ah, const char *name);
+static switch_status_t recog_asr_disable_all_grammars(switch_asr_handle_t *ah);
static switch_status_t recog_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags);
static switch_status_t recog_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags);
+static switch_status_t recog_asr_feed_dtmf(switch_asr_handle_t *ah, const switch_dtmf_t *dtmf, switch_asr_flag_t *flags);
#if 0
static switch_status_t recog_asr_start(switch_asr_handle_t *ah, const char *name);
#endif
@@ -468,12 +483,16 @@ static void recog_asr_float_param(switch_asr_handle_t *ah, char *param, double v
/* recognizer's interface for UniMRCP */
static apt_bool_t recog_message_handler(const mrcp_app_message_t *app_message);
static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message);
+static apt_bool_t recog_stream_open(mpf_audio_stream_t *stream, mpf_codec_t *codec);
static apt_bool_t recog_stream_read(mpf_audio_stream_t *stream, mpf_frame_t *frame);
/* recognizer specific speech_channel_funcs */
-static switch_status_t recog_channel_start(speech_channel_t *schannel, const char *name);
+static switch_status_t recog_channel_start(speech_channel_t *schannel);
static switch_status_t recog_channel_load_grammar(speech_channel_t *schannel, const char *name, grammar_type_t type, const char *data);
static switch_status_t recog_channel_unload_grammar(speech_channel_t *schannel, const char *name);
+static switch_status_t recog_channel_enable_grammar(speech_channel_t *schannel, const char *name);
+static switch_status_t recog_channel_disable_grammar(speech_channel_t *schannel, const char *name);
+static switch_status_t recog_channel_disable_all_grammars(speech_channel_t *schannel);
static switch_status_t recog_channel_check_results(speech_channel_t *schannel);
static switch_status_t recog_channel_set_start_of_input(speech_channel_t *schannel);
static switch_status_t recog_channel_start_input_timers(speech_channel_t *schannel);
@@ -651,10 +670,12 @@ static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const ch
static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
+#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
+ switch_size_t len = *data_len;
+#endif
switch_mutex_lock(queue->mutex);
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
- switch_size_t len = *data_len;
if (queue->file_write) {
switch_file_write(queue->file_write, data, &len);
}
@@ -692,6 +713,9 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch
{
switch_size_t requested = *data_len;
switch_status_t status = SWITCH_STATUS_SUCCESS;
+#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
+ switch_size_t len = *data_len;
+#endif
switch_mutex_lock(queue->mutex);
/* wait for data, if allowed */
@@ -720,7 +744,6 @@ static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch
#ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n", queue->name,
queue->read_bytes, *data_len, requested);
- switch_size_t len = *data_len;
if (queue->file_read) {
switch_file_write(queue->file_read, data, &len);
}
@@ -747,6 +770,20 @@ static switch_status_t audio_queue_clear(audio_queue_t *queue)
return SWITCH_STATUS_SUCCESS;
}
+/**
+ * Wake any threads waiting on this queue
+ *
+ * @param queue the queue to empty
+ * @return SWITCH_STATUS_SUCCESS
+ */
+static switch_status_t audio_queue_signal(audio_queue_t *queue)
+{
+ switch_mutex_lock(queue->mutex);
+ switch_thread_cond_signal(queue->cond);
+ switch_mutex_unlock(queue->mutex);
+ return SWITCH_STATUS_SUCCESS;
+}
+
/**
* Destroy the audio queue
*
@@ -1325,6 +1362,8 @@ static switch_status_t speech_channel_stop(speech_channel_t *schannel)
goto done;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s stopped\n", schannel->name, speech_channel_type_to_string(schannel->type));
+ } else if (schannel->state == SPEECH_CHANNEL_DONE) {
+ speech_channel_set_state_unlocked(schannel, SPEECH_CHANNEL_READY);
}
done:
@@ -1422,9 +1461,19 @@ static switch_status_t speech_channel_read(speech_channel_t *schannel, void *dat
}
switch_mutex_lock(schannel->mutex);
- if (schannel->state == SPEECH_CHANNEL_PROCESSING) {
+ switch (schannel->state) {
+ case SPEECH_CHANNEL_DONE:
+ /* pull any remaining audio - never blocking */
+ if (audio_queue_read(schannel->audio_queue, data, len, 0) == SWITCH_STATUS_FALSE) {
+ /* all frames read */
+ status = SWITCH_STATUS_BREAK;
+ }
+ break;
+ case SPEECH_CHANNEL_PROCESSING:
+ /* IN-PROGRESS */
audio_queue_read(schannel->audio_queue, data, len, block);
- } else {
+ break;
+ default:
status = SWITCH_STATUS_BREAK;
}
switch_mutex_unlock(schannel->mutex);
@@ -1447,6 +1496,8 @@ static const char *speech_channel_state_to_string(speech_channel_state_t state)
return "READY";
case SPEECH_CHANNEL_PROCESSING:
return "PROCESSING";
+ case SPEECH_CHANNEL_DONE:
+ return "DONE";
case SPEECH_CHANNEL_ERROR:
return "ERROR";
}
@@ -1482,7 +1533,7 @@ static switch_status_t speech_channel_set_state_unlocked(speech_channel_t *schan
{
if (schannel->state == SPEECH_CHANNEL_PROCESSING && state != SPEECH_CHANNEL_PROCESSING) {
/* wake anyone waiting for audio data */
- audio_queue_clear(schannel->audio_queue);
+ audio_queue_signal(schannel->audio_queue);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s ==> %s\n", schannel->name, speech_channel_state_to_string(schannel->state),
@@ -1635,6 +1686,8 @@ static switch_status_t synth_speech_read_tts(switch_speech_handle_t *sh, void *d
memset((uint8_t *) data + bytes_read, schannel->silence, *datalen - bytes_read);
}
} else {
+ /* ready for next speak request */
+ speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
*datalen = 0;
status = SWITCH_STATUS_BREAK;
}
@@ -1862,7 +1915,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp
if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) {
/* got COMPLETE */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) COMPLETE\n", schannel->name);
- speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
+ speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE);
} else {
/* received unexpected request state */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP response, request_state = %d\n", schannel->name,
@@ -1880,7 +1933,7 @@ static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp
if (message->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) {
/* got SPEAK-COMPLETE */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SPEAK-COMPLETE\n", schannel->name);
- speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
+ speech_channel_set_state(schannel, SPEECH_CHANNEL_DONE);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name,
(int) message->start_line.method_id);
@@ -2055,19 +2108,24 @@ static const char *grammar_type_to_mime(grammar_type_t type, profile_t *profile)
* Start RECOGNIZE request
*
* @param schannel the channel to start
- * @param name the name of the grammar to use or NULL if to reuse the last grammar
* @return SWITCH_STATUS_SUCCESS if successful
*/
-static switch_status_t recog_channel_start(speech_channel_t *schannel, const char *name)
+static switch_status_t recog_channel_start(speech_channel_t *schannel)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
+ switch_hash_index_t *egk;
mrcp_message_t *mrcp_message;
mrcp_recog_header_t *recog_header;
mrcp_generic_header_t *generic_header;
recognizer_data_t *r;
char *start_input_timers;
const char *mime_type;
- grammar_t *grammar = NULL;
+ char *key;
+ switch_size_t len;
+ grammar_t *grammar;
+ switch_size_t grammar_uri_count = 0;
+ switch_size_t grammar_uri_list_len = 0;
+ char *grammar_uri_list = NULL;
switch_mutex_lock(schannel->mutex);
if (schannel->state != SPEECH_CHANNEL_READY) {
@@ -2088,21 +2146,55 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel, const cha
start_input_timers = (char *) switch_core_hash_find(schannel->params, "start-input-timers");
r->timers_started = zstr(start_input_timers) || strcasecmp(start_input_timers, "false");
- /* get the cached grammar */
- if (zstr(name)) {
- grammar = r->last_grammar;
- } else {
- grammar = (grammar_t *) switch_core_hash_find(r->grammars, name);
- r->last_grammar = grammar;
- }
- if (grammar == NULL) {
- if (name) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Undefined grammar, %s\n", schannel->name, name);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) No grammar specified\n", schannel->name);
+ /* count enabled grammars */
+ for (egk = switch_hash_first(NULL, r->enabled_grammars); egk; egk = switch_hash_next(egk)) {
+ // NOTE: This postponed type check is necessary to allow a non-URI-list grammar to execute alone
+ if (grammar_uri_count == 1 && grammar->type != GRAMMAR_TYPE_URI)
+ goto no_grammar_alone;
+ ++grammar_uri_count;
+ switch_hash_this(egk, (void *) &key, NULL, (void *) &grammar);
+ if (grammar->type != GRAMMAR_TYPE_URI && grammar_uri_count != 1) {
+ no_grammar_alone:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Grammar '%s' can only be used alone (not a URI list)\n", schannel->name, key);
+ status = SWITCH_STATUS_FALSE;
+ goto done;
}
+ len = strlen(grammar->data);
+ if (!len)
+ continue;
+ grammar_uri_list_len += len;
+ if (grammar->data[len - 1] != '\n')
+ grammar_uri_list_len += 2;
+ }
+
+ switch (grammar_uri_count) {
+ case 0:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) No grammar specified\n", schannel->name);
status = SWITCH_STATUS_FALSE;
goto done;
+ case 1:
+ /* grammar should already be the unique grammar */
+ break;
+ default:
+ /* get the enabled grammars list */
+ grammar_uri_list = switch_core_alloc(schannel->memory_pool, grammar_uri_list_len + 1);
+ grammar_uri_list_len = 0;
+ for (egk = switch_hash_first(NULL, r->enabled_grammars); egk; egk = switch_hash_next(egk)) {
+ switch_hash_this(egk, (void *) &key, NULL, (void *) &grammar);
+ len = strlen(grammar->data);
+ if (!len)
+ continue;
+ memcpy(&(grammar_uri_list[grammar_uri_list_len]), grammar->data, len);
+ grammar_uri_list_len += len;
+ if (grammar_uri_list[grammar_uri_list_len - 1] != '\n')
+ {
+ grammar_uri_list_len += 2;
+ grammar_uri_list[grammar_uri_list_len - 2] = '\r';
+ grammar_uri_list[grammar_uri_list_len - 1] = '\n';
+ }
+ }
+ grammar_uri_list[grammar_uri_list_len++] = '\0';
+ grammar = NULL;
}
/* create MRCP message */
@@ -2120,7 +2212,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel, const cha
}
/* set Content-Type */
- mime_type = grammar_type_to_mime(grammar->type, schannel->profile);
+ mime_type = grammar_type_to_mime(grammar ? grammar->type : GRAMMAR_TYPE_URI, schannel->profile);
if (zstr(mime_type)) {
status = SWITCH_STATUS_FALSE;
goto done;
@@ -2129,7 +2221,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel, const cha
mrcp_generic_header_property_add(mrcp_message, GENERIC_HEADER_CONTENT_TYPE);
/* set Content-ID for inline grammars */
- if (grammar->type != GRAMMAR_TYPE_URI) {
+ if (grammar && grammar->type != GRAMMAR_TYPE_URI) {
apt_string_assign(&generic_header->content_id, grammar->name, mrcp_message->pool);
mrcp_generic_header_property_add(mrcp_message, GENERIC_HEADER_CONTENT_ID);
}
@@ -2151,7 +2243,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel, const cha
recog_channel_set_params(schannel, mrcp_message, generic_header, recog_header);
/* set message body */
- apt_string_assign(&mrcp_message->body, grammar->data, mrcp_message->pool);
+ apt_string_assign(&mrcp_message->body, grammar ? grammar->data : grammar_uri_list, mrcp_message->pool);
/* Empty audio queue and send RECOGNIZE to MRCP server */
audio_queue_clear(schannel->audio_queue);
@@ -2286,12 +2378,84 @@ static switch_status_t recog_channel_unload_grammar(speech_channel_t *schannel,
} else {
recognizer_data_t *r = (recognizer_data_t *) schannel->data;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Unloading grammar %s\n", schannel->name, grammar_name);
+ switch_core_hash_delete(r->enabled_grammars, grammar_name);
switch_core_hash_delete(r->grammars, grammar_name);
}
return status;
}
+/**
+ * Enable speech recognition grammar
+ *
+ * @param schannel the recognizer channel
+ * @param grammar_name the name of the grammar to enable
+ * @return SWITCH_STATUS_SUCCESS if successful
+ */
+static switch_status_t recog_channel_enable_grammar(speech_channel_t *schannel, const char *grammar_name)
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ if (zstr(grammar_name)) {
+ status = SWITCH_STATUS_FALSE;
+ } else {
+ recognizer_data_t *r = (recognizer_data_t *) schannel->data;
+ grammar_t *grammar;
+ grammar = (grammar_t *) switch_core_hash_find(r->grammars, grammar_name);
+ if (grammar == NULL)
+ {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Undefined grammar, %s\n", schannel->name, grammar_name);
+ status = SWITCH_STATUS_FALSE;
+ }
+ else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Enabling grammar %s\n", schannel->name, grammar_name);
+ switch_core_hash_insert(r->enabled_grammars, grammar_name, grammar);
+ }
+ }
+
+ return status;
+}
+
+/**
+ * Disable speech recognition grammar
+ *
+ * @param schannel the recognizer channel
+ * @param grammar_name the name of the grammar to disable
+ * @return SWITCH_STATUS_SUCCESS if successful
+ */
+static switch_status_t recog_channel_disable_grammar(speech_channel_t *schannel, const char *grammar_name)
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ if (zstr(grammar_name)) {
+ status = SWITCH_STATUS_FALSE;
+ } else {
+ recognizer_data_t *r = (recognizer_data_t *) schannel->data;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Disabling grammar %s\n", schannel->name, grammar_name);
+ switch_core_hash_delete(r->enabled_grammars, grammar_name);
+ }
+
+ return status;
+}
+
+/**
+ * Disable all speech recognition grammars
+ *
+ * @param schannel the recognizer channel
+ * @return SWITCH_STATUS_SUCCESS if successful
+ */
+static switch_status_t recog_channel_disable_all_grammars(speech_channel_t *schannel)
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+ recognizer_data_t *r = (recognizer_data_t *) schannel->data;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Disabling all grammars\n", schannel->name);
+ switch_core_hash_destroy(&r->enabled_grammars);
+ switch_core_hash_init(&r->enabled_grammars, schannel->memory_pool);
+
+ return status;
+}
+
/**
* Check if recognition is complete
*
@@ -2451,6 +2615,8 @@ static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp
if (id) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) \"%s\": \"%s\"\n", schannel->name, param_name, param_val);
recog_channel_set_header(schannel, id->id, param_val, msg, recog_hdr);
+ } else if (!strcasecmp(param_name, "start-recognize")) {
+ // This parameter is used internally only, not in MRCP headers
} else {
/* this is probably a vendor-specific MRCP param */
apt_str_t apt_param_name = { 0 };
@@ -2737,6 +2903,7 @@ static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec
schannel->data = r;
memset(r, 0, sizeof(recognizer_data_t));
switch_core_hash_init(&r->grammars, ah->memory_pool);
+ switch_core_hash_init(&r->enabled_grammars, ah->memory_pool);
/* Open the channel */
if (zstr(profile_name)) {
@@ -2782,6 +2949,7 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha
speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
const char *grammar_data = NULL;
char *grammar_file_data = NULL;
+ char *start_recognize;
switch_file_t *grammar_file = NULL;
switch_size_t grammar_file_size = 0, to_read = 0;
grammar_type_t type = GRAMMAR_TYPE_UNKNOWN;
@@ -2886,7 +3054,19 @@ static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const cha
goto done;
}
- status = recog_channel_start(schannel, name);
+ start_recognize = (char *) switch_core_hash_find(schannel->params, "start-recognize");
+ if (zstr(start_recognize) || strcasecmp(start_recognize, "false"))
+ {
+ if (recog_channel_disable_all_grammars(schannel) != SWITCH_STATUS_SUCCESS) {
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
+ if (recog_channel_enable_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) {
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
+ status = recog_channel_start(schannel);
+ }
done:
@@ -2914,6 +3094,57 @@ static switch_status_t recog_asr_unload_grammar(switch_asr_handle_t *ah, const c
return status;
}
+/**
+ * Process asr_enable_grammar request from FreeSWITCH.
+ *
+ * FreeSWITCH sends this request to enable recognition on this grammar.
+ * @param ah the FreeSWITCH speech recognition handle
+ * @param name the grammar name.
+ */
+static switch_status_t recog_asr_enable_grammar(switch_asr_handle_t *ah, const char *name)
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
+ if (zstr(name) || speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS || recog_channel_enable_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) {
+ status = SWITCH_STATUS_FALSE;
+ }
+ return status;
+}
+
+/**
+ * Process asr_disable_grammar request from FreeSWITCH.
+ *
+ * FreeSWITCH sends this request to disable recognition on this grammar.
+ * @param ah the FreeSWITCH speech recognition handle
+ * @param name the grammar name.
+ */
+static switch_status_t recog_asr_disable_grammar(switch_asr_handle_t *ah, const char *name)
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
+ if (zstr(name) || speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS || recog_channel_disable_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) {
+ status = SWITCH_STATUS_FALSE;
+ }
+ return status;
+}
+
+/**
+ * Process asr_disable_all_grammars request from FreeSWITCH.
+ *
+ * FreeSWITCH sends this request to disable recognition of all grammars.
+ * @param ah the FreeSWITCH speech recognition handle
+ * @param name the grammar name.
+ */
+static switch_status_t recog_asr_disable_all_grammars(switch_asr_handle_t *ah)
+{
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
+ if (speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS || recog_channel_disable_all_grammars(schannel) != SWITCH_STATUS_SUCCESS) {
+ status = SWITCH_STATUS_FALSE;
+ }
+ return status;
+}
+
/**
* Process asr_close request from FreeSWITCH
*
@@ -2928,6 +3159,10 @@ static switch_status_t recog_asr_close(switch_asr_handle_t *ah, switch_asr_flag_
speech_channel_stop(schannel);
speech_channel_destroy(schannel);
switch_core_hash_destroy(&r->grammars);
+ switch_core_hash_destroy(&r->enabled_grammars);
+ if (r->dtmf_generator) {
+ mpf_dtmf_generator_destroy(r->dtmf_generator);
+ }
/* this lets FreeSWITCH's speech_thread know the handle is closed */
switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED);
@@ -2948,18 +3183,50 @@ static switch_status_t recog_asr_feed(switch_asr_handle_t *ah, void *data, unsig
return speech_channel_write(schannel, data, &slen);
}
+/**
+ * Process asr_feed_dtmf request from FreeSWITCH
+ *
+ * @param ah the FreeSWITCH speech recognition handle
+ * @return SWITCH_STATUS_SUCCESS if successful
+ */
+static switch_status_t recog_asr_feed_dtmf(switch_asr_handle_t *ah, const switch_dtmf_t *dtmf, switch_asr_flag_t *flags)
+{
+ speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
+ recognizer_data_t *r = (recognizer_data_t *) schannel->data;
+ char digits[2];
+
+ if (!r->dtmf_generator) {
+ if (!r->unimrcp_stream) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Cannot queue DTMF: No UniMRCP stream object open\n", schannel->name);
+ return SWITCH_STATUS_FALSE;
+ }
+ r->dtmf_generator = mpf_dtmf_generator_create(r->unimrcp_stream, schannel->unimrcp_session->pool);
+ if (!r->dtmf_generator) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Cannot queue DTMF: Failed to create DTMF generator\n", schannel->name);
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
+ digits[0] = dtmf->digit;
+ digits[1] = '\0';
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Queued DTMF: %s\n", schannel->name, digits);
+ mpf_dtmf_generator_enqueue(r->dtmf_generator, digits);
+ r->dtmf_generator_active = 1;
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
#if 0
/**
* Process asr_start request from FreeSWITCH
* @param ah the FreeSWITCH speech recognition handle
- * @param name name of the grammar to use
* @return SWITCH_STATUS_SUCCESS if successful
*/
-static switch_status_t recog_asr_start(switch_asr_handle_t *ah, const char *name)
+static switch_status_t recog_asr_start(switch_asr_handle_t *ah)
{
switch_status_t status;
speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
- status = recog_channel_start(schannel, name);
+ status = recog_channel_start(schannel);
return status;
}
#endif
@@ -2972,7 +3239,7 @@ static switch_status_t recog_asr_start(switch_asr_handle_t *ah, const char *name
static switch_status_t recog_asr_resume(switch_asr_handle_t *ah)
{
speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
- return recog_channel_start(schannel, NULL);
+ return recog_channel_start(schannel);
}
/**
@@ -3194,6 +3461,23 @@ static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp
return TRUE;
}
+/**
+ * UniMRCP callback requesting open for speech recognition
+ *
+ * @param stream the UniMRCP stream
+ * @param codec the codec
+ * @return TRUE
+ */
+static apt_bool_t recog_stream_open(mpf_audio_stream_t *stream, mpf_codec_t *codec)
+{
+ speech_channel_t *schannel = (speech_channel_t *) stream->obj;
+ recognizer_data_t *r = (recognizer_data_t *) schannel->data;
+
+ r->unimrcp_stream = stream;
+
+ return TRUE;
+}
+
/**
* UniMRCP callback requesting next frame for speech recognition
*
@@ -3204,6 +3488,7 @@ static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp
static apt_bool_t recog_stream_read(mpf_audio_stream_t *stream, mpf_frame_t *frame)
{
speech_channel_t *schannel = (speech_channel_t *) stream->obj;
+ recognizer_data_t *r = (recognizer_data_t *) schannel->data;
switch_size_t to_read = frame->codec_frame.size;
/* grab the data. pad it if there isn't enough */
@@ -3213,6 +3498,13 @@ static apt_bool_t recog_stream_read(mpf_audio_stream_t *stream, mpf_frame_t *fra
}
frame->type |= MEDIA_FRAME_TYPE_AUDIO;
}
+
+ if (r->dtmf_generator_active) {
+ if (!mpf_dtmf_generator_put_frame(r->dtmf_generator, frame)) {
+ if (!mpf_dtmf_generator_sending(r->dtmf_generator))
+ r->dtmf_generator_active = 0;
+ }
+ }
return TRUE;
}
@@ -3231,8 +3523,12 @@ static switch_status_t recog_load(switch_loadable_module_interface_t *module_int
asr_interface->asr_open = recog_asr_open;
asr_interface->asr_load_grammar = recog_asr_load_grammar;
asr_interface->asr_unload_grammar = recog_asr_unload_grammar;
+ asr_interface->asr_enable_grammar = recog_asr_enable_grammar;
+ asr_interface->asr_disable_grammar = recog_asr_disable_grammar;
+ asr_interface->asr_disable_all_grammars = recog_asr_disable_all_grammars;
asr_interface->asr_close = recog_asr_close;
asr_interface->asr_feed = recog_asr_feed;
+ asr_interface->asr_feed_dtmf = recog_asr_feed_dtmf;
#if 0
asr_interface->asr_start = recog_asr_start;
#endif
@@ -3255,7 +3551,7 @@ static switch_status_t recog_load(switch_loadable_module_interface_t *module_int
globals.recog.dispatcher.on_channel_remove = speech_on_channel_remove;
globals.recog.dispatcher.on_message_receive = recog_on_message_receive;
globals.recog.audio_stream_vtable.destroy = NULL;
- globals.recog.audio_stream_vtable.open_rx = NULL;
+ globals.recog.audio_stream_vtable.open_rx = recog_stream_open;
globals.recog.audio_stream_vtable.close_rx = NULL;
globals.recog.audio_stream_vtable.read_frame = recog_stream_read;
globals.recog.audio_stream_vtable.open_tx = NULL;
diff --git a/src/mod/codecs/mod_celt/mod_celt.c b/src/mod/codecs/mod_celt/mod_celt.c
index 37983f3683..8d36b6af12 100644
--- a/src/mod/codecs/mod_celt/mod_celt.c
+++ b/src/mod/codecs/mod_celt/mod_celt.c
@@ -53,8 +53,8 @@ static switch_status_t switch_celt_init(switch_codec_t *codec, switch_codec_flag
return SWITCH_STATUS_FALSE;
}
- context->mode_object = celt_mode_create(codec->implementation->actual_samples_per_second, codec->implementation->samples_per_packet, NULL);
-
+ context->frame_size = codec->implementation->samples_per_packet;
+ context->mode_object = celt_mode_create(codec->implementation->actual_samples_per_second, context->frame_size, NULL);
context->bytes_per_packet = (codec->implementation->bits_per_second * context->frame_size / codec->implementation->actual_samples_per_second + 4) / 8;
/*
@@ -106,15 +106,22 @@ static switch_status_t switch_celt_encode(switch_codec_t *codec,
unsigned int *flag)
{
struct celt_context *context = codec->private_info;
+ int bytes = 0;
if (!context) {
return SWITCH_STATUS_FALSE;
}
- *encoded_data_len = (uint32_t) celt_encode(context->encoder_object, (void *) decoded_data, codec->implementation->samples_per_packet,
- (unsigned char *) encoded_data, context->bytes_per_packet);
+ bytes = (uint32_t) celt_encode(context->encoder_object, (void *) decoded_data, codec->implementation->samples_per_packet,
+ (unsigned char *) encoded_data, context->bytes_per_packet);
- return SWITCH_STATUS_SUCCESS;
+ if (bytes > 0) {
+ *encoded_data_len = (uint32_t) bytes;
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoder Error!\n");
+ return SWITCH_STATUS_GENERR;
}
static switch_status_t switch_celt_decode(switch_codec_t *codec,
@@ -152,23 +159,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_celt_load)
SWITCH_ADD_CODEC(codec_interface, "CELT ultra-low delay");
- switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
- 114, /* the IANA code number */
- "CELT", /* the IANA code name */
- NULL, /* default fmtp to send (can be overridden by the init function) */
- 32000, /* samples transferred per second */
- 32000, /* actual samples transferred per second */
- 32000, /* bits transferred per second */
- 10000, /* number of microseconds per frame */
- 320, /* number of samples per frame */
- 640, /* number of bytes per frame decompressed */
- 0, /* number of bytes per frame compressed */
- 1, /* number of channels represented */
- 1, /* number of frames per network packet */
- switch_celt_init, /* function to initialize a codec handle using this implementation */
- switch_celt_encode, /* function to encode raw data into encoded data */
- switch_celt_decode, /* function to decode encoded data into raw data */
- switch_celt_destroy); /* deinitalize a codec handle using this implementation */
ms_per_frame = 2000;
samples_per_frame = 96;
bytes_per_frame = 192;
diff --git a/src/mod/codecs/mod_com_g729/Makefile.am b/src/mod/codecs/mod_com_g729/Makefile.am
new file mode 100644
index 0000000000..7b631386d3
--- /dev/null
+++ b/src/mod/codecs/mod_com_g729/Makefile.am
@@ -0,0 +1,39 @@
+include $(top_srcdir)/build/modmake.rulesam
+
+MODNAME=mod_com_g729
+VERSION=193
+
+if ISLINUX
+
+G729INSTALLER = $(top_srcdir)/libs/fsg729-$(VERSION)-installer
+LICSERVER=/usr/sbin/freeswitch_licence_server
+VALIDATOR=$(bindir)/validator
+MOD=$(moddir)/mod_com_g729.so
+BUILT_SOURCES = $(G729INSTALLER)
+
+install: $(LICSERVER) $(VALIDATOR) $(MOD)
+
+$(LICSERVER) $(VALIDATOR) $(MOD): $(G729INSTALLER)
+ $(SHELL) $(G729INSTALLER) $(bindir) $(moddir) nobanner
+ $(ECHO)
+ $(ECHO)
+ $(ECHO) Now you can activate your license by running $(MAKE) mod_com_g729-activate
+ $(ECHO)
+ $(ECHO)
+
+$(G729INSTALLER):
+ rm -f $(top_srcdir)/libs/fsg729-*-installer*
+ $(GETG729) fsg729-$(VERSION)-installer
+ chmod 755 $(G729INSTALLER)
+
+clean:
+ rm -f $(top_srcdir)/libs/fsg729-*-installer*
+ rm -rf /tmp/fsg729
+
+activate: $(LICSERVER) $(VALIDATOR) $(MOD)
+ $(VALIDATOR)
+
+uninstall: clean
+ rm -f $(LICSERVER) $(VALIDATOR) $(MOD)
+
+endif
diff --git a/src/mod/codecs/mod_opus/Makefile b/src/mod/codecs/mod_opus/Makefile
new file mode 100644
index 0000000000..a34695678b
--- /dev/null
+++ b/src/mod/codecs/mod_opus/Makefile
@@ -0,0 +1,28 @@
+BASE=../../../..
+
+OPUS=opus-0.9.0
+
+OPUS_DIR=$(switch_srcdir)/libs/$(OPUS)
+OPUS_BUILDDIR=$(switch_builddir)/libs/$(OPUS)
+LOCAL_CFLAGS=-I$(OPUS_DIR)/src -g -O2
+
+IETF_LA=$(OPUS_BUILDDIR)/src/.libs/libietfcodec.a
+CELT_LA=$(OPUS_BUILDDIR)/celt/libcelt/.libs/libcelt0.a
+SILK_LA=$(OPUS_BUILDDIR)/silk/.libs/libSKP_SILK_SDK.a
+
+LOCAL_LIBADD=$(IETF_LA) $(CELT_LA) $(SILK_LA) -lm -lz
+
+include $(BASE)/build/modmake.rules
+
+$(OPUS_DIR):
+ $(GETLIB) $(OPUS).tar.gz
+
+$(OPUS_BUILDDIR)/Makefile: $(OPUS_DIR)
+ mkdir -p $(OPUS_BUILDDIR)
+ cd $(OPUS_BUILDDIR) && $(DEFAULT_VARS) $(OPUS_DIR)/configure --disable-shared --with-pic --srcdir=$(OPUS_DIR)
+ $(TOUCH_TARGET)
+
+$(IETF_LA): $(OPUS_BUILDDIR)/Makefile
+ cd $(OPUS_BUILDDIR) && $(MAKE)
+ $(TOUCH_TARGET)
+
diff --git a/src/mod/codecs/mod_opus/mod_opus.c b/src/mod/codecs/mod_opus/mod_opus.c
new file mode 100644
index 0000000000..b9a31208a4
--- /dev/null
+++ b/src/mod/codecs/mod_opus/mod_opus.c
@@ -0,0 +1,200 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2011, Anthony Minessale II
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Brian K. West
+ *
+ * mod_opus.c -- The OPUS ultra-low delay audio codec (http://www.opus-codec.org/)
+ *
+ */
+
+#include "switch.h"
+#include "opus.h"
+
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load);
+SWITCH_MODULE_DEFINITION(mod_opus, mod_opus_load, NULL, NULL);
+
+struct opus_context {
+ OpusEncoder *encoder_object;
+ OpusDecoder *decoder_object;
+ int frame_size;
+};
+
+static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
+{
+ struct opus_context *context = NULL;
+ int encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
+ int decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
+
+ if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ context->frame_size = codec->implementation->samples_per_packet;
+
+ if (encoding) {
+ /* come up with a way to specify these */
+ int bitrate_bps = codec->implementation->bits_per_second;
+ int mode = MODE_HYBRID;
+ int use_vbr = 1;
+ int complexity = 10;
+ int use_inbandfec = 1;
+ int use_dtx = 1;
+ int bandwidth = BANDWIDTH_FULLBAND;
+
+ context->encoder_object = opus_encoder_create(codec->implementation->actual_samples_per_second, codec->implementation->number_of_channels);
+
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_MODE(mode));
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_BITRATE(bitrate_bps));
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_BANDWIDTH(bandwidth));
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_VBR_FLAG(use_vbr));
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_COMPLEXITY(complexity));
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_INBAND_FEC_FLAG(use_inbandfec));
+ opus_encoder_ctl(context->encoder_object, OPUS_SET_DTX_FLAG(use_dtx));
+
+ }
+
+ if (decoding) {
+ context->decoder_object = opus_decoder_create(codec->implementation->actual_samples_per_second, codec->implementation->number_of_channels);
+ }
+
+ codec->private_info = context;
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t switch_opus_destroy(switch_codec_t *codec)
+{
+ codec->private_info = NULL;
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t switch_opus_encode(switch_codec_t *codec,
+ switch_codec_t *other_codec,
+ void *decoded_data,
+ uint32_t decoded_data_len,
+ uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
+ unsigned int *flag)
+{
+ struct opus_context *context = codec->private_info;
+ int bytes = 0;
+ int len = (int) *encoded_data_len;
+
+ if (!context) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (len > 1275) len = 1275;
+
+ bytes = opus_encode(context->encoder_object, (void *) decoded_data, decoded_data_len / 2, (unsigned char *) encoded_data, len);
+
+ if (bytes > 0) {
+ *encoded_data_len = (uint32_t) bytes;
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Encoder Error!\n");
+ return SWITCH_STATUS_GENERR;
+}
+
+static switch_status_t switch_opus_decode(switch_codec_t *codec,
+ switch_codec_t *other_codec,
+ void *encoded_data,
+ uint32_t encoded_data_len,
+ uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
+ unsigned int *flag)
+{
+ struct opus_context *context = codec->private_info;
+ int samples = 0;
+
+ if (!context) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ samples = opus_decode(context->decoder_object, encoded_data, encoded_data_len, decoded_data, *decoded_data_len);
+
+ if (samples < 0) {
+ return SWITCH_STATUS_GENERR;
+ }
+
+ *decoded_data_len = samples * 2;
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_opus_load)
+{
+ switch_codec_interface_t *codec_interface;
+ int samples = 80;
+ int bytes = 960;
+ int mss = 10000;
+ int x = 0;
+ int rate = 48000;
+ int bits = 32000;
+
+ /* connect my internal structure to the blank pointer passed to me */
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
+ SWITCH_ADD_CODEC(codec_interface, "OPUS (BETA 0.9.0)");
+
+ for (x = 0; x < 2; x++) {
+ switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
+ 115, /* the IANA code number */
+ "Opus-0.9.0",/* the IANA code name */
+ NULL, /* default fmtp to send (can be overridden by the init function) */
+ rate, /* samples transferred per second */
+ rate, /* actual samples transferred per second */
+ bits, /* bits transferred per second */
+ mss, /* number of microseconds per frame */
+ samples, /* number of samples per frame */
+ bytes, /* number of bytes per frame decompressed */
+ 0, /* number of bytes per frame compressed */
+ 1, /* number of channels represented */
+ 1, /* number of frames per network packet */
+ switch_opus_init, /* function to initialize a codec handle using this implementation */
+ switch_opus_encode, /* function to encode raw data into encoded data */
+ switch_opus_decode, /* function to decode encoded data into raw data */
+ switch_opus_destroy); /* deinitalize a codec handle using this implementation */
+
+ bytes *= 2;
+ samples *= 2;
+ mss *= 2;
+
+ }
+
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
+}
+
+/* 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:
+ */
diff --git a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
index 5869d14c3a..3bc5cb4a3d 100644
--- a/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
+++ b/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c
@@ -309,11 +309,13 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,
switch_call_cause_t *cancel_cause)
{
const char *profile;
+ char *dup_profile = NULL;
if (session) {
profile = switch_channel_get_variable(switch_core_session_get_channel(session), "sip_profile");
} else {
- profile = switch_core_get_variable("sip_profile");
+ dup_profile = switch_core_get_variable_dup("sip_profile");
+ profile = dup_profile;
}
if (zstr(profile)) {
profile = "default";
@@ -323,6 +325,8 @@ static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session,
UNPROTECT_INTERFACE(sip_endpoint_interface);
+ switch_safe_free(dup_profile);
+
return switch_core_session_outgoing_channel(session, var_event, "sofia", outbound_profile, new_session, pool, SOF_NONE, cancel_cause);
}
diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c
index 66f62b2295..9fb1f39e11 100644
--- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c
+++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c
@@ -2049,7 +2049,7 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
} else if (!strcasecmp(var, "ext-rtp-ip")) {
char *ip = globals.guess_ip;
if (val && !strcasecmp(val, "auto-nat")) {
- ip = globals.auto_nat ? switch_core_get_variable("nat_public_addr") : globals.guess_ip;
+ ip = globals.auto_nat ? switch_core_get_variable_pdup("nat_public_addr", module_pool) : globals.guess_ip;
} else if (val && !strcasecmp(val, "auto")) {
globals.auto_nat = 0;
ip = globals.guess_ip;
@@ -2523,7 +2523,7 @@ static switch_status_t load_config(void)
memset(&globals, 0, sizeof(globals));
globals.running = 1;
- globals.auto_nat = (switch_core_get_variable("nat_type") ? 1 : 0);
+ globals.auto_nat = (switch_nat_get_type() ? 1 : 0);
switch_find_local_ip(globals.guess_ip, sizeof(globals.guess_ip), NULL, AF_INET);
diff --git a/src/mod/endpoints/mod_gsmopen/.gitignore b/src/mod/endpoints/mod_gsmopen/.gitignore
index 9fdeeb1412..fe8dc68bd5 100644
--- a/src/mod/endpoints/mod_gsmopen/.gitignore
+++ b/src/mod/endpoints/mod_gsmopen/.gitignore
@@ -1,2 +1,4 @@
!/gsmlib/gsmlib-*/aclocal.m4
!/gsmlib/gsmlib-*/configure
+!/gsmlib/gsmlib-1.10.tar.gz
+!/gsmlib/gsmlib_1.10-12ubuntu1.diff.gz
diff --git a/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml b/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml
index 79c00516b9..069792935c 100644
--- a/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml
+++ b/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml
@@ -272,6 +272,15 @@ a FXS branch.
-->
+
+
+
+