freetdm: Removed ftmod_sangoma_boost

This commit is contained in:
David Yat Sin 2011-02-16 11:06:26 -05:00
parent 7b30aec93d
commit 925623c19e
13 changed files with 1 additions and 4836 deletions

View File

@ -39,7 +39,6 @@ libdir = @libdir@
library_includedir = $(prefix)/include
INCS = -I$(FT_SRCDIR)/$(SRC)/include -I$(FT_SRCDIR)/$(SRC)/include/private
INCS += -I$(FT_SRCDIR)/$(SRC)/ftmod/ftmod_sangoma_boost
if HAVE_SNG_SS7
INCS += -I/usr/include/sng_ss7
@ -109,7 +108,6 @@ core-install: install-libLTLIBRARIES
# tools & test programs
#
noinst_PROGRAMS = testtones detect_tones detect_dtmf testpri testr2 testanalog testapp testcid
noinst_PROGRAMS += testsangomaboost
testapp_SOURCES = $(SRC)/testapp.c
testapp_LDADD = libfreetdm.la
@ -143,17 +141,6 @@ testr2_SOURCES = $(SRC)/testr2.c
testr2_LDADD = libfreetdm.la
testr2_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
if HAVE_SCTP
noinst_PROGRAMS += testboost
testboost_SOURCES = $(SRC)/testboost.c
testboost_LDADD = libfreetdm.la
testboost_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
endif
testsangomaboost_SOURCES = $(SRC)/testsangomaboost.c
testsangomaboost_LDADD = libfreetdm.la
testsangomaboost_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
testanalog_SOURCES = $(SRC)/testanalog.c
testanalog_LDADD = libfreetdm.la
testanalog_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
@ -201,14 +188,6 @@ ftmod_isdn_la_LDFLAGS = -shared -module -avoid-version $(LIBISDN_LDFLAGS) $(PCA
ftmod_isdn_la_LIBADD = libfreetdm.la $(LIBISDN_LIBS) $(PCAP_LIBS)
endif
if HAVE_SCTP
mod_LTLIBRARIES += ftmod_sangoma_boost.la
ftmod_sangoma_boost_la_SOURCES = $(SRC)/ftmod/ftmod_sangoma_boost/sangoma_boost_client.c $(SRC)/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c
ftmod_sangoma_boost_la_CFLAGS = $(AM_CFLAGS) $(FTDM_CFLAGS)
ftmod_sangoma_boost_la_LDFLAGS = -shared -module -avoid-version
ftmod_sangoma_boost_la_LIBADD = libfreetdm.la
endif
if HAVE_LIBPRI
mod_LTLIBRARIES += ftmod_libpri.la
ftmod_libpri_la_SOURCES = $(SRC)/ftmod/ftmod_libpri/ftmod_libpri.c $(SRC)/ftmod/ftmod_libpri/lpwrap_pri.c

View File

@ -121,8 +121,7 @@ AC_CHECK_LIB([dl], [dlopen])
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([m], [cos])
AC_CHECK_HEADERS([netinet/sctp.h netdb.h sys/select.h])
AM_CONDITIONAL([HAVE_SCTP],[test "${ac_cv_header_netinet_sctp_h}" = "yes"])
AC_CHECK_HEADERS([netdb.h sys/select.h])
AC_CHECK_FUNC([gethostbyname_r],
[], [AC_CHECK_LIB([nsl], [gethostbyname_r])]

View File

@ -1,20 +0,0 @@
== Boost sigmod current limitations ==
- we don't support having openzap spans with physical channels
belonging to other physical spans. this is due to netborder sangoma abstraction, therefore
any openzap span using sigboost must have only channels belonging to the corresponding
physical span.
This is the reason we added group functionality in openzap core, furthermore, previous groups in openzap
were only possible through adding of b-channels to a single span, but this forces the user to create groups
of channels only whithin the same type of trunk among other things.
- all spans must be configured and then started, cannot configure, start, configure start etc
this is due to netborder telesoft abstraction. that requires configuring everything and
then starting everything at once.
- sangoma_prid and sangoma_brid on Windows had to be compiled hacking make/Makefile.platform to comment all VC runtime checks,
otherwise when running in debug mode exceptions are thrown due to loss of data ie short to char conversions.
== TODO ==
- proper upper layer management of HW alarms (this must be done in mod_openzap.c)

View File

@ -1,146 +0,0 @@
== General Design ==
NBE will do its current loading of spans and configuration process through Sangoma Board Manager (SBM).
After doing SangomaBoardManager::getInstance().configure -> start. It will proceed to initalize
the openzap stack (just as the TelesoftStack is loaded after starting SMB. The procedure will be:
- create a static or malloced zap_io_interface_t
- call zap_global_set_logger with the logging hooks.
- call zap_global_set_memhandler() with the memory hooks.
- call zap_global_init() to initialize the stack
- call zap_add_io_iface() to add the I/O iface.
- iterate over all SBM spans configured for BRI or any boost-managed signaling and:
* call zap_span_create(NBE I/O mod, in_ptrSpan, SMB span name)
* Fill in some members like:
span->trunk_type = E1/T1/J1/FXO/FXS etc ...
* iterate over all channels in SMB span and:
* zap_span_add_channel(zap_span, sock, type:CAS|BCHAN|DCHAN|ETC)
* call zap_configure_span("sangoma_boost", span, sigmsg_callback, "param1", value1, "param2", value1 ...)
* zap_span_start(span);
At this point, NBE would receive signaling msgs via sigmsg_callback registered when configuring
and NBE would request hangup or making calls throug openzap API, like zap_set_state_* and zap_channel_outgoing_call() to place calls.
When NBE wants to check for link status.
zap_get_siglink_state() which would return
ZAP_SIG_STATE_UP (D-chan UP, R2 bits in IDLE, ss7?)
ZAP_SIG_STATE_SUSPENDED (D-chan in power saving mode?)
ZAP_SIG_STATE_DOWN (D-chan down, R2 bits in blocked, ss7?)
Whenever a state in sig link changes, the sigmsg_callback will be used to notify NBE or any other user.
NOTE: right now hardware alarms notification in openzap is seriously broken,
see ozmod_libpri.c process_event ... reads an event from hardware (zap_event_t *),
then checks the event type, if its ZAP_OOB_ALARM_TRAP prepares a zap_sigmsg_t
(signaling event) setting its event_id to ZAP_OOB_ALARM_TRAP, which is *WRONG*
because event_id is of type zap_signal_event_t and not zap_oob_event_t!
this means on alarm the user will get ZAP_SIGEVENT_PROGRESS_MEDIA!! which is
value 7 that is in conflict with ZAP_OOB_ALARM_TRAP, I think a separate
callback should be used if the outside user wants to be notified about
hardware events like HW DTMF or so. Currently there is alreadya generic DTMF
listener.
== Tasks Stage 1 / OpenZAP and Boost changes (To be tested with FreeSWITCH) ==
- Change malloc and other mem functions in openzap
to use internal hooks provided via zap_global_set_memhandler()
which would be called before zap_global_init(), this is
already done for the logger via zap_global_set_logger()
question: should the mem routines allow for memory pool ptr?
this could be useful to provide a memory pool to
the whole module.
question: should we allow hooks for threads and locking?
I think we can skip this one unless needed. They already
use their own threading abstraction which is working for
Linux and Windows. If we ever need to profile threading
we can add profiling hooks.
question: I had to add openzap calls to the hash table and libteletone implementations, is that acceptable?
- Modify zap_global_init() API
This API must just initialize vars, mutexes etc.
and NOT DO ANY CONFIGURATION LOADING, PARSING, SPAN CREATION and I/O
configuration, which is what is currently doing.
We don't want zap_global_init() to create the spans based on that configuration
since NBE will have its own configuration and will take care of creating
the needed data structures on its own.
- Add new zap_std_io_config() API
This API will parse the standard openzap.conf module and create the spans.
This will be used by FS but not by NBE, which will create the openzap spans by itself.
The NBE flow to initialize openzap will be:
- Add new API zap_global_add_io_iface(),
This API will add a new I/O interface structure to the internal openzap hash of I/O structs.
This is needed because NBE I/O structure will NOT be loaded from an openzap module (.so/.dll)
but rather just registered on runtime (probably from a static structure in NBE code).
This openzap hash is used by zap_api_execute() for example, to find the module that can
handle a given API, ie (oz libpri status). This is an example of how an openzap I/O interface
can decide to implement just the ->api() member to handle commands and NOTHING else,
so I/O interfaces not necessary are hardware-related.
- Add new zap_channel_get_siglink_state(zap_channel, zap_siglink_status_t &status)
- Modify mod_openzap.c to read proto= setting in boost spans, this will determine wich boost sig
module will handle the configuration and those channels.
<boost_spans> <span sigmod="bri|ss7|blah"> <param="proto-specific-setting" value="setting"> </span> </boost_spans>
Then as first config arg to zap_config_span() the boost proto module name would be included as "sigmod" which will be used
by ozmod_sangoma_boost to decide which sig module must handle that span configuration
- Create minimal boost mod interface.
ozmod_boost_ss7 should load sig boost mods and get interface via dlsym(boost_get_interface) boost_get_interface(boost_iface);
The boost interface will have
* const char *name // boost sigmod name (brid,ss7d)
* set_write_boost_msg_cb(callback) // tell the stack how to send us boost messages
* set_sig_status_cb(callback); // tell the stack how to notify us about link status changes
* write_boost_msg(struct boost_msg) // send a boost msg to the stack
* configure_span(zap_span_t span, "configuration", value, "configuration", value) // configure a given span
* get_sig_status(openzap_sigstatus_t status)
* start(span) // to start a given openzap span
* stop(span) // to stop the stack on a given openzap span
- Migrate current sangoma_brid sig module to openzap
* Make sangoma_brid a library
* Move from using malloc, threading, locking, logging and I/O to openzap functions. Export the boost sigmod interface and its supporting code.
== State 2 Tasks ==
- Create the I/O NBE interface and supporting functions. It must be possible to poll over the span
given that ozmod_sangoma_boost BRI module and others may need to *wait* for data. The poll()
function in I/O NBE interface would wait on a pthread condition or Windows event, which would
be triggered by some external NBE component registered with Sangoma Board Manager (SMB) for d-chan
data, whenever d-chan data arrives, saves the data in a buffer and triggers the condition to wakeup
any waiter, then the waiter (sangoma_brid or any other boost client) calls zap_channel_read which calls
our own I/O NBE interface read method and retrieves the data from the buffer.
Dropped alternative design:
Another option is to add a new API zap_span_push_incoming_data(span/chan, data); However this changes
the model openzap has followed and I don't think fits that well, since now we have 2 different models
to support in openzap.
== TODO ==
- how about logging specific modules, like, just ozmod_boost, or just the BRI stack?
more work to be done so the BRI module uses zap_log instead of current syslog
then work to be done to be able to filter logs from specific openzap code? is it worth it?
- remove FORCE_SEGFAULT from sprid
=== Shortcomings ==
- we had to drop smg support in the branch where we work on sangoma prid.
After all, most people using sangoma_prid is using freeswitch/openzap and not Sangoma Media Gateway
The problem is in freeswitch/openzap mode, sangoma_boost ozmod takes care of span events (POLLPRI)
where in SMG and Netborder POLLPRI is done typically by sangoma board manager.

View File

@ -1,75 +0,0 @@
/*
* Copyright (c) 2007, Anthony Minessale II
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FTDM_SANGOMA_BOOST_H
#define FTDM_SANGOMA_BOOST_H
#include "sangoma_boost_client.h"
#include "freetdm.h"
#define MAX_CHANS_PER_TRUNKGROUP 1024
typedef enum {
FTDM_SANGOMA_BOOST_RUNNING = (1 << 0),
FTDM_SANGOMA_BOOST_RESTARTING = (1 << 1),
FTDM_SANGOMA_BOOST_EVENTS_RUNNING = (1 << 2),
} ftdm_sangoma_boost_flag_t;
typedef struct ftdm_sangoma_boost_data {
sangomabc_connection_t mcon;
sangomabc_connection_t pcon;
int iteration;
uint32_t flags;
boost_sigmod_interface_t *sigmod;
ftdm_queue_t *boost_queue;
} ftdm_sangoma_boost_data_t;
typedef struct ftdm_sangoma_boost_trunkgroup {
ftdm_mutex_t *mutex;
ftdm_size_t size; /* Number of b-channels in group */
unsigned int last_used_index; /* index of last b-channel used */
ftdm_channel_t* ftdmchans[MAX_CHANS_PER_TRUNKGROUP];
//TODO need to merge congestion timeouts to this struct
} ftdm_sangoma_boost_trunkgroup_t;
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/

View File

@ -1,373 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ftmod_sangoma_boost"
ProjectGUID="{D021EF2A-460D-4827-A0F7-41FDECF46F1B}"
RootNamespace="ftmod_sangoma_boost"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include;..\..\isdn\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4100"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="freetdm.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include;..\..\isdn\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4100"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="freetdm.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4100"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="false"
DebugInformationFormat="3"
DisableSpecificWarnings="4100"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="ftmod_sangoma_boost.c"
>
</File>
<File
RelativePath="sangoma_boost_client.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="ftdm_sangoma_boost.h"
>
</File>
<File
RelativePath="sangoma_boost_client.h"
>
</File>
<File
RelativePath="sangoma_boost_interface.h"
>
</File>
<File
RelativePath="sigboost.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,206 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>ftmod_sangoma_boost</ProjectName>
<ProjectGuid>{D021EF2A-460D-4827-A0F7-41FDECF46F1B}</ProjectGuid>
<RootNamespace>ftmod_sangoma_boost</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;..\..\isdn\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_SANGOMA_BOOST_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ftmod_sangoma_boost.c" />
<ClCompile Include="sangoma_boost_client.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ftdm_sangoma_boost.h" />
<ClInclude Include="sangoma_boost_client.h" />
<ClInclude Include="sangoma_boost_interface.h" />
<ClInclude Include="sigboost.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\msvc\freetdm.2010.vcxproj">
<Project>{93b8812c-3ec4-4f78-8970-ffbfc99e167d}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ftmod_sangoma_boost.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sangoma_boost_client.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ftdm_sangoma_boost.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sangoma_boost_client.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sangoma_boost_interface.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sigboost.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,589 +0,0 @@
/*
* Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE
#if HAVE_NETDB_H
#include <netdb.h>
#endif
#include "freetdm.h"
#include "sangoma_boost_client.h"
#ifndef HAVE_GETHOSTBYNAME_R
extern int gethostbyname_r (const char *__name,
struct hostent *__result_buf,
char *__buf, size_t __buflen,
struct hostent **__result,
int *__h_errnop);
#endif
struct sangomabc_map {
uint32_t event_id;
const char *name;
};
static struct sangomabc_map sangomabc_table[] = {
{SIGBOOST_EVENT_CALL_START, "CALL_START"},
{SIGBOOST_EVENT_CALL_START_ACK, "CALL_START_ACK"},
{SIGBOOST_EVENT_CALL_START_NACK, "CALL_START_NACK"},
{SIGBOOST_EVENT_CALL_PROGRESS, "CALL PROGRESS"},
{SIGBOOST_EVENT_CALL_START_NACK_ACK, "CALL_START_NACK_ACK"},
{SIGBOOST_EVENT_CALL_ANSWERED, "CALL_ANSWERED"},
{SIGBOOST_EVENT_CALL_STOPPED, "CALL_STOPPED"},
{SIGBOOST_EVENT_CALL_STOPPED_ACK, "CALL_STOPPED_ACK"},
{SIGBOOST_EVENT_CALL_RELEASED, "CALL_RELEASED"},
{SIGBOOST_EVENT_SYSTEM_RESTART, "SYSTEM_RESTART"},
{SIGBOOST_EVENT_SYSTEM_RESTART_ACK, "SYSTEM_RESTART_ACK"},
{SIGBOOST_EVENT_HEARTBEAT, "HEARTBEAT"},
{SIGBOOST_EVENT_INSERT_CHECK_LOOP, "LOOP START"},
{SIGBOOST_EVENT_REMOVE_CHECK_LOOP, "LOOP STOP"},
{SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE, "AUTO_CALL_GAP_ABATE"},
{SIGBOOST_EVENT_DIGIT_IN, "DIGIT_IN"}
};
static void sangomabc_print_event_call(sangomabc_connection_t *mcon, sangomabc_event_t *event, int priority, int dir, const char *file, const char *func, int line)
{
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
return;
ftdm_log(file, func, line, mcon->debuglevel, "%s EVENT (%s): %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s] Rdnis=[%s]\n",
dir ? "TX":"RX",
priority ? "P":"N",
sangomabc_event_id_name(event->event_id),
event->event_id,
BOOST_EVENT_SPAN(mcon->sigmod, event),
BOOST_EVENT_CHAN(mcon->sigmod, event),
event->call_setup_id,
event->fseqno,
strlen(event->calling_name)?event->calling_name:"N/A",
(event->called_number_digits_count ? (char *) event->called_number_digits : "N/A"),
(event->calling_number_digits_count ? (char *) event->calling_number_digits : "N/A"),
event->isup_in_rdnis);
}
static void sangomabc_print_event_short(sangomabc_connection_t *mcon, sangomabc_short_event_t *event, int priority, int dir, const char *file, const char *func, int line)
{
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
return;
ftdm_log(file, func, line, mcon->debuglevel, "%s EVENT (%s): %s:(%X) [s%dc%d] Rc=%i CSid=%i Seq=%i \n",
dir ? "TX":"RX",
priority ? "P":"N",
sangomabc_event_id_name(event->event_id),
event->event_id,
BOOST_EVENT_SPAN(mcon->sigmod, event),
BOOST_EVENT_CHAN(mcon->sigmod, event),
event->release_cause,
event->call_setup_id,
event->fseqno);
}
static int create_conn_socket(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
{
#ifndef WIN32
int rc;
struct hostent *result, *local_result;
char buf[512], local_buf[512];
int err = 0, local_err = 0;
if (mcon->sigmod) {
ftdm_log(FTDM_LOG_WARNING, "I should not be called on a sigmod-managed connection!\n");
return 0;
}
memset(&mcon->remote_hp, 0, sizeof(mcon->remote_hp));
memset(&mcon->local_hp, 0, sizeof(mcon->local_hp));
#ifdef HAVE_NETINET_SCTP_H
ftdm_log(FTDM_LOG_DEBUG, "Creating SCTP socket L=%s:%d R=%s:%d\n",
local_ip, local_port, ip, port);
mcon->socket = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
#else
ftdm_log(FTDM_LOG_DEBUG, "Creating UDP socket L=%s:%d R=%s:%d\n",
local_ip, local_port, ip, port);
mcon->socket = socket(AF_INET, SOCK_DGRAM, 0);
#endif
if (mcon->socket >= 0) {
int flag;
flag = 1;
#ifdef HAVE_GETHOSTBYNAME_R_FIVE
gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &err);
gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_err);
if (!err && !local_err) {
#else
gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &result, &err);
gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_result, &local_err);
if (result && local_result) {
#endif
mcon->remote_addr.sin_family = mcon->remote_hp.h_addrtype;
memcpy((char *) &mcon->remote_addr.sin_addr.s_addr, mcon->remote_hp.h_addr_list[0], mcon->remote_hp.h_length);
mcon->remote_addr.sin_port = htons(port);
mcon->local_addr.sin_family = mcon->local_hp.h_addrtype;
memcpy((char *) &mcon->local_addr.sin_addr.s_addr, mcon->local_hp.h_addr_list[0], mcon->local_hp.h_length);
mcon->local_addr.sin_port = htons(local_port);
#ifdef HAVE_NETINET_SCTP_H
setsockopt(mcon->socket, IPPROTO_SCTP, SCTP_NODELAY,
(char *)&flag, sizeof(int));
#endif
if ((rc = bind(mcon->socket,
(struct sockaddr *) &mcon->local_addr,
sizeof(mcon->local_addr))) < 0) {
close(mcon->socket);
mcon->socket = -1;
} else {
#ifdef HAVE_NETINET_SCTP_H
rc=listen(mcon->socket, 100);
if (rc) {
close(mcon->socket);
mcon->socket = -1;
}
#endif
}
}
}
return mcon->socket;
#else
return 0;
#endif // ifndef WIN32
}
int sangomabc_connection_close(sangomabc_connection_t *mcon)
{
#ifndef WIN32
if (mcon->sigmod) {
ftdm_log(FTDM_LOG_WARNING, "I should not be called on a sigmod-managed connection!\n");
return 0;
}
if (mcon->socket > -1) {
close(mcon->socket);
}
if (mcon->mutex) {
ftdm_mutex_lock(mcon->mutex);
ftdm_mutex_unlock(mcon->mutex);
ftdm_mutex_destroy(&mcon->mutex);
}
memset(mcon, 0, sizeof(*mcon));
mcon->socket = -1;
#endif
return 0;
}
int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
{
ftdm_mutex_create(&mcon->mutex);
if (mcon->sigmod) {
/*value of mcon->socket will be ignored in sigmod mode */
return 0;
}
#ifndef WIN32
create_conn_socket(mcon, local_ip, local_port, ip, port);
return mcon->socket;
#else
return 0;
#endif
}
int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause, int flags)
{
sangomabc_event_t *oevent;
sangomabc_short_event_t sevent;
sangomabc_event_t fevent;
int retry = 5;
if (boost_full_event(cmd)) {
sangomabc_event_init((void *)&fevent, cmd, chan, span);
oevent = &fevent;
} else {
sangomabc_event_init(&sevent, cmd, chan, span);
sevent.release_cause = (uint8_t)cause;
oevent = (sangomabc_event_t *)&sevent;
}
oevent->flags = flags;
if (cmd == SIGBOOST_EVENT_SYSTEM_RESTART || cmd == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
mcon->rxseq_reset = 1;
mcon->txseq = 0;
mcon->rxseq = 0;
mcon->txwindow = 0;
}
if (id >= 0) {
oevent->call_setup_id = (uint16_t)id;
}
while (sangomabc_connection_write(mcon, (sangomabc_event_t*)oevent) <= 0) {
if (--retry <= 0) {
ftdm_log(FTDM_LOG_CRIT, "Failed to tx on boost socket: %s\n", strerror(errno));
return -1;
} else {
ftdm_log(FTDM_LOG_WARNING, "Failed to tx on boost socket: %s :retry %i\n", strerror(errno), retry);
ftdm_sleep(1);
}
}
return 0;
}
int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause)
{
sangomabc_short_event_t oevent;
int retry = 5;
sangomabc_event_init(&oevent, cmd, chan, span);
oevent.release_cause = (uint8_t)cause;
if (id >= 0) {
oevent.call_setup_id = (uint16_t)id;
}
while (sangomabc_connection_writep(pcon, (sangomabc_event_t*)&oevent) <= 0) {
if (--retry <= 0) {
ftdm_log(FTDM_LOG_CRIT, "Failed to tx on boost socket: %s\n", strerror(errno));
return -1;
} else {
ftdm_log(FTDM_LOG_WARNING, "Failed to tx on boost socket: %s :retry %i\n", strerror(errno), retry);
ftdm_sleep(1);
}
}
return 0;
}
sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
{
#ifndef WIN32
unsigned int fromlen = sizeof(struct sockaddr_in);
#endif
int bytes = 0;
int msg_ok = 0;
sangomabc_queue_element_t *e = NULL;
if (mcon->sigmod) {
e = ftdm_queue_dequeue(mcon->boost_queue);
if (e) {
bytes = (int)e->size;
memcpy(&mcon->event, e->boostmsg, bytes);
ftdm_safe_free(e);
}
}
#ifndef WIN32
else {
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
(struct sockaddr *) &mcon->local_addr, &fromlen);
}
#endif
if (bytes <= 0) {
return NULL;
}
if (mcon->event.version != SIGBOOST_VERSION) {
ftdm_log(FTDM_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
}
if ((bytes >= MIN_SIZE_CALLSTART_MSG) && boost_full_event(mcon->event.event_id)) {
msg_ok=1;
} else if (bytes == sizeof(sangomabc_short_event_t)) {
msg_ok=1;
} else {
msg_ok=0;
}
if (msg_ok) {
if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
if (mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
mcon->event.event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
mcon->event.event_id != SIGBOOST_EVENT_HEARTBEAT) {
ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "Not reading packets when connection is down. [%s]\n",
sangomabc_event_id_name(mcon->event.event_id));
return NULL;
}
}
if (boost_full_event(mcon->event.event_id)) {
sangomabc_print_event_call(mcon, &mcon->event, 0, 0, file, func, line);
} else {
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)&mcon->event, 0, 0, file, func, line);
}
#if 0
/* NC: NOT USED ANY MORE */
if (mcon->rxseq_reset) {
//if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
ftdm_log(FTDM_LOG_DEBUG, "Rx sync ok\n");
mcon->rxseq = mcon->event.fseqno;
return &mcon->event;
//}
errno=EAGAIN;
ftdm_log(FTDM_LOG_DEBUG, "Waiting for rx sync...\n");
return NULL;
}
#endif
mcon->txwindow = mcon->txseq - mcon->event.bseqno;
mcon->rxseq++;
#if 0
if (mcon->rxseq != mcon->event.fseqno) {
ftdm_log(FTDM_LOG_CRIT, "Invalid Sequence Number Expect=%i Rx=%i\n", mcon->rxseq, mcon->event.fseqno);
return NULL;
}
#endif
return &mcon->event;
} else {
if (iteration == 0) {
ftdm_log(FTDM_LOG_CRIT, "NC - Invalid Event length from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
return NULL;
}
}
return NULL;
}
sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
{
#ifndef WIN32
unsigned int fromlen = sizeof(struct sockaddr_in);
#endif
int bytes = 0;
if (mcon->sigmod) {
/* priority stuff is handled just the same when there is a sigmod */
return sangomabc_connection_read(mcon, iteration);
}
#ifndef WIN32
else {
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT, (struct sockaddr *) &mcon->local_addr, &fromlen);
}
#endif
if (bytes <= 0) {
return NULL;
}
if (mcon->event.version != SIGBOOST_VERSION) {
ftdm_log(FTDM_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
}
if (bytes == sizeof(sangomabc_short_event_t)) {
if (boost_full_event(mcon->event.event_id)) {
sangomabc_print_event_call(mcon, &mcon->event, 1, 0, file, func, line);
} else {
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)&mcon->event, 1, 0, file, func, line);
}
return &mcon->event;
} else {
if (iteration == 0) {
ftdm_log(FTDM_LOG_CRIT, "Critical Error: PQ Invalid Event lenght from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
return NULL;
}
}
return NULL;
}
int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
{
int err = 0;
int event_size=MIN_SIZE_CALLSTART_MSG+event->isup_in_rdnis_size;
ftdm_assert_return(event != NULL, -1, "No event!");
ftdm_assert_return(mcon->socket >= 0, -1, "No mcon->socket!");
ftdm_assert_return(mcon->mutex != NULL, -1, "No mcon->mutex!");
ftdm_assert_return(event->span <= FTDM_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN, -1, "Invalid span when writing boost event\n");
ftdm_assert_return(event->chan <= FTDM_MAX_CHANNELS_PHYSICAL_SPAN, -1, "Invalid chan when writing boost event\n");
if (!boost_full_event(event->event_id)) {
event_size=sizeof(sangomabc_short_event_t);
}
if (sangomabc_test_flag(mcon, MSU_FLAG_DOWN)) {
if (event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART &&
event->event_id != SIGBOOST_EVENT_SYSTEM_RESTART_ACK &&
event->event_id != SIGBOOST_EVENT_HEARTBEAT) {
ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "Not writing packets when connection is down. [%s]\n",
sangomabc_event_id_name(event->event_id));
return 0;
}
}
ftdm_mutex_lock(mcon->mutex);
if (event->event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
mcon->txseq=0;
mcon->rxseq=0;
event->fseqno=0;
} else {
event->fseqno = mcon->txseq++;
}
event->bseqno = mcon->rxseq;
event->version = SIGBOOST_VERSION;
if (boost_full_event(event->event_id)) {
sangomabc_print_event_call(mcon, event, 0, 1, file, func, line);
} else {
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)event, 0, 1, file, func, line);
}
if (mcon->sigmod) {
mcon->sigmod->write_msg(mcon->span, event, event_size);
err = event_size;
}
#ifndef WIN32
else {
err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
}
#endif
ftdm_mutex_unlock(mcon->mutex);
ftdm_assert_return(err == event_size, -1, "Failed to send the boost message completely!");
return err;
}
int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
{
int err = 0;
int event_size=sizeof(sangomabc_event_t);
if (!mcon->sigmod) {
ftdm_assert_return(event != NULL, -1, "No event!");
ftdm_assert_return(mcon->socket >= 0, -1, "No mcon->socket!");
ftdm_assert_return(mcon->mutex != NULL, -1, "No mcon->mutex!");
}
if (!boost_full_event(event->event_id)) {
event_size=sizeof(sangomabc_short_event_t);
}
ftdm_mutex_lock(mcon->mutex);
event->version = SIGBOOST_VERSION;
if (mcon->sigmod) {
mcon->sigmod->write_msg(mcon->span, event, event_size);
err = event_size;
}
#ifndef WIN32
else {
err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
}
#endif
ftdm_mutex_unlock(mcon->mutex);
ftdm_assert_return(err == event_size, -1, "Failed to send boost message completely!");
if (boost_full_event(event->event_id)) {
sangomabc_print_event_call(mcon, event, 1, 1, file, func, line);
} else {
sangomabc_print_event_short(mcon, (sangomabc_short_event_t*)event, 1, 1, file, func, line);
}
return err;
}
void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id)
{
memset(event, 0, sizeof(sangomabc_event_t));
event->event_id = SIGBOOST_EVENT_CALL_START;
if (calling) {
strncpy((char*)event->calling_number_digits, calling, sizeof(event->calling_number_digits)-1);
event->calling_number_digits_count = (uint8_t)strlen(calling);
}
if (called) {
strncpy((char*)event->called_number_digits, called, sizeof(event->called_number_digits)-1);
event->called_number_digits_count = (uint8_t)strlen(called);
}
event->call_setup_id = (uint16_t)setup_id;
}
void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span)
{
if (boost_full_event(event_id)) {
memset(event, 0, sizeof(sangomabc_event_t));
} else {
memset(event, 0, sizeof(sangomabc_short_event_t));
}
event->event_id = event_id;
event->chan = (uint8_t)chan;
event->span = (uint8_t)span;
}
const char *sangomabc_event_id_name(uint32_t event_id)
{
unsigned int x;
const char *ret = NULL;
for (x = 0 ; x < sizeof(sangomabc_table)/sizeof(struct sangomabc_map); x++) {
if (sangomabc_table[x].event_id == event_id) {
ret = sangomabc_table[x].name;
break;
}
}
return ret;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/

View File

@ -1,164 +0,0 @@
/*
* Copyright (c) 2007, Anthony Minessale II, Nenad Corbic
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SANGOMABC_H
#define _SANGOMABC_H
#include "sangoma_boost_interface.h"
#include <ctype.h>
#include <string.h>
#ifndef WIN32
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifdef HAVE_NETINET_SCTP_H
#include <netinet/sctp.h>
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/time.h>
#endif
#include <stdlib.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <stdarg.h>
#include "sigboost.h"
#define sangomabc_test_flag(p,flag) ((p)->flags & (flag))
#define sangomabc_set_flag(p,flag) do { \
((p)->flags |= (flag)); \
} while (0)
#define sangomabc_clear_flag(p,flag) do { \
((p)->flags &= ~(flag)); \
} while (0)
#define sangomabc_copy_flags(dest,src,flagz) do { \
(dest)->flags &= ~(flagz); \
(dest)->flags |= ((src)->flags & (flagz)); \
} while (0)
typedef t_sigboost_callstart sangomabc_event_t;
typedef t_sigboost_short sangomabc_short_event_t;
typedef uint32_t sangomabc_event_id_t;
typedef struct sangomabc_ip_cfg
{
char local_ip[25];
int local_port;
char remote_ip[25];
int remote_port;
}sangomabc_ip_cfg_t;
typedef enum {
MSU_FLAG_EVENT = (1 << 0),
MSU_FLAG_DOWN = (1 << 1)
} sangomabc_flag_t;
struct sangomabc_connection {
ftdm_socket_t socket;
struct sockaddr_in local_addr;
struct sockaddr_in remote_addr;
sangomabc_event_t event;
struct hostent remote_hp;
struct hostent local_hp;
unsigned int flags;
ftdm_mutex_t *mutex;
FILE *log;
unsigned int txseq;
unsigned int rxseq;
unsigned int txwindow;
unsigned int rxseq_reset;
sangomabc_ip_cfg_t cfg;
/* boost signaling mod interface pointer (if not working in TCP mode) */
boost_sigmod_interface_t *sigmod;
ftdm_queue_t *boost_queue;
ftdm_interrupt_t *sock_interrupt;
ftdm_span_t *span;
int debuglevel;
};
typedef struct sangomabc_connection sangomabc_connection_t;
typedef struct sangomabc_queue_element {
unsigned char boostmsg[sizeof(sangomabc_event_t)];
ftdm_size_t size;
} sangomabc_queue_element_t;
/* disable nagle's algorythm */
static __inline__ void sctp_no_nagle(int socket)
{
#ifdef HAVE_NETINET_SCTP_H
int flag = 1;
setsockopt(socket, IPPROTO_SCTP, SCTP_NODELAY, (char *) &flag, sizeof(int));
#endif
}
int sangomabc_connection_close(sangomabc_connection_t *mcon);
int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port);
sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
#define sangomabc_connection_write(_m,_e) __sangomabc_connection_write(_m, _e, __FILE__, __FUNCTION__, __LINE__)
#define sangomabc_connection_writep(_m,_e) __sangomabc_connection_writep(_m, _e, __FILE__, __FUNCTION__, __LINE__)
#define sangomabc_connection_read(_m,_e) __sangomabc_connection_read(_m, _e, __FILE__, __FUNCTION__, __LINE__)
#define sangomabc_connection_readp(_m,_e) __sangomabc_connection_readp(_m, _e, __FILE__, __FUNCTION__, __LINE__)
void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span);
void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id);
const char *sangomabc_event_id_name(uint32_t event_id);
int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int id, int cmd, int cause, int flags);
int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, int id, int cmd, int cause);
#define BOOST_EVENT_SPAN(sigmod, event) ((sigmod) ? event->span : event->span + 1)
#define BOOST_EVENT_CHAN(sigmod, event) ((sigmod) ? event->chan : event->chan + 1)
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/

