Merge branch 'master' of git.freeswitch.org:freeswitch

This commit is contained in:
Moises Silva 2010-10-01 07:07:12 -04:00
commit 588eea410f
325 changed files with 24933 additions and 4354 deletions

View File

@ -1277,11 +1277,9 @@ Global
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.ActiveCfg = Debug|Win32
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.Build.0 = Debug|Win32
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|x64.ActiveCfg = Debug|x64
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|x64.Build.0 = Debug|x64
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.ActiveCfg = Release|Win32
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.Build.0 = Release|Win32
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.ActiveCfg = Release|x64
{1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.Build.0 = Release|x64
{692F6330-4D87-4C82-81DF-40DB5892636E}.All|Win32.ActiveCfg = Release|x64
{692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.ActiveCfg = Release|x64
{692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.Build.0 = Release|x64
@ -1593,22 +1591,18 @@ Global
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Debug|Win32.ActiveCfg = Debug|Win32
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Debug|Win32.Build.0 = Debug|Win32
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Debug|x64.ActiveCfg = Debug|x64
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Debug|x64.Build.0 = Debug|x64
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Release|Win32.ActiveCfg = Release|Win32
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Release|Win32.Build.0 = Release|Win32
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Release|x64.ActiveCfg = Release|x64
{ACFFF684-4D19-4D48-AF12-88EA1D778BDF}.Release|x64.Build.0 = Release|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.All|Win32.ActiveCfg = Release|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.All|x64.ActiveCfg = Release|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.All|x64.Build.0 = Release|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Debug|Win32.ActiveCfg = Debug|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Debug|Win32.Build.0 = Debug|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Debug|x64.ActiveCfg = Debug|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Debug|x64.Build.0 = Debug|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|Win32.ActiveCfg = Release|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|Win32.Build.0 = Release|Win32
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|x64.ActiveCfg = Release|x64
{8F992C49-6C51-412F-B2A3-34EAB708EB65}.Release|x64.Build.0 = Release|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|Win32.ActiveCfg = Release|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.ActiveCfg = Release|x64
{4043FC6A-9A30-4577-8AD5-9B233C9575D8}.All|x64.Build.0 = Release|x64
@ -1637,11 +1631,9 @@ Global
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Debug|Win32.ActiveCfg = Debug|Win32
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Debug|Win32.Build.0 = Debug|Win32
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Debug|x64.ActiveCfg = Debug|x64
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Debug|x64.Build.0 = Debug|x64
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Release|Win32.ActiveCfg = Release|Win32
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Release|Win32.Build.0 = Release|Win32
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Release|x64.ActiveCfg = Release|x64
{0A6B5EA5-6E9B-4A51-931F-ED25AA87B4DF}.Release|x64.Build.0 = Release|x64
{AB91A099-7690-4ECF-8994-E458F4EA1ED4}.All|Win32.ActiveCfg = Release|x64
{AB91A099-7690-4ECF-8994-E458F4EA1ED4}.All|x64.ActiveCfg = Release|x64
{AB91A099-7690-4ECF-8994-E458F4EA1ED4}.All|x64.Build.0 = Release|x64
@ -1736,11 +1728,9 @@ Global
{028C7278-05D7-4E18-82FE-BE231B844F41}.Debug|Win32.ActiveCfg = Debug|Win32
{028C7278-05D7-4E18-82FE-BE231B844F41}.Debug|Win32.Build.0 = Debug|Win32
{028C7278-05D7-4E18-82FE-BE231B844F41}.Debug|x64.ActiveCfg = Debug|x64
{028C7278-05D7-4E18-82FE-BE231B844F41}.Debug|x64.Build.0 = Debug|x64
{028C7278-05D7-4E18-82FE-BE231B844F41}.Release|Win32.ActiveCfg = Release|Win32
{028C7278-05D7-4E18-82FE-BE231B844F41}.Release|Win32.Build.0 = Release|Win32
{028C7278-05D7-4E18-82FE-BE231B844F41}.Release|x64.ActiveCfg = Release|x64
{028C7278-05D7-4E18-82FE-BE231B844F41}.Release|x64.Build.0 = Release|x64
{D7F1E3F2-A3F4-474C-8555-15122571AF52}.All|Win32.ActiveCfg = Release|x64
{D7F1E3F2-A3F4-474C-8555-15122571AF52}.All|x64.ActiveCfg = Release|x64
{D7F1E3F2-A3F4-474C-8555-15122571AF52}.All|x64.Build.0 = Release|x64
@ -1901,11 +1891,9 @@ Global
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Debug|Win32.ActiveCfg = Debug|Win32
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Debug|Win32.Build.0 = Debug|Win32
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Debug|x64.ActiveCfg = Debug|x64
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Debug|x64.Build.0 = Debug|x64
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Release|Win32.ActiveCfg = Release|Win32
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Release|Win32.Build.0 = Release|Win32
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Release|x64.ActiveCfg = Release|x64
{36E854E3-CE12-4348-A125-CCF3F9D74813}.Release|x64.Build.0 = Release|x64
{7B077E7F-1BE7-4291-AB86-55E527B25CAC}.All|Win32.ActiveCfg = Release|x64
{7B077E7F-1BE7-4291-AB86-55E527B25CAC}.All|x64.ActiveCfg = Release|x64
{7B077E7F-1BE7-4291-AB86-55E527B25CAC}.All|x64.Build.0 = Release|x64

View File

@ -267,7 +267,7 @@ src/include/switch_swigable_cpp.h: $(switch_srcdir)/src/include/switch_cpp.h
##
## Applications
##
bin_PROGRAMS = freeswitch fs_cli fs_ivrd
bin_PROGRAMS = freeswitch fs_cli fs_ivrd tone2wav
##
## fs_cli ()
@ -281,6 +281,14 @@ fs_cli_CFLAGS += -DHAVE_EDITLINE -I$(switch_srcdir)/libs/libedit/src
fs_cli_LDADD = libs/libedit/src/.libs/libedit.a
endif
##
## tone2wav ()
##
tone2wav_SOURCES = src/tone2wav.c
tone2wav_CFLAGS = $(AM_CFLAGS)
tone2wav_LDFLAGS = $(AM_LDFLAGS) $(CORE_LIBS)
tone2wav_LDADD = libfreeswitch.la
##
## fs_ivrd ()
##

View File

@ -16,7 +16,7 @@ done
BASEDIR=`pwd`;
LIBDIR=${BASEDIR}/libs;
SUBDIRS="ilbc curl iksemel js js/nsprpub libdingaling libedit libsndfile pcre sofia-sip \
speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-3.8.2 broadvoice silk";
speex sqlite srtp openzap freetdm spandsp libg722_1 portaudio unimrcp tiff-3.8.2 broadvoice silk libcodec2";
if [ ! -f modules.conf ]; then
cp build/modules.conf.in modules.conf

View File

@ -39,6 +39,7 @@ codecs/mod_g723_1
codecs/mod_amr
#codecs/mod_amrwb
#codecs/mod_silk
#codecs/mod_codec2
codecs/mod_g729
codecs/mod_h26x
codecs/mod_bv

View File

@ -22,15 +22,15 @@
</queues>
<!-- WARNING : Configuring XML Agents will updated into the DB upon restart -->
<!-- WARNING : Configuring XML Tiers will reset the provided level and position if provided.-->
<!-- WARNING : Agents and Tiers XML config shouldn't be used in a multi FS shared DB setup(Not currently supported anyway) -->
<!-- WARNING: Configuration of XML Agents will be updated into the DB upon restart. -->
<!-- WARNING: Configuration of XML Tiers will reset the level and position if those were supplied. -->
<!-- WARNING: Agents and Tiers XML config shouldn't be used in a multi FS shared DB setup (Not currently supported anyway) -->
<agents>
<!--<agent name="1000@default" type="callback" contact="[call_timeout=10]user/1000@default" status="Available" max-no-answer="3" wrap-up-time="10" reject-delay-time="10" busy-delay-time="60" />-->
</agents>
<tiers>
<!-- if no level or position is provided, they will default to 0. You should do this to keep db value on restart -->
<!-- <tier agent="1000@default" queue="support@default" level="0" position="1"/> -->
<!-- If no level or position is provided, they will default to 1. You should do this to keep db value on restart. -->
<!-- <tier agent="1000@default" queue="support@default" level="1" position="1"/> -->
</tiers>
</configuration>

View File

@ -8,25 +8,29 @@
<param name="register" value="all"/>
-->
<!-- List of codecs to not register with FreeSWITCH, by default this is empty,
<!--
List of codecs to not register with FreeSWITCH, by default this is empty,
but you may want to not load PCMU and PCMA or may be others to not use your
vocallo resources in codecs that are done well and fast in software.
<param name="noregister" value="PCMU,PCMA"/>
-->
<!--
Transcoding SOAP server URL. If you are installing the soap server (sngtc_server)
in the same box where FreeSWITCH, do not use this value, the default URL
that is hard-coded will work out of the box for local installations.
If you modify this value, you must configure your SOAP server (/etc/sngtc/sngtc_server.conf.xml)
to listen for HTTP requests on the same IP/port that you specify here.
<param name="soapserver" value="http://192.168.1.100:8080"/>
-->
<!--
RTP IP to use
By default, this module asks FreeSWITCH for the local ip address. However if you want to use a specific
IP address you can set it here.
<param name="rtpip" value="192.168.1.1"/>
-->
</settings>
<vocallos>
<!-- The name of the vocallo is the ethernet device name as displayed by ifconfig -->
<vocallo name="eth5">
<!-- Starting UDP port for the vocallo -->
<param name="baseudp" value="5000"/>
<!-- Starting IP address to use for the vocallo modules -->
<param name="vocalloaddr" value="10.1.1.100"/>
</vocallo>
</vocallos>
</configuration>

View File

@ -240,7 +240,7 @@
<!--
dial the extension (1000-1019) for 30 seconds and go to voicemail if the
call fails (continue_on_fail=true), otherwise hang up after a successful
bridge (hangup_after-bridge=true)
bridge (hangup_after_bridge=true)
-->
<extension name="Local_Extension">
<condition field="destination_number" expression="^(10[01][0-9])$">
@ -250,6 +250,7 @@
<action application="bind_meta_app" data="1 b s execute_extension::dx XML features"/>
<action application="bind_meta_app" data="2 b s record_session::$${recordings_dir}/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
<action application="bind_meta_app" data="3 b s execute_extension::cf XML features"/>
<action application="bind_meta_app" data="4 b s execute_extension::att_xfer XML features"/>
<action application="set" data="ringback=${us-ring}"/>
<action application="set" data="transfer_ringback=$${hold_music}"/>
<action application="set" data="call_timeout=30"/>
@ -262,7 +263,7 @@
<action application="set" data="called_party_callgroup=${user_data(${dialed_extension}@${domain_name} var callgroup)}"/>
<!--<action application="export" data="nolocal:sip_secure_media=${user_data(${dialed_extension}@${domain_name} var sip_secure_media)}"/>-->
<action application="hash" data="insert/${domain_name}-last_dial/${called_party_callgroup}/${uuid}"/>
<action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
<action application="bridge" data="{sip_invite_domain=$${domain}}user/${dialed_extension}@${domain_name}"/>
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="bridge" data="loopback/app=voicemail:default ${domain_name} ${dialed_extension}"/>

View File

@ -11,6 +11,14 @@
</condition>
</extension>
<extension name="att_xfer">
<condition field="destination_number" expression="^att_xfer$">
<action application="read" data="3 4 'tone_stream://%(10000,0,350,440)' digits 30000 #"/>
<action application="set" data="origination_cancel_key=#"/>
<action application="att_xfer" data="user/${digits}@$${domain}"/>
</condition>
</extension>
<extension name="is_transfer">
<condition field="destination_number" expression="^is_transfer$"/>
<condition field="${digits}" expression="^(\d+)$">

View File

@ -116,7 +116,7 @@
<!-- used to share presence info across sofia profiles -->
<!-- Name of the db to use for this profile -->
<!--<param name="dbname" value="share_presence"/>-->
<!--<param name="presence-hosts" value="$${domain}"/>-->
<param name="presence-hosts" value="$${domain},$${local_ip_v4}"/>
<!-- ************************************************* -->
<!-- This setting is for AAL2 bitpacking on G726 -->
@ -226,6 +226,8 @@
<!--all inbound reg will stored in the db using this domain -->
<param name="force-register-db-domain" value="$${domain}"/>
<!--<param name="delete-subs-on-register" value="false"/>-->
<!-- enable rtcp on every channel also can be done per leg basis with rtcp_audio_interval_msec variable set to passthru to pass it across a call-->
<!--<param name="rtcp-audio-interval-msec" value="5000"/>-->
<!--<param name="rtcp-video-interval-msec" value="5000"/>-->

View File

@ -904,6 +904,7 @@ AC_CONFIG_FILES([Makefile
src/mod/applications/mod_expr/Makefile
src/mod/applications/mod_fax/Makefile
src/mod/applications/mod_spandsp/Makefile
src/mod/applications/mod_osp/Makefile
src/mod/applications/mod_stress/Makefile
src/mod/applications/mod_hash/Makefile
src/mod/endpoints/mod_portaudio/Makefile
@ -998,6 +999,7 @@ AC_CONFIG_SUBDIRS([libs/spandsp])
AC_CONFIG_SUBDIRS([libs/broadvoice])
AC_CONFIG_SUBDIRS([libs/libg722_1])
AC_CONFIG_SUBDIRS([libs/silk])
AC_CONFIG_SUBDIRS([libs/libcodec2])
case $host in
*-openbsd*)

12
debian/changelog vendored
View File

@ -1,3 +1,15 @@
freeswitch (1.0.6-1ubuntu1) maverick; urgency=low
[ Gabriel Gunderson ]
* upgrade: Added mod_callcenter and pulled out Python into its own
package.
[ Mathieu Parent ]
* Updated Uploaders list
* Updated Standards-Version to 3.9.1
-- Mathieu Parent <sathieu@debian.org> Thu, 23 Sep 2010 15:34:00 +0200
freeswitch (1.0.4-1ubuntu2) karmic; urgency=low
* upgrade: Add more verbosity when building to make it easier to find build

19
debian/control vendored
View File

@ -1,10 +1,11 @@
Source: freeswitch
Section: comm
Priority: extra
Maintainer: Michal Bielicki <michal.bielicki@voiceworks.pl>
Build-Depends: debhelper (>= 5), fakeroot, wget, automake (>=1.9), autoconf, libtool, unixodbc-dev, libasound2-dev, libcurl3-openssl-dev|libcurl4-openssl-dev, libssl-dev, ncurses-dev, libogg-dev, libvorbis-dev, libperl-dev, libgdbm-dev, libdb-dev, libgnutls-dev, libtiff4-dev, python, libx11-dev, uuid-dev
Maintainer: FreeSWITCH developers <freeswitch-dev@lists.freeswitch.org>
Uploaders: Michal Bielicki <michal.bielicki@voiceworks.pl>, Gabriel Gunderson <gabe@gundy.org>, William King <quentusrex@gmail.com>, Mathieu Parent <sathieu@debian.org>
Build-Depends: debhelper (>= 5), fakeroot, wget, automake (>=1.9), autoconf, libtool, unixodbc-dev, libasound2-dev, libcurl3-openssl-dev|libcurl4-openssl-dev, libssl-dev, ncurses-dev, libogg-dev, libvorbis-dev, libperl-dev, libgdbm-dev, libdb-dev, libgnutls-dev, libtiff4-dev, python-dev, libx11-dev, uuid-dev
Homepage: http://freeswitch.org/
Standards-Version: 3.8.4
Standards-Version: 3.9.1
Vcs-Svn: http://svn.freeswitch.org/svn/freeswitch/trunk/
Vcs-Browser: http://fisheye.freeswitch.org/browse/FreeSWITCH
@ -86,6 +87,18 @@ Description: Lua engine for FreeSWITCH
.
This package contains the mod_lua language module.
Package: freeswitch-python
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, freeswitch
Description: Python engine for FreeSWITCH
FreeSWITCH is an open source telephony platform designed to facilitate the
creation of voice and chat driven products scaling from a soft-phone up to a
soft-switch. It can be used as a simple switching engine, a PBX, a media
gateway or a media server to host IVR applications using simple scripts or XML
to control the callflow.
.
This package contains the mod_python language module.
Package: freeswitch-codec-passthru-g7231
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, freeswitch

View File

@ -1,5 +1,6 @@
/opt/freeswitch/conf/autoload_configs/acl.conf.xml
/opt/freeswitch/conf/autoload_configs/alsa.conf.xml
/opt/freeswitch/conf/autoload_configs/callcenter.conf.xml
/opt/freeswitch/conf/autoload_configs/cdr_csv.conf.xml
/opt/freeswitch/conf/autoload_configs/cidlookup.conf.xml
/opt/freeswitch/conf/autoload_configs/conference.conf.xml
@ -26,7 +27,6 @@
/opt/freeswitch/conf/autoload_configs/pocketsphinx.conf.xml
/opt/freeswitch/conf/autoload_configs/portaudio.conf.xml
/opt/freeswitch/conf/autoload_configs/post_load_modules.conf.xml
/opt/freeswitch/conf/autoload_configs/python.conf.xml
/opt/freeswitch/conf/autoload_configs/rss.conf.xml
/opt/freeswitch/conf/autoload_configs/shout.conf.xml
/opt/freeswitch/conf/autoload_configs/skinny.conf.xml
@ -43,7 +43,6 @@
/opt/freeswitch/conf/autoload_configs/zeroconf.conf.xml
/opt/freeswitch/conf/dialplan/default/00_pizza_demo.xml
/opt/freeswitch/conf/dialplan/default/01_example.com.xml
/opt/freeswitch/conf/dialplan/default/99999_enum.xml
/opt/freeswitch/conf/dialplan/default.xml
/opt/freeswitch/conf/dialplan/features.xml
/opt/freeswitch/conf/dialplan/public/00_inbound_did.xml

View File

@ -6,6 +6,7 @@ opt/freeswitch/bin/gentls_cert
opt/freeswitch/bin/scripts/*
opt/freeswitch/conf/autoload_configs/acl.conf.xml
opt/freeswitch/conf/autoload_configs/alsa.conf.xml
opt/freeswitch/conf/autoload_configs/callcenter.conf.xml
opt/freeswitch/conf/autoload_configs/cdr_csv.conf.xml
opt/freeswitch/conf/autoload_configs/cidlookup.conf.xml
opt/freeswitch/conf/autoload_configs/conference.conf.xml
@ -34,7 +35,6 @@ opt/freeswitch/conf/autoload_configs/openzap.conf.xml
opt/freeswitch/conf/autoload_configs/pocketsphinx.conf.xml
opt/freeswitch/conf/autoload_configs/portaudio.conf.xml
opt/freeswitch/conf/autoload_configs/post_load_modules.conf.xml
opt/freeswitch/conf/autoload_configs/python.conf.xml
opt/freeswitch/conf/autoload_configs/rss.conf.xml
opt/freeswitch/conf/autoload_configs/shout.conf.xml
opt/freeswitch/conf/autoload_configs/skinny.conf.xml
@ -51,7 +51,6 @@ opt/freeswitch/conf/autoload_configs/xml_rpc.conf.xml
opt/freeswitch/conf/autoload_configs/zeroconf.conf.xml
opt/freeswitch/conf/dialplan/default/00_pizza_demo.xml
opt/freeswitch/conf/dialplan/default/01_example.com.xml
opt/freeswitch/conf/dialplan/default/99999_enum.xml
opt/freeswitch/conf/dialplan/default.xml
opt/freeswitch/conf/dialplan/features.xml
opt/freeswitch/conf/dialplan/public/00_inbound_did.xml
@ -113,6 +112,7 @@ opt/freeswitch/conf/zt.conf
opt/freeswitch/htdocs/*
opt/freeswitch/lib/libfreeswitch*.so*
opt/freeswitch/lib/libopenzap*.so*
opt/freeswitch/mod/mod_callcenter.so*
opt/freeswitch/mod/mod_cdr_csv.so*
opt/freeswitch/mod/mod_celt.so*
opt/freeswitch/mod/mod_cidlookup.so*

6
debian/rules vendored
View File

@ -13,7 +13,7 @@ export APPLICATIONS_MODULES=applications/mod_cluechoo applications/mod_commands
applications/mod_hash applications/mod_db applications/mod_valet_parking applications/mod_voicemail applications/mod_rss \
applications/mod_spandsp applications/mod_cidlookup applications/mod_curl applications/mod_easyroute \
applications/mod_lcr applications/mod_nibblebill applications/mod_snom \
applications/mod_spy applications/mod_vmd applications/mod_directory
applications/mod_spy applications/mod_vmd applications/mod_directory applications/mod_callcenter
export ASR_TTS_MODULES=asr_tts/mod_tts_commandline
export CODECS_MODULES=codecs/mod_ilbc codecs/mod_h26x codecs/mod_speex codecs/mod_siren codecs/mod_celt
export DIALPLANS_MODULES=dialplans/mod_dialplan_asterisk dialplans/mod_dialplan_directory dialplans/mod_dialplan_xml
@ -24,11 +24,11 @@ export ENDPOINTS_MODULES=endpoints/mod_dingaling endpoints/mod_portaudio endpoin
endpoints/mod_skinny
export EVENT_HANDLERS_MODULES=event_handlers/mod_event_multicast event_handlers/mod_event_socket event_handlers/mod_cdr_csv
export FORMATS_MODULES=formats/mod_local_stream formats/mod_native_file formats/mod_sndfile formats/mod_tone_stream formats/mod_shout
export LANGUAGES_MODULES=languages/mod_spidermonkey languages/mod_perl languages/mod_lua
export LANGUAGES_MODULES=languages/mod_spidermonkey languages/mod_perl languages/mod_lua languages/mod_python
export LOGGERS_MODULES=loggers/mod_console loggers/mod_logfile loggers/mod_syslog
export SAY_MODULES=say/mod_say_en say/mod_say_it say/mod_say_de say/mod_say_fr say/mod_say_es say/mod_say_nl say/mod_say_ru
export TIMERS_MODULES=
export DISABLED_MODULES=applications/mod_memcache applications/mod_soundtouch directories/mod_ldap languages/mod_java languages/mod_python \
export DISABLED_MODULES=applications/mod_memcache applications/mod_soundtouch directories/mod_ldap languages/mod_java \
asr_tts/mod_cepstral asr_tts/mod_lumenvox endpoints/mod_wanpipe \
event_handlers/mod_event_test event_handlers/mod_radius_cdr event_handlers/mod_zeroconf
export XML_INT_MODULES=xml_int/mod_xml_rpc xml_int/mod_xml_curl xml_int/mod_xml_cdr

View File

@ -395,6 +395,8 @@
<prompt phrase="Congratulations, you pressed star. This does not mean you ARE a star. It simply means that you can press buttons and probably have fingers." filename="ivr-congratulations_you_pressed_star.wav"/>
<prompt phrase="All of our engineers are busy assisting other sales guys with demonstrating how cool the CudaTel is. Please stay on the line and your call will be answered in the order it was received." filename="ivr-engineers_busy_assisting_other_sales.wav"/>
<prompt phrase="" filename="ivr-.wav"/>
<prompt phrase="You are already muted." filename="conf-you_are_already_muted.wav"/>
<prompt phrase="You are now bi-directionally muted." filename="conf-you_are_now_bidirectionally_muted.wav"/>
</ivr>
<misc>

View File

@ -1,5 +1,5 @@
###############################################################################################################################
###############################################################################################################################
######################################################################################################################
######################################################################################################################
#
# spec file for package freeswitch
#
@ -26,8 +26,8 @@
#
# Maintainer(s): Michal Bielicki <michal.bielicki (at) ++nospam_please++ seventhsignal.de
#
###############################################################################################################################
###############################################################################################################################
######################################################################################################################
######################################################################################################################
#
# disable rpath checking
%define __arch_install_post /usr/lib/rpm/check-buildroot
@ -48,11 +48,11 @@ URL: http://www.freeswitch.org/
Packager: Michal Bielicki
Vendor: http://www.freeswitch.org/
###############################################################################################################################
######################################################################################################################
#
# Source files and where to get them
# Source files and where to get them
#
###############################################################################################################################
######################################################################################################################
Source0: http://files.freeswitch.org/%{name}-%{version}.tar.bz2
Source1: http://files.freeswitch.org/downloads/libs/celt-0.7.0.tar.gz
Source2: http://files.freeswitch.org/downloads/libs/flite-1.3.99-latest.tar.gz
@ -68,11 +68,11 @@ Source11: http://files.freeswitch.org/downloads/libs/libmemcached-0.32.tar.gz
Prefix: %{prefix}
###############################################################################################################################
######################################################################################################################
#
# Build Dependencies
#
###############################################################################################################################
######################################################################################################################
%if 0%{?suse_version} > 100
#BuildRequires: openldap2-devel
@ -128,11 +128,11 @@ PreReq: %insserv_prereq %fillup_prereq
%endif
###############################################################################################################################
######################################################################################################################
#
# Where the packages are going to be built
# Where the packages are going to be built
#
###############################################################################################################################
######################################################################################################################
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
@ -155,12 +155,12 @@ Our developers are heavily involved in open source and have donated code and oth
other telephony projects including sipXecs, OpenSER, Asterisk, CodeWeaver and OpenPBX.
###############################################################################################################################
######################################################################################################################
#
# Sub Package definitions. Description and Runtime Requirements go here
# What goes into which package is in the files section after the whole build enchilada
# Sub Package definitions. Description and Runtime Requirements go here
# What goes into which package is in the files section after the whole build enchilada
#
###############################################################################################################################
######################################################################################################################
%package devel
@ -277,11 +277,11 @@ Requires: %{name} = %{version}-%{release}
%description openzap
OpenZAP
###############################################################################################################################
######################################################################################################################
#
# Unpack and prepare Source archives, copy stuff around etc ..
# Unpack and prepare Source archives, copy stuff around etc ..
#
###############################################################################################################################
######################################################################################################################
%prep
%setup -b0 -q
@ -297,11 +297,11 @@ cp %{SOURCE9} libs/
cp %{SOURCE10} libs/
cp %{SOURCE11} libs/
###############################################################################################################################
######################################################################################################################
#
# Start the Build process
# Start the Build process
#
###############################################################################################################################
######################################################################################################################
%build
%ifos linux
%if 0%{?suse_version} > 1000 && 0%{?suse_version} < 1030
@ -312,115 +312,115 @@ export QA_RPATHS=$[ 0x0001|0x0002 ]
%endif
%endif
###############################################################################################################################
######################################################################################################################
#
# Here the modules that will be build get defined
# Here the modules that will be build get defined
#
###############################################################################################################################
###############################################################################################################################
######################################################################################################################
######################################################################################################################
#
# Application Modules
# Application Modules
#
###############################################################################################################################
APPLICATION_MODULES_AE="applications/mod_avmd applications/mod_commands applications/mod_conference applications/mod_db applications/mod_directory applications/mod_distributor applications/mod_dptools applications/mod_easyroute applications/mod_enum applications/mod_esf applications/mod_expr applications/mod_callcenter"
######################################################################################################################
APPLICATION_MODULES_AE="applications/mod_avmd applications/mod_callcenter applications/mod_cluechoo applications/mod_commands applications/mod_conference applications/mod_db applications/mod_directory applications/mod_distributor applications/mod_dptools applications/mod_easyroute applications/mod_enum applications/mod_esf applications/mod_expr"
APPLICATION_MODULES_FM="applications/mod_fifo applications/mod_fsv applications/mod_hash applications/mod_lcr applications/mod_limit applications/mod_memcache"
APPLICATION_MODULES_NY=" applications/mod_redis applications/mod_rss applications/mod_soundtouch applications/mod_spandsp applications/mod_stress applications/mod_spy "
APPLICATION_MODULES_NY="applications/mod_nibblebill applications/mod_redis applications/mod_rss applications/mod_soundtouch applications/mod_spandsp applications/mod_stress applications/mod_spy "
APPLICATION_MODULES_VZ="applications/mod_valet_parking applications/mod_vmd applications/mod_voicemail"
APPLICATIONS_MODULES="$APPLICATION_MODULES_AE $APPLICATION_MODULES_FM $APPLICATION_MODULES_NY $APPLICATION_MODULES_VZ"
###############################################################################################################################
######################################################################################################################
#
# Automatic Speech Recognition and Text To Speech Modules
# Automatic Speech Recognition and Text To Speech Modules
#
###############################################################################################################################
######################################################################################################################
ASR_TTS_MODULES="asr_tts/mod_pocketsphinx asr_tts/mod_flite asr_tts/mod_unimrcp"
###############################################################################################################################
######################################################################################################################
#
# Codecs
# Codecs
#
###############################################################################################################################
######################################################################################################################
CODECS_MODULES="codecs/mod_ilbc codecs/mod_h26x codecs/mod_speex codecs/mod_celt codecs/mod_siren codecs/mod_bv"
###############################################################################################################################
######################################################################################################################
#
# Dialplan Modules
# Dialplan Modules
#
###############################################################################################################################
######################################################################################################################
DIALPLANS_MODULES="dialplans/mod_dialplan_asterisk dialplans/mod_dialplan_directory dialplans/mod_dialplan_xml"
###############################################################################################################################
######################################################################################################################
#
# Directory Modules
# Directory Modules
#
###############################################################################################################################
######################################################################################################################
DIRECTORIES_MODULES=""
###############################################################################################################################
######################################################################################################################
#
# Endpoints
# Endpoints
#
###############################################################################################################################
######################################################################################################################
ENDPOINTS_MODULES="endpoints/mod_dingaling endpoints/mod_portaudio endpoints/mod_sofia ../../libs/openzap/mod_openzap endpoints/mod_loopback"
###############################################################################################################################
######################################################################################################################
#
# Event Handlers
# Event Handlers
#
###############################################################################################################################
######################################################################################################################
EVENT_HANDLERS_MODULES="event_handlers/mod_event_multicast event_handlers/mod_event_socket event_handlers/mod_cdr_csv"
###############################################################################################################################
######################################################################################################################
#
# File and Audio Format Handlers
# File and Audio Format Handlers
#
###############################################################################################################################
FORMATS_MODULES="formats/mod_local_stream formats/mod_native_file formats/mod_sndfile formats/mod_tone_stream formats/mod_shout formats/mod_file_string"
###############################################################################################################################
######################################################################################################################
FORMATS_MODULES="formats/mod_local_stream formats/mod_native_file formats/mod_sndfile formats/mod_portaudio_stream formats/mod_tone_stream formats/mod_shout formats/mod_file_string"
######################################################################################################################
#
# Embedded Languages
# Embedded Languages
#
###############################################################################################################################
######################################################################################################################
LANGUAGES_MODULES="languages/mod_lua languages/mod_perl languages/mod_python languages/mod_spidermonkey"
###############################################################################################################################
######################################################################################################################
#
# Logging Modules
# Logging Modules
#
###############################################################################################################################
######################################################################################################################
LOGGERS_MODULES="loggers/mod_console loggers/mod_logfile loggers/mod_syslog"
###############################################################################################################################
######################################################################################################################
#
# Passthru Codecs
# Passthru Codecs
#
###############################################################################################################################
######################################################################################################################
PASSTHRU_CODEC_MODULES="codecs/mod_amr codecs/mod_amrwb codecs/mod_g723_1 codecs/mod_g729"
###############################################################################################################################
######################################################################################################################
#
# Phrase engine language modules
# Phrase engine language modules
#
###############################################################################################################################
######################################################################################################################
SAY_MODULES="say/mod_say_de say/mod_say_en say/mod_say_fr say/mod_say_ru"
###############################################################################################################################
######################################################################################################################
#
# Timers
# Timers
#
###############################################################################################################################
######################################################################################################################
TIMERS_MODULES=
###############################################################################################################################
######################################################################################################################
#
# XML Modules
# XML Modules
#
###############################################################################################################################
######################################################################################################################
XML_INT_MODULES="xml_int/mod_xml_cdr xml_int/mod_xml_curl xml_int/mod_xml_rpc"
###############################################################################################################################
######################################################################################################################
#
# Create one environment variable out of all the module defs
# Create one environment variable out of all the module defs
#
###############################################################################################################################
######################################################################################################################
MYMODULES="$PASSTHRU_CODEC_MODULES $APPLICATIONS_MODULES $CODECS_MODULES $DIALPLANS_MODULES $DIRECTORIES_MODULES $ENDPOINTS_MODULES $ASR_TTS_MODULES $EVENT_HANDLERS_MODULES $FORMATS_MODULES $LANGUAGES_MODULES $LOGGERS_MODULES $SAY_MODULES $TIMERS_MODULES $XML_INT_MODULES"
###############################################################################################################################
######################################################################################################################
#
# Create Modules build list and set variables
# Create Modules build list and set variables
#
###############################################################################################################################
######################################################################################################################
export MODULES=$MYMODULES
test ! -f modules.conf || rm -f modules.conf
@ -431,11 +431,11 @@ export DESTDIR=%{buildroot}/
export PKG_CONFIG_PATH=/usr/bin/pkg-config:$PKG_CONFIG_PATH
export ACLOCAL_FLAGS="-I /usr/share/aclocal"
###############################################################################################################################
######################################################################################################################
#
# Bootstrap, Configure and Build the whole enchilada
# Bootstrap, Configure and Build the whole enchilada
#
###############################################################################################################################
######################################################################################################################
if test ! -f Makefile.in
then
@ -467,11 +467,11 @@ touch .noversion
%{__make}
###############################################################################################################################
######################################################################################################################
#
# Install it and create some required dirs and links
# Install it and create some required dirs and links
#
###############################################################################################################################
######################################################################################################################
%install
%{__make} DESTDIR=%{buildroot} install
@ -502,11 +502,11 @@ touch .noversion
%endif
###############################################################################################################################
######################################################################################################################
#
# Add a freeswitch user with group daemon that will own the whole enchilada
# Add a freeswitch user with group daemon that will own the whole enchilada
#
###############################################################################################################################
######################################################################################################################
%pre
%ifos linux
if ! /usr/bin/id freeswitch &>/dev/null; then
@ -526,11 +526,11 @@ chkconfig --add freeswitch
%postun
###############################################################################################################################
######################################################################################################################
#
# On uninstallation get rid of the freeswitch user
# On uninstallation get rid of the freeswitch user
#
###############################################################################################################################
######################################################################################################################
%{?run_ldconfig:%run_ldconfig}
if [ $1 -eq 0 ]; then
userdel freeswitch || %logmsg "User \"freeswitch\" could not be deleted."
@ -540,19 +540,19 @@ fi
%{__rm} -rf %{buildroot}
%files
###############################################################################################################################
######################################################################################################################
#
# What to install where ... first set default permissions
# What to install where ... first set default permissions
#
###############################################################################################################################
######################################################################################################################
%defattr(-,freeswitch,daemon)
###############################################################################################################################
######################################################################################################################
#
# Directories
# Directories
#
###############################################################################################################################
######################################################################################################################
#
#################################### Basic Directory Structure ################################################################
#################################### Basic Directory Structure #######################################################
#
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf
%dir %attr(0750, freeswitch, daemon) %{prefix}/db
@ -562,7 +562,7 @@ fi
%dir %attr(0750, freeswitch, daemon) %{runtimedir}
%dir %attr(0750, freeswitch, daemon) %{prefix}/scripts
#
#################################### Config Directory Structure ################################################################
#################################### Config Directory Structure #######################################################
#
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/autoload_configs
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/dialplan
@ -579,7 +579,7 @@ fi
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/sip_profiles/internal
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/skinny_profiles
#
#################################### Grammar Directory Structure ################################################################
#################################### Grammar Directory Structure #####################################################
#
%dir %attr(0750, freeswitch, daemon) %{prefix}/grammar/model
%dir %attr(0750, freeswitch, daemon) %{prefix}/grammar/model/communicator
@ -587,11 +587,11 @@ fi
%ifos linux
%config(noreplace) %attr(0644, freeswitch, daemon) /etc/monit.d/freeswitch.monitrc
%endif
###############################################################################################################################
######################################################################################################################
#
# Config Files
# Config Files
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/*.tpl
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/*.ttml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/*.xml
@ -650,60 +650,59 @@ fi
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/xml_curl.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/xml_rpc.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/zeroconf.conf.xml
###############################################################################################################################
######################################################################################################################
#
# Dialplans
# Dialplans
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/dialplan/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/dialplan/default/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/dialplan/public/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/dialplan/skinny-patterns/*.xml
###############################################################################################################################
######################################################################################################################
#
# User Directories
# User Directories
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/directory/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/directory/default/*
###############################################################################################################################
######################################################################################################################
#
# IVR Menues
# IVR Menues
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/ivr_menus/*.xml
###############################################################################################################################
######################################################################################################################
#
# Sip Profiles
# Sip Profiles
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/sip_profiles/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/sip_profiles/internal/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/sip_profiles/external/*.xml
###############################################################################################################################
######################################################################################################################
#
# Other Protocol Profiles (skinny, jingle, mrcp)
# Other Protocol Profiles (skinny, jingle, mrcp)
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/skinny_profiles/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/jingle_profiles/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/mrcp_profiles/*.xml
###############################################################################################################################
######################################################################################################################
#
# Grammar Files
# Grammar Files
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/grammar/default.dic
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/grammar/model/communicator/*
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/grammar/model/wsj1/*
###############################################################################################################################
######################################################################################################################
#
# Other Fíles
# Other Fíles
#
###############################################################################################################################
######################################################################################################################
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/htdocs/*
%ifos linux
#/etc/ld.so.conf.d/*
/etc/rc.d/init.d/freeswitch
/etc/sysconfig/freeswitch
%if 0%{?suse_version} > 100
@ -713,23 +712,25 @@ fi
%ifos linux
%dir %attr(0750, root, root) /etc/monit.d
%endif
###############################################################################################################################
######################################################################################################################
#
# Binaries
# Binaries
#
###############################################################################################################################
######################################################################################################################
%attr(0755, freeswitch, daemon) %{prefix}/bin/*
%{prefix}/lib/libfreeswitch*.so*
###############################################################################################################################
######################################################################################################################
#
# Modules in Alphabetical Order, please keep them that way..
# Modules in Alphabetical Order, please keep them that way..
#
###############################################################################################################################
######################################################################################################################
%{prefix}/mod/mod_amrwb.so*
%{prefix}/mod/mod_avmd.so*
%{prefix}/mod/mod_bv.so*
%{prefix}/mod/mod_callcenter.so*
%{prefix}/mod/mod_cdr_csv.so*
%{prefix}/mod/mod_celt.so*
%{prefix}/mod/mod_cluechoo.so*
%{prefix}/mod/mod_console.so*
%{prefix}/mod/mod_commands.so*
%{prefix}/mod/mod_conference.so*
@ -747,7 +748,6 @@ fi
%{prefix}/mod/mod_event_multicast.so*
%{prefix}/mod/mod_event_socket.so*
%{prefix}/mod/mod_expr.so*
%{prefix}/mod/mod_callcenter.so*
%{prefix}/mod/mod_fifo.so*
%{prefix}/mod/mod_file_string.so*
%{prefix}/mod/mod_flite.so*
@ -762,8 +762,10 @@ fi
%{prefix}/mod/mod_loopback.so*
%{prefix}/mod/mod_memcache.so*
%{prefix}/mod/mod_native_file.so*
%{prefix}/mod/mod_nibblebill.so*
%{prefix}/mod/mod_pocketsphinx.so*
%{prefix}/mod/mod_portaudio.so*
%{prefix}/mod/mod_portaudio_stream.so*
%{prefix}/mod/mod_redis.so*
%{prefix}/mod/mod_rss.so*
%{prefix}/mod/mod_shout.so*
@ -784,13 +786,11 @@ fi
%{prefix}/mod/mod_xml_cdr.so*
%{prefix}/mod/mod_xml_curl.so*
%{prefix}/mod/mod_xml_rpc.so*
###############################################################################################################################
######################################################################################################################
#
# Package for the developer
# Package for the developer
#
###############################################################################################################################
######################################################################################################################
%files devel
%defattr(-, freeswitch, daemon)
%{prefix}/lib/*.a
@ -799,12 +799,11 @@ fi
%{prefix}/mod/*.a
%{prefix}/mod/*.la
%{prefix}/include/*.h
###############################################################################################################################
######################################################################################################################
#
# OpenZAP Module for TDM Interaction
# OpenZAP Module for TDM Interaction
#
###############################################################################################################################
######################################################################################################################
%files openzap
%defattr(-, freeswitch, daemon)
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/tones.conf
@ -817,11 +816,11 @@ fi
%{prefix}/mod/mod_openzap.so*
%{prefix}/mod/ozmod_*.so*
###############################################################################################################################
######################################################################################################################
#
# Passthru Codec Modules
# Passthru Codec Modules
#
###############################################################################################################################
######################################################################################################################
%files codec-passthru-amrwb
%defattr(-,freeswitch,daemon)
%{prefix}/mod/mod_amrwb.so*
@ -838,12 +837,11 @@ fi
%defattr(-,freeswitch,daemon)
%{prefix}/mod/mod_g729.so*
###############################################################################################################################
######################################################################################################################
#
# Embedded Language Modules
# Embedded Language Modules
#
###############################################################################################################################
######################################################################################################################
%files spidermonkey
%defattr(-,freeswitch,daemon)
%{prefix}/mod/mod_spidermonkey*.so*
@ -874,11 +872,11 @@ fi
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/autoload_configs
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/python.conf.xml
###############################################################################################################################
######################################################################################################################
#
# Language Modules
# Language Modules
#
###############################################################################################################################
######################################################################################################################
%files lang-en
%defattr(-, freeswitch, daemon)
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/lang/en
@ -922,12 +920,17 @@ fi
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/lang/ru/dir/*.xml
%{prefix}/mod/mod_say_ru.so*
###############################################################################################################################
######################################################################################################################
#
# Changelog
# Changelog
#
###############################################################################################################################
######################################################################################################################
%changelog
* Thu Sep 30 2010 - michal.bielicki@seventhsignal.de
- added mod_nibblebill to standard modules
* Sun Sep 26 2010 - michal.bielicki@seventhsignal.de
- added portaudio_stream module
- some more formating work
* Mon Jul 19 2010 - michal.bielicki@seventhsignal.de
- new hash module config file added to freeswitch.spec
* Mon Jul 19 2010 - michal.bielicki@seventhsignal.de

1
libs/.gitignore vendored
View File

@ -355,6 +355,7 @@
/libsndfile/Cfg/missing
/libsndfile/M4/Makefile
/libsndfile/M4/Makefile.in
/libsndfile/M4/lt~obsolete.m4
/libsndfile/Makefile
/libsndfile/Makefile.in
/libsndfile/Octave/Makefile

View File

@ -1 +1 @@
Thu Nov 19 09:24:37 EST 2009
Mon Sep 27 13:15:54 CDT 2010

View File

@ -824,7 +824,13 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *),
* Modifier check. Note that if APR_INT64_T_FMT is "d",
* the first if condition is never true.
*/
if ((sizeof(APR_INT64_T_FMT) == 4 &&
/* HACK BY FREESWITCH TEAM TO FIX COMPATIBILITY 2010-09-27 */
if (*fmt == 'l' && *(fmt + 1) == 'l') {
var_type = IS_QUAD;
fmt += 2;
}
else if ((sizeof(APR_INT64_T_FMT) == 4 &&
fmt[0] == APR_INT64_T_FMT[0] &&
fmt[1] == APR_INT64_T_FMT[1]) ||
(sizeof(APR_INT64_T_FMT) == 3 &&
@ -843,6 +849,11 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *),
else if (*fmt == 'l') {
var_type = IS_LONG;
fmt++;
/* HACK BY FREESWITCH TEAM TO FIX COMPATIBILITY 2010-09-27 */
if (*fmt == 'l') {
var_type = IS_QUAD;
fmt++;
}
}
else if (*fmt == 'h') {
var_type = IS_SHORT;

View File

@ -36,7 +36,10 @@
#define closesocket(x) close(x)
#include <fcntl.h>
#else
#pragma warning (disable:6386)
/* These warnings need to be ignored warning in sdk header */
#include <Ws2tcpip.h>
#pragma warning (default:6386)
#endif

View File

@ -110,7 +110,7 @@ ESL_DECLARE(int) esl_config_next_pair(esl_config_t *cfg, char **var, char **val)
*var = *val = NULL;
if (!cfg->path) {
if (!cfg || !cfg->file) {
return 0;
}

View File

@ -513,6 +513,9 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es
char *encode_buf = NULL; /* used for url encoding of variables to make sure unsafe things stay out of the serialized copy */
int clen = 0;
if (!event || !event->headers)
return ESL_FAIL;
*str = NULL;
dlen = blocksize * 2;

View File

@ -312,7 +312,7 @@ ftmod_r2_la_LIBADD = $(MYLIB)
endif
dox doxygen:
cd docs && doxygen $(FT_SRCDIR)/docs/Doxygen.conf
doxygen $(FT_SRCDIR)/docs/Doxygen.conf
mod_freetdm/mod_freetdm.$(DYNAMIC_LIB_EXTEN): $(MYLIB) mod_freetdm/mod_freetdm.c
cd mod_freetdm && make

View File

@ -1,3 +1,3 @@
FREETDM (WORK IN PROGRESS)
FreeTDM
http://wiki.freeswitch.org/wiki/FreeTDM
*shrug*

View File

@ -1,19 +1,47 @@
[span wanpipe]
name => FreeTDM
number => 1
; !! THIS IS A SAMPLE CONFIGURATION ONLY !!
; refer to http://wiki.freeswitch.org/wiki/FreeTDM for further documentation
[general]
; whether to launch a thread for CPU usage monitoring
cpu_monitor => no
; How often (in milliseconds) monitor CPU usage
cpu_monitoring_interval => 1000
; At what CPU percentage raise a CPU alarm
cpu_set_alarm_threshold => 80
; At what CPU percentage stop the CPU alarm
cpu_reset_alarm_threshold => 70
; Which action to take when the CPU alarm is raised
; it can be warn and/or reject calls
; cpu_alarm_action => warn,reject
cpu_alarm_action => warn
; spans are defined with [span <span type> <span name>]
; the span type can either be zt, wanpipe or pika
; the span name can be any unique string
[span wanpipe myWanpipe]
; valid trunk types are: FXO, FXS, EM, E1, T1, J1, BRI, BRI_PTMP
trunk_type => FXS
; add FXS channels from 3 to 4 at wanpipe span 1 to this freetdm span
fxs-channel => 1:3-4
[span wanpipe]
[span wanpipe myWanpipe2]
trunk_type => FXO
; This number will be used as DNIS for FXO devices
fxo-channel => 1:1-2
[span zt]
name => FreeTDM
number => 2
[span zt myZaptelSpan]
number => 9999
fxs-channel => 1
[span zt]
name => FreeTDM
[span zt mySecondZaptelSpan]
; This number will be used as DNIS for FXO devices
number => 2
fxo-channel => 3

View File

@ -1,3 +1,5 @@
<!-- Please refer to http://wiki.freeswitch.org/wiki/FreeTDM for further documentation -->
<configuration name="freetdm.conf" description="FreeTDM Configuration">
<settings>
<param name="debug" value="0"/>
@ -5,6 +7,8 @@
<!--<param name="enable-analog-option" value="call-swap"/>-->
<!--<param name="enable-analog-option" value="3-way"/>-->
</settings>
<!-- use the <pri_spans> tag for native ISDN support (most likely broken at this point, check sangoma_pri_spans or libpri_spans for alternatives) -->
<pri_spans>
<span name="PRI_1">
<!-- Log Levels: none, alert, crit, err, warning, notice, info, debug -->
@ -24,9 +28,11 @@
<param name="context" value="default"/>
</span>
</pri_spans>
<!-- one entry here per openzap span -->
<!-- Analog spans go here -->
<analog_spans>
<span id="1">
<span name="myAnalog">
<!--<param name="hold-music" value="$${moh_uri}"/>-->
<!--<param name="enable-analog-option" value="call-swap"/>-->
<!--<param name="enable-analog-option" value="3-way"/>-->
@ -42,4 +48,5 @@
<!--<param name="fail-dial-regex" value="^5"/>-->
</span>
</analog_spans>
</configuration>

View File

@ -1,3 +1,5 @@
; you dont need this file unless you use PIKA boards
; each category is a config profile
; to apply the profile append it to a channel def in
; openzap.conf with @<profile_name>

View File

@ -1,3 +1,5 @@
; This file is used to generate telephony tones by FreeTDM
[us]
generate-dial => v=-7;%(1000,0,350,440)
detect-dial => 350,440

64
libs/freetdm/mkrelease.sh Executable file
View File

@ -0,0 +1,64 @@
#!/bin/bash
INSTALLPREFIX="/usr/local/freetdm"
VERSION=""
NODOCS="NO"
for i in $*
do
case $i in
--version=*)
VERSION=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--prefix=*)
INSTALLPREFIX=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--nodocs)
NODOCS="YES"
;;
*)
# unknown option
echo "Unknown option $i"
exit
;;
esac
done
if [ "x$VERSION" = "x" ]
then
echo "Provide a version number with --version=<version>"
exit 1
fi
if [ ! -d $INSTALLPREFIX ]
then
mkdir -p $INSTALLPREFIX || exit 1
fi
make clean
make mod_freetdm-clean
if [ $NODOCS = "NO" ]
then
make dox || exit 1
fi
major=$(echo "$VERSION" | cut -d. -f1)
minor=$(echo "$VERSION" | cut -d. -f2)
micro=$(echo "$VERSION" | cut -d. -f3)
release="freetdm-$VERSION"
echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... press any key to continue"
read
mkdir -p $INSTALLPREFIX/$release
cp -r ./* $INSTALLPREFIX/$release
find $INSTALLPREFIX/ -name .libs -exec rm -rf {} \;
find $INSTALLPREFIX/ -name .deps -exec rm -rf {} \;
find $INSTALLPREFIX/ -name *.so -exec rm -rf {} \;
find $INSTALLPREFIX/ -name *.lo -exec rm -rf {} \;
tar -C $INSTALLPREFIX -czf $INSTALLPREFIX/$release.tar.gz $release/

View File

@ -1404,6 +1404,7 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
ftdm_iterator_t *iter = NULL;
ftdm_iterator_t *curr = NULL;
const char *var_name = NULL;
const char *var_value = NULL;
uint32_t spanid, chanid;
@ -1515,13 +1516,14 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
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);
for ( ; iter; iter = ftdm_iterator_next(iter)) {
ftdm_channel_get_current_var(iter, &var_name, &var_value);
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);
}
ftdm_iterator_free(iter);
switch_channel_set_state(channel, CS_INIT);
if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
@ -2180,9 +2182,8 @@ static void ftdm_logger(const char *file, const char *func, int line, int level,
if (switch_vasprintf(&data, fmt, ap) != -1) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, (char *)func, line, NULL, level, "%s", data);
free(data);
}
if (data) free(data);
va_end(ap);
}
@ -2371,6 +2372,121 @@ static int add_profile_parameters(switch_xml_t cfg, const char *profname, ftdm_c
return paramindex;
}
static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans)
{
switch_xml_t myspan, param;
for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
ftdm_status_t zstatus = FTDM_FAIL;
const char *context = "default";
const char *dialplan = "XML";
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, "cfgprofile");
ftdm_span_t *span = NULL;
uint32_t span_id = 0;
unsigned paramindex = 0;
if (!name && !id) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sangoma isdn span missing required attribute 'id' or 'name', skipping ...\n");
continue;
}
if (name) {
zstatus = ftdm_span_find_by_name(name, &span);
} else {
if (switch_is_number(id)) {
span_id = atoi(id);
zstatus = ftdm_span_find(span_id, &span);
}
if (zstatus != FTDM_SUCCESS) {
zstatus = ftdm_span_find_by_name(id, &span);
}
}
if (zstatus != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name));
continue;
}
if (!span_id) {
span_id = ftdm_span_get_id(span);
}
memset(spanparameters, 0, sizeof(spanparameters));
paramindex = 0;
if (configname) {
paramindex = add_profile_parameters(cfg, configname, spanparameters, ftdm_array_len(spanparameters));
if (paramindex) {
ftdm_log(FTDM_LOG_DEBUG, "Added %d parameters from profile %s for span %d\n", paramindex, configname, span_id);
}
}
/* some defaults first */
SPAN_CONFIG[span_id].limit_backend = "hash";
SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_TIMEOUT;
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (ftdm_array_len(spanparameters) == paramindex) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Too many parameters for ss7 span, ignoring any parameter after %s\n", var);
break;
}
if (!strcasecmp(var, "context")) {
context = val;
} else if (!strcasecmp(var, "dialplan")) {
dialplan = val;
} else if (!strcasecmp(var, "call_limit_backend")) {
SPAN_CONFIG[span_id].limit_backend = val;
ftdm_log(FTDM_LOG_DEBUG, "Using limit backend %s for span %d\n", SPAN_CONFIG[span_id].limit_backend, span_id);
} else if (!strcasecmp(var, "call_limit_rate")) {
int calls;
int seconds;
if (sscanf(val, "%d/%d", &calls, &seconds) != 2) {
ftdm_log(FTDM_LOG_ERROR, "Invalid %s parameter, format example: 3/1 for 3 calls per second\n", var);
} else {
if (calls < 1 || seconds < 1) {
ftdm_log(FTDM_LOG_ERROR, "Invalid %s parameter value, minimum call limit must be 1 per second\n", var);
} else {
SPAN_CONFIG[span_id].limit_calls = calls;
SPAN_CONFIG[span_id].limit_seconds = seconds;
}
}
} else if (!strcasecmp(var, "call_limit_reset_event")) {
if (!strcasecmp(val, "answer")) {
SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_ANSWER;
} else {
ftdm_log(FTDM_LOG_ERROR, "Invalid %s parameter value, only accepted event is 'answer'\n", var);
}
} else {
spanparameters[paramindex].var = var;
spanparameters[paramindex].val = val;
paramindex++;
}
}
if (ftdm_configure_span_signaling(span,
"sangoma_isdn",
on_clear_channel_signal,
spanparameters) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Error configuring Sangoma ISDN FreeTDM span %d\n", span_id);
continue;
}
SPAN_CONFIG[span_id].span = span;
switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context));
switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan));
switch_copy_string(SPAN_CONFIG[span_id].type, "Sangoma (ISDN)", sizeof(SPAN_CONFIG[span_id].type));
ftdm_log(FTDM_LOG_DEBUG, "Configured Sangoma ISDN FreeTDM span %d\n", span_id);
ftdm_span_start(span);
}
}
static switch_status_t load_config(void)
{
const char *cf = "freetdm.conf";
@ -2381,7 +2497,8 @@ static switch_status_t load_config(void)
unsigned boosti = 0;
unsigned int i = 0;
ftdm_channel_t *fchan = NULL;
unsigned int chancount = 0;
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *curr = NULL;
memset(boost_spans, 0, sizeof(boost_spans));
memset(&globals, 0, sizeof(globals));
@ -2410,116 +2527,12 @@ static switch_status_t load_config(void)
}
}
if ((spans = switch_xml_child(cfg, "sangoma_pri_spans")) || (spans = switch_xml_child(cfg, "sangoma_bri_spans"))) {
for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
ftdm_status_t zstatus = FTDM_FAIL;
const char *context = "default";
const char *dialplan = "XML";
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, "cfgprofile");
ftdm_span_t *span = NULL;
uint32_t span_id = 0;
unsigned paramindex = 0;
if ((spans = switch_xml_child(cfg, "sangoma_pri_spans"))) {
parse_bri_pri_spans(cfg, spans);
}
if (!name && !id) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sangoma isdn span missing required attribute 'id' or 'name', skipping ...\n");
continue;
}
if (name) {
zstatus = ftdm_span_find_by_name(name, &span);
} else {
if (switch_is_number(id)) {
span_id = atoi(id);
zstatus = ftdm_span_find(span_id, &span);
}
if (zstatus != FTDM_SUCCESS) {
zstatus = ftdm_span_find_by_name(id, &span);
}
}
if (zstatus != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Error finding FreeTDM span id:%s name:%s\n", switch_str_nil(id), switch_str_nil(name));
continue;
}
if (!span_id) {
span_id = ftdm_span_get_id(span);
}
memset(spanparameters, 0, sizeof(spanparameters));
paramindex = 0;
if (configname) {
paramindex = add_profile_parameters(cfg, configname, spanparameters, ftdm_array_len(spanparameters));
if (paramindex) {
ftdm_log(FTDM_LOG_DEBUG, "Added %d parameters from profile %s for span %d\n", paramindex, configname, span_id);
}
}
/* some defaults first */
SPAN_CONFIG[span_id].limit_backend = "hash";
SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_TIMEOUT;
for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (ftdm_array_len(spanparameters) == paramindex) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Too many parameters for ss7 span, ignoring any parameter after %s\n", var);
break;
}
if (!strcasecmp(var, "context")) {
context = val;
} else if (!strcasecmp(var, "dialplan")) {
dialplan = val;
} else if (!strcasecmp(var, "call_limit_backend")) {
SPAN_CONFIG[span_id].limit_backend = val;
ftdm_log(FTDM_LOG_DEBUG, "Using limit backend %s for span %d\n", SPAN_CONFIG[span_id].limit_backend, span_id);
} else if (!strcasecmp(var, "call_limit_rate")) {
int calls;
int seconds;
if (sscanf(val, "%d/%d", &calls, &seconds) != 2) {
ftdm_log(FTDM_LOG_ERROR, "Invalid %s parameter, format example: 3/1 for 3 calls per second\n", var);
} else {
if (calls < 1 || seconds < 1) {
ftdm_log(FTDM_LOG_ERROR, "Invalid %s parameter value, minimum call limit must be 1 per second\n", var);
} else {
SPAN_CONFIG[span_id].limit_calls = calls;
SPAN_CONFIG[span_id].limit_seconds = seconds;
}
}
} else if (!strcasecmp(var, "call_limit_reset_event")) {
if (!strcasecmp(val, "answer")) {
SPAN_CONFIG[span_id].limit_reset_event = FTDM_LIMIT_RESET_ON_ANSWER;
} else {
ftdm_log(FTDM_LOG_ERROR, "Invalid %s parameter value, only accepted event is 'answer'\n", var);
}
} else {
spanparameters[paramindex].var = var;
spanparameters[paramindex].val = val;
paramindex++;
}
}
if (ftdm_configure_span_signaling(span,
"sangoma_isdn",
on_clear_channel_signal,
spanparameters) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Error configuring Sangoma ISDN FreeTDM span %d\n", span_id);
continue;
}
SPAN_CONFIG[span_id].span = span;
switch_copy_string(SPAN_CONFIG[span_id].context, context, sizeof(SPAN_CONFIG[span_id].context));
switch_copy_string(SPAN_CONFIG[span_id].dialplan, dialplan, sizeof(SPAN_CONFIG[span_id].dialplan));
switch_copy_string(SPAN_CONFIG[span_id].type, "Sangoma (ISDN)", sizeof(SPAN_CONFIG[span_id].type));
ftdm_log(FTDM_LOG_DEBUG, "Configured Sangoma ISDN FreeTDM span %d\n", span_id);
ftdm_span_start(span);
}
if ((spans = switch_xml_child(cfg, "sangoma_bri_spans"))) {
parse_bri_pri_spans(cfg, spans);
}
switch_core_hash_init(&globals.ss7_configs, module_pool);
@ -2769,11 +2782,13 @@ static switch_status_t load_config(void)
switch_set_string(SPAN_CONFIG[span_id].dialplan, dialplan);
SPAN_CONFIG[span_id].analog_options = analog_options | globals.analog_options;
chancount = ftdm_span_get_chan_count(span);
for (i = 1; i <= chancount; i++) {
fchan = ftdm_span_get_channel(span, i);
chaniter = ftdm_span_get_chan_iterator(span, NULL);
curr = chaniter;
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
fchan = ftdm_iterator_current(curr);
ftdm_channel_set_private(fchan, &SPAN_CONFIG[span_id].pvts[i]);
}
ftdm_iterator_free(chaniter);
if (dial_regex) {
switch_set_string(SPAN_CONFIG[span_id].dial_regex, dial_regex);
@ -3436,7 +3451,10 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
const char *chan_type;
const char *state;
const char *last_state;
const char *uuid = NULL;
char sessionid[255];
float txgain, rxgain;
switch_core_session_t *session = NULL;
ftdm_alarm_flag_t alarmflag;
ftdm_caller_data_t *caller_data;
ftdm_channel_t *ftdmchan;
@ -3446,6 +3464,7 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
return;
}
strcpy(sessionid, "(none)");
ftdmchan = ftdm_span_get_channel(span, chan_id);
span_id = ftdm_span_get_id(span);
@ -3460,6 +3479,16 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
ftdm_channel_get_sig_status(ftdmchan, &sigstatus);
ftdm_channel_get_alarms(ftdmchan, &alarmflag);
uuid = ftdm_channel_get_uuid(ftdmchan, 0);
if (!zstr(uuid)) {
if (!(session = switch_core_session_locate(uuid))) {
snprintf(sessionid, sizeof(sessionid), "%s (dead)", uuid);
} else {
snprintf(sessionid, sizeof(sessionid), "%s", uuid);
switch_core_session_rwunlock(session);
}
}
stream->write_function(stream,
"span_id: %u\n"
"chan_id: %u\n"
@ -3479,7 +3508,8 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
"aniII: %s\n"
"dnis: %s\n"
"rdnis: %s\n"
"cause: %s\n\n",
"cause: %s\n"
"session: %s\n\n",
span_id,
chan_id,
phspan_id,
@ -3498,7 +3528,8 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
caller_data->aniII,
caller_data->dnis.digits,
caller_data->rdnis.digits,
switch_channel_cause2str(caller_data->hangup_cause));
switch_channel_cause2str(caller_data->hangup_cause),
sessionid);
}
void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream)
@ -3581,6 +3612,8 @@ SWITCH_STANDARD_API(ft_function)
{
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *curr = NULL;
if (!zstr(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
@ -3626,11 +3659,11 @@ SWITCH_STANDARD_API(ft_function)
dump_chan_xml(span, chan_id, stream);
}
} else {
uint32_t j;
uint32_t ccount = ftdm_span_get_chan_count(span);
for (j = 1; j <= ccount; j++) {
dump_chan_xml(span, j, stream);
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
dump_chan_xml(span, ftdm_channel_get_id(ftdm_iterator_current(curr)), stream);
}
ftdm_iterator_free(chaniter);
}
}
@ -3643,15 +3676,20 @@ SWITCH_STANDARD_API(ft_function)
if(chan_id > ftdm_span_get_chan_count(span)) {
stream->write_function(stream, "-ERR invalid channel\n");
} else {
char *dbgstr = NULL;
ftdm_channel_t *fchan = ftdm_span_get_channel(span, chan_id);
dump_chan(span, chan_id, stream);
dbgstr = ftdm_channel_get_history_str(fchan);
stream->write_function(stream, "%s\n", dbgstr);
ftdm_free(dbgstr);
}
} else {
uint32_t j;
uint32_t ccount = ftdm_span_get_chan_count(span);
stream->write_function(stream, "+OK\n");
for (j = 1; j <= ccount; j++) {
dump_chan(span, j, stream);
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
dump_chan(span, ftdm_channel_get_id(ftdm_iterator_current(curr)), stream);
}
ftdm_iterator_free(chaniter);
}
}
@ -3972,7 +4010,7 @@ SWITCH_STANDARD_API(ft_function)
if (rply) {
stream->write_function(stream, "%s", rply);
free(rply);
ftdm_free(rply);
} else {
stream->write_function(stream, "-ERR Usage: %s\n", FT_SYNTAX);
}
@ -4057,8 +4095,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
ftdm_global_set_logger(ftdm_logger);
ftdm_cpu_monitor_disable();
ftdm_global_set_mod_directory(SWITCH_GLOBAL_dirs.mod_dir);
ftdm_global_set_config_directory(SWITCH_GLOBAL_dirs.conf_dir);
if (ftdm_global_init() != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Error loading FreeTDM\n");
return SWITCH_STATUS_TERM;

View File

@ -313,13 +313,6 @@ int main(int argc, char *argv[])
/* set the logging level to use */
ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG);
/* this is optional.
* cpu monitor is a default feature in freetdm that launches 1 thread
* to monitor system-wide CPU usage. If it goes above a predefined threshold
* it will stop accepting calls to try to protect the quality of current calls */
ftdm_cpu_monitor_disable();
/* Initialize the FTDM library */
if (ftdm_global_init() != FTDM_SUCCESS) {
fprintf(stderr, "Error loading FreeTDM\n");

View File

@ -134,8 +134,6 @@ int main(int argc, char *argv[])
ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG);
ftdm_cpu_monitor_disable();
if (ftdm_global_init() != FTDM_SUCCESS) {
fprintf(stderr, "Error loading FreeTDM\n");
exit(-1);

View File

@ -73,8 +73,6 @@ int main(int argc, char *argv[])
ftdm_global_set_default_logger(FTDM_LOG_LEVEL_DEBUG);
ftdm_cpu_monitor_disable();
if (ftdm_global_init() != FTDM_SUCCESS) {
fprintf(stderr, "Error loading FreeTDM\n");
exit(-1);

View File

@ -37,6 +37,27 @@
#include "private/ftdm_core.h"
#ifndef FTDM_MOD_DIR
#define FTDM_MOD_DIR "."
#endif
#define FTDM_MAX_CONF_DIR 512
static char g_ftdm_config_dir[FTDM_MAX_CONF_DIR] = FTDM_CONFIG_DIR;
static char g_ftdm_mod_dir[FTDM_MAX_CONF_DIR] = FTDM_MOD_DIR;
FT_DECLARE(void) ftdm_global_set_mod_directory(const char *path)
{
snprintf(g_ftdm_mod_dir, sizeof(g_ftdm_mod_dir), "%s", path);
ftdm_log(FTDM_LOG_DEBUG, "New mod directory: %s\n", g_ftdm_mod_dir);
}
FT_DECLARE(void) ftdm_global_set_config_directory(const char *path)
{
snprintf(g_ftdm_config_dir, sizeof(g_ftdm_config_dir), "%s", path);
ftdm_log(FTDM_LOG_DEBUG, "New config directory: %s\n", g_ftdm_config_dir);
}
int ftdm_config_open_file(ftdm_config_t *cfg, const char *file_path)
{
FILE *f;
@ -46,7 +67,7 @@ int ftdm_config_open_file(ftdm_config_t *cfg, const char *file_path)
if (file_path[0] == '/') {
path = file_path;
} else {
snprintf(path_buf, sizeof(path_buf), "%s%s%s", FTDM_CONFIG_DIR, FTDM_PATH_SEPARATOR, file_path);
snprintf(path_buf, sizeof(path_buf), "%s%s%s", g_ftdm_config_dir, FTDM_PATH_SEPARATOR, file_path);
path = path_buf;
}
@ -64,7 +85,7 @@ int ftdm_config_open_file(ftdm_config_t *cfg, const char *file_path)
int last = -1;
char *var, *val;
snprintf(path_buf, sizeof(path_buf), "%s%sfreetdm.conf", FTDM_CONFIG_DIR, FTDM_PATH_SEPARATOR);
snprintf(path_buf, sizeof(path_buf), "%s%sfreetdm.conf", g_ftdm_config_dir, FTDM_PATH_SEPARATOR);
path = path_buf;
if ((f = fopen(path, "r")) == 0) {
@ -268,13 +289,24 @@ FT_DECLARE(ftdm_status_t) ftdm_conf_node_create(const char *name, ftdm_conf_node
if (parent) {
/* store who my parent is */
newnode->parent = parent;
/* save any siblings */
sibling = parent->child;
/* as a newborn I am first */
parent->child = newnode;
if (sibling) {
/* store a pointer to my next sibling */
newnode->next = sibling;
/* arrange them in FIFO order (newnode should be last) */
if (!parent->child) {
/* we're the first node being added */
parent->child = newnode;
} else {
if (!parent->last) {
/* we're the second node being added */
parent->last = newnode;
parent->child->next = newnode;
newnode->prev = parent->child;
} else {
/* we're the third or Nth node to be added */
sibling = parent->last;
sibling->next = newnode;
parent->last = newnode;
newnode->prev = sibling;
}
}
}
@ -318,6 +350,26 @@ FT_DECLARE(ftdm_status_t) ftdm_conf_node_destroy(ftdm_conf_node_t *node)
return FTDM_SUCCESS;
}
FT_DECLARE(char *) ftdm_build_dso_path(const char *name, char *path, ftdm_size_t len)
{
#ifdef WIN32
const char *ext = ".dll";
//const char *EXT = ".DLL";
#elif defined (MACOSX) || defined (DARWIN)
const char *ext = ".dylib";
//const char *EXT = ".DYLIB";
#else
const char *ext = ".so";
//const char *EXT = ".SO";
#endif
if (*name == *FTDM_PATH_SEPARATOR) {
snprintf(path, len, "%s%s", name, ext);
} else {
snprintf(path, len, "%s%s%s%s", g_ftdm_mod_dir, FTDM_PATH_SEPARATOR, name, ext);
}
return path;
}
/* For Emacs:
* Local Variables:
* mode:c

View File

@ -50,6 +50,7 @@
#endif
#include "ftdm_cpu_monitor.h"
#define FORCE_HANGUP_TIMER 3000
#define SPAN_PENDING_CHANS_QUEUE_SIZE 1000
#define SPAN_PENDING_SIGNALS_QUEUE_SIZE 1000
#define FTDM_READ_TRACE_INDEX 0
@ -85,6 +86,7 @@ FT_DECLARE(ftdm_time_t) ftdm_current_time_in_ms(void)
}
typedef struct {
uint8_t enabled;
uint8_t running;
uint8_t alarm;
uint32_t interval;
@ -102,6 +104,7 @@ static struct {
ftdm_mutex_t *mutex;
ftdm_mutex_t *span_mutex;
ftdm_mutex_t *group_mutex;
ftdm_sched_t *timingsched;
uint32_t span_index;
uint32_t group_index;
uint32_t running;
@ -110,8 +113,6 @@ static struct {
cpu_monitor_t cpu_monitor;
} globals;
static uint8_t ftdm_cpu_monitor_disabled = 0;
enum ftdm_enum_cpu_alarm_action_flags
{
FTDM_CPU_ALARM_ACTION_WARN = (1 << 0),
@ -243,6 +244,39 @@ static __inline__ void ftdm_std_free(void *pool, void *ptr)
free(ptr);
}
static void ftdm_set_echocancel_call_begin(ftdm_channel_t *chan)
{
ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan);
if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC)) {
if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE)) {
if (caller_data->bearer_capability != FTDM_BEARER_CAP_64K_UNRESTRICTED) {
ftdm_channel_command(chan, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL);
}
} else {
if (caller_data->bearer_capability == FTDM_BEARER_CAP_64K_UNRESTRICTED) {
ftdm_channel_command(chan, FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL);
}
}
}
}
static void ftdm_set_echocancel_call_end(ftdm_channel_t *chan)
{
ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(chan);
if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC)) {
if (ftdm_channel_test_feature(chan, FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE)) {
if (caller_data->bearer_capability != FTDM_BEARER_CAP_64K_UNRESTRICTED) {
ftdm_channel_command(chan, FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL);
}
} else {
if (caller_data->bearer_capability == FTDM_BEARER_CAP_64K_UNRESTRICTED) {
ftdm_channel_command(chan, FTDM_COMMAND_ENABLE_ECHOCANCEL, NULL);
}
}
}
}
FT_DECLARE_DATA ftdm_memory_handler_t g_ftdm_mem_handler =
{
/*.pool =*/ NULL,
@ -463,6 +497,7 @@ static ftdm_status_t ftdm_span_destroy(ftdm_span_t *span)
status = FTDM_FAIL;
}
ftdm_safe_free(span->type);
ftdm_safe_free(span->name);
ftdm_safe_free(span->dtmf_hangup);
}
@ -536,7 +571,7 @@ static void ftdm_span_add(ftdm_span_t *span)
} else {
globals.spans = span;
}
hashtable_insert(globals.span_hash, (void *)span->name, span, HASHTABLE_FLAG_NONE);
hashtable_insert(globals.span_hash, (void *)span->name, span, HASHTABLE_FLAG_FREE_VALUE);
ftdm_mutex_unlock(globals.span_mutex);
}
@ -1249,6 +1284,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *f
case FTDM_CHANNEL_STATE_RING:
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
case FTDM_CHANNEL_STATE_PROGRESS:
case FTDM_CHANNEL_STATE_IDLE:
case FTDM_CHANNEL_STATE_GET_CALLERID:
case FTDM_CHANNEL_STATE_GENRING:
ok = 1;
@ -1290,6 +1326,16 @@ end:
ftdm_log_chan_ex(ftdmchan, file, func, line, FTDM_LOG_LEVEL_DEBUG, "Changed state from %s to %s\n", ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(state));
ftdmchan->last_state = ftdmchan->state;
ftdmchan->state = state;
ftdmchan->history[ftdmchan->hindex].file = file;
ftdmchan->history[ftdmchan->hindex].func = func;
ftdmchan->history[ftdmchan->hindex].line = line;
ftdmchan->history[ftdmchan->hindex].state = ftdmchan->state;
ftdmchan->history[ftdmchan->hindex].last_state = ftdmchan->last_state;
ftdmchan->history[ftdmchan->hindex].time = ftdm_current_time_in_ms();
ftdmchan->hindex++;
if (ftdmchan->hindex == ftdm_array_len(ftdmchan->history)) {
ftdmchan->hindex = 0;
}
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE);
ftdm_mutex_lock(ftdmchan->span->mutex);
@ -1747,7 +1793,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id,
ftdm_channel_t *best_rated = NULL;
ftdm_status_t status = FTDM_FAIL;
int best_rate = 0;
int may_be_available = 0;
*ftdmchan = NULL;
@ -1782,38 +1827,55 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id,
ftdm_mutex_lock(check->mutex);
/* The following if's and gotos replace a big if (this || this || this || this) else { nothing; } */
/* if it is not a voice channel, nothing else to check to open it */
if (!FTDM_IS_VOICE_CHANNEL(check)) {
goto openchan;
}
/* if it's an FXS device with a call active and has callwaiting enabled, we allow to open it twice */
if (check->type == FTDM_CHAN_TYPE_FXS
&& check->token_count == 1
&& ftdm_channel_test_feature(check, FTDM_CHANNEL_FEATURE_CALLWAITING)) {
goto openchan;
}
/* if channel is available, time to open it */
if (chan_is_avail(check)) {
goto openchan;
}
/* not available, but still might be available ... */
calculate_best_rate(check, &best_rated, &best_rate);
if (best_rated) {
may_be_available = 1;
goto openchan;
}
/* the channel is only allowed to be open if not in use, or, for FXS devices with a call with call waiting enabled */
if (
(check->type == FTDM_CHAN_TYPE_FXS
&& check->token_count == 1
&& ftdm_channel_test_feature(check, FTDM_CHANNEL_FEATURE_CALLWAITING))
||
chan_is_avail(check)
||
may_be_available) {
if (!ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) {
status = check->fio->open(check);
if (status == FTDM_SUCCESS) {
ftdm_set_flag(check, FTDM_CHANNEL_OPEN);
}
} else {
status = FTDM_SUCCESS;
/* channel is unavailable, do not open the channel */
goto unlockchan;
openchan:
if (!ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) {
status = check->fio->open(check);
if (status == FTDM_SUCCESS) {
ftdm_set_flag(check, FTDM_CHANNEL_OPEN);
}
ftdm_set_flag(check, FTDM_CHANNEL_INUSE);
ftdm_set_flag(check, FTDM_CHANNEL_OUTBOUND);
*ftdmchan = check;
} else {
status = FTDM_SUCCESS;
}
ftdm_set_flag(check, FTDM_CHANNEL_INUSE);
ftdm_set_flag(check, FTDM_CHANNEL_OUTBOUND);
*ftdmchan = check;
unlockchan:
ftdm_mutex_unlock(check->mutex);
done:
ftdm_mutex_unlock(globals.mutex);
if (status != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Failed to open channel %d:%d\n", span_id, chan_id);
}
return status;
}
@ -1996,11 +2058,17 @@ done:
static ftdm_status_t call_hangup(ftdm_channel_t *chan, const char *file, const char *func, int line)
{
ftdm_set_flag(chan, FTDM_CHANNEL_USER_HANGUP);
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 */
return FTDM_SUCCESS;
}
if (chan->hangup_timer) {
ftdm_sched_cancel_timer(globals.timingsched, chan->hangup_timer);
}
ftdm_channel_set_state(file, func, line, chan, FTDM_CHANNEL_STATE_HANGUP, 1);
} else {
/* the signaling stack did not touch the state,
@ -2158,10 +2226,12 @@ done:
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_place(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
{
ftdm_status_t status = FTDM_FAIL;
ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "null channel");
ftdm_assert_return(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND), FTDM_FAIL, "Call place, but outbound flag not set\n");
ftdm_set_echocancel_call_begin(ftdmchan);
ftdm_channel_lock(ftdmchan);
if (ftdmchan->span->outgoing_call) {
@ -2282,6 +2352,9 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan)
close_dtmf_debug(ftdmchan);
#endif
ftdm_channel_clear_vars(ftdmchan);
if (ftdmchan->hangup_timer) {
ftdm_sched_cancel_timer(globals.timingsched, ftdmchan->hangup_timer);
}
ftdmchan->init_state = FTDM_CHANNEL_STATE_DOWN;
ftdmchan->state = FTDM_CHANNEL_STATE_DOWN;
@ -3524,16 +3597,56 @@ done:
return var;
}
FT_DECLARE(ftdm_iterator_t *) ftdm_channel_get_var_iterator(const ftdm_channel_t *ftdmchan)
static ftdm_iterator_t *get_iterator(ftdm_iterator_type_t type, ftdm_iterator_t *iter)
{
ftdm_hash_iterator_t *iter = NULL;
int allocated = 0;
if (iter) {
if (iter->type != type) {
ftdm_log(FTDM_LOG_ERROR, "Cannot switch iterator types\n");
return NULL;
}
allocated = iter->allocated;
memset(iter, 0, sizeof(*iter));
iter->type = type;
iter->allocated = allocated;
return iter;
}
iter = ftdm_calloc(1, sizeof(*iter));
if (!iter) {
return NULL;
}
iter->type = type;
iter->allocated = 1;
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);
iter = ftdmchan->variable_hash == NULL ? NULL : hashtable_first(ftdmchan->variable_hash);
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))) {
return NULL;
}
iter->pvt.chaniter.index = 1;
iter->pvt.chaniter.span = span;
return iter;
}
@ -3545,11 +3658,9 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_get_current_var(ftdm_iterator_t *iter, co
*var_name = NULL;
*var_val = NULL;
if (!iter) {
return FTDM_FAIL;
}
ftdm_assert_return(iter && (iter->type == FTDM_ITERATOR_VARS) && iter->pvt.hashiter, FTDM_FAIL, "Cannot get variable from invalid iterator!\n");
hashtable_this(iter, &key, NULL, &val);
hashtable_this(iter->pvt.hashiter, &key, NULL, &val);
*var_name = key;
*var_val = val;
@ -3559,16 +3670,175 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_get_current_var(ftdm_iterator_t *iter, co
FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter)
{
if (!iter) {
return NULL;
ftdm_assert_return(iter && iter->type, NULL, "Invalid iterator\n");
switch (iter->type) {
case FTDM_ITERATOR_VARS:
if (!iter->pvt.hashiter) {
return NULL;
}
iter->pvt.hashiter = hashtable_next(iter->pvt.hashiter);
if (!iter->pvt.hashiter) {
return NULL;
}
return iter;
case FTDM_ITERATOR_CHANS:
ftdm_assert_return(iter->pvt.chaniter.index, NULL, "channel iterator index cannot be zero!\n");
if (iter->pvt.chaniter.index == iter->pvt.chaniter.span->chan_count) {
return NULL;
}
iter->pvt.chaniter.index++;
return iter;
default:
break;
}
return hashtable_next(iter);
ftdm_assert_return(0, NULL, "Unknown iterator type\n");
return NULL;
}
FT_DECLARE(void *) ftdm_iterator_current(ftdm_iterator_t *iter)
{
const void *key = NULL;
void *val = NULL;
ftdm_assert_return(iter && iter->type, NULL, "Invalid iterator\n");
switch (iter->type) {
case FTDM_ITERATOR_VARS:
hashtable_this(iter->pvt.hashiter, &key, NULL, &val);
/* I decided to return the key instead of the value since the value can be retrieved using the key */
return (void *)key;
case FTDM_ITERATOR_CHANS:
ftdm_assert_return(iter->pvt.chaniter.index, NULL, "channel iterator index cannot be zero!\n");
ftdm_assert_return(iter->pvt.chaniter.index <= iter->pvt.chaniter.span->chan_count, NULL, "channel iterator index bigger than span chan count!\n");
return iter->pvt.chaniter.span->channels[iter->pvt.chaniter.index];
default:
break;
}
ftdm_assert_return(0, NULL, "Unknown iterator type\n");
return NULL;
}
FT_DECLARE(ftdm_status_t) ftdm_iterator_free(ftdm_iterator_t *iter)
{
/* it's valid to pass a NULL iterator, do not return failure */
if (!iter) {
return FTDM_SUCCESS;
}
if (!iter->allocated) {
memset(iter, 0, sizeof(*iter));
return FTDM_SUCCESS;
}
ftdm_assert_return(iter->type, FTDM_FAIL, "Cannot free invalid iterator\n");
ftdm_safe_free(iter);
return FTDM_SUCCESS;
}
static struct {
ftdm_io_interface_t *pika_interface;
} interfaces;
static void print_channels_by_state(ftdm_stream_handle_t *stream, ftdm_channel_state_t state, int not, int *count)
{
ftdm_hash_iterator_t *i = NULL;
ftdm_span_t *span;
ftdm_channel_t *fchan = NULL;
ftdm_iterator_t *citer = NULL;
ftdm_iterator_t *curr = NULL;
const void *key = NULL;
void *val = NULL;
*count = 0;
ftdm_mutex_lock(globals.mutex);
for (i = hashtable_first(globals.span_hash); i; i = hashtable_next(i)) {
hashtable_this(i, &key, NULL, &val);
if (!key || !val) {
break;
}
span = val;
citer = ftdm_span_get_chan_iterator(span, NULL);
if (!citer) {
continue;
}
for (curr = citer ; curr; curr = ftdm_iterator_next(curr)) {
fchan = ftdm_iterator_current(curr);
if (not && (fchan->state != state)) {
stream->write_function(stream, "[s%dc%d][%d:%d] in state %s\n",
fchan->span_id, fchan->chan_id,
fchan->physical_span_id, fchan->physical_chan_id, ftdm_channel_state2str(fchan->state));
(*count)++;
} else if (!not && (fchan->state == state)) {
stream->write_function(stream, "[s%dc%d][%d:%d] in state %s\n",
fchan->span_id, fchan->chan_id,
fchan->physical_span_id, fchan->physical_chan_id, ftdm_channel_state2str(fchan->state));
(*count)++;
}
}
ftdm_iterator_free(citer);
}
ftdm_mutex_unlock(globals.mutex);
}
static char *handle_core_command(const char *cmd)
{
char *mycmd = NULL;
int argc = 0;
int count = 0;
int not = 0;
char *argv[10] = { 0 };
char *state = NULL;
ftdm_channel_state_t i = FTDM_CHANNEL_STATE_INVALID;
ftdm_stream_handle_t stream = { 0 };
FTDM_STANDARD_STREAM(stream);
if (cmd) {
mycmd = ftdm_strdup(cmd);
argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
} else {
stream.write_function(&stream, "invalid core command\n");
goto done;
}
if (!strcasecmp(argv[0], "state")) {
if (argc < 2) {
stream.write_function(&stream, "core state command requires an argument\n");
goto done;
}
state = argv[1];
if (argv[1][0] == '!') {
not = 1;
state++;
}
for (i = FTDM_CHANNEL_STATE_DOWN; i < FTDM_CHANNEL_STATE_INVALID; i++) {
if (!strcasecmp(state, ftdm_channel_state2str(i))) {
break;
}
}
if (i == FTDM_CHANNEL_STATE_INVALID) {
stream.write_function(&stream, "invalid state %s\n", state);
goto done;
}
print_channels_by_state(&stream, i, not, &count);
stream.write_function(&stream, "\nTotal channels %s %s: %d\n", not ? "not in state" : "in state", ftdm_channel_state2str(i), count);
} else {
stream.write_function(&stream, "invalid core command %s\n", argv[0]);
}
done:
ftdm_safe_free(mycmd);
return stream.data;
}
FT_DECLARE(char *) ftdm_api_execute(const char *cmd)
{
ftdm_io_interface_t *fio = NULL;
@ -3583,6 +3853,10 @@ FT_DECLARE(char *) ftdm_api_execute(const char *cmd)
}
type = dup;
if (!strcasecmp(type, "core")) {
return handle_core_command(cmd);
}
ftdm_mutex_lock(globals.mutex);
if (!(fio = (ftdm_io_interface_t *) hashtable_search(globals.interface_hash, (void *)type))) {
@ -3884,7 +4158,14 @@ static ftdm_status_t load_config(void)
ftdm_log(FTDM_LOG_ERROR, "unknown span variable '%s'\n", var);
}
} else if (!strncasecmp(cfg.category, "general", 7)) {
if (!strncasecmp(var, "cpu_monitoring_interval", sizeof("cpu_monitoring_interval")-1)) {
if (!strncasecmp(var, "cpu_monitor", sizeof("cpu_monitor")-1)) {
if (!strncasecmp(val, "yes", 3)) {
globals.cpu_monitor.enabled = 1;
if (!globals.cpu_monitor.alarm_action_flags) {
globals.cpu_monitor.alarm_action_flags |= FTDM_CPU_ALARM_ACTION_WARN;
}
}
} else if (!strncasecmp(var, "cpu_monitoring_interval", sizeof("cpu_monitoring_interval")-1)) {
if (atoi(val) > 0) {
globals.cpu_monitor.interval = atoi(val);
} else {
@ -3963,27 +4244,6 @@ static ftdm_status_t process_module_config(ftdm_io_interface_t *fio)
return FTDM_SUCCESS;
}
FT_DECLARE(char *) ftdm_build_dso_path(const char *name, char *path, ftdm_size_t len)
{
#ifdef WIN32
const char *ext = ".dll";
//const char *EXT = ".DLL";
#define FTDM_MOD_DIR "." //todo
#elif defined (MACOSX) || defined (DARWIN)
const char *ext = ".dylib";
//const char *EXT = ".DYLIB";
#else
const char *ext = ".so";
//const char *EXT = ".SO";
#endif
if (*name == *FTDM_PATH_SEPARATOR) {
snprintf(path, len, "%s%s", name, ext);
} else {
snprintf(path, len, "%s%s%s%s", FTDM_MOD_DIR, FTDM_PATH_SEPARATOR, name, ext);
}
return path;
}
FT_DECLARE(ftdm_status_t) ftdm_global_add_io_interface(ftdm_io_interface_t *interface1)
{
ftdm_status_t ret = FTDM_SUCCESS;
@ -4499,6 +4759,21 @@ FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span)
return FTDM_SUCCESS;
}
static void execute_safety_hangup(void *data)
{
ftdm_channel_t *fchan = data;
ftdm_channel_lock(fchan);
fchan->hangup_timer = 0;
if (fchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
ftdm_log_chan(fchan, FTDM_LOG_CRIT, "Forcing hangup since the user did not confirmed our hangup after %dms\n", FORCE_HANGUP_TIMER);
call_hangup(fchan, __FILE__, __FUNCTION__, __LINE__);
} else {
ftdm_log_chan(fchan, FTDM_LOG_CRIT, "Not performing safety hangup, channel state is %s\n", ftdm_channel_state2str(fchan->state));
}
ftdm_channel_unlock(fchan);
}
FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t *sigmsg)
{
if (sigmsg->channel) {
@ -4520,11 +4795,15 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t
break;
case FTDM_SIGEVENT_START:
/* 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?
* */
ftdm_clear_flag(sigmsg->channel, FTDM_CHANNEL_HOLD);
{
ftdm_set_echocancel_call_begin(sigmsg->channel);
/* 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?
* */
ftdm_clear_flag(sigmsg->channel, FTDM_CHANNEL_HOLD);
}
break;
case FTDM_SIGEVENT_STOP:
@ -4532,6 +4811,11 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t
ftdm_log_chan_msg(sigmsg->channel, FTDM_LOG_DEBUG, "Ignoring SIGEVENT_STOP since user already requested hangup\n");
goto done;
}
if (sigmsg->channel->state == FTDM_CHANNEL_STATE_TERMINATING) {
ftdm_log_chan_msg(sigmsg->channel, FTDM_LOG_DEBUG, "Scheduling safety hangup timer\n");
/* if the user does not move us to hangup in 2 seconds, we will do it ourselves */
ftdm_sched_timer(globals.timingsched, "safety-hangup", FORCE_HANGUP_TIMER, execute_safety_hangup, sigmsg->channel, &sigmsg->channel->hangup_timer);
}
break;
default:
@ -4630,12 +4914,6 @@ static void ftdm_cpu_monitor_stop(void)
ftdm_interrupt_destroy(&globals.cpu_monitor.interrupt);
}
FT_DECLARE(void) ftdm_cpu_monitor_disable(void)
{
ftdm_cpu_monitor_disabled = 1;
}
FT_DECLARE(ftdm_status_t) ftdm_global_init(void)
{
memset(&globals, 0, sizeof(globals));
@ -4653,6 +4931,14 @@ FT_DECLARE(ftdm_status_t) ftdm_global_init(void)
ftdm_mutex_create(&globals.span_mutex);
ftdm_mutex_create(&globals.group_mutex);
ftdm_sched_global_init();
if (ftdm_sched_create(&globals.timingsched, "freetdm-master") != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "Failed to create master timing schedule context\n");
return FTDM_FAIL;
}
if (ftdm_sched_free_run(globals.timingsched) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "Failed to run master timing schedule context\n");
return FTDM_FAIL;
}
globals.running = 1;
return FTDM_SUCCESS;
}
@ -4669,8 +4955,9 @@ FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void)
ftdm_log(FTDM_LOG_NOTICE, "Modules configured: %d \n", modcount);
globals.cpu_monitor.enabled = 0;
globals.cpu_monitor.interval = 1000;
globals.cpu_monitor.alarm_action_flags = FTDM_CPU_ALARM_ACTION_WARN | FTDM_CPU_ALARM_ACTION_REJECT;
globals.cpu_monitor.alarm_action_flags = 0;
globals.cpu_monitor.set_alarm_threshold = 80;
globals.cpu_monitor.reset_alarm_threshold = 70;
@ -4680,7 +4967,12 @@ FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void)
return FTDM_FAIL;
}
if (!ftdm_cpu_monitor_disabled) {
if (globals.cpu_monitor.enabled) {
ftdm_log(FTDM_LOG_INFO, "CPU Monitor is running interval:%d lo-thres:%d hi-thres:%d\n",
globals.cpu_monitor.interval,
globals.cpu_monitor.set_alarm_threshold,
globals.cpu_monitor.reset_alarm_threshold);
if (ftdm_cpu_monitor_start() != FTDM_SUCCESS) {
return FTDM_FAIL;
}
@ -4699,14 +4991,19 @@ FT_DECLARE(uint32_t) ftdm_running(void)
FT_DECLARE(ftdm_status_t) ftdm_global_destroy(void)
{
ftdm_span_t *sp;
uint32_t sanity = 100;
time_end();
/* many freetdm event loops rely on this variable to decide when to stop, do this first */
globals.running = 0;
/* stop the scheduling thread */
ftdm_free_sched_stop();
/* stop the cpu monitor thread */
ftdm_cpu_monitor_stop();
/* now destroy channels and spans */
globals.span_index = 0;
ftdm_span_close_all();
@ -4731,24 +5028,20 @@ FT_DECLARE(ftdm_status_t) ftdm_global_destroy(void)
globals.spans = NULL;
ftdm_mutex_unlock(globals.span_mutex);
/* destroy signaling and io modules */
ftdm_unload_modules();
while (ftdm_free_sched_running() && --sanity) {
ftdm_log(FTDM_LOG_DEBUG, "Waiting for schedule thread to finish\n");
ftdm_sleep(100);
}
if (!sanity) {
ftdm_log(FTDM_LOG_CRIT, "schedule thread did not stop running, we may crash on shutdown\n");
}
/* finally destroy the globals */
ftdm_mutex_lock(globals.mutex);
ftdm_sched_destroy(&globals.timingsched);
hashtable_destroy(globals.interface_hash);
hashtable_destroy(globals.module_hash);
hashtable_destroy(globals.module_hash);
hashtable_destroy(globals.span_hash);
hashtable_destroy(globals.group_hash);
ftdm_mutex_unlock(globals.mutex);
ftdm_mutex_destroy(&globals.mutex);
ftdm_mutex_destroy(&globals.span_mutex);
ftdm_mutex_destroy(&globals.group_mutex);
memset(&globals, 0, sizeof(globals));
return FTDM_SUCCESS;
@ -5071,6 +5364,42 @@ FT_DECLARE(char *) ftdm_strndup(const char *str, ftdm_size_t inlen)
return new;
}
FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *fchan)
{
char func[255];
char line[255];
char states[255];
uint8_t i = 0;
ftdm_stream_handle_t stream = { 0 };
FTDM_STANDARD_STREAM(stream);
if (!fchan->history[0].file) {
stream.write_function(&stream, "-- No state history --\n");
return stream.data;
}
stream.write_function(&stream, "%-30.30s %-30.30s %s", "-- States --", "-- Function --", "-- Location --\n");
for (i = fchan->hindex; i < ftdm_array_len(fchan->history); i++) {
if (!fchan->history[i].file) {
break;
}
snprintf(states, sizeof(states), "%-5.15s => %-5.15s", ftdm_channel_state2str(fchan->history[i].last_state), ftdm_channel_state2str(fchan->history[i].state));
snprintf(func, sizeof(func), "[%s]", fchan->history[i].func);
snprintf(line, sizeof(func), "[%s:%d]", fchan->history[i].file, fchan->history[i].line);
stream.write_function(&stream, "%-30.30s %-30.30s %s\n", states, func, line);
}
for (i = 0; i < fchan->hindex; i++) {
snprintf(states, sizeof(states), "%-5.15s => %-5.15s", ftdm_channel_state2str(fchan->history[i].last_state), ftdm_channel_state2str(fchan->history[i].state));
snprintf(func, sizeof(func), "[%s]", fchan->history[i].func);
snprintf(line, sizeof(func), "[%s:%d]", fchan->history[i].file, fchan->history[i].line);
stream.write_function(&stream, "%-30.30s %-30.30s %s\n", states, func, line);
}
return stream.data;
}
/* For Emacs:
* Local Variables:

View File

@ -34,6 +34,8 @@
#include "private/ftdm_core.h"
typedef struct ftdm_timer ftdm_timer_t;
static struct {
ftdm_sched_t *freeruns;
ftdm_mutex_t *mutex;
@ -42,6 +44,7 @@ static struct {
struct ftdm_sched {
char name[80];
ftdm_timer_id_t currid;
ftdm_mutex_t *mutex;
ftdm_timer_t *timers;
int freerun;
@ -51,6 +54,7 @@ struct ftdm_sched {
struct ftdm_timer {
char name[80];
ftdm_timer_id_t id;
#ifdef __linux__
struct timeval time;
#endif
@ -172,6 +176,24 @@ FT_DECLARE(ftdm_bool_t) ftdm_free_sched_running(void)
return sched_globals.running;
}
FT_DECLARE(ftdm_bool_t) ftdm_free_sched_stop(void)
{
/* currently we really dont stop the thread here, we rely on freetdm being shutdown and ftdm_running() to be false
* so the scheduling thread dies and we just wait for it here */
uint32_t sanity = 100;
while (ftdm_free_sched_running() && --sanity) {
ftdm_log(FTDM_LOG_DEBUG, "Waiting for main schedule thread to finish\n");
ftdm_sleep(100);
}
if (!sanity) {
ftdm_log(FTDM_LOG_CRIT, "schedule thread did not stop running, we may crash on shutdown\n");
return FTDM_FALSE;
}
return FTDM_TRUE;
}
FT_DECLARE(ftdm_status_t) ftdm_sched_create(ftdm_sched_t **sched, const char *name)
{
ftdm_sched_t *newsched = NULL;
@ -191,6 +213,7 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_create(ftdm_sched_t **sched, const char *na
}
ftdm_set_string(newsched->name, name);
newsched->currid = 1;
*sched = newsched;
ftdm_log(FTDM_LOG_DEBUG, "Created schedule %s\n", name);
@ -219,12 +242,13 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_run(ftdm_sched_t *sched)
int rc = -1;
void *data;
struct timeval now;
ftdm_assert_return(sched != NULL, FTDM_EINVAL, "sched is null!\n");
ftdm_mutex_lock(sched->mutex);
tryagain:
ftdm_mutex_lock(sched->mutex);
rc = gettimeofday(&now, NULL);
if (rc == -1) {
ftdm_log(FTDM_LOG_ERROR, "Failed to retrieve time of day\n");
@ -257,11 +281,16 @@ tryagain:
runtimer->prev->next = runtimer->next;
}
runtimer->id = 0;
ftdm_safe_free(runtimer);
/* avoid deadlocks by releasing the sched lock before triggering callbacks */
ftdm_mutex_unlock(sched->mutex);
callback(data);
/* after calling a callback we must start the scanning again since the
* callback may have added or cancelled timers to the linked list */
* callback or some other thread may have added or cancelled timers to
* the linked list */
goto tryagain;
}
}
@ -283,7 +312,7 @@ done:
}
FT_DECLARE(ftdm_status_t) ftdm_sched_timer(ftdm_sched_t *sched, const char *name,
int ms, ftdm_sched_callback_t callback, void *data, ftdm_timer_t **timer)
int ms, ftdm_sched_callback_t callback, void *data, ftdm_timer_id_t *timerid)
{
ftdm_status_t status = FTDM_FAIL;
#ifdef __linux__
@ -296,8 +325,8 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_timer(ftdm_sched_t *sched, const char *name
ftdm_assert_return(callback != NULL, FTDM_EINVAL, "sched callback is null!\n");
ftdm_assert_return(ms > 0, FTDM_EINVAL, "milliseconds must be bigger than 0!\n");
if (timer) {
*timer = NULL;
if (timerid) {
*timerid = 0;
}
rc = gettimeofday(&now, NULL);
@ -312,6 +341,15 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_timer(ftdm_sched_t *sched, const char *name
if (!newtimer) {
goto done;
}
newtimer->id = sched->currid;
sched->currid++;
if (!sched->currid) {
ftdm_log(FTDM_LOG_NOTICE, "Timer id wrap around for sched %s\n", sched->name);
/* we do not want currid to be zero since is an invalid id
* TODO: check that currid does not exists already in the context, it'd be insane
* though, having a timer to live all that time */
sched->currid++;
}
ftdm_set_string(newtimer->name, name);
newtimer->callback = callback;
@ -332,9 +370,10 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_timer(ftdm_sched_t *sched, const char *name
sched->timers = newtimer;
}
if (timer) {
*timer = newtimer;
if (timerid) {
*timerid = newtimer->id;
}
status = FTDM_SUCCESS;
done:
@ -349,7 +388,7 @@ done:
UNREFERENCED_PARAMETER(ms);
UNREFERENCED_PARAMETER(callback);
UNREFERENCED_PARAMETER(data);
UNREFERENCED_PARAMETER(timer);
UNREFERENCED_PARAMETER(timerid);
#endif
return status;
}
@ -418,53 +457,37 @@ done:
return status;
}
FT_DECLARE(ftdm_status_t) ftdm_sched_cancel_timer(ftdm_sched_t *sched, ftdm_timer_t **intimer)
FT_DECLARE(ftdm_status_t) ftdm_sched_cancel_timer(ftdm_sched_t *sched, ftdm_timer_id_t timerid)
{
ftdm_status_t status = FTDM_FAIL;
ftdm_timer_t *timer;
ftdm_assert_return(sched != NULL, FTDM_EINVAL, "sched is null!\n");
ftdm_assert_return(intimer != NULL, FTDM_EINVAL, "timer is null!\n");
ftdm_assert_return(*intimer != NULL, FTDM_EINVAL, "timer is null!\n");
if (!timerid) {
return FTDM_SUCCESS;
}
ftdm_mutex_lock(sched->mutex);
/* special case where the cancelled timer is the head */
if (*intimer == sched->timers) {
timer = *intimer;
/* the timer next is the new head (even if that means the new head will be NULL)*/
sched->timers = timer->next;
/* if there is a new head, clean its prev member */
if (sched->timers) {
sched->timers->prev = NULL;
}
/* free the old head */
ftdm_safe_free(timer);
status = FTDM_SUCCESS;
*intimer = NULL;
goto done;
}
/* look for the timer and destroy it (we know now that is not head, se we start at the next member after head) */
for (timer = sched->timers->next; timer; timer = timer->next) {
if (timer == *intimer) {
/* look for the timer and destroy it */
for (timer = sched->timers; timer; timer = timer->next) {
if (timer->id == timerid) {
if (timer == sched->timers) {
/* it's the head timer, put a new head */
sched->timers = timer->next;
}
if (timer->prev) {
timer->prev->next = timer->next;
}
if (timer->next) {
timer->next->prev = timer->prev;
}
ftdm_log(FTDM_LOG_DEBUG, "cancelled timer %s\n", timer->name);
ftdm_safe_free(timer);
status = FTDM_SUCCESS;
*intimer = NULL;
break;
}
}
done:
if (status == FTDM_FAIL) {
ftdm_log(FTDM_LOG_ERROR, "Could not find timer %s to cancel it\n", (*intimer)->name);
}
ftdm_mutex_unlock(sched->mutex);

View File

@ -1087,10 +1087,17 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj)
got_d = 1;
x++;
break;
} else {
ftdm_log(FTDM_LOG_ERROR, "failed to open d-channel #%d %d:%d\n", x, span->channels[i]->span_id, span->channels[i]->chan_id);
}
}
}
}
if (!got_d) {
ftdm_log(FTDM_LOG_ERROR, "Failed to get a D-channel in span %d\n", span->span_id);
break;
}
if (lpwrap_init_pri(&isdn_data->spri,
@ -1133,7 +1140,9 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj)
}
ftdm_log(FTDM_LOG_CRIT, "PRI down on span %d\n", isdn_data->spri.span->span_id);
isdn_data->spri.dchan->state = FTDM_CHANNEL_STATE_DOWN;
if (isdn_data->spri.dchan) {
isdn_data->spri.dchan->state = FTDM_CHANNEL_STATE_DOWN;
}
if (!down) {
ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART);
@ -1147,7 +1156,7 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj)
ftdm_sleep(5000);
}
ftdm_log(FTDM_LOG_DEBUG, "PRI thread ended on span %d\n", isdn_data->spri.span->span_id);
ftdm_log(FTDM_LOG_DEBUG, "PRI thread ended on span %d\n", span->span_id);
ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD);
ftdm_clear_flag(isdn_data, FTMOD_LIBPRI_RUNNING);

