No longer enable by default cluster/fallback related operation of MGCP GW.

Moved processing of Signal and RequestNotify parameters in their own function called when they are embedded in CRCX or MDCX.


git-svn-id: http://yate.null.ro/svn/yate/trunk@4377 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2011-05-13 16:59:27 +00:00
parent 186090834c
commit 0cb7bde855
2 changed files with 55 additions and 27 deletions

View File

@ -4,6 +4,10 @@
; standby: bool: Enter standby mode initially
;standby=no
; cluster: bool: Enable cluster mode
; If standby is enabled cluster mode is forced
;cluster=
[engine]
; These parameters are used to initialize the MGCP Engine

View File

@ -66,6 +66,7 @@ private:
void endTransaction(int code = 407, const NamedList* params = 0);
bool reqNotify(String& evt);
bool setSignal(String& req);
bool rqntParams(const MGCPMessage* mm);
static void copyRtpParams(NamedList& dest, const NamedList& src);
MGCPTransaction* m_tr;
String m_connEp;
@ -103,6 +104,9 @@ static MGCPPlugin splugin;
static YMGCPEngine* s_engine = 0;
// cluster and standby support
static bool s_cluster = false;
// warm standby mode
static bool s_standby = false;
@ -182,8 +186,10 @@ bool YMGCPEngine::processEvent(MGCPTransaction* trans, MGCPMessage* msg)
// audit endpoint
NamedList params("");
params.addParam("MD",String(s_engine->maxRecvPacket()));
params.addParam("x-standby",String::boolText(s_standby));
params.addParam("x-started",s_started);
if (s_cluster) {
params.addParam("x-standby",String::boolText(s_standby));
params.addParam("x-started",s_started);
}
trans->setResponse(200,&params);
return true;
}
@ -272,10 +278,12 @@ void MGCPChan::endTransaction(int code, const NamedList* params)
m_tr = 0;
if (!tr)
return;
Debug(this,DebugInfo,"Finishing transaction %p with code %d [%p]",tr,code,this);
tr->userData(0);
mylock.drop();
tr->setResponse(code,params);
if (!tr->msgResponse()) {
Debug(this,DebugInfo,"Finishing transaction %p with code %d [%p]",tr,code,this);
tr->setResponse(code,params);
}
}
// method called for each event requesting notification
@ -296,7 +304,8 @@ void MGCPChan::callAccept(Message& msg)
{
NamedList params("");
params.addParam("I",address());
params.addParam("x-standby",String::boolText(m_standby));
if (s_cluster || m_standby)
params.addParam("x-standby",String::boolText(m_standby));
endTransaction(200,&params);
}
@ -341,7 +350,8 @@ bool MGCPChan::processEvent(MGCPTransaction* tr, MGCPMessage* mm)
}
NamedList params("");
params.addParam("I",address());
params.addParam("x-standby",String::boolText(m_standby));
if (s_cluster || m_standby)
params.addParam("x-standby",String::boolText(m_standby));
if (mm->name() == "DLCX") {
disconnect();
status("deleted");
@ -367,6 +377,7 @@ bool MGCPChan::processEvent(MGCPTransaction* tr, MGCPMessage* mm)
param = mm->params.getParam("x");
if (param)
m_ntfyId = *param;
rqntParams(mm);
if (m_isRtp) {
Message m("chan.rtp");
m.addParam("mgcp_allowed",String::boolText(false));
@ -388,29 +399,36 @@ bool MGCPChan::processEvent(MGCPTransaction* tr, MGCPMessage* mm)
return true;
}
if (mm->name() == "RQNT") {
bool ok = true;
// what we are requested to notify back
NamedString* req = mm->params.getParam("r");
if (req) {
ObjList* lst = req->split(',');
for (ObjList* item = lst->skipNull(); item; item = item->skipNext())
ok = reqNotify(*static_cast<String*>(item->get())) && ok;
delete lst;
}
// what we must signal now
req = mm->params.getParam("s");
if (req) {
ObjList* lst = req->split(',');
for (ObjList* item = lst->skipNull(); item; item = item->skipNext())
ok = setSignal(*static_cast<String*>(item->get())) && ok;
delete lst;
}
tr->setResponse(ok ? 200 : 538,&params);
tr->setResponse(rqntParams(mm) ? 200 : 538,&params);
return true;
}
return false;
}
bool MGCPChan::rqntParams(const MGCPMessage* mm)
{
if (!mm)
return false;
bool ok = true;
// what we are requested to notify back
const NamedString* req = mm->params.getParam("r");
if (req) {
ObjList* lst = req->split(',');
for (ObjList* item = lst->skipNull(); item; item = item->skipNext())
ok = reqNotify(*static_cast<String*>(item->get())) && ok;
delete lst;
}
// what we must signal now
req = mm->params.getParam("s");
if (req) {
ObjList* lst = req->split(',');
for (ObjList* item = lst->skipNull(); item; item = item->skipNext())
ok = setSignal(*static_cast<String*>(item->get())) && ok;
delete lst;
}
return ok;
}
bool MGCPChan::initialEvent(MGCPTransaction* tr, MGCPMessage* mm, const MGCPEndpointId& id)
{
Debug(this,DebugInfo,"MGCPChan::initialEvent(%p,%p,'%s') [%p]",
@ -418,6 +436,7 @@ bool MGCPChan::initialEvent(MGCPTransaction* tr, MGCPMessage* mm, const MGCPEndp
m_connEp = id.id();
m_callId = mm->params.getValue("c");
m_ntfyId = mm->params.getValue("x");
rqntParams(mm);
if (id.user() == "gigi")
m_isRtp = true;
@ -435,7 +454,8 @@ bool MGCPChan::initialEvent(MGCPTransaction* tr, MGCPMessage* mm, const MGCPEndp
}
NamedList params("");
params.addParam("I",address());
params.addParam("x-standby",String::boolText(m_standby));
if (s_cluster || m_standby)
params.addParam("x-standby",String::boolText(m_standby));
copyRename(params,"x-localip",*m,"localip");
copyRename(params,"x-localport",*m,"localport");
m_rtpId = m->getValue("rtpid");
@ -509,6 +529,7 @@ RefPointer<MGCPChan> MGCPPlugin::findConn(const String* id, MGCPChan::IdType typ
void MGCPPlugin::activate(bool standby)
{
lock();
s_cluster = true;
ListIterator iter(channels());
while (GenObject* obj = iter.get()) {
RefPointer<MGCPChan> chan = static_cast<MGCPChan*>(obj);
@ -534,6 +555,7 @@ void MGCPPlugin::initialize()
break;
s_started = Time::secNow();
s_standby = cfg.getBoolValue("general","standby",false);
s_cluster = s_standby || cfg.getBoolValue("general","cluster",false);
s_engine = new YMGCPEngine(sect);
s_engine->debugChain(this);
int n = cfg.sections();
@ -557,8 +579,10 @@ void MGCPPlugin::initialize()
if (sect->getBoolValue("announce",true)) {
MGCPMessage* mm = new MGCPMessage(s_engine,"RSIP",ep->toString());
mm->params.addParam("RM","restart");
mm->params.addParam("x-standby",String::boolText(s_standby));
mm->params.addParam("x-started",s_started);
if (s_cluster) {
mm->params.addParam("x-standby",String::boolText(s_standby));
mm->params.addParam("x-started",s_started);
}
s_engine->sendCommand(mm,ca->address);
}
}