Fixed the component name matching in control operations.

Implemented control of MTP3 with notification to Layer 4 about operational changes caused by management inhibiting.


git-svn-id: http://yate.null.ro/svn/yate/trunk@2807 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2009-08-25 21:07:34 +00:00
parent a695b1e0e8
commit ed4762b3f7
3 changed files with 93 additions and 5 deletions

View File

@ -194,11 +194,11 @@ bool SS7Layer2::control(NamedList& params)
{
String* ret = params.getParam("completion");
const String* oper = params.getParam("operation");
const char* cmp = params.getValue("component");
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)
@ -209,6 +209,8 @@ bool SS7Layer2::control(NamedList& params)
}
return Module::itemComplete(*ret,toString(),part);
}
if (!(cmp && toString() == cmp))
return false;
return (cmd >= 0) && control((Operation)cmd,&params);
}

View File

@ -23,12 +23,18 @@
*/
#include "yatesig.h"
#include <yatephone.h>
#include <stdlib.h>
using namespace TelEngine;
static const TokenDict s_dict_control[] = {
{ "pause", SS7MTP3::Pause },
{ "resume", SS7MTP3::Resume },
{ 0, 0 }
};
typedef GenPointer<SS7Layer2> L2Pointer;
void SS7L3User::notify(SS7Layer3* network, int sls)
@ -341,7 +347,7 @@ SS7MTP3::SS7MTP3(const NamedList& params)
: SignallingComponent(params.safe("SS7MTP3"),&params),
SignallingDumpable(SignallingDumper::Mtp3),
Mutex(true,"SS7MTP3"),
m_total(0), m_active(0)
m_total(0), m_active(0), m_inhibit(false)
{
#ifdef DEBUG
if (debugAt(DebugAll)) {
@ -410,6 +416,8 @@ unsigned int SS7MTP3::countLinks()
bool SS7MTP3::operational(int sls) const
{
if (m_inhibit)
return false;
if (sls < 0)
return (m_active != 0);
const ObjList* l = &m_links;
@ -479,6 +487,56 @@ void SS7MTP3::detach(SS7Layer2* link)
}
}
bool SS7MTP3::control(Operation oper, NamedList* params)
{
bool ok = operational();
switch (oper) {
case Pause:
if (!m_inhibit) {
m_inhibit = true;
if (ok)
SS7Layer3::notify(-1);
}
return true;
case Resume:
if (m_inhibit) {
m_inhibit = false;
if (ok != operational())
SS7Layer3::notify(-1);
}
return true;
case Status:
return ok;
}
return false;
}
bool SS7MTP3::control(NamedList& params)
{
String* ret = params.getParam("completion");
const String* oper = params.getParam("operation");
const char* cmp = params.getValue("component");
int cmd = oper ? oper->toInteger(s_dict_control,-1) : -1;
if (ret) {
if (oper && (cmd < 0))
return false;
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);
}
if (!(cmp && toString() == cmp))
return false;
if (cmd >= 0)
return control((Operation)cmd,&params);
return SignallingDumpable::control(params,this);
}
// Configure and initialize MTP3 and its links
bool SS7MTP3::initialize(const NamedList* config)
{

View File

@ -4903,6 +4903,18 @@ class YSIG_API SS7MTP3 : public SS7Layer3, public SS7L2User, public SignallingDu
{
YCLASS(SS7MTP3,SS7Layer3)
public:
/**
* Control primitives
*/
enum Operation {
// take linkset out of service
Pause = 0x100,
// start linkset operation
Resume = 0x200,
// get operational status
Status = 0x400,
};
/**
* Constructor
* @param params Layer's parameters
@ -4937,6 +4949,15 @@ public:
*/
virtual bool operational(int sls = -1) const;
/**
* Execute a control operation on the linkset
* @param oper Operation to execute
* @param params Optional parameters for the operation
* @return True if the command completed successfully, for query operations
* also indicates the linkset is enabled and operational
*/
virtual bool control(Operation oper, NamedList* params = 0);
/**
* Attach a SS7 Layer 2 (data link) to the network transport. Attach itself to the link
* @param link Pointer to data link to attach
@ -4949,6 +4970,13 @@ public:
*/
virtual void detach(SS7Layer2* link);
/**
* 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);
/**
* Get the total number of links attached
* @return Number of attached data links
@ -4992,13 +5020,13 @@ protected:
unsigned int countLinks();
private:
virtual bool control(NamedList& params)
{ return SignallingDumpable::control(params,this); }
ObjList m_links;
// total links in linkset
unsigned int m_total;
// currently active links
unsigned int m_active;
// inhibited flag
bool m_inhibit;
};
/**