View File

@ -177,7 +177,7 @@ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *
spri->dchan = dchan;
spri->span = span;
if ((spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))){
if (spri->dchan && (spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))){
unsigned char buf[4] = { 0 };
size_t buflen = sizeof(buf), len = 0;
pri_set_debug(spri->pri, debug);

View File

@ -189,7 +189,8 @@ ftdm_state_map_t sangoma_isdn_state_map = {
ZSD_OUTBOUND,
ZSM_UNACCEPTABLE,
{FTDM_CHANNEL_STATE_DIALING, FTDM_END},
{FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_DOWN, FTDM_END}
{FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS,
FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_DOWN, FTDM_END}
},
{
ZSD_OUTBOUND,
@ -471,10 +472,7 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan)
case FTDM_CHANNEL_STATE_RING: /* incoming call request */
{
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending incoming call from %s to %s to FTDM core\n", ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.dnis.digits);
ftdm_channel_add_var(ftdmchan, "isdn_specific_var", "1");
ftdm_channel_add_var(ftdmchan, "isdn_crap", "morecrap");
ftdm_channel_add_var(ftdmchan, "isdn_stuff", "s");
ftdm_channel_add_var(ftdmchan, "isdn_d", "asdsadasdasdsad");
/* we have enough information to inform FTDM of the call*/
sigev.event_id = FTDM_SIGEVENT_START;
ftdm_span_send_signal(ftdmchan->span, &sigev);
@ -558,6 +556,9 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan)
/* We are hangup local call because there was a glare, we are waiting for a
RELEASE on this call, before we can process the saved call */
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Waiting for RELEASE on hungup glared call\n");
} else if (sngisdn_test_flag(sngisdn_info, FLAG_SEND_DISC)) {
/* Remote side sent a PROGRESS message, but cause indicates disconnect or T310 expired*/
sngisdn_snd_disconnect(ftdmchan);
} else {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Hanging up call upon local request!\n");
@ -568,16 +569,15 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan)
if (ftdmchan->last_state == FTDM_CHANNEL_STATE_RING ||
ftdmchan->last_state == FTDM_CHANNEL_STATE_DIALING) {
sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT);
sngisdn_snd_release(ftdmchan, 0);
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) {
sng_isdn_set_avail_rate(ftdmchan->span, SNGISDN_AVAIL_DOWN);
}
sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT);
sngisdn_snd_release(ftdmchan, 0);
} else {
sngisdn_snd_disconnect(ftdmchan);
}
}
/* now go to the HANGUP complete state */
@ -691,7 +691,7 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_isdn_outgoing_call)
return status;
}
static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_sig_status)
static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_chan_sig_status)
{
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) {
*status = FTDM_SIG_STATE_UP;
@ -702,17 +702,34 @@ static FIO_CHANNEL_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_sig_status)
return FTDM_SUCCESS;
}
static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_set_sig_status)
static FIO_CHANNEL_SET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_set_chan_sig_status)
{
ftdm_log(FTDM_LOG_ERROR,"Cannot set channel status in this module\n");
return FTDM_NOTIMPL;
}
static FIO_SPAN_GET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_get_span_sig_status)
{
if (ftdm_test_flag(span->channels[1], FTDM_CHANNEL_SIG_UP)) {
*status = FTDM_SIG_STATE_UP;
} else {
*status = FTDM_SIG_STATE_DOWN;
}
return FTDM_SUCCESS;
}
static FIO_SPAN_SET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_set_span_sig_status)
{
ftdm_log(FTDM_LOG_ERROR,"Cannot set span status in this module\n");
return FTDM_NOTIMPL;
}
static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span)
{
ftdm_log(FTDM_LOG_INFO,"Starting span %s:%u.\n",span->name,span->span_id);
if (sng_isdn_stack_activate(span) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "Failed to activate span %s\n", span->name);
if (sng_isdn_stack_start(span) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "Failed to start span %s\n", span->name);
return FTDM_FAIL;
}
/* clear the monitor thread stop flag */
@ -731,7 +748,8 @@ static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span)
static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span)
{
unsigned i;
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *curr = NULL;
ftdm_log(FTDM_LOG_INFO, "Stopping span %s\n", span->name);
/* throw the STOP_THREAD flag to signal monitor thread stop */
@ -743,11 +761,19 @@ static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span)
ftdm_sleep(10);
}
/* FIXME: deconfigure any links, attached to this span */
/* TODO: Use Moy's channel Iterator when its implemented */
for (i=1;i<=span->chan_count;i++) {
ftdm_safe_free(span->channels[i]->call_data);
if (sng_isdn_stack_stop(span) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "Failed to stop span %s\n", span->name);
}
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
ftdm_safe_free(((ftdm_channel_t*)ftdm_iterator_current(curr))->call_data);
((ftdm_channel_t*)ftdm_iterator_current(curr))->call_data = NULL;
}
ftdm_iterator_free(chaniter);
ftdm_sched_destroy(&((sngisdn_span_data_t*)span->signal_data)->sched);
ftdm_queue_destroy(&((sngisdn_span_data_t*)span->signal_data)->event_queue);
ftdm_safe_free(span->signal_data);
ftdm_log(FTDM_LOG_DEBUG, "Finished stopping span %s\n", span->name);
@ -757,6 +783,9 @@ static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span)
static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config)
{
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *curr = NULL;
sngisdn_span_data_t *span_data;
ftdm_log(FTDM_LOG_INFO, "Configuring ftmod_sangoma_isdn span = %s\n", span->name);
@ -764,13 +793,15 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config)
span_data = ftdm_calloc(1, sizeof(sngisdn_span_data_t));
span_data->ftdm_span = span;
span->signal_data = span_data;
unsigned i;
for (i=1;i <= span->chan_count; i++) {
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
sngisdn_chan_data_t *chan_data = ftdm_calloc(1, sizeof(sngisdn_chan_data_t));
chan_data->ftdmchan = span->channels[i];
span->channels[i]->call_data = chan_data;
chan_data->ftdmchan = ((ftdm_channel_t*)ftdm_iterator_current(curr));
((ftdm_channel_t*)ftdm_iterator_current(curr))->call_data = chan_data;
}
ftdm_iterator_free(chaniter);
if (ftmod_isdn_parse_cfg(ftdm_parameters, span) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Failed to parse configuration\n");
@ -789,8 +820,10 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config)
span->outgoing_call = ftdm_sangoma_isdn_outgoing_call;
span->channel_request = NULL;
span->signal_cb = sig_cb;
span->get_channel_sig_status = ftdm_sangoma_isdn_get_sig_status;
span->set_channel_sig_status = ftdm_sangoma_isdn_set_sig_status;
span->get_channel_sig_status = ftdm_sangoma_isdn_get_chan_sig_status;
span->set_channel_sig_status = ftdm_sangoma_isdn_set_chan_sig_status;
span->get_span_sig_status = ftdm_sangoma_isdn_get_span_sig_status;
span->set_span_sig_status = ftdm_sangoma_isdn_set_span_sig_status;
span->state_map = &sangoma_isdn_state_map;
ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE);
ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE);
@ -852,7 +885,7 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_isdn_init)
for(i=1;i<=MAX_VARIANTS;i++) {
ftdm_mutex_create(&g_sngisdn_data.ccs[i].mutex);
}
/* initalize sng_isdn library */
sng_isdn_init(&g_sngisdn_event_interface);
return FTDM_SUCCESS;
@ -920,16 +953,35 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api)
if (!strcasecmp(argv[0], "l1_stats")) {
ftdm_span_t *span;
if (argc < 2) {
ftdm_log(FTDM_LOG_ERROR, "Usage: ftdm sangoma_isdn l1_stats <span name>\n");
stream->write_function(stream, "Usage: ftdm sangoma_isdn l1_stats <span name>\n");
status = FTDM_FAIL;
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[2]);
stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]);
/* Return SUCCESS because we do not want to print the general FTDM usage list */
status = FTDM_SUCCESS;
goto done;
}
/* TODO: implement PHY stats */
sngisdn_print_phy_stats(stream, span);
}
if (!strcasecmp(argv[0], "show_spans")) {
ftdm_span_t *span = NULL;
if (argc == 2) {
status = ftdm_span_find_by_name(argv[1], &span);
if (FTDM_SUCCESS != status) {
stream->write_function(stream, "-ERR failed to find span with name %s\n", argv[1]);
/* Return SUCCESS because we do not want to print the general FTDM usage list */
status = FTDM_SUCCESS;
goto done;
}
sngisdn_print_span(stream, span);
status = FTDM_SUCCESS;
goto done;
}
sngisdn_print_spans(stream);
}
if (!strcasecmp(argv[0], "check_ids")) {
sngisdn_check_free_ids();

View File

@ -68,6 +68,7 @@ typedef enum {
FLAG_GLARE = (1 << 6),
FLAG_DELAYED_REL = (1 << 7),
FLAG_SENT_PROCEED = (1 << 8),
FLAG_SEND_DISC = (1 << 9),
} sngisdn_flag_t;
@ -127,6 +128,13 @@ typedef enum {
SNGISDN_EVENT_RST_IND,
} ftdm_sngisdn_event_id_t;
/* Only timers that can be cancelled are listed here */
#define SNGISDN_NUM_TIMERS 1
/* Increase NUM_TIMERS as number of ftdm_sngisdn_timer_t increases */
typedef enum {
SNGISDN_TIMER_FACILITY = 0,
} ftdm_sngisdn_timer_t;
typedef struct sngisdn_glare_data {
int16_t suId;
uint32_t suInstId;
@ -148,6 +156,7 @@ typedef struct sngisdn_chan_data {
uint8_t globalFlg;
sngisdn_glare_data_t glare;
ftdm_timer_id_t timers[SNGISDN_NUM_TIMERS];
} sngisdn_chan_data_t;
/* Span specific data */
@ -165,6 +174,7 @@ typedef struct sngisdn_span_data {
uint8_t overlap_dial;
uint8_t setup_arb;
uint8_t facility;
int8_t facility_timeout;
ftdm_sched_t *sched;
ftdm_queue_t *event_queue;
} sngisdn_span_data_t;
@ -223,8 +233,8 @@ typedef struct sngisdn_cc {
ftdm_trunk_type_t trunktype;
uint32_t last_suInstId;
ftdm_mutex_t *mutex;
sngisdn_chan_data_t *active_spInstIds[MAX_INSTID];
sngisdn_chan_data_t *active_suInstIds[MAX_INSTID];
sngisdn_chan_data_t *active_spInstIds[MAX_INSTID+1];
sngisdn_chan_data_t *active_suInstIds[MAX_INSTID+1];
}sngisdn_cc_t;
/* Global sngisdn data */
@ -233,7 +243,8 @@ typedef struct ftdm_sngisdn_data {
uint8_t num_cc; /* 1 ent per switchtype */
struct sngisdn_cc ccs[MAX_VARIANTS+1];
uint8_t num_dchan;
sngisdn_dchan_data_t dchans[MAX_L1_LINKS+1];
sngisdn_dchan_data_t dchans[MAX_L1_LINKS+1];
sngisdn_span_data_t *spans[MAX_L1_LINKS+1]; /* spans are indexed by link_id */
}ftdm_sngisdn_data_t;
@ -349,12 +360,16 @@ void sngisdn_set_span_sig_status(ftdm_span_t *ftdmspan, ftdm_signaling_status_t
void sngisdn_delayed_release(void* p_sngisdn_info);
void sngisdn_delayed_connect(void* p_sngisdn_info);
void sngisdn_delayed_disconnect(void* p_sngisdn_info);
void sngisdn_facility_timeout(void* p_sngisdn_info);
/* Stack management functions */
ftdm_status_t sng_isdn_stack_cfg(ftdm_span_t *span);
ftdm_status_t sng_isdn_stack_activate(ftdm_span_t *span);
ftdm_status_t sng_isdn_stack_start(ftdm_span_t *span);
ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span);
void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span);
void sngisdn_print_spans(ftdm_stream_handle_t *stream);
void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span);
#endif /* __FTMOD_SNG_ISDN_H__ */