View File

@ -1,254 +0,0 @@
/*
* Copyright (c) 2009, Sangoma Technologies
* Moises Silva <moy@sangoma.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SANGOMA_BOOST_INTERFACE_H
#define SANGOMA_BOOST_INTERFACE_H
#include "private/ftdm_core.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
\brief Callback used to notify signaling status changes on a channel
\param ftdmchan The freetdm channel where the signaling status just changed
\param status The new signaling status
*/
#define BOOST_SIG_STATUS_CB_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
typedef void (*boost_sig_status_cb_func_t) BOOST_SIG_STATUS_CB_ARGS;
#define BOOST_SIG_STATUS_CB_FUNCTION(name) void name BOOST_SIG_STATUS_CB_ARGS
/*!
\brief Write a boost msg to a boost endpoint
\param span The freetdm span where this msg was generated
\param msg The generic message pointer, owned by the caller
\param msglen The length of the provided structure pointed by msg
\return FTDM_SUCCESS or FTDM_FAIL
The msg buffer is owned by the caller and it should
be either t_sigboost_callstart or t_sigboost_short
the endpoint receiving the msg will first cast to
t_sigboost_short, check the event type, and if needed.
*/
#define BOOST_WRITE_MSG_ARGS (ftdm_span_t *span, void *msg, ftdm_size_t msglen)
typedef ftdm_status_t (*boost_write_msg_func_t) BOOST_WRITE_MSG_ARGS;
#define BOOST_WRITE_MSG_FUNCTION(name) ftdm_status_t name BOOST_WRITE_MSG_ARGS
/*!
\brief Set the callback to be used by a signaling module to write boost messages
\param callback The callback to be used by the signaling module
The provided callback will be used for the signaling boost module to notify the
user with boost messages.
*/
#define BOOST_SET_WRITE_MSG_CB_ARGS (boost_write_msg_func_t callback)
typedef void (*boost_set_write_msg_cb_func_t) BOOST_SET_WRITE_MSG_CB_ARGS;
#define BOOST_SET_WRITE_MSG_CB_FUNCTION(name) void name BOOST_SET_WRITE_MSG_CB_ARGS
/*!
\brief Notify hardware status change
\param ftdmchan The freetdm channel
\param status The hw status
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS (ftdm_channel_t *ftdmchan, ftdm_channel_hw_link_status_t status)
typedef void (*boost_on_hw_link_status_change_func_t) BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS;
#define BOOST_ON_HW_LINK_STATUS_CHANGE_FUNCTION(name) void name BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS
/*!
\brief Set signaling status callback used by the signaling module to report signaling status changes
\param callback The callback to be used by the signaling module
The provided callback will be used for the signaling boost module to notify the
user with signaling link status changes.
*/
#define BOOST_SET_SIG_STATUS_CB_ARGS (boost_sig_status_cb_func_t callback)
typedef void (*boost_set_sig_status_cb_func_t) BOOST_SET_SIG_STATUS_CB_ARGS;
#define BOOST_SET_SIG_STATUS_CB_FUNCTION(name) void name BOOST_SET_SIG_STATUS_CB_ARGS
/*!
\brief Get the signaling status on the given channel.
\param ftdmchan The freetdm channel
\param status The status pointer where the current signaling status will be set
*/
#define BOOST_GET_CHANNEL_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status)
typedef ftdm_status_t (*boost_get_channel_sig_status_func_t) BOOST_GET_CHANNEL_SIG_STATUS_ARGS;
#define BOOST_GET_CHANNEL_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_GET_CHANNEL_SIG_STATUS_ARGS
/*!
\brief Set the signaling status on the given channel.
\param ftdmchan The freetdm channel
\param status The new status for the channel
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_SET_CHANNEL_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
typedef ftdm_status_t (*boost_set_channel_sig_status_func_t) BOOST_SET_CHANNEL_SIG_STATUS_ARGS;
#define BOOST_SET_CHANNEL_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_SET_CHANNEL_SIG_STATUS_ARGS
/*!
\brief Get the signaling status on the given span.
\param span The freetdm span
\param status The status pointer where the current signaling status will be set
*/
#define BOOST_GET_SPAN_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t *status)
typedef ftdm_status_t (*boost_get_span_sig_status_func_t) BOOST_GET_SPAN_SIG_STATUS_ARGS;
#define BOOST_GET_SPAN_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_GET_SPAN_SIG_STATUS_ARGS
/*!
\brief Set the signaling status on the given span.
\param ftdmchan The freetdm span
\param status The new status for the span
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_SET_SPAN_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status)
typedef ftdm_status_t (*boost_set_span_sig_status_func_t) BOOST_SET_SPAN_SIG_STATUS_ARGS;
#define BOOST_SET_SPAN_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_SET_SPAN_SIG_STATUS_ARGS
/*!
\brief Configure the given span signaling
\param span The freetdm span
\param parameters The array of configuration key,value pairs (must be null terminated)
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_CONFIGURE_SPAN_ARGS (ftdm_span_t *span, ftdm_conf_parameter_t *parameters)
typedef ftdm_status_t (*boost_configure_span_func_t) BOOST_CONFIGURE_SPAN_ARGS;
#define BOOST_CONFIGURE_SPAN_FUNCTION(name) ftdm_status_t name BOOST_CONFIGURE_SPAN_ARGS
/*!
\brief Start the given span
\param span The freetdm span
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_START_SPAN_ARGS (ftdm_span_t *span)
typedef ftdm_status_t (*boost_start_span_func_t) BOOST_START_SPAN_ARGS;
#define BOOST_START_SPAN_FUNCTION(name) ftdm_status_t name BOOST_START_SPAN_ARGS
/*!
\brief Stop the given span
\param span The freetdm span
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_STOP_SPAN_ARGS (ftdm_span_t *span)
typedef ftdm_status_t (*boost_stop_span_func_t) BOOST_START_SPAN_ARGS;
#define BOOST_STOP_SPAN_FUNCTION(name) ftdm_status_t name BOOST_STOP_SPAN_ARGS
/*!
\brief Called when the module is being loaded BEFORE calling anything else
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_ON_LOAD_ARGS (void)
typedef ftdm_status_t (*boost_on_load_func_t) BOOST_ON_LOAD_ARGS;
#define BOOST_ON_LOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_LOAD_ARGS
/*!
\brief Called when the module is being unloaded, last chance to stop everything!
*/
#define BOOST_ON_UNLOAD_ARGS (void)
typedef ftdm_status_t (*boost_on_unload_func_t) BOOST_ON_UNLOAD_ARGS;
#define BOOST_ON_UNLOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_UNLOAD_ARGS
/*!
\brief Called when user wants to execute sigmod api function
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_API_ARGS (ftdm_stream_handle_t *stream, char *cmd)
typedef ftdm_status_t (*boost_api_func_t) BOOST_API_ARGS;
#define BOOST_API_FUNCTION(name) ftdm_status_t name BOOST_API_ARGS
/*!
\brief The boost signaling module interface
*/
typedef struct boost_sigmod_interface_s {
/*! \brief Module name */
const char *name;
/*! \brief write boost message function */
boost_write_msg_func_t write_msg;
/*! \brief set the user write boost message function */
boost_set_write_msg_cb_func_t set_write_msg_cb;
/*! \brief set the user signaling status function */
boost_set_sig_status_cb_func_t set_sig_status_cb;
/*! \brief get channel signaling status */
boost_get_channel_sig_status_func_t get_channel_sig_status;
/*! \brief set channel signaling status */
boost_set_channel_sig_status_func_t set_channel_sig_status;
/*! \brief get span signaling status */
boost_get_span_sig_status_func_t get_span_sig_status;
/*! \brief set span signaling status */
boost_set_span_sig_status_func_t set_span_sig_status;
/*! \brief set notify hardware link status change */
boost_on_hw_link_status_change_func_t on_hw_link_status_change;
/*! \brief configure span signaling */
boost_configure_span_func_t configure_span;
/*! \brief start freetdm span */
boost_start_span_func_t start_span;
/*! \brief stop freetdm span */
boost_stop_span_func_t stop_span;
/*! \brief the module was just loaded */
boost_on_load_func_t on_load;
/*! \brief the module is about to be unloaded */
boost_on_unload_func_t on_unload;
/*! \brief module api function */
boost_api_func_t exec_api;
/*! \brief private pointer for the interface user */
void *pvt;
} boost_sigmod_interface_t;
#ifdef __cplusplus
} // extern C
#endif
#define BOOST_INTERFACE_NAME boost_sigmod_interface
#define BOOST_INTERFACE_NAME_STR "boost_sigmod_interface"
/* use this in your sig boost module to declare your interface */
#ifndef WIN32
#define BOOST_INTERFACE boost_sigmod_interface_t BOOST_INTERFACE_NAME
#else
#define BOOST_INTERFACE __declspec(dllexport) boost_sigmod_interface_t BOOST_INTERFACE_NAME
#endif
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/

