Added method to resolve signaling subcomponent configuration.

Use the new mehod to allow proper configuration of SCCP, management and GTT.


git-svn-id: http://yate.null.ro/svn/yate/trunk@5319 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
andrei 2012-11-02 13:44:30 +00:00
parent 83234869ad
commit 4f22d8e929
3 changed files with 33 additions and 13 deletions

View File

@ -184,6 +184,28 @@ bool SignallingComponent::initialize(const NamedList* config)
return true;
}
void SignallingComponent::resolveConfig(const String& cmpName, NamedList& params, const NamedList* config)
{
if (!config)
return;
String name = config->getValue(cmpName,params);
if (!(name && !name.toBoolean(false)))
return;
static_cast<String&>(params) = name;
NamedString* param = config->getParam(params);
NamedPointer* ptr = YOBJECT(NamedPointer,param);
NamedList* ifConfig = ptr ? YOBJECT(NamedList,ptr->userData()) : 0;
if (ifConfig)
params.copyParams(*ifConfig);
else {
if (config->hasSubParams(params + "."))
params.copySubParams(*config,params + ".");
else
params.addParam("local-config","true");
}
}
bool SignallingComponent::control(NamedList& params)
{
return false;

View File

@ -1645,11 +1645,7 @@ bool SCCPUser::initialize(const NamedList* config)
DDebug(this,DebugInfo,"SCCPUser::initialize(%p) [%p]",config,this);
if (engine()) {
NamedList params("sccp");
if (config) {
String name = config->getValue(YSTRING("sccp"),params);
if (name && !name.toBoolean(false))
static_cast<String&>(params) = name;
}
resolveConfig(YSTRING("sccp"),params,config);
// NOTE SS7SCCP is created on demand!!!
// engine ->build method will search for the requested sccc and
// if it was found will return it with the ref counter incremented
@ -1739,11 +1735,7 @@ bool GTT::initialize(const NamedList* config)
DDebug(this,DebugInfo,"GTT::initialize(%p) [%p]",config,this);
if (engine()) {
NamedList params("sccp");
if (config) {
String name = config->getValue(YSTRING("sccp"),params);
if (name && !name.toBoolean(false))
static_cast<String&>(params) = name;
}
resolveConfig(YSTRING("sccp"),params,config);
if (params.toBoolean(true))
attach(YOBJECT(SCCP,engine()->build("SCCP",params,true)));
} else
@ -2832,9 +2824,7 @@ SS7SCCP::SS7SCCP(const NamedList& params)
m_segTimeout = 20000;
if ((m_type == SS7PointCode::ITU || m_type == SS7PointCode::ANSI) && m_localPointCode) {
NamedList mgmParams("sccp-mgm");
String name = params.getValue(YSTRING("management"),mgmParams);
if (name && !name.toBoolean(false))
static_cast<String&>(mgmParams) = name;
resolveConfig(YSTRING("management"),mgmParams,&params);
mgmParams.setParam("type",m_type == SS7PointCode::ITU ? "ss7-sccp-itu-mgm" : "ss7-sccp-ansi-mgm");
if (mgmParams.toBoolean(true)) {
if (m_type == SS7PointCode::ITU)

View File

@ -657,6 +657,14 @@ public:
*/
virtual bool initialize(const NamedList* config);
/**
* Choose parameters that should be used for object initialization
* @param cmpName The name of the parameter holding the component name
* @param params The list of parameters used to initialize the component
* @param config The received list of parameters
*/
static void resolveConfig(const String& cmpName, NamedList& params, const NamedList* config);
/**
* Query or modify component's settings or operational parameters
* @param params The list of parameters to query or change