View File

@ -62,7 +62,8 @@ ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span)
}
break;
case FTDM_TRUNK_E1:
if (!strcasecmp(switch_name, "euroisdn") || strcasecmp(switch_name, "etsi")) {
if (!strcasecmp(switch_name, "euroisdn") ||
!strcasecmp(switch_name, "etsi")) {
signal_data->switchtype = SNGISDN_SWITCH_EUROISDN;
} else if (!strcasecmp(switch_name, "qsig")) {
signal_data->switchtype = SNGISDN_SWITCH_QSIG;
@ -116,6 +117,8 @@ ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span)
signal_data->span_id = dchan_data->num_spans;
dchan_data->spans[signal_data->span_id] = signal_data;
g_sngisdn_data.spans[signal_data->link_id] = signal_data;
ftdm_log(FTDM_LOG_DEBUG, "%s: cc_id:%d dchan_id:%d span_id:%d\n", span->name, signal_data->cc_id, signal_data->dchan_id, signal_data->span_id);
@ -163,6 +166,7 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
signal_data->overlap_dial = SNGISDN_OPT_DEFAULT;
signal_data->setup_arb = SNGISDN_OPT_DEFAULT;
signal_data->link_id = span->span_id;
span->default_caller_data.bearer_capability = IN_ITC_SPEECH;
/* Cannot set default bearer_layer1 yet, as we do not know the switchtype */
@ -249,11 +253,16 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_
ftdm_span_set_bearer_capability(val, &span->default_caller_data.bearer_capability);
} else if (!strcasecmp(var, "outbound-bearer_layer1")) {
ftdm_span_set_bearer_layer1(val, &span->default_caller_data.bearer_layer1);
} else if (!strcasecmp(var, "facility-timeout")) {
signal_data->facility_timeout = atoi(val);
if (signal_data->facility_timeout < 0) {
signal_data->facility_timeout = 0;
}
} else {
ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var);
}
}
signal_data->link_id = span->span_id;
if (signal_data->switchtype == SNGISDN_SWITCH_INVALID) {
ftdm_log(FTDM_LOG_ERROR, "%s: switchtype not specified", span->name);
return FTDM_FAIL;

View File

@ -35,7 +35,6 @@
#include "ftmod_sangoma_isdn.h"
void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status);
void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
@ -53,23 +52,21 @@ void sngisdn_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status
return;
}
void sngisdn_set_span_sig_status(ftdm_span_t *span, ftdm_signaling_status_t status)
{
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *curr = NULL;
void sngisdn_set_span_sig_status(ftdm_span_t *ftdmspan, ftdm_signaling_status_t status)
{
unsigned i;
/* TODO: use channel iterator once it is implemented */
for (i=1;i<=ftdmspan->chan_count;i++) {
sngisdn_set_chan_sig_status(ftdmspan->channels[i], status);
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
sngisdn_set_chan_sig_status(((ftdm_channel_t*)ftdm_iterator_current(curr)), status);
}
ftdm_iterator_free(chaniter);
return;
}
/* For Emacs:
* Local Variables:
* mode:c

View File

@ -193,10 +193,12 @@ ftdm_status_t sng_isdn_stack_cfg_phy_gen(void)
ftdm_status_t sng_isdn_stack_cfg_phy_psap(ftdm_span_t *span)
{
/*local variables*/
L1Mngmt cfg; /*configuration structure*/
Pst pst; /*post structure*/
ftdm_iterator_t *chaniter;
ftdm_iterator_t *curr;
L1Mngmt cfg;
Pst pst;
S32 d_channel_fd = -1;
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data;
/* initalize the post structure */
@ -219,20 +221,35 @@ ftdm_status_t sng_isdn_stack_cfg_phy_psap(ftdm_span_t *span)
cfg.hdr.elmId.elmntInst1 = signal_data->link_id;
cfg.t.cfg.s.l1PSAP.span = span->channels[1]->physical_span_id;
/* Find the d-channel */
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr);
if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) {
d_channel_fd = ftdmchan->sockfd;
break;
}
}
ftdm_iterator_free(chaniter);
if(d_channel_fd < 0) {
ftdm_log(FTDM_LOG_ERROR, "%s:No d-channels specified\n", span->name);
return FTDM_FAIL;
}
cfg.t.cfg.s.l1PSAP.sockfd = d_channel_fd;
switch(span->trunk_type) {
case FTDM_TRUNK_E1:
cfg.t.cfg.s.l1PSAP.chan = 16;
cfg.t.cfg.s.l1PSAP.type = SNG_L1_TYPE_PRI;
break;
case FTDM_TRUNK_T1:
case FTDM_TRUNK_J1:
cfg.t.cfg.s.l1PSAP.chan = 24;
cfg.t.cfg.s.l1PSAP.type = SNG_L1_TYPE_PRI;
break;
case FTDM_TRUNK_BRI:
case FTDM_TRUNK_BRI_PTMP:
cfg.t.cfg.s.l1PSAP.chan = 3;
cfg.t.cfg.s.l1PSAP.type = SNG_L1_TYPE_BRI;
break;
default:
@ -608,9 +625,10 @@ ftdm_status_t sng_isdn_stack_cfg_q931_dlsap(ftdm_span_t *span)
cfg.hdr.entId.ent = ENTIN;
cfg.hdr.entId.inst = S_INST;
cfg.hdr.elmId.elmnt = STDLSAP;
cfg.hdr.response.selector=0;
cfg.t.cfg.s.inDLSAP.sapId = signal_data->link_id;
cfg.t.cfg.s.inDLSAP.spId = signal_data->link_id;
cfg.t.cfg.s.inDLSAP.swtch = sng_isdn_stack_switchtype(signal_data->switchtype);
@ -656,8 +674,7 @@ ftdm_status_t sng_isdn_stack_cfg_q931_dlsap(ftdm_span_t *span)
cfg.t.cfg.s.inDLSAP.ctldInt[1] = 1;
}
cfg.t.cfg.s.inDLSAP.numRstInd = 255;
cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;
cfg.t.cfg.s.inDLSAP.numRstInd = 255;
cfg.t.cfg.s.inDLSAP.relOpt = TRUE;
#ifdef ISDN_SRV
cfg.t.cfg.s.inDLSAP.bcas = FALSE;
@ -666,16 +683,19 @@ ftdm_status_t sng_isdn_stack_cfg_q931_dlsap(ftdm_span_t *span)
#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 (span->trunk_type == FTDM_TRUNK_BRI ||
span->trunk_type == FTDM_TRUNK_BRI_PTMP) {
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;

View File

@ -38,8 +38,8 @@
void stack_resp_hdr_init(Header *hdr);
ftdm_status_t sng_isdn_activate_phy(ftdm_span_t *span);
ftdm_status_t sng_isdn_activate_q921(ftdm_span_t *span);
ftdm_status_t sng_isdn_activate_q931(ftdm_span_t *span);
ftdm_status_t sng_isdn_deactivate_phy(ftdm_span_t *span);
ftdm_status_t sng_isdn_activate_cc(ftdm_span_t *span);
ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt);
@ -52,14 +52,23 @@ extern ftdm_sngisdn_data_t g_sngisdn_data;
ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span);
ftdm_status_t sng_isdn_stack_activate(ftdm_span_t *span)
ftdm_status_t sng_isdn_stack_start(ftdm_span_t *span)
{
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data;
if (sng_isdn_activate_q921(span) != FTDM_SUCCESS) {
if (sng_isdn_cntrl_q921(span, ABND_ENA, NOTUSED) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q921\n", span->name);
return FTDM_FAIL;
}
/* Try to find an alternative for this */
/* LAPD will call LdUiDatBndCfm before it received a LdLiMacBndCfm from L1,
so we need to give some time before activating q931, as q931 will send a
LdUiDatConReq when activated, and this requires the Mac SAP to be already
bound first */
ftdm_sleep(500);
ftdm_log(FTDM_LOG_DEBUG, "%s:Stack q921 activated\n", span->name);
if (!g_sngisdn_data.ccs[signal_data->cc_id].activation_done) {
g_sngisdn_data.ccs[signal_data->cc_id].activation_done = 1;
@ -70,7 +79,8 @@ ftdm_status_t sng_isdn_stack_activate(ftdm_span_t *span)
ftdm_log(FTDM_LOG_DEBUG, "%s:Stack CC activated\n", span->name);
}
if (sng_isdn_activate_q931(span) != FTDM_SUCCESS) {
if (sng_isdn_cntrl_q931(span, ABND_ENA, SAELMNT) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q931\n", span->name);
return FTDM_FAIL;
}
@ -80,50 +90,72 @@ ftdm_status_t sng_isdn_stack_activate(ftdm_span_t *span)
return FTDM_SUCCESS;
}
ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span)
ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span)
{
/* Stop L1 first, so we do not receive any more frames */
if (sng_isdn_deactivate_phy(span) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack phy\n", span->name);
return FTDM_FAIL;
}
if (sng_isdn_cntrl_q931(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack q931\n", span->name);
return FTDM_FAIL;
}
if (sng_isdn_cntrl_q921(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack q921\n", span->name);
return FTDM_FAIL;
}
ftdm_log(FTDM_LOG_INFO, "%s:Signalling stopped\n", span->name);
return FTDM_SUCCESS;
}
ftdm_status_t sng_isdn_activate_phy(ftdm_span_t *span)
{
/* There is no need to start phy, as it will Q921 will send a activate request to phy when it starts */
return FTDM_SUCCESS;
}
ftdm_status_t sng_isdn_deactivate_phy(ftdm_span_t *span)
{
L1Mngmt cntrl;
Pst pst;
Pst pst;
ftdm_log(FTDM_LOG_ERROR, "%s:PHY control not implemented\n", span->name);
return FTDM_SUCCESS;
/* TODO: phy cntrl not implemented yet */
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data;
sng_isdn_phy_cntrl(&pst, &cntrl);
/* initalize the post structure */
stack_pst_init(&pst);
/* insert the destination Entity */
pst.dstEnt = ENTL1;
/* initalize the control structure */
memset(&cntrl, 0, sizeof(cntrl));
/* initalize the control header */
stack_hdr_init(&cntrl.hdr);
cntrl.hdr.msgType = TCNTRL; /* configuration */
cntrl.hdr.entId.ent = ENTL1; /* entity */
cntrl.hdr.entId.inst = S_INST; /* instance */
cntrl.hdr.elmId.elmnt = STTSAP; /* SAP Specific cntrl */
cntrl.t.cntrl.action = AUBND_DIS;
cntrl.t.cntrl.subAction = SAELMNT;
cntrl.t.cntrl.sapId = signal_data->link_id;
if (sng_isdn_phy_cntrl(&pst, &cntrl)) {
return FTDM_FAIL;
}
return FTDM_SUCCESS;
}
ftdm_status_t sng_isdn_activate_q921(ftdm_span_t *span)
{
ftdm_status_t status;
status = sng_isdn_cntrl_q921(span, ABND_ENA, NOTUSED);
/* Try to find an alternative for this */
/* LAPD will call LdUiDatBndCfm before it received a LdLiMacBndCfm from L1,
so we need to give some time before activating q931, as q931 will send a
LdUiDatConReq when activated, and this requires the Mac SAP to be already
bound first */
if (status == FTDM_SUCCESS) {
ftdm_sleep(500);
}
return status;
}
ftdm_status_t sng_isdn_activate_q931(ftdm_span_t *span)
{
/* TODO: remove this function later, just call sng_isdn_cntrl_q931 directly */
return sng_isdn_cntrl_q931(span, ABND_ENA, SAELMNT);
}
ftdm_status_t sng_isdn_activate_cc(ftdm_span_t *span)
{
CcMngmt cntrl;;
@ -167,7 +199,7 @@ ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t tra
ftdm_log(FTDM_LOG_INFO, "s%d Disabling q921 trace\n", signal_data->link_id);
sngisdn_clear_trace_flag(signal_data, SNGISDN_TRACE_Q921);
if (sng_isdn_cntrl_q921(span, ADISIMM, SAELMNT) != FTDM_SUCCESS) {
if (sng_isdn_cntrl_q921(span, ADISIMM, SATRC) != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "s%d Failed to disable q921 trace\n");
}
}

View File

@ -78,14 +78,13 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
}
sngisdn_info->suInstId = get_unique_suInstId(suId);
sngisdn_info->spInstId = spInstId;
sngisdn_info->spInstId = spInstId;
/* If this is a glared call that was previously saved, we moved
all the info to the current call, so clear the glared saved data */
if (sngisdn_info->glare.spInstId == spInstId) {
clear_call_glare_data(sngisdn_info);
}
}
ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex);
g_sngisdn_data.ccs[suId].active_suInstIds[sngisdn_info->suInstId] = sngisdn_info;
@ -105,7 +104,15 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_TEMPORARY_FAILURE;
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
break;
}
}
#if 0
/* Export ftdmchan variables here if we need to */
ftdm_channel_add_var(ftdmchan, "isdn_specific_var", "1");
ftdm_channel_add_var(ftdmchan, "isdn_crap", "morecrap");
ftdm_channel_add_var(ftdmchan, "isdn_stuff", "s");
ftdm_channel_add_var(ftdmchan, "isdn_d", "asdsadasdasdsad");
#endif
/* Fill in call information */
cpy_calling_num_from_stack(&ftdmchan->caller_data, &conEvnt->cgPtyNmb);
cpy_called_num_from_stack(&ftdmchan->caller_data, &conEvnt->cdPtyNmb);
@ -124,14 +131,12 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
}
if (conEvnt->facilityStr.eh.pres) {
if (signal_data->facility == SNGISDN_OPT_TRUE && conEvnt->facilityStr.eh.pres) {
/* Verify whether the Caller Name will come in a subsequent FACILITY message */
uint16_t ret_val;
uint8_t facility_str[255];
char retrieved_str[255];
memcpy(facility_str, (uint8_t*)&conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len);
ret_val = sng_isdn_retrieve_facility_caller_name(facility_str, conEvnt->facilityStr.facilityStr.len, retrieved_str);
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
@ -142,6 +147,11 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event)
if (ret_val == 1) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Expecting Caller name in FACILITY\n");
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID);
/* Launch timer in case we never get a FACILITY msg */
if (signal_data->facility_timeout) {
ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout,
sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_TIMER_FACILITY]);
}
break;
} else if (ret_val == 0) {
strcpy(ftdmchan->caller_data.cid_name, retrieved_str);
@ -263,6 +273,9 @@ void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event)
/* This is the only valid state we should get a CONNECT ACK on */
/* do nothing */
break;
case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
/* We just hung up an incoming call right after we sent a CONNECT so ignore this message */
break;
default:
ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Processing CONNECT/CONNECT ACK in an invalid state (%s)\n", ftdm_channel_state2str(ftdmchan->state));
@ -289,6 +302,8 @@ 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;
ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n");
@ -302,19 +317,49 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event)
suId, suInstId, spInstId, ces);
switch(evntType) {
case MI_PROGRESS:
if (signal_data->switchtype == SNGISDN_SWITCH_NI2 &&
cnStEvnt->causeDgn[0].eh.pres && cnStEvnt->causeDgn[0].causeVal.pres) {
switch(cnStEvnt->causeDgn[0].causeVal.val) {
case 17: /* User Busy */
case 18: /* No User responding */
case 19: /* User alerting, no answer */
case 21: /* Call rejected, the called party does not with to accept this call */
case 27: /* Destination out of order */
case 31: /* Normal, unspecified */
case 34: /* Circuit/Channel congestion */
case 41: /* Temporary failure */
case 42: /* Switching equipment is experiencing a period of high traffic */
case 47: /* Resource unavailable */
case 58: /* Bearer Capability not available */
case 63: /* Service or option not available */
case 65: /* Bearer Cap not implemented, not supported */
case 79: /* Service or option not implemented, unspecified */
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Cause requires disconnect (cause:%d)\n", cnStEvnt->causeDgn[0].causeVal.val);
ftdmchan->caller_data.hangup_cause = cnStEvnt->causeDgn[0].causeVal.val;
sngisdn_set_flag(sngisdn_info, FLAG_SEND_DISC);
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
goto sngisdn_process_cnst_ind_end;
}
}
/* fall-through */
case MI_ALERTING:
case MI_CALLPROC:
case MI_PROGRESS:
switch(ftdmchan->state) {
case FTDM_CHANNEL_STATE_DIALING:
if (evntType == MI_PROGRESS) {
case FTDM_CHANNEL_STATE_DIALING:
if (evntType == MI_PROGRESS ||
(cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL)) {
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
} else {
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS);
}
break;
case FTDM_CHANNEL_STATE_PROGRESS:
if (evntType == MI_PROGRESS) {
if (evntType == MI_PROGRESS ||
(cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL)) {
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
}
break;
@ -371,6 +416,7 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event)
break;
}
sngisdn_process_cnst_ind_end:
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
@ -638,12 +684,14 @@ void sngisdn_process_flc_ind (sngisdn_event_data_t *sngisdn_event)
void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
int16_t suId = sngisdn_event->suId;
uint32_t suInstId = sngisdn_event->suInstId;
uint32_t spInstId = sngisdn_event->spInstId;
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;
FacEvnt *facEvnt = &sngisdn_event->event.facEvnt;
@ -653,16 +701,31 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event)
case FTDM_CHANNEL_STATE_GET_CALLERID:
/* Update the caller ID Name */
if (facEvnt->facElmt.facStr.pres) {
uint8_t facility_str[255];
memcpy(facility_str, (uint8_t*)&facEvnt->facElmt.facStr.val, facEvnt->facElmt.facStr.len);
char retrieved_str[255];
if (sng_isdn_retrieve_facility_caller_name(facility_str, facEvnt->facElmt.facStr.len, retrieved_str) != FTDM_SUCCESS) {
/* 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 (sng_isdn_retrieve_facility_caller_name(&facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len, retrieved_str) == 0) {
strcpy(ftdmchan->caller_data.cid_name, retrieved_str);
} else {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Failed to retrieve Caller Name from Facility IE\n");
}
if (signal_data->facility_timeout) {
/* Cancel facility timeout */
ftdm_sched_cancel_timer(signal_data->sched, sngisdn_info->timers[SNGISDN_TIMER_FACILITY]);
}
}
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING);
break;
case FTDM_CHANNEL_STATE_RING:
/* We received the caller ID Name in FACILITY, but its too late, facility-timeout already occurred */
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "FACILITY received, but we already proceeded with call\n");
break;
default:
/* We do not support other FACILITY types for now, so do nothing */
break;
@ -794,6 +857,14 @@ void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event)
break;
case 3:
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_PROGRESS:
/* T310 timer has expired */
ftdmchan->caller_data.hangup_cause = staEvnt->causeDgn[0].causeVal.val;
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "T310 Timer expired, hanging up call\n");
sngisdn_set_flag(sngisdn_info, FLAG_SEND_DISC);
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
break;
case FTDM_CHANNEL_STATE_UP:
/* Remote side is still waiting for our CONNECT message */
if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
@ -821,6 +892,22 @@ void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event)
break;
}
break;
case 9: /* Remote switch is in "Incoming call proceeding" state */
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_PROGRESS:
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
case FTDM_CHANNEL_STATE_GET_CALLERID:
/* Do nothing */
break;
case FTDM_CHANNEL_STATE_UP:
/* Remote switch missed our CONNECT message, re-send */
ftdm_sched_timer(((sngisdn_span_data_t*)ftdmchan->span->signal_data)->sched, "delayed_connect", 1, sngisdn_delayed_connect, (void*) sngisdn_info, NULL);
break;
default:
ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state));
break;
}
break;
case 10: /* Remote switch is in active state */
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_UP:
@ -836,17 +923,6 @@ void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event)
break;
}
break;
case 9:
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_PROGRESS:
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
/* Do nothing */
break;
default:
ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Don't know how to handle incompatible state. remote call state:%d our state:%s\n", call_state, ftdm_channel_state2str(ftdmchan->state));
break;
}
break;
case 22:
switch (ftdmchan->state) {
case FTDM_CHANNEL_STATE_UP:

View File

@ -409,7 +409,7 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan)
sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data;
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data;
if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) {
if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) {
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending CONNECT, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId);
sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT);
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
@ -450,6 +450,14 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan)
cnStEvnt.chanId.chanNmbSlotMap.len = 1;
cnStEvnt.chanId.chanNmbSlotMap.val[0] = ftdmchan->physical_chan_id;
}
cnStEvnt.progInd.eh.pres = PRSNT_NODEF;
cnStEvnt.progInd.location.pres = PRSNT_NODEF;
cnStEvnt.progInd.location.val = IN_LOC_USER;
cnStEvnt.progInd.codeStand0.pres = PRSNT_NODEF;
cnStEvnt.progInd.codeStand0.val = IN_CSTD_CCITT;
cnStEvnt.progInd.progDesc.pres = PRSNT_NODEF;
cnStEvnt.progInd.progDesc.val = IN_PD_NOTETEISDN; /* Not end-to-end ISDN */
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
if (sng_isdn_con_response(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, signal_data->dchan_id, sngisdn_info->ces)) {

View File

@ -45,8 +45,8 @@ void sngisdn_rcv_con_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, Co
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
uint8_t bchan_no = 0;
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_chan_data_t *sngisdn_info = NULL;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Con Ind on unconfigured cc\n");
ftdm_assert(g_sngisdn_data.dchans[dChan].num_spans != 0, "Con Ind on unconfigured dchan\n");
@ -96,7 +96,7 @@ void sngisdn_rcv_con_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, Co
ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex);
memcpy(&sngisdn_event->event.conEvnt, conEvnt, sizeof(*conEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
@ -104,8 +104,8 @@ void sngisdn_rcv_con_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, Co
void sngisdn_rcv_con_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, int16_t dChan, uint8_t ces)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_chan_data_t *sngisdn_info = NULL;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Con Cfm on unconfigured cc\n");
ftdm_assert(g_sngisdn_data.dchans[dChan].num_spans != 0, "Con Cfm on unconfigured dchan\n");
@ -118,6 +118,7 @@ void sngisdn_rcv_con_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, Cn
if (!sngisdn_info->spInstId) {
ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex);
sngisdn_info->spInstId = spInstId;
g_sngisdn_data.ccs[suId].active_spInstIds[spInstId] = sngisdn_info;
ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex);
@ -146,8 +147,8 @@ void sngisdn_rcv_con_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, Cn
void sngisdn_rcv_cnst_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, uint8_t evntType, int16_t dChan, uint8_t ces)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_chan_data_t *sngisdn_info = NULL;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_assert(g_sngisdn_data.ccs[suId].activation_done != 0, "Cnst Ind on unconfigured cc\n");
ftdm_assert(g_sngisdn_data.dchans[dChan].num_spans != 0, "Cnst Ind on unconfigured dchan\n");
@ -160,6 +161,7 @@ void sngisdn_rcv_cnst_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, C
if (!sngisdn_info->spInstId) {
ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex);
sngisdn_info->spInstId = spInstId;
g_sngisdn_data.ccs[suId].active_spInstIds[spInstId] = sngisdn_info;
ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex);
@ -188,15 +190,15 @@ void sngisdn_rcv_cnst_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, C
memcpy(&sngisdn_event->event.cnStEvnt, cnStEvnt, sizeof(*cnStEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
void sngisdn_rcv_disc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, DiscEvnt *discEvnt)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_chan_data_t *sngisdn_info = NULL;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_assert(spInstId != 0, "Received DISCONNECT with invalid id");
@ -207,13 +209,6 @@ void sngisdn_rcv_disc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, D
ftdm_assert(0, "Inconsistent call states\n");
return;
}
if (!sngisdn_info->spInstId) {
ftdm_mutex_lock(g_sngisdn_data.ccs[suId].mutex);
sngisdn_info->spInstId = spInstId;
g_sngisdn_data.ccs[suId].active_spInstIds[spInstId] = sngisdn_info;
ftdm_mutex_unlock(g_sngisdn_data.ccs[suId].mutex);
}
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received DISCONNECT (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
@ -229,7 +224,7 @@ void sngisdn_rcv_disc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, D
memcpy(&sngisdn_event->event.discEvnt, discEvnt, sizeof(*discEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
@ -237,21 +232,22 @@ void sngisdn_rcv_disc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, D
void sngisdn_rcv_rel_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, RelEvnt *relEvnt)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_chan_data_t *sngisdn_info = NULL;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
ftdm_log(FTDM_LOG_CRIT, "Could not find matching call suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId);
ftdm_assert(0, "Inconsistent call states\n");
/* It seems that Trillium has a bug where they sometimes send release twice on a call, so do not crash on these for now */
/* ftdm_assert(0, "Inconsistent call states\n"); */
return;
}
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received RELEASE/RELEASE COMPLETE (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_REL_IND;
@ -270,7 +266,7 @@ void sngisdn_rcv_dat_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, In
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -283,7 +279,7 @@ void sngisdn_rcv_dat_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, In
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received DATA IND suId:%u suInstId:%u spInstId:%u\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_DAT_IND;
@ -302,7 +298,7 @@ void sngisdn_rcv_sshl_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, S
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -315,7 +311,7 @@ void sngisdn_rcv_sshl_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, S
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received SSHL IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_SSHL_IND;
@ -335,7 +331,7 @@ void sngisdn_rcv_sshl_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, S
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -348,7 +344,7 @@ void sngisdn_rcv_sshl_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, S
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received SSHL CFM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_SSHL_CFM;
@ -360,14 +356,14 @@ void sngisdn_rcv_sshl_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, S
memcpy(&sngisdn_event->event.ssHlEvnt, ssHlEvnt, sizeof(*ssHlEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
void sngisdn_rcv_rmrt_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -380,7 +376,7 @@ void sngisdn_rcv_rmrt_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, R
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received RMRT IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_RMRT_IND;
@ -392,7 +388,7 @@ void sngisdn_rcv_rmrt_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, R
memcpy(&sngisdn_event->event.rmRtEvnt, rmRtEvnt, sizeof(*rmRtEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
@ -400,7 +396,7 @@ void sngisdn_rcv_rmrt_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, R
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -413,7 +409,7 @@ void sngisdn_rcv_rmrt_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, R
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received RESUME/RETRIEVE CFM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_RMRT_CFM;
@ -425,7 +421,7 @@ void sngisdn_rcv_rmrt_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, R
memcpy(&sngisdn_event->event.rmRtEvnt, rmRtEvnt, sizeof(*rmRtEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
@ -433,7 +429,7 @@ void sngisdn_rcv_flc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, St
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -446,7 +442,7 @@ void sngisdn_rcv_flc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, St
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received FLOW CONTROL IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_FLC_IND;
@ -457,7 +453,7 @@ void sngisdn_rcv_flc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, St
memcpy(&sngisdn_event->event.staEvnt, staEvnt, sizeof(*staEvnt));
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ftdm_queue_enqueue(((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->event_queue, sngisdn_event);
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
@ -466,7 +462,7 @@ void sngisdn_rcv_fac_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, Fa
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -478,7 +474,7 @@ void sngisdn_rcv_fac_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, Fa
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received FACILITY IND (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_FAC_IND;
@ -499,7 +495,7 @@ void sngisdn_rcv_sta_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, St
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
sngisdn_chan_data_t *sngisdn_info;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
if (!(spInstId && get_ftdmchan_by_spInstId(suId, spInstId, &sngisdn_info) == FTDM_SUCCESS) &&
!(suInstId && get_ftdmchan_by_suInstId(suId, suInstId, &sngisdn_info) == FTDM_SUCCESS)) {
@ -512,7 +508,7 @@ void sngisdn_rcv_sta_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, St
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Received STATUS CONFIRM (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId);
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_STA_CFM;
@ -532,7 +528,7 @@ void sngisdn_rcv_srv_ind (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
unsigned i;
sngisdn_span_data_t *signal_data;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_log(FTDM_LOG_INFO, "Received SERVICE IND (dChan:%d ces:%u)\n", dChan, ces);
@ -540,7 +536,7 @@ void sngisdn_rcv_srv_ind (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces
for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) {
signal_data = g_sngisdn_data.dchans[dChan].spans[i];
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_SRV_IND;
@ -550,7 +546,7 @@ void sngisdn_rcv_srv_ind (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces
sngisdn_event->signal_data = signal_data;
memcpy(&sngisdn_event->event.srvEvnt, srvEvnt, sizeof(*srvEvnt));
ftdm_queue_enqueue((signal_data)->event_queue, sngisdn_event);
ftdm_queue_enqueue((signal_data)->event_queue, sngisdn_event);
}
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
}
@ -560,8 +556,8 @@ void sngisdn_rcv_srv_cfm (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
unsigned i;
sngisdn_span_data_t *signal_data;
sngisdn_event_data_t *sngisdn_event;
sngisdn_span_data_t *signal_data = NULL;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_log(FTDM_LOG_INFO, "Received SERVICE CFM (dChan:%d ces:%u)\n", dChan, ces);
@ -569,7 +565,7 @@ void sngisdn_rcv_srv_cfm (int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces
for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) {
signal_data = g_sngisdn_data.dchans[dChan].spans[i];
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_SRV_CFM;
@ -588,16 +584,17 @@ void sngisdn_rcv_rst_ind (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
unsigned i;
sngisdn_span_data_t *signal_data;
sngisdn_event_data_t *sngisdn_event;
sngisdn_span_data_t *signal_data = NULL;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_log(FTDM_LOG_INFO, "Received RESTART IND (dChan:%d ces:%u type:%u)\n", dChan, ces, evntType);
/* Enqueue the event to each span within the dChan */
for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) {
signal_data = g_sngisdn_data.dchans[dChan].spans[i];
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_RST_IND;
@ -618,7 +615,7 @@ void sngisdn_rcv_rst_cfm (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
unsigned i;
sngisdn_span_data_t *signal_data;
sngisdn_event_data_t *sngisdn_event;
sngisdn_event_data_t *sngisdn_event = NULL;
ftdm_log(FTDM_LOG_INFO, "Received RESTART CFM (dChan:%d ces:%u type:%u)\n", dChan, ces, evntType);
@ -626,7 +623,7 @@ void sngisdn_rcv_rst_cfm (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces
for(i=1; i<=g_sngisdn_data.dchans[dChan].num_spans; i++) {
signal_data = g_sngisdn_data.dchans[dChan].spans[i];
sngisdn_event = ftdm_malloc(sizeof(*sngisdn_event));
ftdm_assert(sngisdn_event, "Failed to allocate memory\n");
ftdm_assert(sngisdn_event != NULL, "Failed to allocate memory\n");
memset(sngisdn_event, 0, sizeof(*sngisdn_event));
sngisdn_event->event_id = SNGISDN_EVENT_RST_CFM;
@ -645,30 +642,24 @@ void sngisdn_rcv_rst_cfm (int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces
void sngisdn_rcv_phy_ind(SuId suId, Reason reason)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
if (reason != LL1_REASON_CON_REQ_FAIL) {
ftdm_log(FTDM_LOG_INFO, "[SNGISDN PHY] D-chan %d : %s\n", suId, DECODE_LL1_REASON(reason));
}
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
void sngisdn_rcv_q921_ind(BdMngmt *status)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
unsigned j,k;
ftdm_span_t *ftdmspan = NULL;
for(j=1;j<=g_sngisdn_data.num_dchan;j++) {
for(k=1;k<=g_sngisdn_data.dchans[j].num_spans;k++) {
if (g_sngisdn_data.dchans[j].spans[k]->link_id == status->t.usta.lnkNmb) {
ftdmspan = (ftdm_span_t*)g_sngisdn_data.dchans[j].spans[k]->ftdm_span;
}
}
{
ftdm_span_t *ftdmspan;
sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[status->t.usta.lnkNmb];
if (!signal_data) {
ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb);
return;
}
if (ftdmspan == NULL) {
ftdm_log(FTDM_LOG_WARNING, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb);
ftdmspan = signal_data->ftdm_span;
if (!ftdmspan) {
ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.lnkNmb);
return;
}
@ -699,69 +690,56 @@ void sngisdn_rcv_q921_ind(BdMngmt *status)
}
break;
}
ISDN_FUNC_TRACE_EXIT(__FUNCTION__)
return;
}
void sngisdn_rcv_q931_ind(InMngmt *status)
{
ISDN_FUNC_TRACE_ENTER(__FUNCTION__);
ftdm_span_t *ftdmspan = NULL;
{
if (status->t.usta.alarm.cause == 287) {
get_memory_info();
return;
}
switch (status->t.usta.alarm.category) {
case (LCM_CATEGORY_INTERFACE):
ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
status->t.usta.suId,
DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
/* clean this up later */
switch (status->t.usta.alarm.event) {
case LCM_EVENT_UP:
case LCM_EVENT_DOWN:
{
unsigned j,k;
for(j=1;j<=g_sngisdn_data.num_dchan;j++) {
for(k=1;k<=g_sngisdn_data.dchans[j].num_spans;k++) {
if (g_sngisdn_data.dchans[j].spans[k]->link_id == status->t.usta.suId) {
ftdmspan = (ftdm_span_t*)g_sngisdn_data.dchans[j].spans[k]->ftdm_span;
}
}
}
if (ftdmspan == NULL) {
ftdm_log(FTDM_LOG_CRIT, "Received q931 LCM EVENT on unconfigured span (suId:%u)\n", status->t.usta.suId);
return;
}
if (status->t.usta.alarm.event == LCM_EVENT_UP) {
sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_UP);
sng_isdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_UP);
} else {
sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN);
sng_isdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING);
}
}
break;
switch (status->t.usta.alarm.event) {
case LCM_EVENT_UP:
case LCM_EVENT_DOWN:
{
ftdm_span_t *ftdmspan;
sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[status->t.usta.suId];
if (!signal_data) {
ftdm_log(FTDM_LOG_INFO, "Received q921 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId);
return;
}
break;
ftdmspan = signal_data->ftdm_span;
if (status->t.usta.alarm.event == LCM_EVENT_UP) {
ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
status->t.usta.suId,
DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_UP);
sng_isdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_UP);
} else {
ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
status->t.usta.suId,
DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN);
sng_isdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING);
}
}
break;
default:
ftdm_log(FTDM_LOG_DEBUG, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
status->t.usta.suId,
DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
break;
ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
status->t.usta.suId,
DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
}
ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
return;
}
@ -907,12 +885,13 @@ void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...)
break;
case SNG_LOGLEVEL_CRIT:
ftdm_log(FTDM_LOG_CRIT, "sng_isdn->%s", data);
/*ftdm_assert(0, "Got an error from stack");*/
/* ftdm_assert(0, "Got an error from stack"); */
break;
default:
ftdm_log(FTDM_LOG_INFO, "sng_isdn->%s", data);
break;
}
ftdm_safe_free(data);
return;
}

View File

@ -73,8 +73,10 @@ void __inline__ clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info)
sngisdn_info->glare.suInstId, sngisdn_info->glare.spInstId,
sngisdn_info->suInstId, sngisdn_info->spInstId);
ftdm_mutex_lock(g_sngisdn_data.ccs[sngisdn_info->glare.suId].mutex);
g_sngisdn_data.ccs[sngisdn_info->glare.suId].active_spInstIds[sngisdn_info->glare.spInstId]=NULL;
ftdm_mutex_lock(g_sngisdn_data.ccs[sngisdn_info->glare.suId].mutex);
if (sngisdn_info->glare.spInstId != sngisdn_info->spInstId) {
g_sngisdn_data.ccs[sngisdn_info->glare.suId].active_spInstIds[sngisdn_info->glare.spInstId]=NULL;
}
g_sngisdn_data.ccs[sngisdn_info->glare.suId].active_suInstIds[sngisdn_info->glare.suInstId]=NULL;
ftdm_mutex_unlock(g_sngisdn_data.ccs[sngisdn_info->glare.suId].mutex);
@ -132,16 +134,22 @@ ftdm_status_t __inline__ get_ftdmchan_by_spInstId(uint8_t cc_id, uint32_t spInst
return FTDM_SUCCESS;
}
ftdm_status_t sng_isdn_set_avail_rate(ftdm_span_t *ftdmspan, sngisdn_avail_t avail)
ftdm_status_t sng_isdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail)
{
unsigned i;
if (ftdmspan->trunk_type == FTDM_TRUNK_BRI ||
ftdmspan->trunk_type == FTDM_TRUNK_BRI_PTMP) {
if (span->trunk_type == FTDM_TRUNK_BRI ||
span->trunk_type == FTDM_TRUNK_BRI_PTMP) {
for(i=1; i<=ftdmspan->chan_count; i++) {
ftdm_log_chan(ftdmspan->channels[i], FTDM_LOG_DEBUG, "Setting availability rate to:%d\n", avail);
ftdmspan->channels[i]->availability_rate = avail;
ftdm_iterator_t *chaniter = NULL;
ftdm_iterator_t *curr = NULL;
chaniter = ftdm_span_get_chan_iterator(span, NULL);
for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) {
ftdm_log_chan(((ftdm_channel_t*)ftdm_iterator_current(curr)), FTDM_LOG_DEBUG, "Setting availability rate to:%d\n", avail);
((ftdm_channel_t*)ftdm_iterator_current(curr))->availability_rate = avail;
}
ftdm_iterator_free(chaniter);
}
return FTDM_SUCCESS;
}
@ -427,6 +435,24 @@ void sngisdn_delayed_disconnect(void* p_sngisdn_info)
return;
}
void sngisdn_facility_timeout(void* p_sngisdn_info)
{
sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info;
ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan;
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data;
ftdm_mutex_lock(ftdmchan->mutex);
if (ftdmchan->state == FTDM_CHANNEL_STATE_GET_CALLERID) {
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Facility timeout reached proceeding with call (suId:%d suInstId:%u spInstId:%u)\n",
signal_data->cc_id, sngisdn_info->spInstId, sngisdn_info->suInstId);
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING);
}
ftdm_mutex_unlock(ftdmchan->mutex);
return;
}
ftdm_status_t sngisdn_check_free_ids(void)
{
unsigned i;
@ -534,6 +560,77 @@ ftdm_user_layer1_prot_t sngisdn_get_usrInfoLyr1Prot_from_user(uint8_t layer1_pro
return FTDM_USER_LAYER1_PROT_ULAW;
}
void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span)
{
L1Mngmt sts;
sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data;
memset(&sts, 0, sizeof(sts));
sng_isdn_phy_stats(signal_data->link_id , &sts);
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, " Span:%s", span->name);
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, " Performance Counters");
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, "RX Packets:\t%u\tTX Packets:\t%u\tEvents:%u\n", sts.t.sts.rx_packets, sts.t.sts.tx_packets, sts.t.sts.rx_events);
stream->write_function(stream, "RX Bytes:\t%u\tTX Bytes:\t%u\n\n", sts.t.sts.rx_bytes, sts.t.sts.tx_bytes);
stream->write_function(stream, "TX Queue:\t%u/%u\tRX Queue:\t%u/%u\tEvents Queue:\t%u/%u\n",
sts.t.sts.num_frames_in_tx_queue,sts.t.sts.tx_queue_len,
sts.t.sts.num_frames_in_rx_queue, sts.t.sts.rx_queue_len,
sts.t.sts.rx_events_in_queue, sts.t.sts.event_queue_len);
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, " Errors");
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, "RX Errors:\t%u\tTX Errors:\t%u\n", sts.t.sts.rx_errors, sts.t.sts.tx_errors);
stream->write_function(stream, "RX Dropped:\t%u\tTX Dropped:\t%u\tEvents Dropped:\t%u\n", sts.t.sts.rx_dropped, sts.t.sts.tx_dropped,sts.t.sts.rx_events_dropped);
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, " RX Errors Details");
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, "CRC:\t\t%u\tFrame:\t\t%u\tOverruns:\t%u\n", sts.t.sts.rx_crc_errors, sts.t.sts.rx_frame_errors, sts.t.sts.rx_over_errors);
stream->write_function(stream, "Fifo:\t\t%u\tAborts:\t\t%u\tMissed:\t\t%u\n", sts.t.sts.rx_fifo_errors, sts.t.sts.rx_hdlc_abort_counter, sts.t.sts.rx_missed_errors);
stream->write_function(stream, "Length:\t\t%u\n", sts.t.sts.rx_length_errors);
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, " TX Errors Details");
stream->write_function(stream, "\n---------------------------------------------------------------------\n");
stream->write_function(stream, "Aborted:\t%u\tFifo:\t\t%u\tCarrier:\t%u\n", sts.t.sts.tx_aborted_errors, sts.t.sts.tx_fifo_errors, sts.t.sts.tx_carrier_errors);
return;
}
void sngisdn_print_span(ftdm_stream_handle_t *stream, ftdm_span_t *span)
{
ftdm_signaling_status_t sigstatus;
ftdm_alarm_flag_t alarmbits;
ftdm_channel_t *fchan;
alarmbits = FTDM_ALARM_NONE;
fchan = ftdm_span_get_channel(span, 1);
if (fchan) {
ftdm_channel_get_alarms(fchan, &alarmbits);
}
ftdm_span_get_sig_status(span, &sigstatus);
stream->write_function(stream, "span:%s physical:%s signalling:%s\n",
span->name, alarmbits ? "ALARMED" : "OK",
ftdm_signaling_status2str(sigstatus));
return;
}
void sngisdn_print_spans(ftdm_stream_handle_t *stream)
{
int i;
for(i=1;i<=MAX_L1_LINKS;i++) {
if (g_sngisdn_data.spans[i]) {
sngisdn_print_span(stream, g_sngisdn_data.spans[i]->ftdm_span);
}
}
return;
}
/* For Emacs:
* Local Variables:
* mode:c

View File

@ -85,35 +85,35 @@ int ft_to_sngss7_cfg_all(void)
if (ftmod_ss7_mtp1_gen_config()) {
SS7_CRITICAL("MTP1 General configuration FAILED!\n");
SS7_ASSERT
return 1;
} else {
SS7_INFO("MTP1 General configuration DONE\n");
}
if (ftmod_ss7_mtp2_gen_config()) {
SS7_CRITICAL("MTP2 General configuration FAILED!\n");
SS7_ASSERT
return 1;
} else {
SS7_INFO("MTP2 General configuration DONE\n");
}
if (ftmod_ss7_mtp3_gen_config()) {
SS7_CRITICAL("MTP3 General configuration FAILED!\n");
SS7_ASSERT
return 1;
} else {
SS7_INFO("MTP3 General configuration DONE\n");
}
if (ftmod_ss7_isup_gen_config()) {
SS7_CRITICAL("ISUP General configuration FAILED!\n");
SS7_ASSERT
return 1;
} else {
SS7_INFO("ISUP General configuration DONE\n");
}
if (ftmod_ss7_cc_gen_config()) {
SS7_CRITICAL("CC General configuration FAILED!\n");
SS7_ASSERT
return 1;
} else {
SS7_INFO("CC General configuration DONE\n");
}
@ -131,7 +131,7 @@ int ft_to_sngss7_cfg_all(void)
/* configure mtp1 */
if (ftmod_ss7_mtp1_psap_config(x)) {
SS7_CRITICAL("MTP1 PSAP %d configuration FAILED!\n", x);
SS7_ASSERT;
return 1;;
} else {
SS7_INFO("MTP1 PSAP %d configuration DONE!\n", x);
}
@ -139,7 +139,7 @@ int ft_to_sngss7_cfg_all(void)
/* configure mtp2 */
if (ftmod_ss7_mtp2_dlsap_config(x)) {
SS7_CRITICAL("MTP2 DLSAP %d configuration FAILED!\n",x);
SS7_ASSERT;
return 1;;
} else {
SS7_INFO("MTP2 DLSAP %d configuration DONE!\n", x);
}
@ -147,7 +147,7 @@ int ft_to_sngss7_cfg_all(void)
/* configure mtp3 */
if (ftmod_ss7_mtp3_dlsap_config(x)) {
SS7_CRITICAL("MTP3 DLSAP %d configuration FAILED!\n", x);
SS7_ASSERT;
return 1;;
} else {
SS7_INFO("MTP3 DLSAP %d configuration DONE!\n", x);
}
@ -166,14 +166,14 @@ int ft_to_sngss7_cfg_all(void)
if (ftmod_ss7_mtp3_nsap_config(x)) {
SS7_CRITICAL("MTP3 NSAP %d configuration FAILED!\n", x);
SS7_ASSERT
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);
SS7_ASSERT
return 1;
} else {
SS7_INFO("ISUP NSAP %d configuration DONE!\n", x);
}
@ -192,7 +192,7 @@ int ft_to_sngss7_cfg_all(void)
if (ftmod_ss7_mtp3_linkset_config(x)) {
SS7_CRITICAL("MTP3 LINKSET %d configuration FAILED!\n", x);
SS7_ASSERT
return 1;
} else {
SS7_INFO("MTP3 LINKSET %d configuration DONE!\n", x);
}
@ -211,9 +211,9 @@ int ft_to_sngss7_cfg_all(void)
if (ftmod_ss7_mtp3_route_config(x)) {
SS7_CRITICAL("MTP3 ROUTE %d configuration FAILED!\n", x);
SS7_ASSERT
return 1;
} else {
SS7_INFO("MTP3 ROUTE %d configuration DONE!\n");
SS7_INFO("MTP3 ROUTE %d configuration DONE!\n",x);
}
/* set the CONFIGURED flag */
@ -227,9 +227,9 @@ int ft_to_sngss7_cfg_all(void)
if (ftmod_ss7_mtp3_route_config(0)) {
SS7_CRITICAL("MTP3 ROUTE 0 configuration FAILED!\n");
SS7_ASSERT
return 1;
} else {
SS7_INFO("MTP3 ROUTE %d configuration DONE!\n");
SS7_INFO("MTP3 ROUTE 0 configuration DONE!\n");
}
/* set the CONFIGURED flag */
@ -244,14 +244,14 @@ int ft_to_sngss7_cfg_all(void)
if (ftmod_ss7_isup_isap_config(x)) {
SS7_CRITICAL("ISUP ISAP %d configuration FAILED!\n", x);
SS7_ASSERT
return 1;
} else {
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);
SS7_ASSERT
return 1;
} else {
SS7_INFO("CC ISAP %d configuration DONE!\n", x);
}
@ -270,9 +270,11 @@ int ft_to_sngss7_cfg_all(void)
if (ftmod_ss7_isup_intf_config(x)) {
SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x);
SS7_ASSERT
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 */
@ -289,7 +291,7 @@ int ft_to_sngss7_cfg_all(void)
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);
SS7_ASSERT
return 1;
} else {
SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
}
@ -444,8 +446,8 @@ int ftmod_ss7_mtp3_gen_config(void)
cfg.t.cfg.s.snGen.tmr.t21.enb = TRUE; /* t21 - waiting to restart traffic routed through adjacent SP */
cfg.t.cfg.s.snGen.tmr.t21.val = 650;
# if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || defined(TDS_ROLL_UPGRADE_SUPPORT))
cfg.t.cfg.s.snGen.t26.enb = TRUE; /* t26 - waiting to repeat traffic restart waiting message for ANSI */
cfg.t.cfg.s.snGen.t26.val = 600;
cfg.t.cfg.s.snGen.tmr.t26.enb = TRUE; /* t26 - waiting to repeat traffic restart waiting message for ANSI */
cfg.t.cfg.s.snGen.tmr.t26.val = 600;
# endif
#endif
@ -644,7 +646,7 @@ 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 = SD_ERR_NRM;
cfg.t.cfg.s.sdDLSAP.errType = k->mtp2.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.t2.enb = TRUE; /* timer 2 - Not Aligned Timer */
@ -744,10 +746,6 @@ int ftmod_ss7_mtp3_dlsap_config(int id)
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 */
# if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || SS7_CHINA)
cfg.t.cfg.s.snDLSAP.l2Type = LSN_MTP2_56KBPS; /* layer 2 type - 56kbps MTP2 link, 1.536Mbps MTP2 link or QSAAL link */
cfg.t.cfg.s.snDLSAP.isCLink = FALSE; /* identifies if the link is a C type link.Required to check if sls has to be rotated.*/
# endif
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 */
@ -775,17 +773,46 @@ 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 */
#if( SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || SS7_CHINA )
cfg.t.cfg.s.snDLSAP.dpcLen = DPC24; /* dpc length 24 bits */
#else
cfg.t.cfg.s.snDLSAP.dpcLen = DPC14; /* dpc length 14 bits */
#endif
cfg.t.cfg.s.snDLSAP.spId = k->mtp3.mtp2Id ;/* service provider id */
#if (SS7_ITU88 || SS7_CHINA || SS7_TTC || SS7_NTT || SS7_BICI )
cfg.t.cfg.s.snDLSAP.flushContFlag = FALSE; /* flush continue handling */
#else
cfg.t.cfg.s.snDLSAP.flushContFlag = TRUE; /* flush continue handling */
#endif
switch (k->mtp3.linkType) {
/**************************************************************************/
case (LSN_SW_ANS):
case (LSN_SW_ANS96):
case (LSN_SW_CHINA):
cfg.t.cfg.s.snDLSAP.dpcLen = DPC24; /* dpc length 24 bits */
cfg.t.cfg.s.snDLSAP.l2Type = LSN_MTP2_56KBPS; /* layer 2 type - 56kbps MTP2 link, 1.536Mbps MTP2 link or QSAAL link */
cfg.t.cfg.s.snDLSAP.isCLink = FALSE; /* identifies if the link is a C type link.Required to check if sls has to be rotated.*/
break;
/**************************************************************************/
case (LSN_SW_ITU):
cfg.t.cfg.s.snDLSAP.dpcLen = DPC14; /* dpc length 14 bits */
break;
/**************************************************************************/
default:
cfg.t.cfg.s.snDLSAP.dpcLen = DPC14; /* dpc length 14 bits */
break;
/**************************************************************************/
} /* switch (k->mtp3.linkType) */
switch (k->mtp3.linkType) {
/**************************************************************************/
case (LSN_SW_ANS):
case (LSN_SW_ANS96):
cfg.t.cfg.s.snDLSAP.flushContFlag = TRUE; /* flush continue handling */
break;
/**************************************************************************/
case (LSN_SW_ITU):
case (LSN_SW_CHINA):
cfg.t.cfg.s.snDLSAP.flushContFlag = FALSE; /* flush continue handling */
break;
/**************************************************************************/
default:
cfg.t.cfg.s.snDLSAP.flushContFlag = FALSE; /* flush continue handling */
break;
/**************************************************************************/
} /* switch (k->mtp3.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.t2.enb = TRUE; /* t2 - waiting for changeover ack */
@ -900,7 +927,7 @@ int ftmod_ss7_mtp3_linkset_config(int id)
{
Pst pst;
SnMngmt cfg;
U16 c;
int c;
sng_link_set_t *k = &g_ftdm_sngss7_data.cfg.mtpLinkSet[id];
/* initalize the post structure */
@ -927,12 +954,13 @@ int ftmod_ss7_mtp3_linkset_config(int id)
cfg.t.cfg.s.snLnkSet.lnkSetType = k->linkType; /* link type */
cfg.t.cfg.s.snLnkSet.adjDpc = k->apc; /* adjacent DPC */
cfg.t.cfg.s.snLnkSet.nmbActLnkReqd = k->minActive; /* minimum number of active links */
cfg.t.cfg.s.snLnkSet.nmbCmbLnkSet = 1; /* number of combined link sets */
for (c = 0; c < LSN_MAXCMBLNK; c++) {
cfg.t.cfg.s.snLnkSet.cmbLnkSet[c].cmbLnkSetId = c+1;
cfg.t.cfg.s.snLnkSet.nmbCmbLnkSet = k->numLinks; /* number of combined link sets */
for(c = 0; c < k->numLinks;c++) {
cfg.t.cfg.s.snLnkSet.cmbLnkSet[c].cmbLnkSetId = k->links[c];
cfg.t.cfg.s.snLnkSet.cmbLnkSet[c].lnkSetPrior = 0;
}
return(sng_cfg_mtp3(&pst, &cfg));
}
@ -1209,12 +1237,12 @@ int ftmod_ss7_isup_ckt_config(int id)
cfg.t.cfg.s.siCir.typeCntrl = k->typeCntrl; /* type of control */
cfg.t.cfg.s.siCir.contReq = FALSE; /* continuity check required */
#if (SI_218_COMP || SS7_ANS88 || SS7_ANS92 || SS7_ANS95 || SS7_BELL)
cfg.t.cfg.s.siCir.firstCic =; /* First cic in the circuit group */
cfg.t.cfg.s.siCir.numCir =; /* Number of circuits in the circuit group */
cfg.t.cfg.s.siCir.firstCic = 1; /* First cic in the circuit group */
cfg.t.cfg.s.siCir.numCir = 24; /* Number of circuits in the circuit group */
cfg.t.cfg.s.siCir.nonSS7Con = TRUE; /* connecting to non SS7 network */
cfg.t.cfg.s.siCir.outTrkGrpN =; /* outgoing trunk group number (For EXM) */
cfg.t.cfg.s.siCir.cvrTrkClli =; /* Trunk Group number (For CVR validation) */
cfg.t.cfg.s.siCir.clli =; /* common language location identifier */
cfg.t.cfg.s.siCir.outTrkGrpN.length = 0; /* outgoing trunk group number (For EXM) */
cfg.t.cfg.s.siCir.cvrTrkClli.length = 0; /* Trunk Group number (For CVR validation) */
cfg.t.cfg.s.siCir.clli.length = 0; /* common language location identifier */
#endif
cfg.t.cfg.s.siCir.cirTmr.t3.enb = TRUE; /* t3 timer - overload received */
cfg.t.cfg.s.siCir.cirTmr.t3.val = k->t3;

View File

@ -48,8 +48,6 @@ static ftdm_status_t handle_print_usuage(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_blocks(ftdm_stream_handle_t *stream, int span, int chan, int verbose);
static ftdm_status_t handle_set_unblks(ftdm_stream_handle_t *stream, int span, int chan, int verbose);
static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name);
static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *name);
@ -63,6 +61,21 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int chan, int verbose);
static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose);
static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int chan, int verbose);
static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int chan, int verbose);
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_activate_link(ftdm_stream_handle_t *stream, char *name);
static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *name);
static ftdm_status_t handle_activate_linkset(ftdm_stream_handle_t *stream, char *name);
static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, char *name);
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_linkset(ftdm_stream_handle_t *stream, char *name);
@ -282,20 +295,12 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "block")) {
} else if (!strcasecmp(argv[c], "inhibit")) {
/**************************************************************************/
if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
c++;
if (!strcasecmp(argv[c], "span")) {
/**********************************************************************/
if (check_arg_count(argc, 5)) goto handle_cli_error_argc;
if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan;
handle_set_blocks(stream, span, chan, verbose);
/**********************************************************************/
} else if (!strcasecmp(argv[c], "link")) {
if (!strcasecmp(argv[c], "link")) {
/**********************************************************************/
if (check_arg_count(argc, 3)) goto handle_cli_error_argc;
c++;
@ -309,7 +314,26 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "unblock")) {
} else if (!strcasecmp(argv[c], "uninhibit")) {
/**************************************************************************/
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_set_uninhibit(stream, argv[c]);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"unblock\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "blo")) {
/**************************************************************************/
if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
c++;
@ -320,18 +344,101 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan;
handle_set_unblks(stream, span, chan, verbose);
/**********************************************************************/
} else if (!strcasecmp(argv[c], "link")) {
/**********************************************************************/
if (check_arg_count(argc, 3)) goto handle_cli_error_argc;
c++;
handle_set_uninhibit(stream, argv[c]);
handle_tx_blo(stream, span, chan, verbose);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"unblock\" command\n");
stream->write_function(stream, "Unknown \"block\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "ubl")) {
/**************************************************************************/
if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
c++;
if (!strcasecmp(argv[c], "span")) {
/**********************************************************************/
if (check_arg_count(argc, 5)) goto handle_cli_error_argc;
if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan;
handle_tx_ubl(stream, span, chan, verbose);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"ubl\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "cgb")) {
/**************************************************************************/
if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
c++;
if (!strcasecmp(argv[c], "span")) {
/**********************************************************************/
if (check_arg_count(argc, 5)) goto handle_cli_error_argc;
if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan;
c = c + 4;
if (check_arg_count(argc, 7)) goto handle_cli_error_argc;
if (!strcasecmp(argv[c], "range")) {
/******************************************************************/
c++;
range = atoi(argv[c]);
/******************************************************************/
} else {
/******************************************************************/
stream->write_function(stream, "Unknown \"cgb range\" command\n");
goto handle_cli_error;
/******************************************************************/
}
handle_tx_cgb(stream, span, chan, range, verbose);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"cgb\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "cgu")) {
/**************************************************************************/
if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
c++;
if (!strcasecmp(argv[c], "span")) {
/**********************************************************************/
if (check_arg_count(argc, 5)) goto handle_cli_error_argc;
if (extract_span_chan(argv, c, &span, &chan)) goto handle_cli_error_span_chan;
c = c + 4;
if (check_arg_count(argc, 7)) goto handle_cli_error_argc;
if (!strcasecmp(argv[c], "range")) {
/******************************************************************/
c++;
range = atoi(argv[c]);
/******************************************************************/
} else {
/******************************************************************/
stream->write_function(stream, "Unknown \"cgu range\" command\n");
goto handle_cli_error;
/******************************************************************/
}
handle_tx_cgu(stream, span, chan, range, verbose);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"cgu\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
@ -389,7 +496,97 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
stream->write_function(stream, "Unknown \"grs\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "lpo")) {
/**************************************************************************/
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_tx_lpo(stream, argv[c]);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"lpo\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "lpr")) {
/**************************************************************************/
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_tx_lpr(stream, argv[c]);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"lpr\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "activate")) {
/**************************************************************************/
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_activate_link(stream, argv[c]);
/**********************************************************************/
}else if (!strcasecmp(argv[c], "linkset")) {
/**********************************************************************/
if (check_arg_count(argc, 3)) goto handle_cli_error_argc;
c++;
handle_activate_linkset(stream, argv[c]);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"activate\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else if (!strcasecmp(argv[c], "deactivate")) {
/**************************************************************************/
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_deactivate_link(stream, argv[c]);
/**********************************************************************/
}else if (!strcasecmp(argv[c], "linkset")) {
/**********************************************************************/
if (check_arg_count(argc, 3)) goto handle_cli_error_argc;
c++;
handle_deactivate_linkset(stream, argv[c]);
/**********************************************************************/
} else {
/**********************************************************************/
stream->write_function(stream, "Unknown \"deactivate\" command\n");
goto handle_cli_error;
/**********************************************************************/
}
/**************************************************************************/
} else {
/**************************************************************************/
@ -433,10 +630,22 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream)
stream->write_function(stream, "ftdm ss7 show inreset span X chan Y\n");
stream->write_function(stream, "\n");
stream->write_function(stream, "Ftmod_sangoma_ss7 circuit control:\n");
stream->write_function(stream, "ftdm ss7 block span X chan Y\n");
stream->write_function(stream, "ftdm ss7 unblk span X chan Y\n");
stream->write_function(stream, "ftdm ss7 blo span X chan Y\n");
stream->write_function(stream, "ftdm ss7 ubl span X chan Y\n");
stream->write_function(stream, "ftdm ss7 rsc span X chan Y\n");
stream->write_function(stream, "ftdm ss7 grs span X chan Y range Z\n");
stream->write_function(stream, "ftdm ss7 cgb span X chan Y range Z\n");
stream->write_function(stream, "ftdm ss7 cgu span X chan Y range Z\n");
stream->write_function(stream, "\n");
stream->write_function(stream, "Ftmod_sangoma_ss7 link control:\n");
stream->write_function(stream, "ftdm ss7 inhibit link X\n");
stream->write_function(stream, "ftdm ss7 uninhibit link X\n");
stream->write_function(stream, "ftdm ss7 activate link X\n");
stream->write_function(stream, "ftdm ss7 deactivate link X\n");
stream->write_function(stream, "ftdm ss7 activate linkset X\n");
stream->write_function(stream, "ftdm ss7 deactivate linkset X\n");
stream->write_function(stream, "ftdm ss7 lpo link X\n");
stream->write_function(stream, "ftdm ss7 lpr link X\n");
stream->write_function(stream, "\n");
return FTDM_SUCCESS;
@ -811,87 +1020,100 @@ static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span,
/******************************************************************************/
static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
{
int x;
sngss7_chan_data_t *ss7_info;
ftdm_channel_t *ftdmchan;
int lspan;
int lchan;
ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN;
int x;
sngss7_chan_data_t *ss7_info;
ftdm_channel_t *ftdmchan;
int lspan;
int lchan;
ftdm_signaling_status_t sigstatus = FTDM_SIG_STATE_DOWN;
sng_isup_ckt_t *ckt;
x=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;
ftdmchan = ss7_info->ftdmchan;
/* extract the circuit to make it easier to work with */
ckt = &g_ftdm_sngss7_data.cfg.isupCkt[x];
/* if span == 0 then all spans should be printed */
if (span == 0) {
lspan = ftdmchan->physical_span_id;
lspan = ckt->span;
} else {
lspan = span;
}
/* if chan == 0 then all chans should be printed */
if (chan == 0) {
lchan = ftdmchan->physical_chan_id;
lchan = ckt->chan;
} else {
lchan = chan;
}
if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) {
/* grab the signaling_status */
ftdm_channel_get_sig_status(ftdmchan, &sigstatus);
/* check if this circuit is one of the circuits we're interested in */
if ((ckt->span == lspan) && (ckt->chan == lchan)) {
if (ckt->type == HOLE) {
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|NOT USED\n",
ckt->span,
ckt->chan,
ckt->cic);
} else if (ckt->type == SIG) {
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|SIGNALING LINK\n",
ckt->span,
ckt->chan,
ckt->cic);
} else {
ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
ftdmchan = ss7_info->ftdmchan;
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|sig_status=%s|state=%s|",
ftdmchan->physical_span_id,
ftdmchan->physical_chan_id,
ss7_info->circuit->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_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, "\n");
/* grab the signaling_status */
ftdm_channel_get_sig_status(ftdmchan, &sigstatus);
stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|sig_status=%s|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_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, "\n");
} /* if ( hole, sig, voice) */
} /* if ( span and chan) */
} /* if ( cic != 0) */
/* go the next circuit */
x++;
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */
@ -899,7 +1121,7 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
return FTDM_SUCCESS;
}
/******************************************************************************/
static ftdm_status_t handle_set_blocks(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
{
int x;
sngss7_chan_data_t *ss7_info;
@ -934,7 +1156,12 @@ static ftdm_status_t handle_set_blocks(ftdm_stream_handle_t *stream, int span, i
/* check if there is a pending state change|give it a bit to clear */
if (check_for_state_change(ftdmchan)) {
SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic);
/* check if we need to die */
SS7_ASSERT;
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
/* move to the next channel */
continue;
} else {
/* throw the ckt block flag */
sngss7_set_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);
@ -960,7 +1187,7 @@ static ftdm_status_t handle_set_blocks(ftdm_stream_handle_t *stream, int span, i
}
/******************************************************************************/
static ftdm_status_t handle_set_unblks(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
{
int x;
sngss7_chan_data_t *ss7_info;
@ -995,7 +1222,12 @@ static ftdm_status_t handle_set_unblks(ftdm_stream_handle_t *stream, int span, i
/* check if there is a pending state change|give it a bit to clear */
if (check_for_state_change(ftdmchan)) {
SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic);
/* check if we need to die */
SS7_ASSERT;
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
/* move to the next channel */
continue;
} else {
/* throw the ckt block flag */
sngss7_set_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX);
@ -1154,17 +1386,17 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na
/******************************************************************************/
static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
{
int x;
sngss7_chan_data_t *ss7_info;
ftdm_channel_t *ftdmchan;
int lspan;
int lchan;
int x;
sngss7_chan_data_t *sngss7_info;
ftdm_channel_t *ftdmchan;
int lspan;
int lchan;
x=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;
ftdmchan = ss7_info->ftdmchan;
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
ftdmchan = sngss7_info->ftdmchan;
/* if span == 0 then all spans should be printed */
if (span == 0) {
@ -1181,27 +1413,31 @@ static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int c
}
if ((ftdmchan->physical_span_id == lspan) && (ftdmchan->physical_chan_id == lchan)) {
/* now that we have the right channel...put a lock on it so no-one else can use it */
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
/* check if there is a pending state change|give it a bit to clear */
if (check_for_state_change(ftdmchan)) {
SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", ss7_info->circuit->cic);
SS7_ASSERT;
} else {
/* throw the ckt block flag */
sngss7_set_flag(ss7_info, FLAG_RESET_TX);
/* throw the reset flag */
sngss7_set_flag(sngss7_info, FLAG_RESET_TX);
/* set the channel to suspended state */
switch (ftdmchan->state) {
/**************************************************************************/
case FTDM_CHANNEL_STATE_RESTART:
/* go to idle so that we can redo the restart state*/
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IDLE);
break;
/**************************************************************************/
default:
/* set the state of the channel to restart...the rest is done by the chan monitor */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
break;
/**************************************************************************/
}
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
} /* if ( span and chan) */
} /* if ( cic != 0) */
} /* if ( cic == voice) */
/* go the next circuit */
x++;
@ -1240,7 +1476,12 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
/* check if there is a pending state change|give it a bit to clear */
if (check_for_state_change(ftdmchan)) {
SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", sngss7_info->circuit->cic);
/* check if we need to die */
SS7_ASSERT;
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
/* move to the next channel */
continue;
} else {
/* throw the grp reset flag */
sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);
@ -1270,6 +1511,355 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c
return FTDM_SUCCESS;
}
/******************************************************************************/
static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose)
{
int x;
sngss7_chan_data_t *sngss7_info;
ftdm_channel_t *ftdmchan;
ftdm_channel_t *main_chan = NULL;
sngss7_span_data_t *sngss7_span;
int byte = 0;
int bit = 0;
ftdm_sigmsg_t sigev;
memset (&sigev, 0, sizeof (sigev));
if (range > 31) {
stream->write_function(stream, "Invalid range value %d", range);
return FTDM_SUCCESS;
}
x=1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
/* extract the channel and span info for this circuit */
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
ftdmchan = sngss7_info->ftdmchan;
sngss7_span = ftdmchan->span->mod_data;
/* check if this circuit is part of the block */
if ((ftdmchan->physical_span_id == span) &&
((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) {
/* now that we have the right channel...put a lock on it so no-one else can use it */
ftdm_mutex_lock(ftdmchan->mutex);
/* throw the grp maint. block flag */
sngss7_set_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
/* bring the sig status down */
sigev.chan_id = ftdmchan->chan_id;
sigev.span_id = ftdmchan->span_id;
sigev.channel = ftdmchan;
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_DOWN;
ftdm_span_send_signal(ftdmchan->span, &sigev);
/* if this is the first channel in the range */
if (ftdmchan->physical_chan_id == chan) {
/* attach the cgb information */
main_chan = ftdmchan;
sngss7_span->tx_cgb.circuit = sngss7_info->circuit->id;
sngss7_span->tx_cgb.range = range-1;
sngss7_span->tx_cgb.type = 0; /* maintenace block */
} /* if (ftdmchan->physical_chan_id == chan) */
/* update the status field */
sngss7_span->tx_cgb.status[byte] = (sngss7_span->tx_cgb.status[byte] | (1 << bit));
/* update the bit and byte counter*/
bit ++;
if (bit == 8) {
byte++;
bit = 0;
}
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
} /* if ( span and chan) */
} /* if ( cic == voice) */
/* go the next circuit */
x++;
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */
/* send the circuit group block */
ft_to_sngss7_cgb(main_chan);
return FTDM_SUCCESS;
}
/******************************************************************************/
static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose)
{
int x;
sngss7_chan_data_t *sngss7_info;
ftdm_channel_t *ftdmchan;
ftdm_channel_t *main_chan = NULL;
sngss7_span_data_t *sngss7_span;
int byte = 0;
int bit = 0;
ftdm_sigmsg_t sigev;
memset (&sigev, 0, sizeof (sigev));
if (range > 31) {
stream->write_function(stream, "Invalid range value %d", range);
return FTDM_SUCCESS;
}
x=1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
/* extract the channel and span info for this circuit */
sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
ftdmchan = sngss7_info->ftdmchan;
sngss7_span = ftdmchan->span->mod_data;
/* check if this circuit is part of the block */
if ((ftdmchan->physical_span_id == span) &&
((ftdmchan->physical_chan_id >= chan) && (ftdmchan->physical_chan_id < (chan+range)))) {
/* now that we have the right channel...put a lock on it so no-one else can use it */
ftdm_mutex_lock(ftdmchan->mutex);
/* throw the grp maint. block flag */
sngss7_clear_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);
/* bring the sig status up */
sigev.chan_id = ftdmchan->chan_id;
sigev.span_id = ftdmchan->span_id;
sigev.channel = ftdmchan;
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_UP;
ftdm_span_send_signal(ftdmchan->span, &sigev);
/* if this is the first channel in the range */
if (ftdmchan->physical_chan_id == chan) {
/* attach the cgb information */
main_chan = ftdmchan;
sngss7_span->tx_cgu.circuit = sngss7_info->circuit->id;
sngss7_span->tx_cgu.range = range-1;
sngss7_span->tx_cgu.type = 0; /* maintenace block */
} /* if (ftdmchan->physical_chan_id == chan) */
/* update the status field */
sngss7_span->tx_cgu.status[byte] = (sngss7_span->tx_cgu.status[byte] | (1 << bit));
/* update the bit and byte counter*/
bit ++;
if (bit == 8) {
byte++;
bit = 0;
}
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
} /* if ( span and chan) */
} /* if ( cic == voice) */
/* go the next circuit */
x++;
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */
/* send the circuit group block */
ft_to_sngss7_cgu(main_chan);
return FTDM_SUCCESS;
}
/******************************************************************************/
static ftdm_status_t handle_activate_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.mtpLink[x].id != 0) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
/* send the uninhibit request */
if (ftmod_ss7_activate_mtplink(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]);
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_deactivate_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.mtpLink[x].id != 0) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
/* send the deactivate request */
if (ftmod_ss7_deactivate2_mtplink(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]);
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_linkset(ftdm_stream_handle_t *stream, char *name)
{
int x = 0;
/* find the linkset request by it's name */
x = 1;
while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
/* send the activate request */
if (ftmod_ss7_activate_mtplinkSet(x)) {
stream->write_function(stream, "Failed to activate linkset=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the linkset */
handle_status_linkset(stream, &name[0]);
goto success;
}
/* move to the next linkset */
x++;
} /* while (id != 0) */
stream->write_function(stream, "Could not find linkset=%s\n", name);
success:
return FTDM_SUCCESS;
}
/******************************************************************************/
static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, char *name)
{
int x = 0;
/* find the linkset request by it's name */
x = 1;
while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
/* send the deactivate request */
if (ftmod_ss7_deactivate2_mtplinkSet(x)) {
stream->write_function(stream, "Failed to deactivate linkset=%s\n", name);
return FTDM_FAIL;
}
/* print the new status of the linkset */
handle_status_linkset(stream, &name[0]);
goto success;
}
/* move to the next linkset */
x++;
} /* while (id != 0) */
stream->write_function(stream, "Could not find linkset=%s\n", name);
success:
return FTDM_SUCCESS;
}
/******************************************************************************/
static ftdm_status_t handle_tx_lpo(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.mtpLink[x].id != 0) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
/* send the uninhibit request */
if (ftmod_ss7_lpo_mtplink(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]);
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_tx_lpr(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.mtpLink[x].id != 0) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {
/* send the uninhibit request */
if (ftmod_ss7_lpr_mtplink(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]);
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 extract_span_chan(char *argv[10], int pos, int *span, int *chan)
{

View File

@ -50,6 +50,17 @@ 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_activate_mtplink(uint32_t id);
int ftmod_ss7_deactivate_mtplink(uint32_t id);
int ftmod_ss7_deactivate2_mtplink(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);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@ -64,7 +75,7 @@ int ft_to_sngss7_activate_all(void)
if (ftmod_ss7_enable_isap(x)) {
SS7_CRITICAL("ISAP %d Enable: NOT OK\n", x);
SS7_ASSERT;
return 1;
} else {
SS7_INFO("ISAP %d Enable: OK\n", x);
}
@ -83,7 +94,7 @@ int ft_to_sngss7_activate_all(void)
if (ftmod_ss7_enable_nsap(x)) {
SS7_CRITICAL("NSAP %d Enable: NOT OK\n", x);
SS7_ASSERT;
return 1;
} else {
SS7_INFO("NSAP %d Enable: OK\n", x);
}
@ -102,7 +113,7 @@ int ft_to_sngss7_activate_all(void)
if (ftmod_ss7_enable_mtpLinkSet(x)) {
SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
SS7_ASSERT;
return 1;
} else {
SS7_INFO("LinkSet \"%s\" Enable: OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
}
@ -271,6 +282,248 @@ int ftmod_ss7_uninhibit_mtplink(uint32_t id)
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_activate_mtplink(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.mtpLink[id].id;
cntrl.t.cntrl.action = AENA; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_deactivate_mtplink(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.mtpLink[id].id;
cntrl.t.cntrl.action = ADISIMM; /* Deactivate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_deactivate2_mtplink(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.mtpLink[id].id;
cntrl.t.cntrl.action = ADISIMM_L2; /* Deactivate...layer 2 only */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_activate_mtplinkSet(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 = STLNKSET;
cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
cntrl.t.cntrl.action = AACTLNKSET; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_deactivate_mtplinkSet(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 = STLNKSET;
cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
cntrl.t.cntrl.action = ADEACTLNKSET; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_deactivate2_mtplinkSet(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 = STLNKSET;
cntrl.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
cntrl.t.cntrl.action = ADEACTLNKSET_L2; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_lpo_mtplink(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.mtpLink[id].id;
cntrl.t.cntrl.action = ACTION_LPO; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
int ftmod_ss7_lpr_mtplink(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.mtpLink[id].id;
cntrl.t.cntrl.action = ACTION_LPR; /* Activate */
cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
return (sng_cntrl_mtp3(&pst, &cntrl));
}
/******************************************************************************/
/******************************************************************************/
/* For Emacs:
* Local Variables:

View File

@ -109,6 +109,10 @@ void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta)
/******************************************************************************/
void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
{
char buf[50];
int x = 1;
memset(buf, '\0', sizeof(buf));
switch (sta->t.usta.alarm.category) {
/**************************************************************************/
@ -126,23 +130,39 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
case (LSD_EVENT_REMOTE_CONG_END):
case (LSD_EVENT_RX_REMOTE_SIPO):
/* 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]) {
break;
}
x++;
}
if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
}
switch (sta->t.usta.alarm.cause) {
/******************************************************************/
case (LCM_CAUSE_UNKNOWN):
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d] %s\n",
sta->t.usta.evntParm[0],
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event));
break;
/******************************************************************/
case (LCM_CAUSE_MGMT_INITIATED):
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d][MGMT] %s\n",
sta->t.usta.evntParm[0],
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s[MGMT] %s\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event));
break;
/******************************************************************/
default:
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d] %s (***unknown cause***)\n",
sta->t.usta.evntParm[0],
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s (***unknown cause***)\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event));
break;
/******************************************************************/
@ -150,23 +170,71 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
break;
/**********************************************************************/
case (LSD_EVENT_PROT_ERR):
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d] %s : %s\n",
sta->t.usta.evntParm[0],
/* 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]) {
break;
}
x++;
}
if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event),
DECODE_LSD_CAUSE(sta->t.usta.alarm.cause));
break;
/**********************************************************************/
case (LSD_EVENT_ALIGN_LOST):
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d] %s : %s\n",
sta->t.usta.evntParm[0],
/* 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]) {
break;
}
x++;
}
if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event),
DECODE_DISC_REASON(sta->t.usta.evntParm[1]));
break;
/**********************************************************************/
case (LSD_EVENT_RTB_FULL):
case (LSD_EVENT_RTB_FULL_OVER):
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d] %s : RTB Queue Len(%d)|Oldest BSN(%d)|Tx Queue Len(%d)|Outstanding Frames(%d)\n",
sta->t.usta.evntParm[0],
/* 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]) {
break;
}
x++;
}
if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[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",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event),
sta->t.usta.evntParm[1],
sta->t.usta.evntParm[2],
@ -175,15 +243,47 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
break;
/**********************************************************************/
case (LSD_EVENT_NEG_ACK):
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d] %s : RTB Queue Len(%d)\n",
sta->t.usta.evntParm[0],
/* 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]) {
break;
}
x++;
}
if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : RTB Queue Len(%d)\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event),
sta->t.usta.evntParm[1]);
break;
/**********************************************************************/
case (LSD_EVENT_DAT_CFM_SDT):
ftdm_log(FTDM_LOG_ERROR,"[MTP2][SAPID:%d] %s : %d\n",
sta->t.usta.evntParm[0],
/* 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]) {
break;
}
x++;
}
if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
} else {
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
}
ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %d\n",
buf,
DECODE_LSD_EVENT(sta->t.usta.alarm.event),
DECODE_DISC_REASON(sta->t.usta.evntParm[1]));
break;
@ -251,15 +351,35 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
/******************************************************************************/
void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
{
char buf[50];
int x = 1;
memset(buf, '\0', sizeof(buf));
switch (sta->hdr.elmId.elmnt) {
/**************************************************************************/
case (STDLSAP):
/* 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) {
break;
}
x++;
}
if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {
sprintf(buf, "[SAPID:%d]", sta->hdr.elmId.elmntInst1);
} else {
sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtpLink[x].name);
}
switch (sta->t.usta.alarm.event) {
/**********************************************************************/
case (LSN_EVENT_INV_OPC_OTHER_END):
ftdm_log(FTDM_LOG_ERROR,"[MTP3][SAPID:%d] %s : %s : OPC(0x%X%X%X%X)\n",
sta->hdr.elmId.elmntInst1,
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),
DECODE_LSN_CAUSE(sta->t.usta.alarm.cause),
sta->t.usta.evntParm[3],
@ -269,16 +389,16 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
break;
/**********************************************************************/
case (LSN_EVENT_INV_SLC_OTHER_END):
ftdm_log(FTDM_LOG_ERROR,"[MTP3][SAPID:%d] %s : %s : SLC(%d)\n",
sta->hdr.elmId.elmntInst1,
ftdm_log(FTDM_LOG_ERROR,"[MTP3]%s %s : %s : SLC(%d)\n",
buf,
DECODE_LSN_EVENT(sta->t.usta.alarm.event),
DECODE_LSN_CAUSE(sta->t.usta.alarm.cause),
sta->t.usta.evntParm[0]);
break;
/**********************************************************************/
default:
ftdm_log(FTDM_LOG_ERROR,"[MTP3][SAPID:%d] %s(%d) : %s(%d)\n",
sta->hdr.elmId.elmntInst1,
ftdm_log(FTDM_LOG_ERROR,"[MTP3]%s %s(%d) : %s(%d)\n",
buf,
DECODE_LSN_EVENT(sta->t.usta.alarm.event),
sta->t.usta.alarm.event,
DECODE_LSN_CAUSE(sta->t.usta.alarm.cause),
@ -303,13 +423,53 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
break;
/**************************************************************************/
case (STROUT):
ftdm_log(FTDM_LOG_ERROR,"[MTP3][DPC:0x%d%d%d%d] %s : %s\n",
sta->t.usta.evntParm[0],
sta->t.usta.evntParm[1],
sta->t.usta.evntParm[2],
sta->t.usta.evntParm[3],
DECODE_LSN_EVENT(sta->t.usta.alarm.event),
DECODE_LSN_CAUSE(sta->t.usta.alarm.cause));
switch (sta->t.usta.alarm.event) {
/**********************************************************************/
case (LSN_EVENT_RX_TRANSFER_MSG):
switch (sta->t.usta.evntParm[5]) {
/******************************************************************/
case (0x23):
ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFC\n");
break;
/******************************************************************/
case (0x34):
ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFR\n");
break;
/******************************************************************/
case (0x54):
ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFA\n");
break;
/******************************************************************/
case (0x14):
ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFP\n");
break;
/******************************************************************/
case (0x24):
ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFP (cluster)\n");
break;
/******************************************************************/
case (0x64):
ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFA (cluster)\n");
break;
/******************************************************************/
case (0x44):
ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFR (cluster)\n");
break;
/******************************************************************/
} /* switch (sta->t.usta.evntParm[5]) */
break;
/**********************************************************************/
default:
ftdm_log(FTDM_LOG_ERROR,"[MTP3][DPC:0x%d%d%d%d] %s : %s\n",
sta->t.usta.evntParm[0],
sta->t.usta.evntParm[1],
sta->t.usta.evntParm[2],
sta->t.usta.evntParm[3],
DECODE_LSN_EVENT(sta->t.usta.alarm.event),
DECODE_LSN_CAUSE(sta->t.usta.alarm.cause));
break;
/**********************************************************************/
} /* switch (sta->t.usta.alarm.event) */
break;
/**************************************************************************/
default:
@ -336,6 +496,12 @@ void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta)
/* initalize the msg variable to NULLs */
memset(&msg[0], '\0', sizeof(&msg));
/* if the event is REMOTE/LOCAL we don't need to print these */
if ((sta->t.usta.alarm.event == LSI_EVENT_REMOTE) ||
(sta->t.usta.alarm.event == LSI_EVENT_LOCAL)) {
return;
}
/* point p to the first spot in msg */
p = &msg[0];
@ -568,6 +734,8 @@ void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta)
DECODE_LSI_EVENT(sta->t.usta.alarm.event),
DECODE_LSI_CAUSE(sta->t.usta.alarm.cause));
return;
} /* handle_isup_alarm */
/******************************************************************************/

View File

@ -46,7 +46,7 @@ ftdm_sngss7_data_t g_ftdm_sngss7_data;
/* PROTOTYPES *****************************************************************/
static void *ftdm_sangoma_ss7_run (ftdm_thread_t * me, void *obj);
static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan);
void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan);
static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_event);
static ftdm_status_t ftdm_sangoma_ss7_stop (ftdm_span_t * span);
@ -272,10 +272,8 @@ 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;
sngss7_chan_data_t *sngss7_info = NULL;
sngss7_event_data_t *sngss7_event = NULL;
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
int i;
ftdm_log (FTDM_LOG_INFO, "ftmod_sangoma_ss7 monitor thread for span=%u started.\n", ftdmspan->span_id);
@ -344,73 +342,22 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
/**********************************************************************/
} /* switch ((ftdm_interrupt_wait(ftdm_sangoma_ss7_int, 100))) */
/* extract the span data structure */
sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
/* check if there is a GRA to proccess on the span */
if (sngss7_span->rx_gra.range > 0) {
check_if_rx_gra_started(ftdmspan);
} /* if (sngss7->span->rx_gra.range > 0) */
/* check if there is a GRS being processed on the span */
if (sngss7_span->rx_grs.range > 0) {
ftdm_log(FTDM_LOG_DEBUG, "Found Rx GRS on span %d...checking circuits\n", ftdmspan->span_id);
/*SS7_DEBUG("Found Rx GRS on span %d...checking circuits\n", ftdmspan->span_id);*/
/* check if the rx_grs has started */
check_if_rx_grs_started(ftdmspan);
/* check all the circuits in the range to see if they are done resetting */
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
/* check if the rx_grs has cleared */
check_if_rx_grs_processed(ftdmspan);
} /* if (sngss7_span->rx_grs.range > 0) */
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
SS7_ASSERT;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
/* 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)) {
/* this channel is still resetting...do nothing */
goto GRS_UNLOCK_ALL;
} /* if (!sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) */
} else {
/* state change pending */
goto GRS_UNLOCK_ALL;
}
} /* for ( i = circuit; i < (circuit + range + 1); i++) */
SS7_DEBUG("All circuits out of reset for GRS: circuit=%d, range=%d\n",
sngss7_span->rx_grs.circuit,
sngss7_span->rx_grs.range);
/* check all the circuits in the range to see if they are done resetting */
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n",i);
SS7_ASSERT;
}
/* throw the GRP reset flag complete flag */
sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);
/* move the channel to the down state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
} /* for ( i = circuit; i < (circuit + range + 1); i++) */
GRS_UNLOCK_ALL:
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
SS7_ASSERT;
}
/* unlock the channel */
ftdm_mutex_unlock(ftdmchan->mutex);
}
} /* if (ftdmspan->grs.range > 0) */
/* check each channel on the span to see if there is an un-procressed SUS/RES flag */
check_for_res_sus_flag(ftdmspan);
} /* master while loop */
/* clear the IN_THREAD flag so that we know the thread is done */
@ -513,11 +460,11 @@ static void ftdm_sangoma_ss7_process_stack_event (sngss7_event_data_t *sngss7_ev
}
/******************************************************************************/
static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
{
ftdm_sigmsg_t sigev;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
int i = 0;
ftdm_sigmsg_t sigev;
memset (&sigev, 0, sizeof (sigev));
@ -544,10 +491,13 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
i++;
}
/* check if the end of pulsing character has arrived or the right number of digits */
if (ftdmchan->caller_data.dnis.digits[i] == 0xF) {
/* check if the end of pulsing (ST) character has arrived or the right number of digits */
if (ftdmchan->caller_data.dnis.digits[i-1] == 'F') {
SS7_DEBUG_CHAN(ftdmchan, "Received the end of pulsing character %s\n", "");
/* remove the ST */
ftdmchan->caller_data.dnis.digits[i-1] = '\0';
/*now go to the RING state */
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RING);
@ -569,7 +519,7 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
sngss7_info->t35.beat,
sngss7_info->t35.callback,
&sngss7_info->t35,
&sngss7_info->t35.heartbeat_timer)) {
&sngss7_info->t35.hb_timer_id)) {
SS7_ERROR ("Unable to schedule timer, hanging up call!\n");
@ -594,8 +544,8 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
/* kill t35 if active */
if (sngss7_info->t35.heartbeat_timer) {
ftdm_sched_cancel_timer (sngss7_info->t35.sched,&sngss7_info->t35.heartbeat_timer);
if (sngss7_info->t35.hb_timer_id) {
ftdm_sched_cancel_timer (sngss7_info->t35.sched, sngss7_info->t35.hb_timer_id);
}
SS7_DEBUG_CHAN(ftdmchan, "Sending incoming call from %s to %s to FTDM core\n",
@ -785,14 +735,19 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/**************************************************************************/
case FTDM_CHANNEL_STATE_DOWN: /*the call is finished and removed */
if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) {
SS7_DEBUG("re-entering state from processing block/unblock request ... do nothing\n");
break;
}
/* check if there is a reset response that needs to be sent */
if (sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) {
/* send a RSC-RLC */
ft_to_sngss7_rsca (ftdmchan);
/* clear the reset flag */
sngss7_clear_flag (sngss7_info, FLAG_RESET_RX);
}
clear_rx_rsc_flags(sngss7_info);
} /* if (sngss7_test_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)) &&
@ -814,27 +769,24 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
/* clear the grp reset flag */
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);
clear_rx_grs_flags(sngss7_info);
}/* if ( sngss7_test_flag ( sngss7_info, FLAG_GRP_RESET_RX ) ) */
/* check if we got the reset response */
if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX_RSP)) {
/* clear the reset flag */
sngss7_clear_flag(sngss7_info, FLAG_RESET_TX_RSP);
sngss7_clear_flag(sngss7_info, FLAG_RESET_SENT);
sngss7_clear_flag(sngss7_info, FLAG_RESET_TX);
}
clear_tx_rsc_flags(sngss7_info);
} /* if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX_RSP)) */
if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {
/* clear the reset flag */
sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);
sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_TX);
sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_BASE);
sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_SENT);
}
clear_tx_grs_flags(sngss7_info);
/* clean out the spans GRA structure */
sngss7_span_data_t *span = ftdmchan->span->mod_data;
span->rx_gra.circuit = 0;
span->rx_gra.range = 0;
} /* if (sngss7_test_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) ||
@ -846,16 +798,25 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
!(sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
!(sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX))) {
/* check if the sig status is down, and bring it up if it isn't */
if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", "");
/* all flags are down so we can bring up the sig status */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_UP;
ftdm_span_send_signal (ftdmchan->span, &sigev);
}
/* 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))) {
/* check if the sig status is down, and bring it up if it isn't */
if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", "");
/* all flags are down so we can bring up the sig status */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_UP;
ftdm_span_send_signal (ftdmchan->span, &sigev);
} /* 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);
/* there is still another reset pending so go back to reset*/
@ -864,8 +825,8 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
} /* if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) */
/* check if t35 is active */
if (sngss7_info->t35.heartbeat_timer) {
ftdm_sched_cancel_timer (sngss7_info->t35.sched, &sngss7_info->t35.heartbeat_timer);
if (sngss7_info->t35.hb_timer_id) {
ftdm_sched_cancel_timer (sngss7_info->t35.sched, sngss7_info->t35.hb_timer_id);
}
/* clear all of the call specific data store in the channel structure */
@ -1012,34 +973,52 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
SS7_DEBUG_CHAN(ftdmchan,"Current flags: 0x%X\n", sngss7_info->flags);
/**********************************************************************/
if (sngss7_test_flag (sngss7_info, FLAG_INFID_PAUSED)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE flag %s\n", "");
/* bring the channel signaling status to down */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_DOWN;
ftdm_span_send_signal (ftdmchan->span, &sigev);
if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing RESUME%s\n", "");
/* check the last state and return to it to allow the call to finish */
goto suspend_goto_last;
}
if (sngss7_test_flag (sngss7_info, FLAG_INFID_RESUME)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing RESUME flag %s\n", "");
/* the reset flag is set for the first channel in the span at handle_resume */
/* clear the resume flag */
/* clear the RESUME flag */
sngss7_clear_flag(sngss7_info, FLAG_INFID_RESUME);
/* go to restart state */
goto suspend_goto_last;
}
/* 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))) {
/* go back to the reset state */
goto suspend_goto_restart;
} else {
/* bring the sig status back up */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_UP;
ftdm_span_send_signal(ftdmchan->span, &sigev);
}
/* go back to the last state */
goto suspend_goto_last;
} /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */
if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE%s\n", "");
/* bring the sig status down */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_DOWN;
ftdm_span_send_signal(ftdmchan->span, &sigev);
/* go back to the last state */
goto suspend_goto_last;
} /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) { */
/**********************************************************************/
if (sngss7_test_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 */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_DOWN;
ftdm_span_send_signal(ftdmchan->span, &sigev);
/* send a BLA */
ft_to_sngss7_bla (ftdmchan);
@ -1053,6 +1032,11 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* clear the unblock flag */
sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);
/* bring the sig status up */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_UP;
ftdm_span_send_signal(ftdmchan->span, &sigev);
/* send a uba */
ft_to_sngss7_uba (ftdmchan);
@ -1064,6 +1048,11 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
if (sngss7_test_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 */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_DOWN;
ftdm_span_send_signal(ftdmchan->span, &sigev);
/* send a blo */
ft_to_sngss7_blo (ftdmchan);
@ -1077,6 +1066,11 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* clear the unblock flag */
sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX);
/* bring the sig status up */
sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
sigev.sigstatus = FTDM_SIG_STATE_UP;
ftdm_span_send_signal(ftdmchan->span, &sigev);
/* send a ubl */
ft_to_sngss7_ubl (ftdmchan);
@ -1117,14 +1111,10 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
ftdm_span_send_signal (ftdmchan->span, &sigev);
/* remove any reset flags */
sngss7_clear_flag (sngss7_info, FLAG_GRP_RESET_TX_RSP);
sngss7_clear_flag (sngss7_info, FLAG_GRP_RESET_TX);
sngss7_clear_flag (sngss7_info, FLAG_RESET_TX_RSP);
sngss7_clear_flag (sngss7_info, FLAG_RESET_TX);
sngss7_clear_flag (sngss7_info, FLAG_RESET_SENT);
sngss7_clear_flag (sngss7_info, FLAG_GRP_RESET_RX);
sngss7_clear_flag (sngss7_info, FLAG_RESET_RX);
sngss7_clear_flag (sngss7_info, FLAG_GRP_RESET_BASE);
clear_rx_grs_flags(sngss7_info);
clear_tx_grs_flags(sngss7_info);
clear_rx_rsc_flags(sngss7_info);
clear_tx_rsc_flags(sngss7_info);
/* bring the channel down */
goto suspend_goto_last;
@ -1133,8 +1123,14 @@ static void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
if (sngss7_test_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", "");;
/* throw the channel into reset from our side since it is already in reset from the remote side */
sngss7_set_flag (sngss7_info, FLAG_RESET_TX);
/* remove the UCIC block flag */
sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
/* remove the UCIC unblock flag */
sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
/* throw the channel into reset to sync states */
sngss7_set_flag(sngss7_info, FLAG_RESET_TX);
/* bring the channel into restart again */
goto suspend_goto_restart;
@ -1182,9 +1178,10 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
/* check if there is a pending state change, give it a bit to clear */
if (check_for_state_change(ftdmchan)) {
SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", sngss7_info->circuit->cic);
ftdm_mutex_unlock(ftdmchan->mutex);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
/* check if we need to die */
SS7_ASSERT;
/* end the request */
goto outgoing_fail;
};
/* check if the channel sig state is UP */
@ -1295,6 +1292,7 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
ftdm_channel_t *ftdmchan = NULL;
sngss7_chan_data_t *sngss7_info = NULL;
sngss7_span_data_t *sngss7_span = NULL;
sng_isup_inf_t *sngss7_intf = NULL;
int x;
@ -1304,15 +1302,26 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
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->mod_data;
sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
/* throw the pause flag */
sngss7_set_flag(sngss7_info, FLAG_INFID_PAUSED);
/* 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) {
@ -1320,7 +1329,10 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
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);
@ -1446,6 +1458,9 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_ss7_span_config)
static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init)
{
/*this function is called by the FT-core to load the signaling module */
uint32_t major = 0;
uint32_t minor = 0;
uint32_t build = 0;
ftdm_log (FTDM_LOG_INFO, "Loading ftmod_sangoma_ss7...\n");
@ -1454,6 +1469,8 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init)
sngss7_id = 0;
cmbLinkSetId = 1;
/* initalize the global gen_config flag */
g_ftdm_sngss7_data.gen_config = 0;
@ -1493,6 +1510,10 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init)
/* initalize sng_ss7 library */
sng_isup_init (&sng_event);
/* print the version of the library being used */
sng_isup_version(&major, &minor, &build);
SS7_INFO("Loaded LibSng-SS7 %d.%d.%d\n", major, minor, build);
/* crash on assert fail */
ftdm_global_set_crash_policy (FTDM_CRASH_ON_ASSERT);

