Keep the link inhibition reasons as a bit map of flags.

git-svn-id: http://yate.null.ro/svn/yate/trunk@3541 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2010-08-27 04:52:18 +00:00
parent 70dbc1e8a5
commit 86c22e68d7
2 changed files with 36 additions and 23 deletions

View File

@ -569,7 +569,7 @@ unsigned int SS7MTP3::countLinks()
if (!(p && *p))
continue;
total++;
if ((*p)->operational() && !(*p)->m_unchecked)
if ((*p)->operational() && !((*p)->inhibited() & (SS7Layer2::Unchecked|SS7Layer2::Inactive)))
active++;
}
m_total = total;
@ -594,10 +594,10 @@ bool SS7MTP3::operational(int sls) const
return false;
}
bool SS7MTP3::inhibited(int sls) const
int SS7MTP3::inhibited(int sls) const
{
if (sls < 0)
return m_inhibit;
return m_inhibit ? SS7Layer2::Inactive : 0;
const ObjList* l = &m_links;
for (; l; l = l->next()) {
L2Pointer* p = static_cast<L2Pointer*>(l->get());
@ -606,7 +606,7 @@ bool SS7MTP3::inhibited(int sls) const
if ((*p)->sls() == sls)
return (*p)->inhibited();
}
return true;
return SS7Layer2::Inactive;
}
int SS7MTP3::getSequence(int sls) const
@ -811,7 +811,7 @@ bool SS7MTP3::initialize(const NamedList* config)
continue;
if (linkSls >= 0)
link->sls(linkSls);
link->m_unchecked = m_checklinks;
link->m_inhibited = m_checklinks ? SS7Layer2::Unchecked : 0;
attach(link);
if (!link->initialize(linkConfig))
detach(link);
@ -928,13 +928,13 @@ bool SS7MTP3::receivedMSU(const SS7MSU& msu, SS7Layer2* link, int sls)
#endif
bool maint = (msu.getSIF() == SS7MSU::MTN) || (msu.getSIF() == SS7MSU::MTNS);
if (link) {
if (link->m_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_unchecked = false;
link->m_inhibited = 0;
notify(link);
}
}
@ -964,14 +964,14 @@ void SS7MTP3::notify(SS7Layer2* link)
#endif
if (link) {
if (link->operational()) {
if (link->m_unchecked) {
if (link->inhibited() & SS7Layer2::Unchecked) {
u_int64_t t = Time::now() + 50000 + (::random() % 100000);
if ((t < link->m_check) || (t - 4000000 > link->m_check))
link->m_check = t;
}
}
else
link->m_unchecked = m_checklinks;
link->m_inhibited = m_checklinks ? SS7Layer2::Unchecked : 0;
}
// if operational status of a link changed notify upper layer
if (act != m_active) {

View File

@ -4861,6 +4861,20 @@ public:
Status = 0x400,
};
/**
* Link inhibition reason bits
*/
enum Inhibitions {
// basic maintenance checks not performed
Unchecked = 0x01,
// management inactivation
Inactive = 0x02,
// locally inhibited
Local = 0x04,
// remotely inhibited
Remote = 0x08,
};
/**
* Push a Message Signal Unit down the protocol stack
* @param msu Message data, starting with Service Indicator Octet
@ -4930,11 +4944,11 @@ public:
{ if ((m_sls < 0) || !m_l2user) m_sls = linkSel; }
/**
* Check if the link is inhibited by MTP3 Management
* @return True if the link is inhibited and should not be used
* Retrieve the inhibition flags set by MTP3 Management
* @return Inhibition flags ORed together, zero if not inhibited
*/
inline bool inhibited() const
{ return m_inhibited || m_unchecked; }
inline int inhibited() const
{ return m_inhibited; }
/**
* Get the sequence number of the last MSU received
@ -4967,7 +4981,7 @@ protected:
inline SS7Layer2()
: m_autoEmergency(true), m_lastSeqRx(-1),
m_l2userMutex(true,"SS7Layer2::l2user"), m_l2user(0), m_sls(-1),
m_check(0), m_unchecked(true), m_inhibited(false)
m_check(0), m_inhibited(Unchecked)
{ }
/**
@ -5018,8 +5032,7 @@ private:
SS7L2User* m_l2user;
int m_sls;
u_int64_t m_check;
bool m_unchecked;
bool m_inhibited;
int m_inhibited;
};
/**
@ -5257,12 +5270,12 @@ public:
virtual bool operational(int sls = -1) const = 0;
/**
* Check if a specific link is inhibited
* Retrieve inhibition flags of a specific link
* @param sls Signalling Link to check
* @return True if the specified link is inhibited and should not be used
* @return Inhibitions of the specified link, zero if not inhibited
*/
virtual bool inhibited(int sls) const
{ return false; }
virtual int inhibited(int sls) const
{ return 0; }
/**
* Get the sequence number of the last MSU received on a link
@ -6465,11 +6478,11 @@ public:
virtual bool operational(int sls = -1) const;
/**
* Check if a specific link is inhibited
* Retrieve inhibition flags of a specific link
* @param sls Signalling Link to check
* @return True if the specified link is inhibited and should not be used
* @return Inhibitions of the specified link, zero if not inhibited
*/
virtual bool inhibited(int sls) const;
virtual int inhibited(int sls) const;
/**
* Get the sequence number of the last MSU received on a link