Do not set context "-" or "error" from [contexts] in regexroute, return message value instead.

This allows properly rejecting calls from preroute stage.


git-svn-id: http://yate.null.ro/svn/yate/trunk@5175 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2012-07-02 15:32:56 +00:00
parent fbb10ee055
commit cc8fc64078
1 changed files with 8 additions and 5 deletions

View File

@ -717,10 +717,10 @@ static bool oneContext(Message &msg, String &str, const String &context, String
bool RouteHandler::received(Message &msg)
{
u_int64_t tmr = Time::now();
String called(msg.getValue("called"));
String called(msg.getValue(YSTRING("called")));
if (called.null())
return false;
const char *context = msg.getValue("context","default");
const char *context = msg.getValue(YSTRING("context"),"default");
Lock lock(s_mutex);
if (oneContext(msg,called,context,msg.retValue())) {
Debug(DebugInfo,"Routing call to '%s' in context '%s' via '%s' in " FMT64 " usec",
@ -746,10 +746,10 @@ bool PrerouteHandler::received(Message &msg)
{
u_int64_t tmr = Time::now();
// return immediately if there is already a context
if (!s_prerouteall && msg.getValue("context"))
if (!s_prerouteall && msg.getValue(YSTRING("context")))
return false;
String caller(msg.getValue("caller"));
String caller(msg.getValue(YSTRING("caller")));
if (!s_prerouteall && caller.null())
return false;
@ -758,7 +758,10 @@ bool PrerouteHandler::received(Message &msg)
if (oneContext(msg,caller,"contexts",ret)) {
Debug(DebugInfo,"Classifying caller '%s' in context '%s' in " FMT64 " usec",
caller.c_str(),ret.c_str(),Time::now()-tmr);
msg.addParam("context",ret);
if (ret == YSTRING("-") || ret == YSTRING("error"))
msg.retValue() = ret;
else
msg.setParam("context",ret);
return true;
}
Debug(DebugInfo,"Could not classify call from '%s', wasted " FMT64 " usec",