View File

@ -79,7 +79,8 @@ typedef enum {
typedef enum {
CONFIGURED = (1 << 0),
ACTIVE = (1 << 1)
ACTIVE = (1 << 1),
SNGSS7_PAUSED = (1 << 7)
} sng_flag_t;
typedef struct sng_mtp_link {
@ -139,7 +140,6 @@ typedef struct sng_mtp_link {
uint32_t t23;
uint32_t t24;
uint32_t t25;
uint32_t t26;
uint32_t t27;
uint32_t t28;
uint32_t t29;
@ -163,6 +163,8 @@ typedef struct sng_link_set {
uint32_t flags;
uint32_t apc;
uint32_t linkType;
uint32_t switchType;
uint32_t ssf;
uint32_t minActive;
uint32_t numLinks;
uint32_t links[16];
@ -174,9 +176,11 @@ typedef struct sng_route {
uint32_t flags;
uint32_t dpc;
uint32_t cmbLinkSetId;
uint32_t linkSetId;
uint32_t linkType;
uint32_t switchType;
uint32_t ssf;
uint32_t nwId;
uint32_t isSTP;
uint32_t t6;
uint32_t t8;
@ -188,6 +192,7 @@ typedef struct sng_route {
uint32_t t19;
uint32_t t21;
uint32_t t25;
uint32_t t26;
} sng_route_t;
typedef struct sng_isup_intf {
@ -312,7 +317,7 @@ typedef struct ftdm_sngss7_data {
}ftdm_sngss7_data_t;
typedef struct sngss7_timer_data {
ftdm_timer_t *heartbeat_timer;
ftdm_timer_id_t hb_timer_id;
int beat;
int counter;
ftdm_sched_callback_t callback;
@ -329,6 +334,9 @@ typedef struct sngss7_glare_data {
typedef struct sngss7_group_data {
uint32_t circuit;
uint32_t range;
uint8_t status[255];
uint8_t type;
uint8_t cause;
}sngss7_group_data_t;
typedef struct sngss7_chan_data {
@ -347,7 +355,12 @@ typedef struct sngss7_chan_data {
typedef struct sngss7_span_data {
ftdm_sched_t *sched;
sngss7_group_data_t rx_grs;
sngss7_group_data_t rx_gra;
sngss7_group_data_t tx_grs;
sngss7_group_data_t rx_cgb;
sngss7_group_data_t tx_cgb;
sngss7_group_data_t rx_cgu;
sngss7_group_data_t tx_cgu;
ftdm_queue_t *event_queue;
}sngss7_span_data_t;
@ -376,8 +389,8 @@ typedef struct sngss7_event_data
typedef enum {
FLAG_RESET_RX = (1 << 0),
FLAG_RESET_TX = (1 << 1),
FLAG_RESET_RX = (1 << 0),
FLAG_RESET_TX = (1 << 1),
FLAG_RESET_SENT = (1 << 2),
FLAG_RESET_TX_RSP = (1 << 3),
FLAG_GRP_RESET_RX = (1 << 4),
@ -387,27 +400,25 @@ typedef enum {
FLAG_GRP_RESET_TX = (1 << 8),
FLAG_GRP_RESET_SENT = (1 << 9),
FLAG_GRP_RESET_TX_RSP = (1 << 10),
FLAG_REMOTE_REL = (1 << 11),
FLAG_LOCAL_REL = (1 << 12),
FLAG_GLARE = (1 << 13),
FLAG_INFID_RESUME = (1 << 14),
FLAG_INFID_PAUSED = (1 << 15),
FLAG_REMOTE_REL = (1 << 11),
FLAG_LOCAL_REL = (1 << 12),
FLAG_GLARE = (1 << 13),
FLAG_INFID_RESUME = (1 << 14),
FLAG_INFID_PAUSED = (1 << 15),
FLAG_CKT_UCIC_BLOCK = (1 << 16),
FLAG_CKT_UCIC_UNBLK = (1 << 17),
FLAG_CKT_LC_BLOCK_RX = (1 << 18),
FLAG_CKT_LC_UNBLK_RX = (1 << 19),
FLAG_CKT_MN_BLOCK_RX = (1 << 20),
FLAG_CKT_MN_BLOCK_TX = (1 << 21),
FLAG_CKT_MN_UNBLK_RX = (1 << 22),
FLAG_CKT_MN_UNBLK_RX = (1 << 21),
FLAG_CKT_MN_BLOCK_TX = (1 << 22),
FLAG_CKT_MN_UNBLK_TX = (1 << 23),
FLAG_GRP_HW_BLOCK_RX = (1 << 24),
FLAG_GRP_HW_BLOCK_TX = (1 << 25),
FLAG_GRP_MN_BLOCK_RX = (1 << 26),
FLAG_GRP_MN_BLOCK_TX = (1 << 27),
FLAG_GRP_HW_UNBLK_RX = (1 << 28),
FLAG_GRP_HW_UNBLK_TX = (1 << 29),
FLAG_GRP_MN_UNBLK_RX = (1 << 30),
FLAG_GRP_MN_UNBLK_TX = (1 << 31)
FLAG_GRP_HW_UNBLK_TX = (1 << 28),
FLAG_GRP_MN_UNBLK_TX = (1 << 29)
} flag_t;
/******************************************************************************/
@ -415,9 +426,14 @@ typedef enum {
extern ftdm_sngss7_data_t g_ftdm_sngss7_data;
extern uint32_t sngss7_id;
extern ftdm_sched_t *sngss7_sched;
extern int cmbLinkSetId;
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
/* in ftmod_sangoma_ss7_main.c */
void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan);
/* in ftmod_sangoma_ss7_logger.c */
void handle_sng_log(uint8_t level, char *fmt,...);
void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta);
void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);
@ -425,6 +441,7 @@ 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);
/* in ftmod_sangoma_ss7_cfg.c */
int ft_to_sngss7_cfg_all(void);
int ftmod_ss7_mtp1_gen_config(void);
int ftmod_ss7_mtp2_gen_config(void);
@ -443,14 +460,26 @@ int ftmod_ss7_isup_ckt_config(int id);
int ftmod_ss7_isup_isap_config(int id);
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_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);
/* in ftmod_sangoma_ss7_sta.c */
int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm);
int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm);
int ft_to_sngss7_activate_all(void);
/* in ftmod_sangoma_ss7_out.c */
void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan);
@ -465,7 +494,12 @@ void ft_to_sngss7_uba(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_lpa(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_gra(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_grs(ftdm_channel_t *ftdmchan);
void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan);
/* in ftmod_sangoma_ss7_in.c */
void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
@ -478,6 +512,7 @@ void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit);
/* in ftmod_sangoma_ss7_handle.c */
ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType);
ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
@ -508,6 +543,13 @@ ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t ci
ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
/* in ftmod_sangoma_ss7_xml.c */
int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span);
/* in ftmod_sangoma_ss7_cli.c */
ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data);
/* in ftmod_sangoma_ss7_support.c */
uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
@ -519,11 +561,19 @@ int check_for_reset(sngss7_chan_data_t *sngss7_info);
ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan);
unsigned long get_unique_id(void);
int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span);
ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan);
ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan);
ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan);
ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan);
ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info);
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);
/* in ftmod_sangoma_ss7_timers.c */
void handle_isup_t35(void *userdata);
ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data);
/******************************************************************************/
/* MACROS *********************************************************************/
@ -654,7 +704,14 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
#define sngss7_clear_flag(obj, flag) ((obj)->flags &= ~(flag))
#define sngss7_set_flag(obj, flag) ((obj)->flags |= (flag))
# define SS7_ASSERT *(int*)0=0;
#ifdef SS7_PRODUCTION
# define SS7_ASSERT \
SS7_INFO_CHAN(ftdmchan,"Production Mode, continuing%s\n", "");
#else
# define SS7_ASSERT \
SS7_ERROR_CHAN(ftdmchan, "Debugging Mode, ending%s\n", ""); \
*(int*)0=0;
#endif
/******************************************************************************/
/******************************************************************************/

