Added an inline method to check specific inhibition flags of a link.

Changed a lot of debugging messages and levels to improve readability.


git-svn-id: http://yate.null.ro/svn/yate/trunk@3548 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2010-08-27 12:22:41 +00:00
parent a3f692b5fb
commit 385caf375c
6 changed files with 48 additions and 30 deletions

View File

@ -235,10 +235,12 @@ bool SS7Layer2::inhibit(int setFlags, int clrFlags)
{
int old = m_inhibited;
m_inhibited = (m_inhibited | setFlags) & ~clrFlags;
DDebug(this,DebugInfo,"Link inhibition changed 0x%02X -> 0x%02X [%p]",
old,m_inhibited,this);
if (((old != 0) ^ (m_inhibited != 0)) && operational())
notify();
if (old != m_inhibited) {
Debug(this,DebugNote,"Link inhibition changed 0x%02X -> 0x%02X [%p]",
old,m_inhibited,this);
if (((old != 0) ^ (m_inhibited != 0)) && operational())
notify();
}
return true;
}

View File

@ -569,7 +569,7 @@ unsigned int SS7MTP3::countLinks()
if (!(p && *p))
continue;
total++;
if ((*p)->operational() && !((*p)->inhibited() & (SS7Layer2::Unchecked|SS7Layer2::Inactive)))
if ((*p)->operational() && !((*p)->inhibited(SS7Layer2::Unchecked|SS7Layer2::Inactive)))
active++;
}
m_total = total;
@ -829,7 +829,8 @@ bool SS7MTP3::initialize(const NamedList* config)
continue;
if (linkSls >= 0)
link->sls(linkSls);
link->m_inhibited = m_checklinks ? SS7Layer2::Unchecked : 0;
if (m_checklinks)
link->inhibit(SS7Layer2::Unchecked);
attach(link);
if (!link->initialize(linkConfig))
detach(link);
@ -940,24 +941,27 @@ bool SS7MTP3::receivedMSU(const SS7MSU& msu, SS7Layer2* link, int sls)
if (debugAt(DebugInfo)) {
String tmp;
tmp << label << " (" << label.opc().pack(cpType) << ":" << label.dpc().pack(cpType) << ":" << label.sls() << ")";
Debug(this,DebugAll,"Received MSU from link '%s' %p with SLS=%d. Address: %s",
link->toString().c_str(),link,sls,tmp.c_str());
Debug(this,DebugAll,"Received MSU from link %d '%s' %p. Address: %s",
sls,link->toString().c_str(),link,tmp.c_str());
}
#endif
bool maint = (msu.getSIF() == SS7MSU::MTN) || (msu.getSIF() == SS7MSU::MTNS);
if (link) {
if (link->inhibited() & SS7Layer2::Unchecked) {
if (link->inhibited(SS7Layer2::Unchecked)) {
if (!maint)
return false;
if (label.sls() == sls) {
Debug(this,DebugNote,"Placing link '%s' %d in service [%p]",
link->toString().c_str(),sls,this);
link->m_inhibited = 0;
Debug(this,DebugNote,"Placing link %d '%s' in service [%p]",
sls,link->toString().c_str(),this);
link->m_inhibited &= ~SS7Layer2::Unchecked;
notify(link);
}
}
if (!maint && (msu.getSIF() != SS7MSU::SNM) && link->inhibited())
if (!maint && (msu.getSIF() != SS7MSU::SNM) && link->inhibited()) {
Debug(this,DebugMild,"Received MSU on inhibited link %d '%s' [%p]",
sls,link->toString().c_str(),this);
return false;
}
}
// first try to call the user part
HandledMSU handled = SS7Layer3::receivedMSU(msu,label,sls);
@ -995,8 +999,12 @@ void SS7MTP3::notify(SS7Layer2* link)
link->m_check = t;
}
}
else
link->m_inhibited = m_checklinks ? SS7Layer2::Unchecked : 0;
else {
if (m_checklinks)
link->inhibit(SS7Layer2::Unchecked,0);
else
link->inhibit(0,SS7Layer2::Unchecked);
}
}
// if operational status of a link changed notify upper layer
if (act != m_active) {

View File

@ -383,7 +383,7 @@ HandledMSU SS7Management::receivedMSU(const SS7MSU& msu, const SS7Label& label,
const unsigned char* s = msu.getData(label.length()+2,len);
if (!s)
return false;
Debug(this,DebugInfo,"%s (code len=%u) [%p]",msg->name(),len,this);
Debug(this,DebugAll,"%s (code len=%u) [%p]",msg->name(),len,this);
SS7Label lbl(label,label.sls(),0);
SS7MSU answer(msu.getSIO(),lbl,0,len+1);
unsigned char* d = answer.getData(lbl.length()+1,len+1);
@ -418,7 +418,7 @@ HandledMSU SS7Management::receivedMSU(const SS7MSU& msu, const SS7Label& label,
else if (msg->type() == SS7MsgSNM::CBA) {
if (!len--)
return false;
Debug(this,DebugInfo,"%s (code len=%u) [%p]",msg->name(),len,this);
Debug(this,DebugAll,"%s (code len=%u) [%p]",msg->name(),len,this);
lock();
SnmPending* pend = 0;
for (ObjList* l = m_pending.skipNull(); l; l = l->skipNext()) {
@ -447,7 +447,7 @@ HandledMSU SS7Management::receivedMSU(const SS7MSU& msu, const SS7Label& label,
msg->type() == SS7MsgSNM::ECA) {
if (!len--)
return false;
Debug(this,DebugInfo,"%s (code len=%u) [%p]",msg->name(),len,this);
Debug(this,DebugAll,"%s (code len=%u) [%p]",msg->name(),len,this);
lock();
SnmPending* pend = 0;
for (ObjList* l = m_pending.skipNull(); l; l = l->skipNext()) {
@ -662,8 +662,7 @@ bool SS7Management::control(NamedList& params)
void SS7Management::notify(SS7Layer3* network, int sls)
{
Debug(this,DebugStub,"Please implement SS7Management::notify(%p,%d) [%p]",
network,sls,this);
Debug(this,DebugAll,"SS7Management::notify(%p,%d) [%p]",network,sls,this);
if (network && (sls >= 0)) {
bool linkAvail[256];
int txSls;
@ -736,7 +735,7 @@ bool SS7Management::postpone(SS7MSU* msu, const SS7Label& label, int txSls,
bool SS7Management::timeout(const SS7MSU& msu, const SS7Label& label, int txSls, bool final)
{
Debug(this,DebugStub,"Timeout %u%s [%p]",txSls,(final ? " final" : ""),this);
Debug(this,DebugAll,"Timeout %u%s [%p]",txSls,(final ? " final" : ""),this);
if (!final)
return true;
const unsigned char* buf = msu.getData(label.length()+1,1);
@ -834,7 +833,7 @@ HandledMSU SS7Maintenance::receivedMSU(const SS7MSU& msu, const SS7Label& label,
SS7MSU answer(msu.getSIO(),lbl,0,len+2);
unsigned char* d = answer.getData(lbl.length()+1,len+2);
if (!d)
return true;
return false;
addr.clear();
addr << SS7PointCode::lookup(lbl.type()) << "," << lbl;
if (debugAt(DebugAll))
@ -861,8 +860,6 @@ HandledMSU SS7Maintenance::receivedMSU(const SS7MSU& msu, const SS7Label& label,
void SS7Maintenance::notify(SS7Layer3* network, int sls)
{
Debug(this,DebugStub,"Please implement SS7Maintenance::notify(%p,%d) [%p]",
network,sls,this);
}
/* vi: set ts=8 sw=4 sts=4 noet: */

View File

@ -806,6 +806,7 @@ void SS7Router::notify(SS7Layer3* network, int sls)
DDebug(this,DebugInfo,"Notified %s on %p sls %d [%p]",
(network ? (network->operational() ? "net-up" : "net-down") : "no-net"),
network,sls,this);
bool useMe = false;
Lock lock(this);
if (network) {
if (network->operational()) {
@ -828,8 +829,7 @@ void SS7Router::notify(SS7Layer3* network, int sls)
else {
if (!m_restart.started())
restart();
network = this;
sls = -1;
useMe = true;
}
}
else
@ -839,8 +839,13 @@ void SS7Router::notify(SS7Layer3* network, int sls)
ObjList* l = &m_layer4;
for (; l; l = l->next()) {
L4Pointer* p = static_cast<L4Pointer*>(l->get());
if (p && *p)
(*p)->notify(network,sls);
if (p && *p) {
SS7Layer4* l4 = *p;
if (useMe && (l4 != m_mngmt) && (l4 != m_maint))
l4->notify(this,-1);
else
l4->notify(network,sls);
}
}
}

View File

@ -105,8 +105,6 @@ bool SS7Testing::sendTraffic()
void SS7Testing::notify(SS7Layer3* network, int sls)
{
Debug(this,DebugStub,"Please implement SS7Testing::notify(%p,%d) [%p]",
network,sls,this);
}
void SS7Testing::timerTick(const Time& when)

View File

@ -5056,6 +5056,14 @@ public:
inline int inhibited() const
{ return m_inhibited; }
/**
* Check some of the inhibition flags set by MTP3 Management
* @params flags Flags to check for, ORed together
* @return True if any of the specified inhibition flags is active
*/
inline bool inhibited(int flags) const
{ return (m_inhibited & flags) != 0; }
/**
* Get the sequence number of the last MSU received
* @return Last FSN received, negative if not available