Added late router, allows repeating routing in call.execute stage.
git-svn-id: http://yate.null.ro/svn/yate/trunk@1675 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
357067432e
commit
f8b38541c9
|
@ -0,0 +1,14 @@
|
||||||
|
[general]
|
||||||
|
; Global settings of the late routing module
|
||||||
|
|
||||||
|
; enabled: boolean: Enable late routing module operation
|
||||||
|
;enabled=true if regexp and called are set, false if any is empty
|
||||||
|
|
||||||
|
; priority: int: Priority of call.execute handler
|
||||||
|
;priority=75
|
||||||
|
|
||||||
|
; regexp: string: Regular expression describing callto match rules
|
||||||
|
;regexp=
|
||||||
|
|
||||||
|
; called: string: Template for creating calling number from regexp match
|
||||||
|
;called=\0
|
|
@ -30,7 +30,7 @@ PROGS := cdrbuild.yate cdrfile.yate regexroute.yate \
|
||||||
ysipchan.yate \
|
ysipchan.yate \
|
||||||
yiaxchan.yate \
|
yiaxchan.yate \
|
||||||
yjinglechan.yate \
|
yjinglechan.yate \
|
||||||
server/pbxassist.yate server/dbpbx.yate \
|
server/pbxassist.yate server/dbpbx.yate server/lateroute.yate \
|
||||||
server/park.yate server/queues.yate \
|
server/park.yate server/queues.yate \
|
||||||
server/regfile.yate server/accfile.yate server/register.yate \
|
server/regfile.yate server/accfile.yate server/register.yate \
|
||||||
server/yradius.yate \
|
server/yradius.yate \
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
/**
|
||||||
|
* lateroute.cpp
|
||||||
|
* This file is part of the YATE Project http://YATE.null.ro
|
||||||
|
*
|
||||||
|
* Last chance routing in call.execute messages.
|
||||||
|
*
|
||||||
|
* Yet Another Telephony Engine - a fully featured software PBX and IVR
|
||||||
|
* Copyright (C) 2004-2006 Null Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <yatephone.h>
|
||||||
|
|
||||||
|
using namespace TelEngine;
|
||||||
|
namespace { // anonymous
|
||||||
|
|
||||||
|
class LateRouter : public Plugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LateRouter();
|
||||||
|
~LateRouter();
|
||||||
|
virtual void initialize();
|
||||||
|
};
|
||||||
|
|
||||||
|
class LateHandler : public MessageHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline LateHandler(unsigned priority)
|
||||||
|
: MessageHandler("call.execute",priority)
|
||||||
|
{ }
|
||||||
|
virtual bool received(Message& msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
static Regexp s_regexp;
|
||||||
|
static String s_called;
|
||||||
|
static Mutex s_mutex;
|
||||||
|
static LateHandler* s_handler = 0;
|
||||||
|
|
||||||
|
INIT_PLUGIN(LateRouter);
|
||||||
|
|
||||||
|
UNLOAD_PLUGIN(unloadNow)
|
||||||
|
{
|
||||||
|
if (unloadNow) {
|
||||||
|
if (!s_mutex.lock(500000))
|
||||||
|
return false;
|
||||||
|
TelEngine::destruct(s_handler);
|
||||||
|
s_mutex.unlock();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LateHandler::received(Message& msg)
|
||||||
|
{
|
||||||
|
String dest = msg.getValue("callto");
|
||||||
|
if (dest.null() || !msg.getBoolValue("lateroute",true))
|
||||||
|
return false;
|
||||||
|
Lock lock(s_mutex);
|
||||||
|
if (s_called.null() || !dest.matches(s_regexp))
|
||||||
|
return false;
|
||||||
|
String callto = dest;
|
||||||
|
dest = dest.replaceMatches(s_called);
|
||||||
|
msg.replaceParams(dest);
|
||||||
|
if (dest.trimBlanks().null())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String called = msg.getValue("called");
|
||||||
|
msg.clearParam("callto");
|
||||||
|
msg.setParam("called",dest);
|
||||||
|
msg.setParam("lateroute",String::boolText(false));
|
||||||
|
msg = "call.route";
|
||||||
|
bool ok = Engine::dispatch(msg);
|
||||||
|
dest = msg.retValue();
|
||||||
|
msg.retValue().clear();
|
||||||
|
msg = "call.execute";
|
||||||
|
ok = ok && dest && (dest != "-") && (dest != "error");
|
||||||
|
if (ok && (dest == callto)) {
|
||||||
|
Debug(DebugMild,"Call to '%s' late routed back to itself!",callto.c_str());
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
// restore most of what we changed and let it pass through
|
||||||
|
msg.setParam("called",called);
|
||||||
|
msg.setParam("callto",callto);
|
||||||
|
msg.clearParam("lateroute");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Debug(DebugInfo,"Late routing call to '%s' via '%s'",callto.c_str(),dest.c_str());
|
||||||
|
// let it pass through to the new target
|
||||||
|
msg.setParam("callto",dest);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LateRouter::LateRouter()
|
||||||
|
: Plugin("lateroute")
|
||||||
|
{
|
||||||
|
Output("Loaded module Late Router");
|
||||||
|
}
|
||||||
|
|
||||||
|
LateRouter::~LateRouter()
|
||||||
|
{
|
||||||
|
Output("Unloading module Late Router");
|
||||||
|
}
|
||||||
|
|
||||||
|
void LateRouter::initialize()
|
||||||
|
{
|
||||||
|
Output("Initializing module Late Router");
|
||||||
|
Configuration cfg(Engine::configFile("lateroute"));
|
||||||
|
s_mutex.lock();
|
||||||
|
s_regexp = cfg.getValue("general","regexp");
|
||||||
|
s_called = cfg.getValue("general","called","\\0");
|
||||||
|
s_mutex.unlock();
|
||||||
|
if (!s_handler && cfg.getBoolValue("general","enabled",(s_regexp && s_called))) {
|
||||||
|
s_handler = new LateHandler(cfg.getIntValue("general","priority",75));
|
||||||
|
Engine::install(s_handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // anonymous namespace
|
||||||
|
|
||||||
|
/* vi: set ts=8 sw=4 sts=4 noet: */
|
|
@ -0,0 +1,272 @@
|
||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="8.00"
|
||||||
|
Name="_lateroute"
|
||||||
|
ProjectGUID="{2F410A9D-D671-4928-7ACF-7268AF39D934}"
|
||||||
|
RootNamespace="_lateroute"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory=".\Release\server"
|
||||||
|
IntermediateDirectory=".\Release\modules"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||||
|
UseOfMFC="0"
|
||||||
|
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
PreprocessorDefinitions="NDEBUG"
|
||||||
|
MkTypLibCompatible="true"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
TargetEnvironment="1"
|
||||||
|
TypeLibraryName=".\Release/_lateroute.tlb"
|
||||||
|
HeaderFileName=""
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="2"
|
||||||
|
InlineFunctionExpansion="1"
|
||||||
|
AdditionalIncludeDirectories=".,.."
|
||||||
|
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE"
|
||||||
|
StringPooling="true"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
EnableFunctionLevelLinking="true"
|
||||||
|
PrecompiledHeaderFile=".\Release\modules/_lateroute.pch"
|
||||||
|
AssemblerListingLocation=".\Release\modules/"
|
||||||
|
ObjectFile=".\Release\modules/"
|
||||||
|
ProgramDataBaseFileName=".\Release\modules/"
|
||||||
|
WarningLevel="3"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
PreprocessorDefinitions="NDEBUG"
|
||||||
|
Culture="1033"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
IgnoreImportLibrary="true"
|
||||||
|
OutputFile="Release/server/lateroute.yate"
|
||||||
|
LinkIncremental="1"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
ProgramDatabaseFile=".\Release/lateroute.pdb"
|
||||||
|
ImportLibrary=".\Release/lateroute.lib"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile=".\Release/_lateroute.bsc"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory=".\Debug\server"
|
||||||
|
IntermediateDirectory=".\Debug\modules"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
|
||||||
|
UseOfMFC="0"
|
||||||
|
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
PreprocessorDefinitions="_DEBUG"
|
||||||
|
MkTypLibCompatible="true"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
TargetEnvironment="1"
|
||||||
|
TypeLibraryName=".\Debug/_lateroute.tlb"
|
||||||
|
HeaderFileName=""
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=".,.."
|
||||||
|
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
PrecompiledHeaderFile=".\Debug\modules/_lateroute.pch"
|
||||||
|
AssemblerListingLocation=".\Debug\modules/"
|
||||||
|
ObjectFile=".\Debug\modules/"
|
||||||
|
ProgramDataBaseFileName=".\Debug\modules/"
|
||||||
|
WarningLevel="3"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
PreprocessorDefinitions="_DEBUG"
|
||||||
|
Culture="1033"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
IgnoreImportLibrary="true"
|
||||||
|
OutputFile="Debug/server/lateroute.yate"
|
||||||
|
LinkIncremental="1"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile=".\Debug/lateroute.pdb"
|
||||||
|
ImportLibrary=".\Debug/lateroute.lib"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
OutputFile=".\Debug/_lateroute.bsc"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\modules\server\lateroute.cpp"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""
|
||||||
|
PreprocessorDefinitions=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""
|
||||||
|
PreprocessorDefinitions=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="version.rc"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
PreprocessorDefinitions=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
PreprocessorDefinitions=""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
Loading…
Reference in New Issue