Implemented basic control operation for SS7 Layer 2.
git-svn-id: http://yate.null.ro/svn/yate/trunk@2771 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
6b26ff031a
commit
cf8adabc1d
|
@ -23,27 +23,34 @@
|
|||
*/
|
||||
|
||||
#include "yatesig.h"
|
||||
#include <yatephone.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
using namespace TelEngine;
|
||||
|
||||
static TokenDict s_dict_prio[] = {
|
||||
{"regular", SS7MSU::Regular},
|
||||
{"special", SS7MSU::Special},
|
||||
{"circuit", SS7MSU::Circuit},
|
||||
{"facility", SS7MSU::Facility},
|
||||
{0,0}
|
||||
};
|
||||
static const TokenDict s_dict_prio[] = {
|
||||
{ "regular", SS7MSU::Regular },
|
||||
{ "special", SS7MSU::Special },
|
||||
{ "circuit", SS7MSU::Circuit },
|
||||
{ "facility", SS7MSU::Facility },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static TokenDict s_dict_netind[] = {
|
||||
{"international", SS7MSU::International},
|
||||
{"spareinternational", SS7MSU::SpareInternational},
|
||||
{"national", SS7MSU::National},
|
||||
{"reservednational", SS7MSU::ReservedNational},
|
||||
{0,0}
|
||||
};
|
||||
static const TokenDict s_dict_netind[] = {
|
||||
{ "international", SS7MSU::International },
|
||||
{ "spareinternational", SS7MSU::SpareInternational },
|
||||
{ "national", SS7MSU::National },
|
||||
{ "reservednational", SS7MSU::ReservedNational },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const TokenDict s_dict_control[] = {
|
||||
{ "pause", SS7Layer2::Pause },
|
||||
{ "resume", SS7Layer2::Resume },
|
||||
{ "align", SS7Layer2::Align },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
SS7MSU::SS7MSU(unsigned char sio, const SS7Label label, void* value, unsigned int len)
|
||||
{
|
||||
|
@ -183,6 +190,28 @@ bool SS7Layer2::control(Operation oper, NamedList* params)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool SS7Layer2::control(NamedList& params)
|
||||
{
|
||||
String* ret = params.getParam("completion");
|
||||
const String* oper = params.getParam("operation");
|
||||
int cmd = oper ? oper->toInteger(s_dict_control,-1) : -1;
|
||||
if (ret) {
|
||||
if (oper && (cmd < 0))
|
||||
return false;
|
||||
const char* cmp = params.getValue("component");
|
||||
String part = params.getValue("partword");
|
||||
if (cmp) {
|
||||
if (toString() != cmp)
|
||||
return false;
|
||||
for (const TokenDict* d = s_dict_control; d->token; d++)
|
||||
Module::itemComplete(*ret,d->token,part);
|
||||
return true;
|
||||
}
|
||||
return Module::itemComplete(*ret,toString(),part);
|
||||
}
|
||||
return (cmd >= 0) && control((Operation)cmd,¶ms);
|
||||
}
|
||||
|
||||
ObjList* SS7Layer2::recoverMSU()
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -633,8 +633,11 @@ void SS7MTP3::notify(SS7Layer2* link)
|
|||
Debug(this,DebugInfo,"%sLinkset has %u/%u active links [%p]",tmp.null()?"":tmp.c_str(),m_active,m_total,this);
|
||||
#endif
|
||||
// if operational status changed notify upper layer
|
||||
if (ok != operational())
|
||||
if (ok != operational()) {
|
||||
Debug(this,DebugNote,"Linkset is%s operational [%p]",
|
||||
(operational() ? "" : " not"),this);
|
||||
SS7Layer3::notify(link ? link->sls() : -1);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=8 sw=4 sts=4 noet: */
|
||||
|
|
|
@ -4137,6 +4137,13 @@ public:
|
|||
*/
|
||||
virtual bool control(Operation oper, NamedList* params = 0);
|
||||
|
||||
/**
|
||||
* Query or modify layer's settings or operational parameters
|
||||
* @param params The list of parameters to query or change
|
||||
* @return True if the control operation was executed
|
||||
*/
|
||||
virtual bool control(NamedList& params);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -4780,7 +4787,7 @@ protected:
|
|||
|
||||
private:
|
||||
virtual bool control(NamedList& params)
|
||||
{ return SignallingDumpable::control(params,this); }
|
||||
{ return SignallingDumpable::control(params,this) || SS7Layer2::control(params); }
|
||||
void unqueueAck(unsigned char bsn);
|
||||
bool txPacket(const DataBlock& packet, bool repeat, SignallingInterface::PacketType type = SignallingInterface::Unknown);
|
||||
void setLocalStatus(unsigned int status);
|
||||
|
|
|
@ -1267,6 +1267,10 @@ bool SigDriver::received(Message& msg, int id)
|
|||
return true;
|
||||
}
|
||||
return Driver::received(msg,id);
|
||||
case Control:
|
||||
if (m_engine && m_engine->control(msg))
|
||||
return true;
|
||||
return Driver::received(msg,id);
|
||||
case Halt:
|
||||
clearTrunk();
|
||||
if (m_engine)
|
||||
|
@ -1557,13 +1561,37 @@ bool SigDriver::commandComplete(Message& msg, const String& partLine,
|
|||
msg.retValue() = params.getValue("completion");
|
||||
}
|
||||
}
|
||||
else if (partLine == "control") {
|
||||
if (m_engine) {
|
||||
NamedList params("");
|
||||
params.addParam("partword",partWord);
|
||||
params.addParam("completion",msg.retValue());
|
||||
if (m_engine->control(params))
|
||||
msg.retValue() = params.getValue("completion");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
String tmp = partLine;
|
||||
if (tmp.startSkip("control")) {
|
||||
if (m_engine) {
|
||||
NamedList params("");
|
||||
params.addParam("component",tmp);
|
||||
params.addParam("partword",partWord);
|
||||
params.addParam("completion",msg.retValue());
|
||||
if (m_engine->control(params))
|
||||
msg.retValue() = params.getValue("completion");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool status = partLine.startsWith("status");
|
||||
bool drop = !status && partLine.startsWith("drop");
|
||||
if (!(status || drop))
|
||||
return Driver::commandComplete(msg,partLine,partWord);
|
||||
|
||||
Lock lock(this);
|
||||
// line='status sig': add trunks
|
||||
// line='status sig': add trunks and topmost components
|
||||
if (partLine == m_statusCmd) {
|
||||
ObjList* o;
|
||||
m_trunksMutex.lock();
|
||||
|
|
Loading…
Reference in New Issue