Added capability to issue a DLCX to clear all connections when becoming operational.

Each remote endpoint has its connections cleared when recovering from error.


git-svn-id: http://voip.null.ro/svn/yate@2717 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2009-06-16 16:02:50 +00:00
parent 372be65a5a
commit 6dab45edd7
2 changed files with 22 additions and 2 deletions

View File

@ -66,3 +66,6 @@
; Defaults to 32 if chans is 30 or 31 (E1), 24 if chans is 23 (T1), number of ; Defaults to 32 if chans is 30 or 31 (E1), 24 if chans is 23 (T1), number of
; circuits in all other cases ; circuits in all other cases
;increment= ;increment=
; clearconn: bool: Clear all connections of remote endpoints when initialized
;clearconn=no

View File

@ -157,6 +157,8 @@ public:
{ return mySpan()->fxo(); } { return mySpan()->fxo(); }
inline bool fxs() inline bool fxs()
{ return mySpan()->fxs(); } { return mySpan()->fxs(); }
inline void needClear()
{ m_needClear = true; }
bool processEvent(MGCPTransaction* tr, MGCPMessage* mm); bool processEvent(MGCPTransaction* tr, MGCPMessage* mm);
bool processNotify(const String& package, const String& event, const String& fullName); bool processNotify(const String& package, const String& event, const String& fullName);
void processDelete(MGCPMessage* mm, const String& error); void processDelete(MGCPMessage* mm, const String& error);
@ -190,6 +192,7 @@ private:
int m_remotePort; int m_remotePort;
int m_remotePayload; int m_remotePayload;
const char* m_payloads; const char* m_payloads;
bool m_needClear;
// Synchronous transaction data // Synchronous transaction data
MGCPTransaction* m_tr; MGCPTransaction* m_tr;
RefPointer<MGCPMessage> m_msg; RefPointer<MGCPMessage> m_msg;
@ -821,6 +824,7 @@ bool MGCPSpan::init(const NamedList& params)
break; break;
} }
m_increment = config->getIntValue("increment",m_increment); m_increment = config->getIntValue("increment",m_increment);
bool clear = config->getBoolValue("clearconn",false);
m_circuits = new MGCPCircuit*[m_count]; m_circuits = new MGCPCircuit*[m_count];
unsigned int i; unsigned int i;
for (i = 0; i < m_count; i++) for (i = 0; i < m_count; i++)
@ -845,6 +849,8 @@ bool MGCPSpan::init(const NamedList& params)
break; break;
} }
circuit->ref(); circuit->ref();
if (clear)
circuit->needClear();
} }
return ok; return ok;
} }
@ -1028,7 +1034,7 @@ MGCPCircuit::MGCPCircuit(unsigned int code, MGCPSpan* span, const char* id)
m_epId(id), m_statusReq(Missing), m_epId(id), m_statusReq(Missing),
m_localPort(0), m_sdpSession(0), m_sdpVersion(0), m_localPort(0), m_sdpSession(0), m_sdpVersion(0),
m_remotePort(0), m_remotePayload(-1), m_remotePort(0), m_remotePayload(-1),
m_payloads(s_payloads), m_tr(0) m_payloads(s_payloads), m_needClear(false), m_tr(0)
{ {
Debug(&splugin,DebugAll,"MGCPCircuit::MGCPCircuit(%u,%p,'%s') [%p]", Debug(&splugin,DebugAll,"MGCPCircuit::MGCPCircuit(%u,%p,'%s') [%p]",
code,span,id,this); code,span,id,this);
@ -1166,8 +1172,10 @@ bool MGCPCircuit::setupConn()
return false; return false;
if (m_connId.null()) if (m_connId.null())
m_connId = mm->params.getParam("i"); m_connId = mm->params.getParam("i");
if (m_connId.null()) if (m_connId.null()) {
m_needClear = true;
return false; return false;
}
MimeSdpBody* sdp = static_cast<MimeSdpBody*>(mm->sdp[0]); MimeSdpBody* sdp = static_cast<MimeSdpBody*>(mm->sdp[0]);
if (sdp) { if (sdp) {
m_remoteIp.clear(); m_remoteIp.clear();
@ -1298,6 +1306,11 @@ bool MGCPCircuit::status(Status newStat, bool sync)
break; break;
m_statusReq = SignallingCircuit::status(); m_statusReq = SignallingCircuit::status();
return false; return false;
case Idle:
if (m_needClear) {
m_needClear = false;
clearConn(true);
}
default: default:
m_payloads = s_payloads; m_payloads = s_payloads;
cleanupRtp(); cleanupRtp();
@ -1392,6 +1405,10 @@ bool MGCPCircuit::processNotify(const String& package, const String& event, cons
else if (event &= "hu") { else if (event &= "hu") {
if (SignallingCircuit::status() == Connected) if (SignallingCircuit::status() == Connected)
status(Idle,false); status(Idle,false);
if (m_needClear) {
m_needClear = false;
clearConn(true);
}
return enqueueEvent(SignallingCircuitEvent::OnHook,fullName); return enqueueEvent(SignallingCircuitEvent::OnHook,fullName);
} }
else if (event &= "hf") else if (event &= "hf")