View File

@ -42,24 +42,30 @@
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rel (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rlc (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_iam(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_acm(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_anm(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rel(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rlc(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rsc (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rsca (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rsc(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_rsca(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_blo (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_bla (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_ubl (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_uba (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_blo(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_bla(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_ubl(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_uba(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_lpa (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_lpa(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_gra (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_grs (ftdm_channel_t * ftdmchan);
void ft_to_sngss7_gra(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_grs(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan);
void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@ -67,8 +73,9 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;;
SiConEvnt iam;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;;
const char *nadi = NULL;
SiConEvnt iam;
sngss7_info->suInstId = get_unique_id ();
sngss7_info->spInstId = 0;
@ -98,7 +105,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
iam.fwdCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF;
iam.fwdCallInd.isdnUsrPrtInd.val = ISUP_USED;
iam.fwdCallInd.isdnUsrPrtPrfInd.pres = PRSNT_NODEF;
iam.fwdCallInd.isdnUsrPrtPrfInd.val = PREF_REQAW;
iam.fwdCallInd.isdnUsrPrtPrfInd.val = PREF_PREFAW;
iam.fwdCallInd.isdnAccInd.pres = PRSNT_NODEF;
iam.fwdCallInd.isdnAccInd.val = ISDNACC_ISDN;
iam.fwdCallInd.sccpMethInd.pres = PRSNT_NODEF;
@ -113,21 +120,89 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
iam.txMedReq.eh.pres = PRSNT_NODEF;
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)) {
/* include only if we're running ANSI */
iam.fwdCallInd.transCallNInd.pres = PRSNT_NODEF;
iam.fwdCallInd.transCallNInd.val = 0x0;
iam.usrServInfoA.eh.pres = PRSNT_NODEF;
iam.usrServInfoA.infoTranCap.pres = PRSNT_NODEF;
switch (ftdmchan->caller_data.bearer_capability) {
/**********************************************************************/
case (FTDM_BEARER_CAP_SPEECH):
iam.usrServInfoA.infoTranCap.val = 0x0; /* speech as per ATIS-1000113.3.2005 */
break;
/**********************************************************************/
case (FTDM_BEARER_CAP_64K_UNRESTRICTED):
iam.usrServInfoA.infoTranCap.val = 0x8; /* unrestricted digital as per ATIS-1000113.3.2005 */
break;
/**********************************************************************/
case (FTDM_BEARER_CAP_3_1KHZ_AUDIO):
iam.usrServInfoA.infoTranCap.val = 0x10; /* 3.1kHz audio as per ATIS-1000113.3.2005 */
break;
/**********************************************************************/
default:
SS7_ERROR_CHAN(ftdmchan, "Unknown Bearer capability falling back to speech%s\n", " ");
iam.usrServInfoA.infoTranCap.val = 0x0; /* speech as per ATIS-1000113.3.2005 */
break;
/**********************************************************************/
} /* switch (ftdmchan->caller_data.bearer_capability) */
iam.usrServInfoA.cdeStand.pres = PRSNT_NODEF;
iam.usrServInfoA.cdeStand.val = 0x0; /* ITU-T standardized coding */
iam.usrServInfoA.tranMode.pres = PRSNT_NODEF;
iam.usrServInfoA.tranMode.val = 0x0; /* circuit mode */
iam.usrServInfoA.infoTranRate0.pres = PRSNT_NODEF;
iam.usrServInfoA.infoTranRate0.val = 0x10; /* 64kbps origination to destination */
iam.usrServInfoA.infoTranRate1.pres = PRSNT_NODEF;
iam.usrServInfoA.infoTranRate1.val = 0x10; /* 64kbps destination to origination */
iam.usrServInfoA.chanStruct.pres = PRSNT_NODEF;
iam.usrServInfoA.chanStruct.val = 0x1; /* 8kHz integrity */
iam.usrServInfoA.config.pres = PRSNT_NODEF;
iam.usrServInfoA.config.val = 0x0; /* point to point configuration */
iam.usrServInfoA.establish.pres = PRSNT_NODEF;
iam.usrServInfoA.establish.val = 0x0; /* on demand */
iam.usrServInfoA.symmetry.pres = PRSNT_NODEF;
iam.usrServInfoA.symmetry.val = 0x0; /* bi-directional symmetric */
iam.usrServInfoA.usrInfLyr1Prot.pres = PRSNT_NODEF;
iam.usrServInfoA.usrInfLyr1Prot.val = 0x2; /* G.711 ulaw */
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);
/* copy down the calling number information */
copy_cgPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cgPtyNum);
copy_cgPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cgPtyNum);
/* check if the user would like a custom NADI value for the calling Pty Num */
nadi = ftdm_channel_get_var(ftdmchan, "ss7_nadi");
if ((nadi != NULL) && (*nadi)) {
SS7_DEBUG_CHAN(ftdmchan,"Found user supplied NADI value \"%s\"\n", nadi);
iam.cgPtyNum.natAddrInd.val = atoi(nadi);
} else {
SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found, using \"3\" %s\n", " ");
iam.cgPtyNum.natAddrInd.val = 0x03;
}
sng_cc_con_request (sngss7_info->spId,
sngss7_info->suInstId,
sngss7_info->spInstId,
sngss7_info->circuit->id,
&iam,
0);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx IAM\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\", cld = \"%s\"\n",
sngss7_info->circuit->cic,
ftdmchan->caller_data.cid_num.digits,
ftdmchan->caller_data.dnis.digits);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -144,29 +219,29 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
memset (&acm, 0x0, sizeof (acm));
/* fill in the needed information for the ACM */
acm.bckCallInd.eh.pres = PRSNT_NODEF;
acm.bckCallInd.chrgInd.pres = PRSNT_NODEF;
acm.bckCallInd.chrgInd.val = 0x00;
acm.bckCallInd.cadPtyStatInd.pres = PRSNT_NODEF;
acm.bckCallInd.cadPtyStatInd.val = 0x01;
acm.bckCallInd.cadPtyCatInd.pres = PRSNT_NODEF;
acm.bckCallInd.cadPtyCatInd.val = 0x00;
acm.bckCallInd.end2EndMethInd.pres = PRSNT_NODEF;
acm.bckCallInd.end2EndMethInd.val = 0x00;
acm.bckCallInd.intInd.pres = PRSNT_NODEF;
acm.bckCallInd.intInd.val = 0x00;
acm.bckCallInd.end2EndInfoInd.pres = PRSNT_NODEF;
acm.bckCallInd.end2EndInfoInd.val = 0x00;
acm.bckCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF;
acm.bckCallInd.isdnUsrPrtInd.val = 0x0;
acm.bckCallInd.holdInd.pres = PRSNT_NODEF;
acm.bckCallInd.holdInd.val = 0x00;
acm.bckCallInd.isdnAccInd.pres = PRSNT_NODEF;
acm.bckCallInd.isdnAccInd.val = 0x0;
acm.bckCallInd.echoCtrlDevInd.pres = PRSNT_NODEF;
acm.bckCallInd.echoCtrlDevInd.val = 0x0;
acm.bckCallInd.sccpMethInd.pres = PRSNT_NODEF;
acm.bckCallInd.sccpMethInd.val = 0x00;
acm.bckCallInd.eh.pres = PRSNT_NODEF;
acm.bckCallInd.chrgInd.pres = PRSNT_NODEF;
acm.bckCallInd.chrgInd.val = CHRG_CHRG;
acm.bckCallInd.cadPtyStatInd.pres = PRSNT_NODEF;
acm.bckCallInd.cadPtyStatInd.val = 0x01;
acm.bckCallInd.cadPtyCatInd.pres = PRSNT_NODEF;
acm.bckCallInd.cadPtyCatInd.val = CADCAT_ORDSUBS;
acm.bckCallInd.end2EndMethInd.pres = PRSNT_NODEF;
acm.bckCallInd.end2EndMethInd.val = E2EMTH_NOMETH;
acm.bckCallInd.intInd.pres = PRSNT_NODEF;
acm.bckCallInd.intInd.val = INTIND_NOINTW;
acm.bckCallInd.end2EndInfoInd.pres = PRSNT_NODEF;
acm.bckCallInd.end2EndInfoInd.val = E2EINF_NOINFO;
acm.bckCallInd.isdnUsrPrtInd.pres = PRSNT_NODEF;
acm.bckCallInd.isdnUsrPrtInd.val = ISUP_USED;
acm.bckCallInd.holdInd.pres = PRSNT_NODEF;
acm.bckCallInd.holdInd.val = HOLD_NOTREQD;
acm.bckCallInd.isdnAccInd.pres = PRSNT_NODEF;
acm.bckCallInd.isdnAccInd.val = ISDNACC_NONISDN;
acm.bckCallInd.echoCtrlDevInd.pres = PRSNT_NODEF;
acm.bckCallInd.echoCtrlDevInd.val = 0x1; /* ec device present */
acm.bckCallInd.sccpMethInd.pres = PRSNT_NODEF;
acm.bckCallInd.sccpMethInd.val = SCCPMTH_NOIND;
/* send the ACM request to LibSngSS7 */
sng_cc_con_status (1,
@ -176,7 +251,7 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)
&acm,
ADDRCMPLT);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx ACM\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ACM\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -200,7 +275,7 @@ void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan)
&anm,
5);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx ANM\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx ANM\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -233,7 +308,9 @@ void ft_to_sngss7_rel (ftdm_channel_t * ftdmchan)
sngss7_info->circuit->id,
&rel);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx REL\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx REL cause=%d \n",
sngss7_info->circuit->cic,
ftdmchan->caller_data.hangup_cause );
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -256,7 +333,7 @@ void ft_to_sngss7_rlc (ftdm_channel_t * ftdmchan)
sngss7_info->circuit->id,
&rlc);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx RLC\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RLC\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -277,7 +354,7 @@ void ft_to_sngss7_rsc (ftdm_channel_t * ftdmchan)
SIT_STA_CIRRESREQ,
NULL);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx RSC\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RSC\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -298,7 +375,7 @@ void ft_to_sngss7_rsca (ftdm_channel_t * ftdmchan)
SIT_STA_CIRRESRSP,
NULL);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx RSC-RLC\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx RSC-RLC\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -319,7 +396,7 @@ void ft_to_sngss7_blo (ftdm_channel_t * ftdmchan)
SIT_STA_CIRBLOREQ,
NULL);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx BLO\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx BLO\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -340,7 +417,7 @@ void ft_to_sngss7_bla (ftdm_channel_t * ftdmchan)
SIT_STA_CIRBLORSP,
NULL);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx BLA\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx BLA\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -362,7 +439,7 @@ ft_to_sngss7_ubl (ftdm_channel_t * ftdmchan)
SIT_STA_CIRUBLREQ,
NULL);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx UBL\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx UBL\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -383,7 +460,7 @@ void ft_to_sngss7_uba (ftdm_channel_t * ftdmchan)
SIT_STA_CIRUBLRSP,
NULL);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx UBA\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx UBA\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -404,7 +481,7 @@ void ft_to_sngss7_lpa (ftdm_channel_t * ftdmchan)
SIT_STA_LOOPBACKACK,
NULL);
SS7_MSG_TRACE(ftdmchan, sngss7_info, "Tx LPA\n");
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx LPA\n", sngss7_info->circuit->cic);
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
@ -445,7 +522,8 @@ void ft_to_sngss7_gra (ftdm_channel_t * ftdmchan)
SIT_STA_GRSRSP,
&gra);
SS7_INFO_CHAN(ftdmchan, "Tx GRA (%d:%d)\n",
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx GRA (%d:%d)\n",
sngss7_info->circuit->cic,
sngss7_info->circuit->cic,
(sngss7_info->circuit->cic + sngss7_span->rx_grs.range));
@ -463,7 +541,7 @@ void ft_to_sngss7_grs (ftdm_channel_t * ftdmchan)
SiStaEvnt grs;
memset (&grs, 0x0, sizeof (grs));
memset (&grs, 0x0, sizeof(grs));
grs.rangStat.eh.pres = PRSNT_NODEF;
grs.rangStat.range.pres = PRSNT_NODEF;
@ -477,7 +555,8 @@ void ft_to_sngss7_grs (ftdm_channel_t * ftdmchan)
SIT_STA_GRSREQ,
&grs);
SS7_INFO_CHAN(ftdmchan, "Tx GRS (%d:%d)\n",
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx GRS (%d:%d)\n",
sngss7_info->circuit->cic,
sngss7_info->circuit->cic,
(sngss7_info->circuit->cic + sngss7_span->tx_grs.range));
@ -485,6 +564,205 @@ void ft_to_sngss7_grs (ftdm_channel_t * ftdmchan)
return;
}
/******************************************************************************/
void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
int x = 0;
SiStaEvnt cgba;
memset (&cgba, 0x0, sizeof(cgba));
/* fill in the circuit group supervisory message */
cgba.cgsmti.eh.pres = PRSNT_NODEF;
cgba.cgsmti.typeInd.pres = PRSNT_NODEF;
cgba.cgsmti.typeInd.val = sngss7_span->rx_cgb.type;
cgba.rangStat.eh.pres = PRSNT_NODEF;
/* fill in the range */
cgba.rangStat.range.pres = PRSNT_NODEF;
cgba.rangStat.range.val = sngss7_span->rx_cgb.range;
/* fill in the status */
cgba.rangStat.status.pres = PRSNT_NODEF;
cgba.rangStat.status.len = ((sngss7_span->rx_cgb.range + 1) >> 3) + (((sngss7_span->rx_cgb.range + 1) & 0x07) ? 1 : 0);
for(x = 0; x < cgba.rangStat.status.len; x++){
cgba.rangStat.status.val[x] = sngss7_span->rx_cgb.status[x];
}
sng_cc_sta_request (1,
0,
0,
sngss7_span->rx_cgb.circuit,
0,
SIT_STA_CGBRSP,
&cgba);
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGBA (%d:%d)\n",
sngss7_info->circuit->cic,
sngss7_info->circuit->cic,
(sngss7_info->circuit->cic + sngss7_span->rx_cgb.range));
/* clean out the saved data */
memset(&sngss7_span->rx_cgb, 0x0, sizeof(sngss7_group_data_t));
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
int x = 0;
SiStaEvnt cgua;
memset (&cgua, 0x0, sizeof(cgua));
/* fill in the circuit group supervisory message */
cgua.cgsmti.eh.pres = PRSNT_NODEF;
cgua.cgsmti.typeInd.pres = PRSNT_NODEF;
cgua.cgsmti.typeInd.val = sngss7_span->rx_cgu.type;
cgua.rangStat.eh.pres = PRSNT_NODEF;
/* fill in the range */
cgua.rangStat.range.pres = PRSNT_NODEF;
cgua.rangStat.range.val = sngss7_span->rx_cgu.range;
/* fill in the status */
cgua.rangStat.status.pres = PRSNT_NODEF;
cgua.rangStat.status.len = ((sngss7_span->rx_cgu.range + 1) >> 3) + (((sngss7_span->rx_cgu.range + 1) & 0x07) ? 1 : 0);
for(x = 0; x < cgua.rangStat.status.len; x++){
cgua.rangStat.status.val[x] = sngss7_span->rx_cgu.status[x];
}
sng_cc_sta_request (1,
0,
0,
sngss7_span->rx_cgu.circuit,
0,
SIT_STA_CGURSP,
&cgua);
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGUA (%d:%d)\n",
sngss7_info->circuit->cic,
sngss7_info->circuit->cic,
(sngss7_info->circuit->cic + sngss7_span->rx_cgu.range));
/* clean out the saved data */
memset(&sngss7_span->rx_cgu, 0x0, sizeof(sngss7_group_data_t));
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SiStaEvnt cgb;
int x = 0;
memset (&cgb, 0x0, sizeof(cgb));
/* fill in the circuit group supervisory message */
cgb.cgsmti.eh.pres = PRSNT_NODEF;
cgb.cgsmti.typeInd.pres = PRSNT_NODEF;
cgb.cgsmti.typeInd.val = sngss7_span->tx_cgb.type;
/* fill in the range */
cgb.rangStat.eh.pres = PRSNT_NODEF;
cgb.rangStat.range.pres = PRSNT_NODEF;
cgb.rangStat.range.val = sngss7_span->tx_cgb.range;
/* fill in the status */
cgb.rangStat.status.pres = PRSNT_NODEF;
cgb.rangStat.status.len = ((sngss7_span->tx_cgb.range + 1) >> 3) + (((sngss7_span->tx_cgb.range + 1) & 0x07) ? 1 : 0);
for(x = 0; x < cgb.rangStat.status.len; x++){
cgb.rangStat.status.val[x] = sngss7_span->tx_cgb.status[x];
}
sng_cc_sta_request (1,
0,
0,
sngss7_span->tx_cgb.circuit,
0,
SIT_STA_CGBREQ,
&cgb);
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGB (%d:%d)\n",
sngss7_info->circuit->cic,
sngss7_info->circuit->cic,
(sngss7_info->circuit->cic + sngss7_span->tx_cgb.range));
/* clean out the saved data */
memset(&sngss7_span->tx_cgb, 0x0, sizeof(sngss7_group_data_t));
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
/******************************************************************************/
void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan)
{
SS7_FUNC_TRACE_ENTER (__FUNCTION__);
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SiStaEvnt cgu;
int x = 0;
memset (&cgu, 0x0, sizeof(cgu));
/* fill in the circuit group supervisory message */
cgu.cgsmti.eh.pres = PRSNT_NODEF;
cgu.cgsmti.typeInd.pres = PRSNT_NODEF;
cgu.cgsmti.typeInd.val = sngss7_span->tx_cgu.type;
/* fill in the range */
cgu.rangStat.eh.pres = PRSNT_NODEF;
cgu.rangStat.range.pres = PRSNT_NODEF;
cgu.rangStat.range.val = sngss7_span->tx_cgu.range;
/* fill in the status */
cgu.rangStat.status.pres = PRSNT_NODEF;
cgu.rangStat.status.len = ((sngss7_span->tx_cgu.range + 1) >> 3) + (((sngss7_span->tx_cgu.range + 1) & 0x07) ? 1 : 0);
for(x = 0; x < cgu.rangStat.status.len; x++){
cgu.rangStat.status.val[x] = sngss7_span->tx_cgu.status[x];
}
sng_cc_sta_request (1,
0,
0,
sngss7_span->tx_cgu.circuit,
0,
SIT_STA_CGUREQ,
&cgu);
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx CGU (%d:%d)\n",
sngss7_info->circuit->cic,
sngss7_info->circuit->cic,
(sngss7_info->circuit->cic + sngss7_span->tx_cgu.range));
/* clean out the saved data */
memset(&sngss7_span->tx_cgu, 0x0, sizeof(sngss7_group_data_t));
SS7_FUNC_TRACE_EXIT (__FUNCTION__);
return;
}
/******************************************************************************/
/* For Emacs:
* Local Variables:

View File

@ -68,7 +68,7 @@ int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm)
sta.hdr.elmId.elmnt = STLNKSET;
sta.hdr.elmId.elmntInst1 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
sta.hdr.elmId.elmntInst2 = 1;
sta.hdr.elmId.elmntInst2 = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].links[0];
return(sng_sta_mtp3(&sta, cfm));
}

View File

@ -57,6 +57,15 @@ unsigned long get_unique_id(void);
ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan);
ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan);
ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan);
ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan);
ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan);
ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info);
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);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@ -72,9 +81,10 @@ uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
int k;
int j;
int flag;
int odd;
char tmp[2];
unsigned char lower;
unsigned char upper;
uint8_t lower;
uint8_t upper;
/**************************************************************************/
cgPtyNum->eh.pres = PRSNT_NODEF;
@ -104,81 +114,73 @@ uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
k = 0;
j = 0;
flag = 0;
odd = 0;
upper = 0x0;
lower = 0x0;
while (1) {
/* grab a digit from the ftdm digits */
tmp[0] = ftdm->cid_num.digits[k];
/* check if the digit is a number and that is not null */
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
/* move on to the next value */
k++;
tmp[0] = ftdm->cid_num.digits[k];
} /* while(!(isdigit(tmp))) */
/* check if tmp is null or a digit */
if (tmp[0] != '\0') {
if (isdigit(tmp[0])) {
lower = atoi(&tmp[0]);
/* push it into the lower nibble */
lower = atoi(&tmp[0]);
/* move to the next digit */
k++;
/* grab a digit from the ftdm digits */
tmp[0] = ftdm->cid_num.digits[k];
/* check if the digit is a number and that is not null */
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
k++;
tmp[0] = ftdm->cid_num.digits[k];
} else {
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
k++;
tmp[0] = ftdm->cid_num.digits[k];
} /* while(!(isdigit(tmp))) */
} /* while(!(isdigit(tmp))) */
if (tmp[0] != '\0') {
lower = atoi(&tmp[0]);
k++;
tmp[0] = ftdm->cid_num.digits[k];
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
} /* (isdigit(tmp)) */
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
tmp[0] = ftdm->cid_num.digits[k];
if (tmp[0] != '\0') {
if (isdigit(tmp[0])) {
/* check if tmp is null or a digit */
if (tmp[0] != '\0') {
/* push the digit into the upper nibble */
upper = (atoi(&tmp[0])) << 4;
} else {
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
k++;
tmp[0] = ftdm->cid_num.digits[k];
} /* while(!(isdigit(tmp))) */
if (tmp[0] != '\0') {
upper = (atoi(&tmp[0])) << 4;
k++;
} else {
flag = 1;
upper = 0xf;
} /* if (tmp != '\0') */
} /* if (isdigit(tmp)) */
} else {
if (flag == 1) {
/* there is no upper ... fill in 0 */
upper = 0x0;
} else {
/* throw the odd flag */
odd = 1;
/* throw the end flag */
flag = 1;
upper = 0xf;
} /* if (flag == 1) */
} /* if (tmp != '\0') */
} /* if (tmp != '\0') */
} else {
/* keep the odd flag down */
odd = 0;
/* throw the flag */
flag = 1;
}
/* push the digits into the trillium structure */
cgPtyNum->addrSig.val[j] = upper | lower;
/* increment the trillium pointer */
j++;
if (flag) {
break;
} else {
k++;
}
/* if the flag is up we're through all the digits */
if (flag) break;
/* move to the next digit */
k++;
} /* while(1) */
cgPtyNum->addrSig.len = j;
/**************************************************************************/
cgPtyNum->oddEven.pres = PRSNT_NODEF;
cgPtyNum->oddEven.val = ((cgPtyNum->addrSig.val[j] >> 4) == 0x0 ) ? 0x01 : 0x00;
cgPtyNum->oddEven.val = odd;
/**************************************************************************/
return 0;
}
@ -196,9 +198,10 @@ uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
int k;
int j;
int flag;
int odd;
char tmp[2];
unsigned char lower;
unsigned char upper;
uint8_t lower;
uint8_t upper;
/**************************************************************************/
cdPtyNum->eh.pres = PRSNT_NODEF;
@ -217,77 +220,74 @@ uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
/* atoi will search through memory starting from the pointer it is given until
* it finds the \0...since tmp is on the stack it will start going through the
* possibly causing corruption. Hard code a \0 to prevent this
*/
*/ /* dnis */
tmp[1] = '\0';
k = 0;
j = 0;
flag = 0;
odd = 0;
upper = 0x0;
lower = 0x0;
while (1) {
/* grab a digit from the ftdm digits */
tmp[0] = ftdm->dnis.digits[k];
/* check if the digit is a number and that is not null */
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
/* move on to the next value */
k++;
tmp[0] = ftdm->dnis.digits[k];
} /* while(!(isdigit(tmp))) */
/* check if tmp is null or a digit */
if (tmp[0] != '\0') {
if (isdigit(tmp[0])) {
lower = atoi(&tmp[0]);
/* push it into the lower nibble */
lower = atoi(&tmp[0]);
/* move to the next digit */
k++;
/* grab a digit from the ftdm digits */
tmp[0] = ftdm->dnis.digits[k];
/* check if the digit is a number and that is not null */
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
k++;
tmp[0] = ftdm->dnis.digits[k];
} else {
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
k++;
tmp[0] = ftdm->dnis.digits[k];
} /* while(!(isdigit(tmp))) */
} /* while(!(isdigit(tmp))) */
if (tmp[0] != '\0') {
lower = atoi(&tmp[0]);
k++;
tmp[0] = ftdm->dnis.digits[k];
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
} /* (isdigit(tmp)) */
} else {
flag = 1;
lower = 0xf;
} /* if (tmp != '\0') */
tmp[0] = ftdm->dnis.digits[k];
if (tmp[0] != '\0') {
if (isdigit(tmp[0])) {
/* check if tmp is null or a digit */
if (tmp[0] != '\0') {
/* push the digit into the upper nibble */
upper = (atoi(&tmp[0])) << 4;
} else {
while (!(isdigit(tmp[0])) && (tmp[0] != '\0')) {
k++;
tmp[0] = ftdm->dnis.digits[k];
} /* while(!(isdigit(tmp))) */
if (tmp[0] != '\0') {
upper = (atoi(&tmp[0])) << 4;
k++;
} else {
flag = 1;
upper = 0xf;
} /* if (tmp != '\0') */
} /* if (isdigit(tmp)) */
} else {
if (flag == 1) {
upper = 0x0;
} else {
/* there is no upper ... fill in ST */
upper = 0xF;
/* throw the odd flag */
odd = 1;
/* throw the end flag */
flag = 1;
upper = 0xf;
} /* if (flag == 1) */
} /* if (tmp != '\0') */
} /* if (tmp != '\0') */
} else {
/* keep the odd flag down */
odd = 1;
/* need to add the ST */
lower = 0xF;
upper = 0x0;
/* throw the flag */
flag = 1;
}
/* push the digits into the trillium structure */
cdPtyNum->addrSig.val[j] = upper | lower;
/* increment the trillium pointer */
j++;
if (flag) {
break;
} else {
k++;
}
/* if the flag is up we're through all the digits */
if (flag) break;
/* move to the next digit */
k++;
} /* while(1) */
cdPtyNum->addrSig.len = j;
@ -295,7 +295,7 @@ uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
/**************************************************************************/
cdPtyNum->oddEven.pres = PRSNT_NODEF;
cdPtyNum->oddEven.val = ((cdPtyNum->addrSig.val[j] >> 4) == 0x0 ) ? 0x01 : 0x00;
cdPtyNum->oddEven.val = odd;
/**************************************************************************/
return 0;
@ -313,9 +313,9 @@ uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
j = 0;
for (i = 0; i < str.len; i++) {
sprintf(&ftdm[j], "%d", (str.val[i] & 0x0F));
sprintf(&ftdm[j], "%X", (str.val[i] & 0x0F));
j++;
sprintf(&ftdm[j], "%d", ((str.val[i] & 0xF0) >> 4));
sprintf(&ftdm[j], "%X", ((str.val[i] & 0xF0) >> 4));
j++;
}
@ -325,6 +325,8 @@ uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
} else {
ftdm[j] = '\0';
}
} else {
SS7_ERROR("Asked to copy tknStr that is not present!\n");
return 1;
@ -450,6 +452,353 @@ unsigned long get_unique_id(void)
return(sngss7_id);
}
/******************************************************************************/
ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)
{
ftdm_channel_t *ftdmchan = NULL;
sngss7_chan_data_t *sngss7_info = NULL;
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
int i;
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
continue;
}
/* check if the GRP_RESET_RX flag is already up */
if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX)) {
/* we have already processed this channel...move along */
continue;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
/* clear up any pending state changes */
while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
ftdm_sangoma_ss7_process_state_change (ftdmchan);
}
SS7_INFO_CHAN(ftdmchan, "Rx GRS (%d:%d)\n",
g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic,
(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_grs.circuit].cic + sngss7_span->rx_grs.range));
/* flag the channel as having received a reset */
sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_RX);
switch (ftdmchan->state) {
/**************************************************************************/
case FTDM_CHANNEL_STATE_RESTART:
/* go to idle so that we can redo the restart state*/
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IDLE);
break;
/**************************************************************************/
default:
/* set the state of the channel to restart...the rest is done by the chan monitor */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
break;
/**************************************************************************/
} /* switch (ftdmchan->state) */
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
} /* for (chans in GRS */
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
{
ftdm_channel_t *ftdmchan = NULL;
sngss7_chan_data_t *sngss7_info = NULL;
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
int i;
int byte = 0;
int bit = 0;
ftdm_log(FTDM_LOG_DEBUG, "Found Rx GRS on span %d...checking circuits\n", ftdmspan->span_id);
/* check all the circuits in the range to see if they are done resetting */
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
continue;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
/* 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)) {
/* this channel is still resetting...do nothing */
goto GRS_UNLOCK_ALL;
} /* if (!sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) */
} else {
/* state change pending */
goto GRS_UNLOCK_ALL;
}
} /* for ( i = circuit; i < (circuit + range + 1); i++) */
SS7_DEBUG("All circuits out of reset for GRS: circuit=%d, range=%d\n",
sngss7_span->rx_grs.circuit,
sngss7_span->rx_grs.range);
/* check all the circuits in the range to see if they are done resetting */
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n",i);
/* check if we need to die */
SS7_ASSERT;
/* move along */
continue;
}
/* throw the GRP reset flag complete flag */
sngss7_set_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))) {
sngss7_span->rx_grs.status[byte] = (sngss7_span->rx_grs.status[byte] | (1 << bit));
} /* if blocked */
/* update the bit and byte counter*/
bit ++;
if (bit == 8) {
byte++;
bit = 0;
}
} /* for ( i = circuit; i < (circuit + range + 1); i++) */
GRS_UNLOCK_ALL:
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
continue;
}
/* unlock the channel */
ftdm_mutex_unlock(ftdmchan->mutex);
}
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
{
ftdm_channel_t *ftdmchan = NULL;
sngss7_chan_data_t *sngss7_info = NULL;
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
int i;
for ( i = sngss7_span->rx_gra.circuit; i < (sngss7_span->rx_gra.circuit + sngss7_span->rx_gra.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
continue;
}
/* check if the channel is already procoessing the GRA */
if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {
/* move along */
continue;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
/* clear up any pending state changes */
while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
ftdm_sangoma_ss7_process_state_change (ftdmchan);
}
SS7_INFO_CHAN(ftdmchan, "Rx GRA (%d:%d)\n",
g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic,
(g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span->rx_gra.circuit].cic + sngss7_span->rx_gra.range));
switch (ftdmchan->state) {
/**********************************************************************/
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);
/* go to DOWN */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
break;
/**********************************************************************/
case FTDM_CHANNEL_STATE_DOWN:
/* do nothing, just drop the message */
SS7_DEBUG("Receveived GRA in down state, dropping\n");
break;
/**********************************************************************/
case FTDM_CHANNEL_STATE_TERMINATING:
case FTDM_CHANNEL_STATE_HANGUP:
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);
break;
/**********************************************************************/
default:
/* ITU Q764-2.9.5.1.c -> release the circuit */
if (sngss7_span->rx_gra.cause != 0) {
ftdmchan->caller_data.hangup_cause = sngss7_span->rx_gra.cause;
} else {
ftdmchan->caller_data.hangup_cause = 98; /* Message not compatiable with call state */
}
/* go to terminating to hang up the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
break;
/**********************************************************************/
}
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
} /* for ( circuits in request */
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)
{
ftdm_channel_t *ftdmchan = NULL;
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_sigmsg_t sigev;
int x;
for (x = 1; x < (ftdmspan->chan_count + 1); x++) {
/* extract the channel structure and sngss7 channel data */
ftdmchan = ftdmspan->channels[x];
/* if the call data is NULL move on */
if (ftdmchan->call_data == NULL) continue;
sngss7_info = ftdmchan->call_data;
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
memset (&sigev, 0, sizeof (sigev));
sigev.chan_id = ftdmchan->chan_id;
sigev.span_id = ftdmchan->span_id;
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)) &&
(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP))) {
/* clear up any pending state changes */
while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
ftdm_sangoma_ss7_process_state_change (ftdmchan);
}
/* throw the channel into SUSPENDED to process the flag */
/* after doing this once the sig status will be down */
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
}
/* 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)) {
/* clear up any pending state changes */
while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
ftdm_sangoma_ss7_process_state_change (ftdmchan);
}
/* got SUSPENDED state to clear the flag */
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
}
/* unlock the channel */
ftdm_mutex_unlock(ftdmchan->mutex);
} /* for (x = 1; x < (span->chan_count + 1); x++) */
/* signal the core that sig events are queued for processing */
ftdm_span_trigger_signals(ftdmspan);
return FTDM_SUCCESS;
}
/******************************************************************************/
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);
return FTDM_SUCCESS;
}
/******************************************************************************/
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);
return FTDM_SUCCESS;
}
/******************************************************************************/
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);
return FTDM_SUCCESS;
}
/******************************************************************************/
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);
return FTDM_SUCCESS;
}
/******************************************************************************/
/******************************************************************************/

