Sanitize the custom SIP cause codes, must be >= 300.
Allow altering the SIP code in the chan.disconnected message. git-svn-id: http://yate.null.ro/svn/yate/trunk@4195 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
5278f71b7f
commit
edf28bc0c7
|
@ -1997,7 +1997,7 @@ YateSIPConnection::YateSIPConnection(Message& msg, const String& uri, const char
|
||||||
tmp = "Invalid address: ";
|
tmp = "Invalid address: ";
|
||||||
tmp << m_uri;
|
tmp << m_uri;
|
||||||
msg.setParam("reason",tmp);
|
msg.setParam("reason",tmp);
|
||||||
setReason(tmp);
|
setReason(tmp,500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int maxf = msg.getIntValue("antiloop",s_maxForwards);
|
int maxf = msg.getIntValue("antiloop",s_maxForwards);
|
||||||
|
@ -2236,7 +2236,7 @@ void YateSIPConnection::hangup()
|
||||||
if (m_reason) {
|
if (m_reason) {
|
||||||
// FIXME: add SIP and Q.850 cause codes, set the proper reason
|
// FIXME: add SIP and Q.850 cause codes, set the proper reason
|
||||||
MimeHeaderLine* hl = new MimeHeaderLine("Reason","SIP");
|
MimeHeaderLine* hl = new MimeHeaderLine("Reason","SIP");
|
||||||
if ((m_reasonCode >= 300) && (m_reasonCode != 487))
|
if ((m_reasonCode >= 300) && (m_reasonCode <= 699) && (m_reasonCode != 487))
|
||||||
hl->setParam("cause",String(m_reasonCode));
|
hl->setParam("cause",String(m_reasonCode));
|
||||||
hl->setParam("text",MimeHeaderLine::quote(m_reason));
|
hl->setParam("text",MimeHeaderLine::quote(m_reason));
|
||||||
m->addHeader(hl);
|
m->addHeader(hl);
|
||||||
|
@ -2420,7 +2420,7 @@ bool YateSIPConnection::process(SIPEvent* ev)
|
||||||
m_dialog = *ev->getTransaction()->recentMessage();
|
m_dialog = *ev->getTransaction()->recentMessage();
|
||||||
mylock.drop();
|
mylock.drop();
|
||||||
|
|
||||||
if (msg && !msg->isOutgoing() && msg->isAnswer() && (code >= 300)) {
|
if (msg && !msg->isOutgoing() && msg->isAnswer() && (code >= 300) && (code <= 699)) {
|
||||||
updateTags = false;
|
updateTags = false;
|
||||||
m_cancel = false;
|
m_cancel = false;
|
||||||
m_byebye = false;
|
m_byebye = false;
|
||||||
|
@ -3035,7 +3035,7 @@ void YateSIPConnection::disconnected(bool final, const char *reason)
|
||||||
Debug(this,DebugAll,"YateSIPConnection::disconnected() '%s' [%p]",reason,this);
|
Debug(this,DebugAll,"YateSIPConnection::disconnected() '%s' [%p]",reason,this);
|
||||||
if (reason) {
|
if (reason) {
|
||||||
int code = lookup(reason,dict_errors);
|
int code = lookup(reason,dict_errors);
|
||||||
if (code)
|
if (code >= 300 && code <= 699)
|
||||||
setReason(lookup(code,SIPResponses,reason),code);
|
setReason(lookup(code,SIPResponses,reason),code);
|
||||||
else
|
else
|
||||||
setReason(reason);
|
setReason(reason);
|
||||||
|
@ -3199,7 +3199,7 @@ bool YateSIPConnection::msgDrop(Message& msg, const char* reason)
|
||||||
if (!Channel::msgDrop(msg,reason))
|
if (!Channel::msgDrop(msg,reason))
|
||||||
return false;
|
return false;
|
||||||
int code = lookup(reason,dict_errors);
|
int code = lookup(reason,dict_errors);
|
||||||
if (code >= 300) {
|
if (code >= 300 && code <= 699) {
|
||||||
m_reasonCode = code;
|
m_reasonCode = code;
|
||||||
m_reason = lookup(code,SIPResponses,reason);
|
m_reason = lookup(code,SIPResponses,reason);
|
||||||
}
|
}
|
||||||
|
@ -3279,6 +3279,14 @@ bool YateSIPConnection::msgUpdate(Message& msg)
|
||||||
|
|
||||||
void YateSIPConnection::endDisconnect(const Message& msg, bool handled)
|
void YateSIPConnection::endDisconnect(const Message& msg, bool handled)
|
||||||
{
|
{
|
||||||
|
const String* reason = msg.getParam("reason");
|
||||||
|
if (!TelEngine::null(reason)) {
|
||||||
|
int code = reason->toInteger(dict_errors);
|
||||||
|
if (code >= 300 && code <= 699)
|
||||||
|
setReason(lookup(code,SIPResponses,*reason),code);
|
||||||
|
else
|
||||||
|
setReason(*reason,m_reasonCode);
|
||||||
|
}
|
||||||
const char* prefix = msg.getValue("osip-prefix");
|
const char* prefix = msg.getValue("osip-prefix");
|
||||||
if (TelEngine::null(prefix))
|
if (TelEngine::null(prefix))
|
||||||
return;
|
return;
|
||||||
|
@ -3388,6 +3396,8 @@ void YateSIPConnection::callRejected(const char* error, const char* reason, cons
|
||||||
{
|
{
|
||||||
Channel::callRejected(error,reason,msg);
|
Channel::callRejected(error,reason,msg);
|
||||||
int code = lookup(error,dict_errors,500);
|
int code = lookup(error,dict_errors,500);
|
||||||
|
if (code < 300 || code > 699)
|
||||||
|
code = 500;
|
||||||
Lock lock(driver());
|
Lock lock(driver());
|
||||||
if (m_tr && (m_tr->getState() == SIPTransaction::Process)) {
|
if (m_tr && (m_tr->getState() == SIPTransaction::Process)) {
|
||||||
if (code == 401)
|
if (code == 401)
|
||||||
|
|
Loading…
Reference in New Issue