diff --git a/conf.d/ciscosm.conf.sample b/conf.d/ciscosm.conf.sample index 3d508de2..a3407882 100644 --- a/conf.d/ciscosm.conf.sample +++ b/conf.d/ciscosm.conf.sample @@ -60,7 +60,8 @@ ; channel: int: Number of the channel inside the session, must match remote config ;channel=0 -; autostart: bool: Automatically try to align the remote MTP2 at startup +; autostart: bool: Automatically align the remote MTP2 at startup or on failure +; This should be enabled (default) for normal operation ;autostart=yes ; autoemergency: boolean: Emergency align link if owner linkset is down diff --git a/conf.d/ysigchan.conf.sample b/conf.d/ysigchan.conf.sample index b9fbe5d8..eb4daa9b 100644 --- a/conf.d/ysigchan.conf.sample +++ b/conf.d/ysigchan.conf.sample @@ -495,6 +495,7 @@ ;link= ; autostart: bool: Automatically enable the linkset at startup +; This should be enabled (default) for normal operation ;autostart=yes ; checklinks: boolean: Check that the links answer to maintenance messages @@ -523,7 +524,8 @@ ; ss7-mtp2: SS7 Message Transfer Part - Layer 2 ;type=ss7-mtp2 -; autostart: bool: Automatically try to align the MTP2 at startup +; autostart: bool: Automatically try to align the MTP2 at startup or on failure +; This should be enabled (default) for normal operation ;autostart=yes ; emergency: boolean: Emergency align SS7 MTP2 layer at startup diff --git a/libs/ysig/layer2.cpp b/libs/ysig/layer2.cpp index f7d396fc..d30379da 100644 --- a/libs/ysig/layer2.cpp +++ b/libs/ysig/layer2.cpp @@ -253,7 +253,8 @@ SS7MTP2::SS7MTP2(const NamedList& params, unsigned int status) m_interval(0), m_resend(0), m_abort(0), m_fillTime(0), m_congestion(false), m_bsn(127), m_fsn(127), m_bib(true), m_fib(true), m_lastFsn(128), m_lastBsn(127), m_lastBib(true), m_errors(0), - m_resendMs(250), m_abortMs(5000), m_fillIntervalMs(20), m_fillLink(true) + m_resendMs(250), m_abortMs(5000), m_fillIntervalMs(20), m_fillLink(true), + m_autostart(false) { #ifdef DEBUG if (debugAt(DebugAll)) { @@ -320,7 +321,7 @@ bool SS7MTP2::initialize(const NamedList* config) config->getIntValue("debuglevel",-1))); m_autoEmergency = config->getBoolValue("autoemergency",true); } - bool noStart = true; + m_autostart = !config || config->getBoolValue("autostart",true); if (config && !iface()) { NamedString* name = config->getParam("sig"); if (!name) @@ -348,9 +349,8 @@ bool SS7MTP2::initialize(const NamedList* config) if (!(ifc->initialize(ifConfig) && control((Operation)SignallingInterface::Enable,ifConfig))) TelEngine::destruct(SignallingReceiver::attach(0)); } - noStart = !config->getBoolValue("autostart",true); } - return iface() && (noStart || control(Resume,const_cast(config))); + return iface() && control(Resume,const_cast(config)); } bool SS7MTP2::control(Operation oper, NamedList* params) @@ -359,6 +359,7 @@ bool SS7MTP2::control(Operation oper, NamedList* params) lock(); m_fillLink = params->getBoolValue("filllink",m_fillLink); m_autoEmergency = params->getBoolValue("autoemergency",m_autoEmergency); + m_autostart = params->getBoolValue("autostart",m_autostart); // The following are for test purposes if (params->getBoolValue("toggle-bib")) m_bib = !m_bib; @@ -376,12 +377,11 @@ bool SS7MTP2::control(Operation oper, NamedList* params) } switch (oper) { case Pause: - m_status = OutOfService; - abortAlignment(); + abortAlignment(false); transmitLSSU(); return true; case Resume: - if (aligned()) + if (aligned() || !m_autostart) return true; // fall-through case Align: @@ -399,7 +399,7 @@ bool SS7MTP2::notify(SignallingInterface::Notification event) switch (event) { case SignallingInterface::LinkDown: Debug(this,DebugWarn,"Interface is down - realigning [%p]",this); - abortAlignment(); + abortAlignment(m_autostart); break; case SignallingInterface::LinkUp: Debug(this,DebugInfo,"Interface is up [%p]",this); @@ -409,7 +409,7 @@ bool SS7MTP2::notify(SignallingInterface::Notification event) event,lookup(event,SignallingInterface::s_notifName),this); if (++m_errors >= 4) { Debug(this,DebugWarn,"Got %d errors - realigning [%p]",m_errors,this); - abortAlignment(); + abortAlignment(m_autostart); } } return true; @@ -430,7 +430,7 @@ void SS7MTP2::timerTick(const Time& when) unlock(); if (aborting) { Debug(this,DebugWarn,"Timeout for MSU acknowledgement, realigning [%p]",this); - abortAlignment(); + abortAlignment(m_autostart); return; } if (operational()) { @@ -764,7 +764,7 @@ void SS7MTP2::processLSSU(unsigned int status) setRemoteStatus(status); if (status == Busy) { if (unaligned) - abortAlignment(); + abortAlignment(m_autostart); else m_congestion = true; return; @@ -779,7 +779,7 @@ void SS7MTP2::processLSSU(unsigned int status) break; default: if (!m_interval) - abortAlignment(); + abortAlignment(m_autostart); else if (m_lStatus != OutOfService && m_lStatus != OutOfAlignment) m_interval = 0; } @@ -848,10 +848,12 @@ void SS7MTP2::startAlignment(bool emergency) SS7Layer2::notify(); } -void SS7MTP2::abortAlignment() +void SS7MTP2::abortAlignment(bool retry) { lock(); DDebug(this,DebugNote,"Aborting alignment [%p]",this); + if (!retry) + m_status = OutOfService; setLocalStatus(OutOfService); m_interval = Time::now() + 1000000; m_abort = m_resend = 0; diff --git a/libs/ysig/yatesig.h b/libs/ysig/yatesig.h index b1163c75..6cfff00c 100644 --- a/libs/ysig/yatesig.h +++ b/libs/ysig/yatesig.h @@ -6912,8 +6912,9 @@ protected: /** * Abort an alignment procedure if link errors occur + * @param retry Keep trying to align */ - void abortAlignment(); + void abortAlignment(bool retry = true); /** * Start the link proving period @@ -6962,6 +6963,8 @@ private: unsigned int m_fillIntervalMs; // fill link with end-to-end FISU/LSSU bool m_fillLink; + // automatically align on resume + bool m_autostart; }; /** diff --git a/modules/server/ciscosm.cpp b/modules/server/ciscosm.cpp index f3473ea0..ba8d2880 100644 --- a/modules/server/ciscosm.cpp +++ b/modules/server/ciscosm.cpp @@ -434,6 +434,7 @@ protected: u_int16_t m_bearerId; // Bearer ID NOTE it is set to 0 SignallingTimer m_confReqTimer; // The configuration request timer bool m_printMsg; // Flag used to see if we print this layer messages + bool m_autostart; // Automatically align on resume static const TokenDict s_messages[]; static const TokenDict s_connectM[]; static const TokenDict s_errors[]; @@ -1572,7 +1573,7 @@ SLT::SLT(const String& name, const NamedList& param) SessionUser(1), m_status(Unconfigured), m_rStatus(OutOfService), m_reqStatus(OutOfService), m_messageId(1), m_channelId(0), m_bearerId(0), - m_confReqTimer(0), m_printMsg(false) + m_confReqTimer(0), m_printMsg(false), m_autostart(false) { #ifdef DEBUG String tmp; @@ -1593,7 +1594,8 @@ SLT::SLT(const String& name, const NamedList& param) m_confReqTimer.interval(param,"configuration",250,5000,true); m_printMsg = param.getBoolValue("printslt",false); m_autoEmergency = param.getBoolValue("autoemergency",true); - if (param.getBoolValue("autostart",true)) + m_autostart = param.getBoolValue("autostart",true); + if (m_autostart) m_reqStatus = NormalAlignment; } @@ -1664,6 +1666,7 @@ bool SLT::control(Operation oper, NamedList* params) { if (params) { m_autoEmergency = params->getBoolValue("autoemergency",m_autoEmergency); + m_autostart = params->getBoolValue("autostart",m_autostart); m_printMsg = params->getBoolValue("printslt",m_printMsg); } switch (oper) { @@ -1672,8 +1675,9 @@ bool SLT::control(Operation oper, NamedList* params) sendManagement(Disconnect_R); return true; case Resume: - if (aligned()) + if (aligned() || !m_autostart) return true; + // fall through case Align: { bool emg = getEmergency(params); @@ -1849,12 +1853,10 @@ void SLT::processSltMessage(u_int16_t msgType, DataBlock& data) } break; case Disconnect_C: - setRemoteStatus(OutOfService); - if (m_reqStatus == EmergencyAlignment || m_reqStatus == NormalAlignment) - sendConnect(m_reqStatus == NormalAlignment ? Normal : Emergency); - break; case Disconnect_I: setRemoteStatus(OutOfService); + if (!m_autostart) + break; if (m_reqStatus == EmergencyAlignment || m_reqStatus == NormalAlignment) sendConnect(m_reqStatus == NormalAlignment ? Normal : Emergency); break; @@ -1866,7 +1868,7 @@ void SLT::processSltMessage(u_int16_t msgType, DataBlock& data) case Link_State_Controller_I: processCIndication(data); break; - default: + default: const char* mes = messageType((Messages)msgType); if (mes) DDebug(this,DebugWarn,"Received unhandled SLT message: %s",mes); @@ -2037,6 +2039,8 @@ void SLT::configure(bool start) setStatus(Configured); SS7Layer2::notify(); DDebug(this,DebugInfo,"requested status = %s",statusName(m_reqStatus,false)); + if (!m_autostart) + return; if (m_reqStatus == NormalAlignment || m_reqStatus == EmergencyAlignment) sendConnect(m_reqStatus == NormalAlignment ? Normal : Emergency); }