View File

@ -64,7 +64,7 @@ void handle_isup_t35(void *userdata)
sngss7_set_flag(sngss7_info, FLAG_LOCAL_REL);
/* hang up on timer expiry */
ftdmchan->caller_data.hangup_cause = 102;
ftdmchan->caller_data.hangup_cause = 28;
/* end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_CANCEL);

View File

@ -46,6 +46,8 @@ typedef struct sng_timeslot
int gap;
int hole;
}sng_timeslot_t;
int cmbLinkSetId;
/******************************************************************************/
/* PROTOTYPES *****************************************************************/
@ -343,11 +345,11 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
/**********************************************************************/
} else if (!strcasecmp(parm->var, "apc")) {
mtpLinkSet.apc = atoi(parm->val);
SS7_DEBUG("\tFoundmtpLinkSet->apc = %d\n", mtpLinkSet.apc);
SS7_DEBUG("\tFound mtpLinkSet->apc = %d\n", mtpLinkSet.apc);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "minActive")) {
mtpLinkSet.minActive = atoi(parm->val);
SS7_DEBUG("\tFoundmtpLinkSet->minActive = %d\n", mtpLinkSet.minActive);
SS7_DEBUG("\tFound mtpLinkSet->minActive = %d\n", mtpLinkSet.minActive);
/**********************************************************************/
} else {
SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val);
@ -385,8 +387,6 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
if (count < 1 || count > 15 ) {
SS7_ERROR("Invalid number of mtp_links found (%d)\n", count);
return FTDM_FAIL;
} else {
mtpLinkSet.numLinks = count;
}
/* now we need to see if this linkset exists already or not and grab an Id */
@ -418,8 +418,7 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
mtpLink[i].mtp3.apc = mtpLinkSet.apc;
mtpLink[i].mtp3.linkSetId = mtpLinkSet.id;
/* fill in the mtplink structure */
mtpLinkSet.links[count] = ftmod_ss7_fill_in_mtpLink(&mtpLink[i]);
ftmod_ss7_fill_in_mtpLink(&mtpLink[i]);
/* increment the links counter */
count++;
@ -428,6 +427,10 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
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;
@ -497,27 +500,27 @@ static int ftmod_ss7_parse_mtp_link(ftdm_conf_node_t *mtp_link, sng_mtp_link_t *
if (!strcasecmp(parm->val, "itu92")) {
mtpLink->mtp2.linkType = LSD_SW_ITU92;
mtpLink->mtp3.linkType = LSN_SW_ITU;
SS7_DEBUG("\tFoundmtpLink->linkType = \"ITU92\"\n");
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("\tFoundmtpLink->linkType = \"ITU88\"\n");
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("\tFoundmtpLink->linkType = \"ANSI96\"\n");
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("\tFoundmtpLink->linkType = \"ANSI92\"\n");
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("\tFoundmtpLink->linkType = \"ANSI88\"\n");
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("\tFoundmtpLink->linkType = \"ETSI\"\n");
SS7_DEBUG("\tFound mtpLink->linkType = \"ETSI\"\n");
} else {
SS7_ERROR("\tFound an invalid linktype of \"%s\"!\n", parm->val);
return FTDM_FAIL;
@ -526,31 +529,40 @@ static int ftmod_ss7_parse_mtp_link(ftdm_conf_node_t *mtp_link, sng_mtp_link_t *
} else if (!strcasecmp(parm->var, "switchType")) {
if (!strcasecmp(parm->val, "itu97")) {
mtpLink->mtp3.switchType = LSI_SW_ITU97;
SS7_DEBUG("\tFoundmtpLink->switchType = \"ITU97\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"ITU97\"\n");
} else if (!strcasecmp(parm->val, "itu88")) {
mtpLink->mtp3.switchType = LSI_SW_ITU;
SS7_DEBUG("\tFoundmtpLink->switchType = \"ITU88\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"ITU88\"\n");
} else if (!strcasecmp(parm->val, "itu92")) {
mtpLink->mtp3.switchType = LSI_SW_ITU;
SS7_DEBUG("\tFoundmtpLink->switchType = \"ITU92\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"ITU92\"\n");
} else if (!strcasecmp(parm->val, "itu00")) {
mtpLink->mtp3.switchType = LSI_SW_ITU2000;
SS7_DEBUG("\tFoundmtpLink->switchType = \"ITU00\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"ITU00\"\n");
} else if (!strcasecmp(parm->val, "ETSIV2")) {
mtpLink->mtp3.switchType = LSI_SW_ETSI;
SS7_DEBUG("\tFoundmtpLink->switchType = \"ETSIV2\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"ETSIV2\"\n");
} else if (!strcasecmp(parm->val, "ETSIV3")) {
mtpLink->mtp3.switchType = LSI_SW_ETSIV3;
SS7_DEBUG("\tFoundmtpLink->switchType = \"ETSIV3\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"ETSIV3\"\n");
} else if (!strcasecmp(parm->val, "UK")) {
mtpLink->mtp3.switchType = LSI_SW_UK;
SS7_DEBUG("\tFoundmtpLink->switchType = \"UK\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"UK\"\n");
} else if (!strcasecmp(parm->val, "RUSSIA")) {
mtpLink->mtp3.switchType = LSI_SW_RUSSIA;
SS7_DEBUG("\tFoundmtpLink->switchType = \"RUSSIA\"\n");
SS7_DEBUG("\tFound mtpLink->switchType = \"RUSSIA\"\n");
} else if (!strcasecmp(parm->val, "INDIA")) {
mtpLink->mtp3.switchType = LSI_SW_INDIA;
SS7_DEBUG("\tFoundmtpLink->switchType = \"INDIA\"\n");
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;
@ -568,7 +580,7 @@ static int ftmod_ss7_parse_mtp_link(ftdm_conf_node_t *mtp_link, sng_mtp_link_t *
/**********************************************************************/
} else if (!strcasecmp(parm->var, "slc")) {
mtpLink->mtp3.slc = atoi(parm->val);
SS7_DEBUG("\tFoundmtpLink->slc = \"%d\"\n",mtpLink->mtp3.slc);
SS7_DEBUG("\tFound mtpLink->slc = \"%d\"\n",mtpLink->mtp3.slc);
/**********************************************************************/
} else {
SS7_ERROR("\tFound an invalid parameter \"%s\"!\n", parm->val);
@ -649,14 +661,17 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)
/* check if the name matches */
if (!strcasecmp((char *)g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, parm->val)) {
/* grab the mtpLink id value first*/
int id = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].links[0];
/* now, harvest the required infomormation from the global structure */
mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLink[id].mtp3.linkType;
mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLink[id].mtp3.switchType;
mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLink[id].mtp3.ssf;
mtpRoute.cmbLinkSetId = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id;
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++;
@ -692,9 +707,11 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)
parm = parm + 1;
}
ftmod_ss7_fill_in_nsap(&mtpRoute);
ftmod_ss7_fill_in_mtp3_route(&mtpRoute);
ftmod_ss7_fill_in_nsap(&mtpRoute);
return FTDM_SUCCESS;
}
@ -738,7 +755,6 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
int num_parms = isup_interface->n_parameters;
int i;
int linkSetId;
int linkId;
memset(&sng_isup, 0x0, sizeof(sng_isup));
memset(&sng_isap, 0x0, sizeof(sng_isap));
@ -772,36 +788,25 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
/* 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 nwID from the nsap */
int y = 1;
while (g_ftdm_sngss7_data.cfg.nsap[y].id != 0) {
if ((g_ftdm_sngss7_data.cfg.nsap[y].linkType == g_ftdm_sngss7_data.cfg.mtpRoute[x].linkType) &&
(g_ftdm_sngss7_data.cfg.nsap[y].switchType == g_ftdm_sngss7_data.cfg.mtpRoute[x].switchType) &&
(g_ftdm_sngss7_data.cfg.nsap[y].ssf == g_ftdm_sngss7_data.cfg.mtpRoute[x].ssf)) {
/* 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 */
y++;
} /* while (g_ftdm_sngss7_data.cfg.mtp3_isup[y].id != 0) */
/* check how we exited the last while loop */
if (g_ftdm_sngss7_data.cfg.nsap[y].id == 0) {
SS7_ERROR("\tFailed to find the nwID for = \"%s\"!\n", parm->val);
return FTDM_FAIL;
} else {
sng_isup.nwId = g_ftdm_sngss7_data.cfg.nsap[y].nwId;
z++;
}
break;
}
x++;
@ -846,10 +851,15 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
}
/* trickle down the SPC to all sub entities */
linkSetId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].cmbLinkSetId;
for (i = 0; i < g_ftdm_sngss7_data.cfg.mtpLinkSet[linkSetId].numLinks; i ++) {
linkId = g_ftdm_sngss7_data.cfg.mtpLinkSet[linkSetId].links[i];
g_ftdm_sngss7_data.cfg.mtpLink[linkId].mtp3.spc = g_ftdm_sngss7_data.cfg.spc;
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;
}
i++;
}
ftmod_ss7_fill_in_isap(&sng_isap);
@ -858,8 +868,6 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
ftmod_ss7_fill_in_isup_interface(&sng_isup);
g_ftdm_sngss7_data.cfg.isap[sng_isap.id].spId = sng_isup.id;
return FTDM_SUCCESS;
}
@ -957,7 +965,7 @@ static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink)
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 = 20;
g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t7 = 40;
}
if (mtpLink->mtp3.t1 != 0) {
@ -1057,21 +1065,19 @@ static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink)
/******************************************************************************/
static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)
{
int count;
int i = mtpLinkSet->id;
strcpy((char *)g_ftdm_sngss7_data.cfg.mtpLinkSet[i].name, (char *)mtpLinkSet->name);
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 = g_ftdm_sngss7_data.cfg.mtpLink[1].mtp3.linkType; /* KONRAD FIX ME */
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;
g_ftdm_sngss7_data.cfg.mtpLinkSet[i].numLinks = mtpLinkSet->numLinks;
for (count = 0; count < mtpLinkSet->numLinks; count++) {
g_ftdm_sngss7_data.cfg.mtpLinkSet[i].links[count] = mtpLinkSet->links[count];
}
g_ftdm_sngss7_data.cfg.mtpLinkSet[i].numLinks = 0;
return 0;
}
@ -1083,8 +1089,7 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
/* 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 (g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc == mtp3_route->dpc) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpRoute[i].name, mtp3_route->name)) {
/* we have a match so break out of this loop */
break;
}
@ -1106,8 +1111,10 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc = mtp3_route->dpc;
g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType = mtp3_route->linkType;
g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType = mtp3_route->switchType;
g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId = 1; /* mtp3_route->cmbLinkSetId;*/
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].ssf = mtp3_route->ssf;
if (mtp3_route->t6 != 0) {
g_ftdm_sngss7_data.cfg.mtpRoute[i].t6 = mtp3_route->t6;
@ -1159,6 +1166,11 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
} else {
g_ftdm_sngss7_data.cfg.mtpRoute[i].t25 = 100;
}
if (mtp3_route->t26 != 0) {
g_ftdm_sngss7_data.cfg.mtpRoute[i].t26 = mtp3_route->t26;
} else {
g_ftdm_sngss7_data.cfg.mtpRoute[i].t26 = 100;
}
return 0;
}
@ -1184,15 +1196,17 @@ 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);
}
g_ftdm_sngss7_data.cfg.nsap[i].spId = g_ftdm_sngss7_data.cfg.nsap[i].id;
g_ftdm_sngss7_data.cfg.nsap[i].suId = g_ftdm_sngss7_data.cfg.nsap[i].id;
g_ftdm_sngss7_data.cfg.nsap[i].nwId = g_ftdm_sngss7_data.cfg.nsap[i].id;
g_ftdm_sngss7_data.cfg.nsap[i].nwId = mtp3_route->nwId;
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;
@ -1208,7 +1222,7 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
/* 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 (g_ftdm_sngss7_data.cfg.isupIntf[i].nwId == sng_isup->nwId) {
if (!strcasecmp(g_ftdm_sngss7_data.cfg.isupIntf[i].name, sng_isup->name)) {
/* we have a match so break out of this loop */
break;
@ -1381,7 +1395,8 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap)
}
g_ftdm_sngss7_data.cfg.isap[i].id = sng_isap->id;
g_ftdm_sngss7_data.cfg.isap[i].suId = 1; /*KONRAD FIX ME */
g_ftdm_sngss7_data.cfg.isap[i].suId = sng_isap->id;
g_ftdm_sngss7_data.cfg.isap[i].spId = sng_isap->id;
g_ftdm_sngss7_data.cfg.isap[i].switchType = sng_isap->switchType;
g_ftdm_sngss7_data.cfg.isap[i].ssf = sng_isap->ssf;
@ -1458,7 +1473,7 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap)
if (sng_isap->tex != 0) {
g_ftdm_sngss7_data.cfg.isap[i].tex = sng_isap->tex;
} else {
g_ftdm_sngss7_data.cfg.isap[i].tex = 10;
g_ftdm_sngss7_data.cfg.isap[i].tex = 1000;
}
if (sng_isap->tcrm != 0) {
g_ftdm_sngss7_data.cfg.isap[i].tcrm = sng_isap->tcrm;
@ -1499,7 +1514,9 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i
SS7_DEBUG("found existing mtp3 self route\n");
return FTDM_SUCCESS;
} else {
SS7_ERROR("found new mtp3 self route but it does not much the route already configured\n");
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;
}
@ -1583,11 +1600,10 @@ static int ftmod_ss7_fill_in_circuits(char *ch_map, int cicbase, int typeCntrl,
g_ftdm_sngss7_data.cfg.isupCkt[x].chan = count;
if (timeslot.siglink) {
g_ftdm_sngss7_data.cfg.isupCkt[x].type = SIG;
} else if (timeslot.hole) {
g_ftdm_sngss7_data.cfg.isupCkt[x].type = HOLE;
} else {
g_ftdm_sngss7_data.cfg.isupCkt[x].type = VOICE;
g_ftdm_sngss7_data.cfg.isupCkt[x].type = HOLE;
}
if (timeslot.channel) {
g_ftdm_sngss7_data.cfg.isupCkt[x].cic = cicbase;
cicbase++;
@ -1608,6 +1624,10 @@ static int ftmod_ss7_fill_in_circuits(char *ch_map, int cicbase, int typeCntrl,
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;

View File

@ -280,6 +280,25 @@ static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start
ftdm_channel_set_feature(chan, FTDM_CHANNEL_FEATURE_DTMF_DETECT);
dtmf = "hardware";
}
err = sangoma_tdm_get_hw_ec(chan->sockfd, &tdm_api);
if (err > 0) {
ftdm_channel_set_feature(chan, FTDM_CHANNEL_FEATURE_HWEC);
}
#ifdef WP_API_FEATURE_HWEC_PERSIST
err = sangoma_tdm_get_hwec_persist_status(chan->sockfd, &tdm_api);
if (err == 0) {
ftdm_channel_set_feature(chan, FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE);
}
#else
if (span->trunk_type == FTDM_TRUNK_BRI || span->trunk_type == FTDM_TRUNK_BRI_PTMP) {
ftdm_log(FTDM_LOG_WARNING, "WP_API_FEATURE_HWEC_PERSIST feature is not supported \
with your version of libsangoma, you should update your Wanpipe drivers\n");
}
#endif
}
#ifdef LIBSANGOMA_VERSION
@ -598,18 +617,33 @@ static FIO_COMMAND_FUNCTION(wanpipe_command)
break;
case FTDM_COMMAND_ENABLE_ECHOCANCEL:
{
#ifdef WP_API_FEATURE_EC_CHAN_STAT
err=sangoma_tdm_get_hwec_chan_status(ftdmchan->sockfd, &tdm_api);
if (err > 0) {
/* Hardware echo canceller already enabled */
err = 0;
break;
}
#endif
err=sangoma_tdm_enable_hwec(ftdmchan->sockfd, &tdm_api);
if (err) {
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HWEC Enable Failed");
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HWEC Enable Failed");
return FTDM_FAIL;
}
}
break;
case FTDM_COMMAND_DISABLE_ECHOCANCEL:
{
#ifdef WP_API_FEATURE_EC_CHAN_STAT
err=sangoma_tdm_get_hwec_chan_status(ftdmchan->sockfd, &tdm_api);
if (!err) {
/* Hardware echo canceller already disabled */
break;
}
#endif
err=sangoma_tdm_disable_hwec(ftdmchan->sockfd, &tdm_api);
if (err) {
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HWEC Disable Failed");
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "HWEC Disable Failed");
return FTDM_FAIL;
}
}

