Added support for redirecting calls from routing - SIP for now.
git-svn-id: http://voip.null.ro/svn/yate@354 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
b3551d1044
commit
0336a613ee
|
@ -485,6 +485,20 @@ const SIPHeaderLine* SIPMessage::getLastHeader(const char* name) const
|
|||
return res;
|
||||
}
|
||||
|
||||
void SIPMessage::clearHeaders(const char* name)
|
||||
{
|
||||
if (!(name && *name))
|
||||
return;
|
||||
ObjList* l = &header;
|
||||
while (l) {
|
||||
const SIPHeaderLine* t = static_cast<const SIPHeaderLine*>(l->get());
|
||||
if (t && (t->name() &= name))
|
||||
l->remove();
|
||||
else
|
||||
l = l->next();
|
||||
}
|
||||
}
|
||||
|
||||
int SIPMessage::countHeaders(const char* name) const
|
||||
{
|
||||
if (!(name && *name))
|
||||
|
|
|
@ -348,16 +348,31 @@ public:
|
|||
|
||||
/**
|
||||
* Append a new header line constructed from name and content
|
||||
* @param name Name of the header to add
|
||||
* @param value Content of the new header line
|
||||
*/
|
||||
inline void addHeader(const char* name, const char* value = 0)
|
||||
{ header.append(new SIPHeaderLine(name,value)); }
|
||||
|
||||
/**
|
||||
* Append an already constructed header line
|
||||
* @param line Header line to add
|
||||
*/
|
||||
inline void addHeader(SIPHeaderLine* line)
|
||||
{ header.append(line); }
|
||||
|
||||
/**
|
||||
* Clear all header lines that match a name
|
||||
* @param name Name of the header to clear
|
||||
*/
|
||||
void clearHeaders(const char* name);
|
||||
|
||||
/**
|
||||
* Set a header line constructed from name and content
|
||||
*/
|
||||
inline void setHeader(const char* name, const char* value = 0)
|
||||
{ clearHeaders(name); addHeader(name,value); }
|
||||
|
||||
/**
|
||||
* Creates a binary buffer from a SIPMessage.
|
||||
*/
|
||||
|
|
|
@ -315,11 +315,12 @@ bool Channel::msgTransfer(Message& msg)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Channel::callRouted(Message& msg)
|
||||
bool Channel::callRouted(Message& msg)
|
||||
{
|
||||
status("routed");
|
||||
if (m_billid.null())
|
||||
m_billid = msg.getValue("billid");
|
||||
return true;
|
||||
}
|
||||
|
||||
void Channel::callAccept(Message& msg)
|
||||
|
@ -835,18 +836,19 @@ bool Router::route()
|
|||
}
|
||||
|
||||
if (ok) {
|
||||
chan->callRouted(*m_msg);
|
||||
*m_msg = "call.execute";
|
||||
m_msg->setParam("callto",m_msg->retValue());
|
||||
m_msg->clearParam("error");
|
||||
m_msg->clearParam("reason");
|
||||
m_msg->retValue().clear();
|
||||
ok = Engine::dispatch(m_msg);
|
||||
if (ok)
|
||||
chan->callAccept(*m_msg);
|
||||
else
|
||||
chan->callReject(m_msg->getValue("error","noconn"),
|
||||
m_msg->getValue("reason","Could not connected to target"));
|
||||
if (chan->callRouted(*m_msg)) {
|
||||
*m_msg = "call.execute";
|
||||
m_msg->setParam("callto",m_msg->retValue());
|
||||
m_msg->clearParam("error");
|
||||
m_msg->clearParam("reason");
|
||||
m_msg->retValue().clear();
|
||||
ok = Engine::dispatch(m_msg);
|
||||
if (ok)
|
||||
chan->callAccept(*m_msg);
|
||||
else
|
||||
chan->callReject(m_msg->getValue("error","noconn"),
|
||||
m_msg->getValue("reason","Could not connected to target"));
|
||||
}
|
||||
}
|
||||
else
|
||||
chan->callReject(m_msg->getValue("error","noroute"),
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
virtual bool msgAnswered(Message& msg);
|
||||
virtual bool msgTone(Message& msg, const char* tone);
|
||||
virtual bool msgText(Message& msg, const char* text);
|
||||
virtual void callRouted(Message& msg);
|
||||
virtual bool callRouted(Message& msg);
|
||||
virtual void callAccept(Message& msg);
|
||||
virtual void callReject(const char* error, const char* reason);
|
||||
void startRouter();
|
||||
|
@ -1034,11 +1034,23 @@ bool YateSIPConnection::msgText(Message& msg, const char* text)
|
|||
return false;
|
||||
}
|
||||
|
||||
void YateSIPConnection::callRouted(Message& msg)
|
||||
bool YateSIPConnection::callRouted(Message& msg)
|
||||
{
|
||||
Channel::callRouted(msg);
|
||||
if (m_tr && (m_tr->getState() == SIPTransaction::Process))
|
||||
if (m_tr && (m_tr->getState() == SIPTransaction::Process)) {
|
||||
String s(msg.retValue());
|
||||
if (s.startSkip("redirect/",false) && s) {
|
||||
Debug(this,DebugAll,"YateSIPConnection redirecting to '%s' [%p]",s.c_str(),this);
|
||||
SIPMessage* m = new SIPMessage(m_tr->initialMessage(), 302);
|
||||
m->addHeader("Contact",s);
|
||||
m_tr->setResponse(m);
|
||||
m->deref();
|
||||
m_byebye = false;
|
||||
return false;
|
||||
}
|
||||
m_tr->setResponse(183);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void YateSIPConnection::callAccept(Message& msg)
|
||||
|
|
|
@ -1106,8 +1106,9 @@ public:
|
|||
/**
|
||||
* Notification on progress of incoming call
|
||||
* @param msg Notification call.route message just after being dispatched
|
||||
* @return True to continue with the call, false to abort the route
|
||||
*/
|
||||
virtual void callRouted(Message& msg);
|
||||
virtual bool callRouted(Message& msg);
|
||||
|
||||
/**
|
||||
* Notification on success of incoming call
|
||||
|
|
Loading…
Reference in New Issue