View File

@ -1,221 +0,0 @@
/****************************************************************************
* sigboost.h $Revision: 1.13 $
*
* Definitions for the sigboost interface.
*
* WARNING WARNING WARNING
*
* This file is used by sangoma_mgd and perhaps other programs. Any changes
* to this file must be coordinated with other user programs,
*
* Copyright (C) 2005 Xygnada Technology, Inc.
*
****************************************************************************/
#ifndef _SIGBOOST_H_
#define _SIGBOOST_H_
#define SIGBOOST_VERSION 103
// handy to define integer types that actually work on both Lin and Win
#include <freetdm.h>
enum e_sigboost_event_id_values
{
SIGBOOST_EVENT_CALL_START = 0x80, /*128*/
SIGBOOST_EVENT_CALL_START_ACK = 0x81, /*129*/
SIGBOOST_EVENT_CALL_START_NACK = 0x82, /*130*/
SIGBOOST_EVENT_CALL_START_NACK_ACK = 0x83, /*131*/
SIGBOOST_EVENT_CALL_ANSWERED = 0x84, /*132*/
SIGBOOST_EVENT_CALL_STOPPED = 0x85, /*133*/
SIGBOOST_EVENT_CALL_STOPPED_ACK = 0x86, /*134*/
SIGBOOST_EVENT_SYSTEM_RESTART = 0x87, /*135*/
SIGBOOST_EVENT_SYSTEM_RESTART_ACK = 0x88, /*136*/
/* CALL_RELEASED is aimed to fix a race condition that became obvious
* when the boost socket was replaced by direct function calls
* and the channel hunting was moved to freetdm, the problem is
* we can get CALL_STOPPED msg and reply with CALL_STOPPED_ACK
* but the signaling module will still (in PRI) send RELEASE and
* wait for RELEASE_COMPLETE from the isdn network before
* marking the channel as available, therefore freetdm should
* also not mark the channel as available until CALL_RELEASED
* is received, for socket mode we can continue working as usual
* with CALL_STOPPED being the last step because the hunting is
* done in the signaling module.
* */
SIGBOOST_EVENT_CALL_RELEASED = 0x51, /* 81 */
SIGBOOST_EVENT_CALL_PROGRESS = 0x50, /*decimal 80*/
/* Following IDs are ss7boost to sangoma_mgd only. */
SIGBOOST_EVENT_HEARTBEAT = 0x89, /*137*/
SIGBOOST_EVENT_INSERT_CHECK_LOOP = 0x8a, /*138*/
SIGBOOST_EVENT_REMOVE_CHECK_LOOP = 0x8b, /*139*/
SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE = 0x8c, /*140*/
SIGBOOST_EVENT_DIGIT_IN = 0x8d, /*141*/
};
#define BOOST_DECODE_EVENT_ID(id) \
(id==SIGBOOST_EVENT_CALL_START)?"SIGBOOST_EVENT_CALL_START": \
(id==SIGBOOST_EVENT_CALL_START_ACK)?"SIGBOOST_EVENT_CALL_START_ACK": \
(id==SIGBOOST_EVENT_CALL_START_NACK)?"SIGBOOST_EVENT_CALL_START_NACK": \
(id==SIGBOOST_EVENT_CALL_ANSWERED)?"SIGBOOST_EVENT_CALL_ANSWERED": \
(id==SIGBOOST_EVENT_CALL_STOPPED)?"SIGBOOST_EVENT_CALL_STOPPED": \
(id==SIGBOOST_EVENT_CALL_STOPPED_ACK)?"SIGBOOST_EVENT_CALL_STOPPED_ACK": \
(id==SIGBOOST_EVENT_SYSTEM_RESTART)?"SIGBOOST_EVENT_SYSTEM_RESTART": \
(id==SIGBOOST_EVENT_SYSTEM_RESTART_ACK)?"SIGBOOST_EVENT_SYSTEM_RESTART_ACK": \
(id==SIGBOOST_EVENT_CALL_RELEASED)?"SIGBOOST_EVENT_CALL_RELEASED": \
(id==SIGBOOST_EVENT_CALL_PROGRESS)?"SIGBOOST_EVENT_CALL_PROGRESS": \
(id==SIGBOOST_EVENT_HEARTBEAT)?"SIGBOOST_EVENT_HEARTBEAT": \
(id==SIGBOOST_EVENT_INSERT_CHECK_LOOP)?"SIGBOOST_EVENT_INSERT_CHECK_LOOP": \
(id==SIGBOOST_EVENT_REMOVE_CHECK_LOOP)?"SIGBOOST_EVENT_REMOVE_CHECK_LOOP": \
(id==SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE)?"SIGBOOST_EVENT_AUTO_CALL_GAP_ABATE": \
(id==SIGBOOST_EVENT_DIGIT_IN)?"SIGBOOST_EVENT_DIGIT_IN": "Unknown"
enum e_sigboost_release_cause_values
{
SIGBOOST_RELEASE_CAUSE_UNDEFINED = 0,
SIGBOOST_RELEASE_CAUSE_NORMAL = 16,
/* probable elimination */
//SIGBOOST_RELEASE_CAUSE_BUSY = 0x91, /* 145 */
//SIGBOOST_RELEASE_CAUSE_CALLED_NOT_EXIST = 0x92, /* 146 */
//SIGBOOST_RELEASE_CAUSE_CIRCUIT_RESET = 0x93, /* 147 */
//SIGBOOST_RELEASE_CAUSE_NOANSWER = 0x94, /* 148 */
};
enum e_sigboost_call_setup_ack_nack_cause_values
{
//SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 34, /* Q.850 value - don't use */
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 117, /* non Q.850 value indicates local all ckt busy
causing sangoma_mgd to perform automatic call
gapping*/
SIGBOOST_CALL_SETUP_NACK_TEST_CKT_BUSY = 17, /* Q.850 value */
SIGBOOST_CALL_SETUP_NACK_INVALID_NUMBER = 28, /* Q.850 value */
SIGBOOST_CALL_SETUP_CSUPID_DBL_USE = 200, /* unused Q.850 value */
};
enum e_sigboost_huntgroup_values
{
SIGBOOST_HUNTGRP_SEQ_ASC = 0x00, /* sequential with lowest available first */
SIGBOOST_HUNTGRP_SEQ_DESC = 0x01, /* sequential with highest available first */
SIGBOOST_HUNTGRP_RR_ASC = 0x02, /* round-robin with lowest available first */
SIGBOOST_HUNTGRP_RR_DESC = 0x03, /* round-robin with highest available first */
};
enum e_sigboost_event_info_par_values
{
SIGBOOST_EVI_SPARE = 0x00,
SIGBOOST_EVI_ALERTING = 0x01,
SIGBOOST_EVI_PROGRESS = 0x02,
};
enum e_sigboost_progress_flags
{
SIGBOOST_PROGRESS_RING = (1 << 0),
SIGBOOST_PROGRESS_MEDIA = (1 << 1)
};
#define MAX_DIALED_DIGITS 31
/* Next two defines are used to create the range of values for call_setup_id
* in the t_sigboost structure.
* 0..((CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN) - 1) */
#define CORE_MAX_SPANS 200
#define CORE_MAX_CHAN_PER_SPAN 32
#define MAX_PENDING_CALLS CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN
/* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
/* Should only be used by server */
#define MAX_CALL_SETUP_ID 0xFFFF
#define SIZE_CUSTOM 900
#define SIZE_RDNIS SIZE_CUSTOM
#pragma pack(1)
typedef struct
{
uint8_t capability;
uint8_t uil1p;
} t_sigboost_bearer;
typedef struct
{
uint8_t digits_count;
char digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
uint8_t npi;
uint8_t ton;
uint8_t screening_ind;
uint8_t presentation_ind;
}t_sigboost_digits;
typedef struct
{
uint16_t version;
uint32_t event_id;
/* delete sequence numbers - SCTP does not need them */
uint32_t fseqno;
uint32_t bseqno;
uint16_t call_setup_id;
uint32_t trunk_group;
uint8_t span;
uint8_t chan;
uint32_t flags;
/* struct timeval tv; */
t_sigboost_digits called;
t_sigboost_digits calling;
t_sigboost_digits rdnis;
/* ref. Q.931 Table 4-11 and Q.951 Section 3 */
char calling_name[MAX_DIALED_DIGITS + 1];
t_sigboost_bearer bearer;
uint8_t hunt_group;
uint16_t custom_data_size;
char custom_data[SIZE_CUSTOM]; /* it's a null terminated string */
} t_sigboost_callstart;
#define called_number_digits_count called.digits_count
#define called_number_digits called.digits
#define calling_number_digits_count calling.digits_count
#define calling_number_digits calling.digits
#define calling_number_screening_ind calling.screening_ind
#define calling_number_presentation calling.presentation_ind
#define isup_in_rdnis_size custom_data_size
#define isup_in_rdnis custom_data
#define MIN_SIZE_CALLSTART_MSG sizeof(t_sigboost_callstart) - SIZE_CUSTOM
typedef struct
{
uint16_t version;
uint32_t event_id;
/* delete sequence numbers - SCTP does not need them */
uint32_t fseqno;
uint32_t bseqno;
uint16_t call_setup_id;
uint32_t trunk_group;
uint8_t span;
uint8_t chan;
uint32_t flags;
/* struct timeval tv; */
uint8_t release_cause;
} t_sigboost_short;
#pragma pack()
static __inline__ int boost_full_event(int event_id)
{
switch (event_id) {
case SIGBOOST_EVENT_CALL_START:
case SIGBOOST_EVENT_DIGIT_IN:
case SIGBOOST_EVENT_CALL_PROGRESS:
return 1;
default:
break;
}
return 0;
}
#endif