View File

@ -170,8 +170,8 @@ static const char *chanpath = NULL;
static const char dahdi_ctlpath[] = "/dev/dahdi/ctl";
static const char dahdi_chanpath[] = "/dev/dahdi/channel";
static const char zt_ctlpath[] = "/dev/ftdm/ctl";
static const char zt_chanpath[] = "/dev/ftdm/channel";
static const char zt_ctlpath[] = "/dev/zap/ctl";
static const char zt_chanpath[] = "/dev/zap/channel";
static ftdm_socket_t CONTROL_FD = ZT_INVALID_SOCKET;
@ -974,7 +974,7 @@ FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event)
*/
FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
{
uint32_t i, event_id = 0;
uint32_t i, event_id = FTDM_OOB_INVALID;
zt_event_t zt_event_id = 0;
for(i = 1; i <= span->chan_count; i++) {
@ -1022,6 +1022,8 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
event_id = FTDM_OOB_OFFHOOK;
} else if (span->channels[i]->type == FTDM_CHAN_TYPE_FXO) {
event_id = FTDM_OOB_RING_START;
} else {
event_id = FTDM_OOB_NOOP;
}
}
break;

View File

@ -386,7 +386,7 @@ typedef struct ftdm_conf_parameter {
} ftdm_conf_parameter_t;
/*! \brief Opaque general purpose iterator */
typedef void ftdm_iterator_t;
typedef struct ftdm_iterator ftdm_iterator_t;
/*! \brief Channel commands that can be executed through ftdm_channel_command() */
typedef enum {
@ -667,9 +667,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_set_sig_status(ftdm_span_t *span, ftdm_signa
/*! \brief Get span signaling status (ie: whether protocol layer is up or down) */
FT_DECLARE(ftdm_status_t) ftdm_span_get_sig_status(ftdm_span_t *span, ftdm_signaling_status_t *status);
/*! \brief Get span signaling status (ie: whether protocol layer is up or down) */
FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan);
/*!
* \brief Set user private data in the channel
*
@ -1032,8 +1029,19 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_add_var(ftdm_channel_t *ftdmchan, const c
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
* \note The iterator pointer returned is only valid while the channel is open and it'll be destroyed when the channel is closed. */
FT_DECLARE(ftdm_iterator_t *) ftdm_channel_get_var_iterator(const ftdm_channel_t *ftdmchan);
* \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);
@ -1041,6 +1049,11 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_get_current_var(ftdm_iterator_t *iter, co
/*! \brief Advance iterator */
FT_DECLARE(ftdm_iterator_t *) ftdm_iterator_next(ftdm_iterator_t *iter);
/*! \brief Free iterator
* \note You must free an iterator after using it unless you plan to reuse it
*/
FT_DECLARE(ftdm_status_t) ftdm_iterator_free(ftdm_iterator_t *iter);
/*! \brief Get the span pointer associated to the channel */
FT_DECLARE(ftdm_span_t *) ftdm_channel_get_span(const ftdm_channel_t *ftdmchan);
@ -1144,6 +1157,12 @@ FT_DECLARE(uint32_t) ftdm_span_get_id(const ftdm_span_t *span);
/*! \brief Get the span name */
FT_DECLARE(const char *) ftdm_span_get_name(const ftdm_span_t *span);
/*! \brief Get iterator for the span channels
* \param span The span containing the channels
* \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator.
*/
FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter);
/*!
* \brief Execute a text command. The text command output will be returned and must be free'd
*
@ -1154,16 +1173,6 @@ FT_DECLARE(const char *) ftdm_span_get_name(const ftdm_span_t *span);
*/
FT_DECLARE(char *) ftdm_api_execute(const char *cmd);
/*!
* \brief Disables CPU monitoring
*
* \note CPU monitoring is enabled by default. This means a thread will be launched at startup (ftdm_global_init)
* with the sole purpose of monitoring system-wide CPU usage. If the CPU usage raises above a defined
* threshold, no new calls will be accepted (neither incoming or outgoing)
*
*/
FT_DECLARE(void) ftdm_cpu_monitor_disable(void);
/*!
* \brief Create a configuration node
*
@ -1255,7 +1264,13 @@ FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *channe
/*! \brief For display debugging purposes you can display this string which describes the last channel internal state */
FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *channel);
/*! \brief For display debugging purposes you can display this string which describes the last channel internal state */
/*! \brief For display debugging purposes you can display this string which describes the history of the channel
* \param channel The channel to get the history from
* \return History string for the channel. You must free the string with ftdm_free
*/
FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *channel);
/*! \brief Initialize channel state for an outgoing call */
FT_DECLARE(ftdm_status_t) ftdm_channel_init(ftdm_channel_t *ftdmchan);
/*! \brief Initialize the library */
@ -1279,6 +1294,12 @@ FT_DECLARE(void) ftdm_global_set_logger(ftdm_logger_t logger);
/*! \brief Set the default logger level */
FT_DECLARE(void) ftdm_global_set_default_logger(int level);
/*! \brief Set the directory to look for modules */
FT_DECLARE(void) ftdm_global_set_mod_directory(const char *path);
/*! \brief Set the directory to look for configs */
FT_DECLARE(void) ftdm_global_set_config_directory(const char *path);
/*! \brief Check if the FTDM library is initialized and running */
FT_DECLARE(ftdm_bool_t) ftdm_running(void);

View File

@ -356,6 +356,15 @@ typedef struct {
} ftdm_dtmf_debug_t;
#endif
typedef struct {
const char *file;
const char *func;
int line;
ftdm_channel_state_t state;
ftdm_channel_state_t last_state;
ftdm_time_t time;
} ftdm_channel_history_entry_t;
/* 2^8 table size, one for each byte (sample) value */
#define FTDM_GAINS_TABLE_SIZE 256
struct ftdm_channel {
@ -381,6 +390,8 @@ struct ftdm_channel {
ftdm_channel_state_t state;
ftdm_channel_state_t last_state;
ftdm_channel_state_t init_state;
ftdm_channel_history_entry_t history[10];
uint8_t hindex;
ftdm_mutex_t *mutex;
teletone_dtmf_detect_state_t dtmf_detect;
uint32_t buffer_delay;
@ -425,6 +436,7 @@ struct ftdm_channel {
float txgain;
int availability_rate;
void *user_private;
ftdm_timer_id_t hangup_timer;
#ifdef FTDM_DEBUG_DTMF
ftdm_dtmf_debug_t dtmfdbg;
#endif
@ -583,6 +595,10 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, cons
/* dequeue pending signals and notify the user via the span signal callback */
FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span);
/*! \brief clear the tone detector state */
FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan);
/*!
\brief Assert condition
*/
@ -619,6 +635,9 @@ FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span);
#define ftdm_log_chan(fchan, level, format, ...) ftdm_log(level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__)
#define ftdm_log_chan_msg(fchan, level, msg) ftdm_log(level, "[s%dc%d][%d:%d] " msg, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id)
#define ftdm_span_lock(span) ftdm_mutex_lock(span->mutex)
#define ftdm_span_unlock(span) ftdm_mutex_unlock(span->mutex)
FT_DECLARE_DATA extern const char *FTDM_LEVEL_NAMES[9];
static __inline__ void ftdm_abort(void)

View File

@ -44,8 +44,8 @@ extern "C" {
#define FTDM_MICROSECONDS_PER_SECOND 1000000
typedef struct ftdm_sched ftdm_sched_t;
typedef struct ftdm_timer ftdm_timer_t;
typedef void (*ftdm_sched_callback_t)(void *data);
typedef uint64_t ftdm_timer_id_t;
/*! \brief Create a new scheduling context */
FT_DECLARE(ftdm_status_t) ftdm_sched_create(ftdm_sched_t **sched, const char *name);
@ -62,18 +62,22 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_free_run(ftdm_sched_t *sched);
* \param name Timer name, typically unique but is not required to be unique, any null terminated string is fine (required)
* \param callback The callback to call upon timer expiration (required)
* \param data Optional data to pass to the callback
* \param timer The timer that was created, it can be NULL if you dont care,
* but you need this if you want to be able to cancel the timer with ftdm_sched_cancel_timer
* \param timer Timer id pointer to store the id of the newly created timer. It can be null
* if you do not need to know the id, but you need this if you want to be able
* to cancel the timer with ftdm_sched_cancel_timer
*/
FT_DECLARE(ftdm_status_t) ftdm_sched_timer(ftdm_sched_t *sched, const char *name,
int ms, ftdm_sched_callback_t callback, void *data, ftdm_timer_t **timer);
int ms, ftdm_sched_callback_t callback, void *data, ftdm_timer_id_t *timer);
/*!
* \brief Cancel the timer
* Note that there is a race between cancelling and triggering a timer.
* By the time you call this function the timer may be about to be triggered.
* This is specially true with timers in free run schedule.
* \param sched The scheduling context (required)
* \param timer The timer to cancel (required)
*/
FT_DECLARE(ftdm_status_t) ftdm_sched_cancel_timer(ftdm_sched_t *sched, ftdm_timer_t **timer);
FT_DECLARE(ftdm_status_t) ftdm_sched_cancel_timer(ftdm_sched_t *sched, ftdm_timer_id_t timer);
/*! \brief Destroy the context and all of the scheduled timers in it */
FT_DECLARE(ftdm_status_t) ftdm_sched_destroy(ftdm_sched_t **sched);
@ -91,6 +95,9 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_global_init(void);
/*! \brief Checks if the main scheduling thread is running */
FT_DECLARE(ftdm_bool_t) ftdm_free_sched_running(void);
/*! \brief Stop the main scheduling thread (if running) */
FT_DECLARE(ftdm_bool_t) ftdm_free_sched_stop(void);
#ifdef __cplusplus
}
#endif

View File

@ -191,6 +191,8 @@ typedef enum {
FTDM_CHANNEL_FEATURE_CALLERID = (1 << 4), /*!< Channel can detect caller id (read-only) */
FTDM_CHANNEL_FEATURE_PROGRESS = (1 << 5), /*!< Channel can detect inband progress (read-only) */
FTDM_CHANNEL_FEATURE_CALLWAITING = (1 << 6), /*!< Channel will allow call waiting (ie: FXS devices) (read/write) */
FTDM_CHANNEL_FEATURE_HWEC = (1<<7), /*!< Channel has a hardware echo canceller */
FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE = (1<<8), /*!< hardware echo canceller is disabled when there are no calls on this channel */
} ftdm_channel_feature_t;
typedef enum {
@ -322,9 +324,15 @@ struct ftdm_conf_node {
/* first node child */
struct ftdm_conf_node *child;
/* last node child */
struct ftdm_conf_node *last;
/* next node sibling */
struct ftdm_conf_node *next;
/* prev node sibling */
struct ftdm_conf_node *prev;
/* my parent if any */
struct ftdm_conf_node *parent;
};
@ -366,6 +374,23 @@ typedef ftdm_status_t (*ftdm_span_start_t)(ftdm_span_t *span);
typedef ftdm_status_t (*ftdm_span_stop_t)(ftdm_span_t *span);
typedef ftdm_status_t (*ftdm_channel_sig_read_t)(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t size);
typedef enum {
FTDM_ITERATOR_VARS = 1,
FTDM_ITERATOR_CHANS,
} ftdm_iterator_type_t;
struct ftdm_iterator {
ftdm_iterator_type_t type;
unsigned int allocated:1;
union {
struct {
uint32_t index;
const ftdm_span_t *span;
} chaniter;
ftdm_hash_iterator_t *hashiter;
} pvt;
};
#ifdef __cplusplus
}
#endif

View File

@ -267,7 +267,7 @@ TELETONE_API(int) teletone_mux_tones(teletone_generation_session_t *ts, teletone
ts->samples * 2);
}
}
return ts->samples;
return ts->samples / ts->channels;
}
TELETONE_API(int) teletone_run(teletone_generation_session_t *ts, const char *cmd)

0
libs/libcodec2/.update Normal file
View File

0
libs/libcodec2/AUTHORS Normal file
View File

502
libs/libcodec2/COPYING Normal file
View File

@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

0
libs/libcodec2/ChangeLog Normal file
View File

236
libs/libcodec2/INSTALL Normal file
View File

@ -0,0 +1,236 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@ -0,0 +1,98 @@
AM_CFLAGS = -Isrc -Wall -lm
AUTOMAKE_OPTS = gnu
NAME = libcodec2
AM_CPPFLAGS = $(AM_CFLAGS)
EXTRA_DIST = pitch/hts1a.p \
pitch/hts2a.p \
octave/glottal.m \
octave/lsp_pdf.m \
octave/phase.m \
octave/pl2.m \
octave/plinterp.m \
octave/plnlp.m \
octave/plpitch.m \
octave/postfilter.m \
octave/load_raw.m \
octave/phase2.m \
octave/pitch_test.m \
octave/plamp.m \
octave/pl.m \
octave/plphase.m \
octave/png.m \
octave/pulse.m \
raw/b0067.raw \
raw/forig_speex_8k.raw \
raw/hts1.raw \
raw/hts2.raw \
raw/mmt1.raw \
raw/morig_speex_8k.raw \
raw/f2400.raw \
raw/hts1a_g729a.raw \
raw/hts2a_g729a.raw \
raw/hts.raw \
raw/mmt1_speex_8k.raw \
raw/forig_g729a.raw \
raw/hts1a_gsm13k.raw \
raw/hts2a_gsm13k.raw \
raw/m2400.raw \
raw/morig_g729a.raw \
raw/forig_gsm13k.raw \
raw/hts1a.raw \
raw/hts2a.raw \
raw/mmt1_g729a.raw \
raw/morig_gsm13k.raw \
raw/forig.raw \
raw/hts1a_speex_8k.raw \
raw/hts2a_speex_8k.raw \
raw/mmt1_gsm13k.raw \
raw/morig.raw \
script/menu.sh \
script/playraw.sh \
script/raw2wav.sh \
script/wav2raw.sh \
wav/f2400.wav \
wav/hts1a_c2_v0.1.wav \
wav/hts1a.wav \
wav/hts2a_speex_8k.wav \
wav/mmt1_speex_8k.wav \
wav/morig.wav \
wav/forig_speex_8k.wav \
wav/hts1a_g729a.wav \
wav/hts2a_c2_v0.1.wav \
wav/hts2a.wav \
wav/mmt1.wav \
wav/forig.wav \
wav/hts1a_speex_8k.wav \
wav/hts2a_g729a.wav \
wav/m2400.wav \
wav/morig_speex_8k.wav \
src/globals.c \
doc/A_m.gif \
doc/omega_0.gif \
doc/phi_m.gif \
doc/s_n.gif \
doc/s_n.txt \
unittest/lsp2.txt \
unittest/lsp7.txt \
unittest/lspd78.txt \
unittest/lsp3.txt \
unittest/lsp8.txt \
unittest/lspd910.txt \
unittest/lsp4.txt \
unittest/lsp9.txt \
unittest/lsp10.txt \
unittest/lsp5.txt \
unittest/lspd123.txt \
unittest/lsp1.txt \
unittest/lsp6.txt \
unittest/lspd456.txt \
src/codeall.sh \
src/fq20.sh \
src/listen1.sh \
src/listen.sh \
src/listensim.sh \
src/sim.sh
SUBDIRS = src unittest

0
libs/libcodec2/NEWS Normal file
View File

0
libs/libcodec2/README Normal file
View File

View File

@ -0,0 +1,4 @@
#! /bin/sh
srcpath=$(dirname $0 2>/dev/null ) || srcpath="."
$srcpath/configure "$@" --disable-shared --with-pic

View File

@ -0,0 +1,26 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
AC_INIT(libcodec2, 1.0, david@rowetel.com)
AM_INIT_AUTOMAKE(libcodec2,1.0)
# Checks for programs.
AC_PROG_CC
AC_PROG_LIBTOOL
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
AC_CHECK_LIB([m], [main])
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([floor pow sqrt])
AC_CONFIG_FILES([Makefile src/Makefile unittest/Makefile])
AC_OUTPUT

BIN
libs/libcodec2/doc/A_m.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

BIN
libs/libcodec2/doc/s_n.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1 @@
s(n)=A_1cos(\omega_0+\phi_1)+A_2cos(2\omega_0+\phi_2)+...+A_Lcos(L\omega_0+\phi_L)

View File

@ -0,0 +1,25 @@
% glottal.m
% David Rowe 12 Sep 2009
% Matlab script to generate the phase spectra of a glottal pulse
% lpc10 pulse from spandsp. When the file glottal.c was used as a part of the
% excitation phase component in phase.c, phase_synth_zero_order(), no difference
% in speech quality was apparent. So left out of code for now.
sh=12
kexc = [ 8, -16, 26, -48, 86, -162, 294, -502, 718, -728, 184 672, -610, -672, 184, 728, 718, 502, 294, 162, 86, 48, 26, 16, 8];
kexc = shift(kexc,sh);
kexc = [kexc(1:sh) zeros(1,512-25) kexc(sh+1:25)];
figure(1)
plot(kexc)
figure(2)
G = fft(kexc);
plot((1:256)*(4000/256),unwrap(angle(G(1:256))))
f=fopen("glottal.c","wt");
fprintf(f,"float glottal[]={\n");
for m=1:255
fprintf(f," %f,\n",angle(G(m)));
endfor
fprintf(f," %f};\n",angle(G(256)));
fclose(f);

View File

@ -0,0 +1,8 @@
% load_raw.m
% David Rowe 7 Oct 2009
function s = load_raw(fn)
fs=fopen(fn,"rb");
s = fread(fs,Inf,"short");
plot(s)
endfunction

View File

@ -0,0 +1,50 @@
% lsp_pdf.m
% David Rowe 2 Oct 2009
% Plots histograms (PDF estimates) of LSP training data
function lsp_pdf(lsp)
[r,c] = size(lsp);
% LSPs
figure(3);
clf;
[x,y] = hist(lsp(:,1),100);
plot(y*4000/pi,x,";1;");
hold on;
for i=2:c
[x,y] = hist(lsp(:,i),100);
legend = sprintf(";%d;",i);
plot(y*4000/pi,x,legend);
endfor
hold off;
grid;
% LSP differences
figure(4);
clf;
subplot(211)
[x,y] = hist(lsp(:,1),100);
plot(y,x,";1;");
hold on;
for i=2:5
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
legend = sprintf(";%d;",i);
plot(y,x,legend);
endfor
hold off;
grid;
subplot(212)
[x,y] = hist(lsp(:,6)-lsp(:,5),100);
plot(y,x,";6;");
hold on;
for i=7:c
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
legend = sprintf(";%d;",i);
plot(y,x,legend);
endfor
hold off;
grid;
endfunction

View File

@ -0,0 +1,56 @@
% phase.m
% David Rowe August 2009
% experiments with phase for sinusoidal codecs
function phase(samname, F0, png)
Wo=2*pi*F0/8000;
P=2*pi/Wo;
L = floor(pi/Wo);
Nsam = 16000;
N = 80;
F = Nsam/N;
A = 10000/L;
phi = zeros(1,L);
s = zeros(1,Nsam);
for m=floor(L/2):L
phi_off(m) = -m*Wo*8;
end
for f=1:F
phi(1) = phi(1) + Wo*N;
phi(1) = mod(phi(1),2*pi);
for m=1:L
phi(m) = m*phi(1);
end
x = zeros(1,N);
for m=1:L
x = x + A*cos(m*Wo*(0:(N-1)) + phi(m));
endfor
s((f-1)*N+1:f*N) = x;
endfor
figure(1);
clf;
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
if (nargin == 3)
% small image to fit blog
__gnuplot_set__ terminal png size 450,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
endfunction

View File

@ -0,0 +1,50 @@
% phase2.m
% David Rowe Sep 2009
% experiments with phase for sinusoidal codecs, looking at phase
% of excitation with real Am samples from hts1
function phase2(samname, png)
N = 16000;
f=45;
model = load("../src/hts1a_model.txt");
phase = load("../src/hts1a_phase_phase.txt");
Wo = model(f,1);
P=2*pi/Wo;
L = model(f,2);
A = model(f,3:(L+2));
phi = phase(f,1:L);
phi = zeros(1,L);
for m=L/2:L
phi(m) = 2*pi*rand(1,1);
end
s = zeros(1,N);
for m=1:L
s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m));
s = s + s_m;
endfor
figure(1);
clf;
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
if (nargin == 2)
% small image to fit blog
__gnuplot_set__ terminal png size 450,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
endfunction

View File

@ -0,0 +1,39 @@
% pitch_test.m
% David Rowe Sep 2009
% Constructs a sequence to test the pitch estimator
function pitch_test(samname)
M=320;
F=200;
fs=fopen(samname,"wb");
f0 = 100;
for f=1:200
Wo=2*pi*f0/8000;
P=2*pi/Wo;
L = floor(pi/Wo);
A = 10000/L;
phi = zeros(1,L);
s = zeros(1,M);
for m=1:L
s = s + A*cos(m*Wo*(0:(M-1)) + phi(m));
endfor
figure(1);
clf;
plot(s);
fwrite(fs,s,"short");
f0 = f0 + 5;
if (f0 > 400)
f0 = 100;
endif
endfor
fclose(fs);
endfunction

View File

@ -0,0 +1,42 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
function pl(samname1, start_sam, end_sam, pngname)
fs=fopen(samname1,"rb");
s=fread(fs,Inf,"short");
st = 1;
en = length(s);
if (nargin >= 2)
st = start_sam;
endif
if (nargin >= 3)
en = end_sam;
endif
figure(1);
clf;
plot(s(st:en));
axis([1 en-st min(s) max(s)]);
if (nargin == 4)
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
endif
endfunction

View File

@ -0,0 +1,50 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
function pl2(samname1, samname2, start_sam, end_sam, pngname)
fs1=fopen(samname1,"rb");
s1=fread(fs1,Inf,"short");
fs2=fopen(samname2,"rb");
s2=fread(fs2,Inf,"short");
st = 1;
en = length(s1);
if (nargin >= 3)
st = start_sam;
endif
if (nargin >= 4)
en = end_sam;
endif
figure(1);
clf;
subplot(211);
l1 = strcat("r;",samname1,";");
plot(s1(st:en), l1);
axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
subplot(212);
l2 = strcat("r;",samname2,";");
plot(s2(st:en),l2);
axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
if (nargin == 5)
% small image
__gnuplot_set__ terminal png size 420,300
s = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(s)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
s = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(s)
replot;
endif
endfunction

View File

@ -0,0 +1,166 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot ampltiude modelling information from dump files.
function plamp(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
sw__name = strcat(samname,"_sw_.txt");
if (file_in_path(".",sw__name))
Sw_ = load(sw__name);
endif
model_name = strcat(samname,"_model.txt");
model = load(model_name);
modelq_name = strcat(samname,"_qmodel.txt");
if (file_in_path(".",modelq_name))
modelq = load(modelq_name);
endif
pw_name = strcat(samname,"_pw.txt");
if (file_in_path(".",pw_name))
Pw = load(pw_name);
endif
lsp_name = strcat(samname,"_lsp.txt");
if (file_in_path(".",lsp_name))
lsp = load(lsp_name);
endif
phase_name = strcat(samname,"_phase.txt");
if (file_in_path(".",phase_name))
phase = load(phase_name);
endif
phase_name_ = strcat(samname,"_phase_.txt");
if (file_in_path(".",phase_name_))
phase_ = load(phase_name_);
endif
snr_name = strcat(samname,"_snr.txt");
if (file_in_path(".",snr_name))
snr = load(snr_name);
endif
k = ' ';
do
figure(1);
clf;
% s = [ Sn(2*(f-2)-1,:) Sn(2*(f-2),:) ];
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s);
axis([1 length(s) -20000 20000]);
figure(2);
Wo = model(f,1);
L = model(f,2);
Am = model(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r");
axis([1 4000 -10 80]);
hold on;
% plot((0:255)*4000/256, Sw(f-2,:),";Sw;");
plot((0:255)*4000/256, Sw(f,:),";Sw;");
if (file_in_path(".",modelq_name))
Amq = modelq(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" );
if (file_in_path(".",pw_name))
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;c");
endif
signal = Am * Am';
noise = (Am-Amq) * (Am-Amq)';
snr1 = 10*log10(signal/noise);
Am_err_label = sprintf(";Am error SNR %4.2f dB;m",snr1);
plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label);
endif
if (file_in_path(".",snr_name))
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
plot(1,1,snr_label);
endif
% phase model - determine SNR and error spectrum for phase model 1
if (file_in_path(".",phase_name_))
orig = Am.*exp(j*phase(f,1:L));
synth = Am.*exp(j*phase_(f,1:L));
signal = orig * orig';
noise = (orig-synth) * (orig-synth)';
snr_phase = 10*log10(signal/noise);
phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
endif
if (file_in_path(".",lsp_name))
for l=1:10
plot([lsp(f,l)*4000/pi lsp(f,l)*4000/pi], [60 80], 'r');
endfor
endif
hold off;
if (file_in_path(".",phase_name))
figure(3);
plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;");
axis;
if (file_in_path(".",phase_name_))
hold on;
plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;");
hold off;
endif
figure(2);
endif
% autocorrelation function to research voicing est
%M = length(s);
%sw = s .* hanning(M)';
%for k=0:159
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
%endfor
%figure(4);
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
%plot(R/R(1),R_label);
%grid
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
figure(1);
pngname = sprintf("%s_%d_sn.png",samname,f);
print(pngname, '-dpng', "-S500,500")
pngname = sprintf("%s_%d_sn_large.png",samname,f);
print(pngname, '-dpng', "-S800,600")
figure(2);
pngname = sprintf("%s_%d_sw.png",samname,f);
print(pngname, '-dpng', "-S500,500")
pngname = sprintf("%s_%d_sw_large.png",samname,f);
print(pngname, '-dpng', "-S800,600")
endif
until (k == 'q')
printf("\n");
endfunction

View File

@ -0,0 +1,11 @@
load ../unittest/tinterp_prev.txt;
load ../unittest/tinterp_interp.txt;
load ../unittest/tinterp_next.txt;
clf;
plot(tinterp_prev(:,1), 20.0*log10(tinterp_prev(:,2)),";prev;")
hold on;
plot(tinterp_interp(:,1), 20.0*log10(tinterp_interp(:,2)),'g+-;interp;')
plot(tinterp_next(:,1), 20.0*log10(tinterp_next(:,2)),'ro-;next;')
hold off;
axis([0 pi 0 80])

View File

@ -0,0 +1,134 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot NLP states from dump files.
function plnlp(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
fw_name = strcat(samname,"_fw.txt");
if (file_in_path(".",fw_name))
fw = load(fw_name);
endif
e_name = strcat(samname,"_e.txt");
if (file_in_path(".",e_name))
e = load(e_name);
endif
p_name = strcat(samname,".p");
if (file_in_path(".",p_name))
p = load(p_name);
endif
sq_name = strcat(samname,"_sq.txt");
if (file_in_path(".",sq_name))
sq = load(sq_name);
endif
dec_name = strcat(samname,"_dec.txt");
if (file_in_path(".",dec_name))
dec = load(dec_name);
endif
do
figure(1);
clf;
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s, ";Sn;");
grid
axis([1 length(s) -20000 20000]);
figure(2);
plot((0:255)*4000/256, Sw(f,:),";Sw;");
grid
axis([1 4000 -10 80]);
hold on;
f0 = 8000/p(f);
Wo = 2*pi/p(f);
L = floor(pi/Wo);
f0_label = sprintf("b;P=%3.1f F0=%3.0f;",p(f),f0);
for m=1:L-1
plot([ m*Wo*4000/pi m*Wo*4000/pi], [10 60], 'b');
endfor
plot([ L*Wo*4000/pi L*Wo*4000/pi], [10 60], f0_label);
hold off;
if (file_in_path(".",fw_name))
figure(3);
if (file_in_path(".",e_name))
subplot(211);
endif
plot((0:255)*800/256, fw(f,:)/max(fw(f,:)), ";Fw;");
axis([1 400 0 1]);
if (file_in_path(".",e_name))
subplot(212);
e_concat = [ e(2*f-1,:) e(2*f,:) ];
plot(e_concat(1:400)/max(e_concat(1:400)), "+;MBE E(f);");
axis([1 400 0 1]);
endif
endif
if (file_in_path(".",sq_name))
figure(4);
sq_concat = [ sq(2*f-1,:) sq(2*f,:) ];
axis
plot(sq_concat, ";sq;");
endif
if (file_in_path(".",dec_name))
figure(5);
plot(dec(f,:), ";dec;");
endif
figure(2);
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
pngname = sprintf("%s_%d",samname,f);
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
until (k == 'q')
printf("\n");
endfunction

View File

@ -0,0 +1,198 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot phase modelling information from dump files.
function plphase(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
model_name = strcat(samname,"_model.txt");
model = load(model_name);
sw__name = strcat(samname,"_sw_.txt");
if (file_in_path(".",sw__name))
Sw_ = load(sw__name);
endif
pw_name = strcat(samname,"_pw.txt");
if (file_in_path(".",pw_name))
Pw = load(pw_name);
endif
ak_name = strcat(samname,"_ak.txt");
if (file_in_path(".",ak_name))
ak = load(ak_name);
endif
phase_name = strcat(samname,"_phase.txt");
if (file_in_path(".",phase_name))
phase = load(phase_name);
endif
phase_name_ = strcat(samname,"_phase_.txt");
if (file_in_path(".",phase_name_))
phase_ = load(phase_name_);
endif
snr_name = strcat(samname,"_snr.txt");
if (file_in_path(".",snr_name))
snr = load(snr_name);
endif
sn_name_ = strcat(samname,".raw");
if (file_in_path(".",sn_name_))
fs_ = fopen(sn_name_,"rb");
sn_ = fread(fs_,Inf,"short");
endif
k = ' ';
do
figure(1);
clf;
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s);
grid;
axis([1 length(s) -20000 20000]);
if (k == 'p')
pngname = sprintf("%s_%d_sn",samname,f);
png(pngname);
endif
figure(2);
Wo = model(f,1);
L = model(f,2);
Am = model(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Am),"r;Am;");
axis([1 4000 -10 80]);
hold on;
plot((0:255)*4000/256, Sw(f,:),";Sw;");
grid;
if (file_in_path(".",sw__name))
plot((0:255)*4000/256, Sw_(f,:),"g;Sw_;");
endif
if (file_in_path(".",pw_name))
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;");
endif
if (file_in_path(".",snr_name))
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
plot(1,1,snr_label);
endif
% phase model - determine SNR and error spectrum for phase model 1
if (file_in_path(".",phase_name_))
orig = Am.*exp(j*phase(f,1:L));
synth = Am.*exp(j*phase_(f,1:L));
signal = orig * orig';
noise = (orig-synth) * (orig-synth)';
snr_phase = 10*log10(signal/noise);
phase_err_label = sprintf("g;phase_err SNR %4.2f dB;",snr_phase);
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
endif
hold off;
if (k == 'p')
pngname = sprintf("%s_%d_sw",samname,f);
png(pngname);
endif
if (file_in_path(".",phase_name))
figure(3);
plot((1:L)*Wo*4000/pi, phase(f,1:L)*180/pi, "-o;phase;");
axis;
if (file_in_path(".", phase_name_))
hold on;
plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase_;");
grid
hold off;
endif
if (k == 'p')
pngname = sprintf("%s_%d_phase",samname,f);
png(pngname);
endif
endif
% synthesised speech
if (file_in_path(".",sn_name_))
figure(4);
s_ = sn_((f-3)*80+1:(f+1)*80);
plot(s_);
axis([1 length(s_) -20000 20000]);
if (k == 'p')
pngname = sprintf("%s_%d_sn_",samname,f)
png(pngname);
endif
endif
if (file_in_path(".",ak_name))
figure(5);
axis;
akw = ak(f,:);
weight = 1.0 .^ (0:length(akw)-1);
akw = akw .* weight;
H = 1./fft(akw,8000);
subplot(211);
plot(20*log10(abs(H(1:4000))),";LPC mag spec;");
grid;
subplot(212);
plot(angle(H(1:4000))*180/pi,";LPC phase spec;");
grid;
if (k == 'p')
% stops multimode errors from gnuplot, I know not why...
figure(2);
figure(5);
pngname = sprintf("%s_%d_lpc",samname,f);
png(pngname);
endif
endif
% autocorrelation function to research voicing est
%M = length(s);
%sw = s .* hanning(M)';
%for k=0:159
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
%endfor
%figure(4);
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
%plot(R/R(1),R_label);
%grid
figure(2);
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
pngname = sprintf("%s_%d",samname,f);
png(pngname);
endif
until (k == 'q')
printf("\n");
endfunction

View File

@ -0,0 +1,36 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% plpitch.m
% Plots two pitch tracks on top of each other, used for comparing pitch
% estimators
function plpitch(pitch1_name, pitch2_name, start_fr, end_fr)
pitch1 = load(pitch1_name);
pitch2 = load(pitch2_name);
st = 1;
en = length(pitch1);
if (nargin >= 3)
st = start_fr;
endif
if (nargin >= 4)
en = end_fr;
endif
figure(1);
clf;
l1 = strcat("r;",pitch1_name,";")
l1
st
en
plot(pitch1(st:en), l1);
axis([1 en-st 20 160]);
l2 = strcat("g;",pitch2_name,";");
hold on;
plot(pitch2(st:en),l2);
hold off;
endfunction

View File

@ -0,0 +1,25 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Replot current plot as a png, generates small and large versions
function png(pngname)
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endfunction

View File

@ -0,0 +1,24 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot postfilter doing its thing
function postfilter(samname)
p = load(samname);
figure(1);
plot(p(:,1),";energy;");
hold on;
plot(p(:,2),";bg_est;");
hold off;
grid;
pngname=sprintf("%s_postfilter_1", samname);
png(pngname);
figure(2);
plot(p(:,3),";% unvoiced;");
grid;
pngname=sprintf("%s_postfilter_2", samname);
png(pngname);
endfunction

View File

@ -0,0 +1,37 @@
% pulse.m
% David Rowe August 2009
%
% Experiments with human pulse perception for sinusoidal codecs
function pulse(samname)
A = 1000;
K = 16000;
N = 80;
frames = K/N;
s = zeros(1,K);
for f=1:frames
% lets try placing np random pulses in every frame
P = 20 + (160-20)*rand(1,1);
Wo = 2*pi/P;
L = floor(pi/Wo);
sf = zeros(1,N);
for m=1:L/2:L
pos = floor(rand(1,1)*N)+1;
%pos = 50;
for l=m:m+L/2-1
sf = sf + A*cos(l*Wo*((f-1)*N+1:f*N) - pos*l*Wo);
endfor
endfor
s((f-1)*N+1:f*N) = sf;
endfor
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
endfunction

View File

@ -0,0 +1,298 @@
111.627907
97.959183
97.959183
97.959183
87.272736
78.048775
112.280701
120.000008
61.538464
68.817207
84.210526
90.140846
90.140846
90.140846
101.587303
80.000000
72.727272
95.522392
90.140846
90.140846
101.587303
90.140846
85.333336
86.486488
91.428574
91.428574
91.428574
91.428574
91.428574
90.140846
86.486488
86.486488
85.333336
85.333336
85.333336
81.012657
74.418610
71.111115
71.111115
71.111115
71.111115
68.085106
68.085106
67.368423
67.368423
70.329674
70.329674
70.329674
71.111115
74.418610
74.418610
75.294121
79.012352
85.333336
96.969704
111.627907
111.627907
120.000008
111.627907
104.347832
104.347832
97.959183
104.347832
104.347832
104.347832
104.347832
104.347832
104.347832
104.347832
104.347832
97.959183
97.959183
112.280701
112.280701
96.969704
96.969704
96.969704
110.344841
104.347832
97.959183
97.959183
104.347832
97.959183
104.347832
120.000008
104.347832
120.000008
120.000008
97.959183
83.116882
75.294121
71.910118
71.910110
71.910110
71.910110
75.294121
76.190483
80.000008
80.000008
84.210526
85.333336
90.140846
101.587303
108.474571
104.347832
120.000008
120.000008
104.347832
104.347832
71.111115
88.888893
75.294121
111.627907
120.000008
120.000008
97.959183
111.627907
111.627907
111.627907
97.959183
92.307693
92.307693
92.307693
92.307693
120.000008
111.627907
111.627907
86.486488
85.333336
85.333336
90.140846
95.522392
101.587311
101.587311
104.918037
104.347832
104.347832
111.627907
120.000008
97.959183
104.347832
111.627907
88.888893
80.000000
81.012657
85.333336
85.333336
86.486488
91.428574
90.140846
91.428574
96.969704
96.969704
95.522392
95.522392
95.522392
96.969704
96.969704
98.461533
104.918022
97.959183
97.959183
97.959183
104.347832
120.000008
120.000008
92.307693
92.307693
77.108429
79.012344
75.294121
75.294121
76.190483
76.190483
80.000008
81.012657
85.333336
85.333336
85.333336
85.333336
85.333336
90.140846
90.140846
91.428574
96.969704
98.461533
120.000008
120.000008
104.347832
97.959183
97.959183
104.918037
120.000008
120.000008
120.000008
104.347832
92.307693
72.727272
72.727272
76.190483
84.210533
88.888901
120.000008
104.347832
120.000008
120.000008
111.627907
92.307693
97.959183
97.959183
111.627907
120.000008
120.000008
97.959183
97.959183
104.347832
104.347832
104.347832
111.627907
120.000008
97.959183
104.347832
97.959183
97.959183
84.210526
94.117653
96.969704
110.344841
120.000008
97.959183
97.959183
104.347832
97.959183
104.347832
97.959183
97.959183
111.627907
120.000008
92.307693
92.307693
98.461533
98.461533
104.918022
111.627907
111.627907
92.307693
97.959183
92.307693
92.307693
92.307693
92.307693
92.307693
57.657658
90.140846
90.140846
95.522392
101.587311
101.587311
108.474586
111.627907
97.959183
111.627907
120.000008
92.307693
74.418610
74.418610
74.418610
74.418610
76.190483
72.727280
76.190483
76.190483
69.565224
66.666672
54.700855
56.637169
56.637169
71.910110
90.140846
90.140846
72.727272
72.727272
72.727272
72.727272
55.172413
57.142857
55.172413
90.140846
95.522392
101.587311
101.587311
71.910110
74.418610
46.376812
40.000000
95.522392
0
0

Some files were not shown because too many files have changed in this diff Show More