Skip to content

Commit

Permalink
when going into maintenance mode, unregister all endpoints that are n…
Browse files Browse the repository at this point in the history
…ot in calls and tell them alternate, otherwise cisco endpoints won't switch gatekeeper
  • Loading branch information
willamowius committed Dec 15, 2017
1 parent 3327d2d commit 0af14c3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
42 changes: 35 additions & 7 deletions RasTbl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ bool EndpointRec::SendURQ(H225_UnregRequestReason::Choices reason, int preemptio
&& !UsesH46017())
return false; // no valid RAS address

RasServer *RasSrv = RasServer::Instance();
RasServer * RasSrv = RasServer::Instance();
H225_RasMessage ras_msg;
ras_msg.SetTag(H225_RasMessage::e_unregistrationRequest);
H225_UnregistrationRequest & urq = ras_msg;
Expand All @@ -1031,6 +1031,13 @@ bool EndpointRec::SendURQ(H225_UnregRequestReason::Choices reason, int preemptio
urq.m_endpointIdentifier = GetEndpointIdentifier();
urq.m_callSignalAddress.SetSize(1);
urq.m_callSignalAddress[0] = GetCallSignalAddress();
if (Toolkit::Instance()->IsMaintenanceMode()) {
H225_ArrayOf_AlternateGK alternates = Toolkit::Instance()->GetMaintenanceAlternate();
if (alternates.GetSize() > 0) {
urq.IncludeOptionalField(H225_UnregistrationRequest::e_alternateGatekeeper);
urq.m_alternateGatekeeper = alternates;
}
}

SetUsesH460P(false);
#ifdef HAS_H46017
Expand Down Expand Up @@ -1822,12 +1829,14 @@ void RegistrationTable::RemoveByEndptr(const endptr & eptr)
{
RasServer::Instance()->LogAcctEvent(GkAcctLogger::AcctUnregister, eptr);
EndpointRec *ep = eptr.operator->(); // evil
if (RasServer::Instance()->IsPassThroughRegistrant())
RasServer::Instance()->RemoveAdditiveRegistration(ep->GetAliases());
ep->SetUsesH460P(false);
ep->RemoveNATSocket();
WriteLock lock(listLock);
InternalRemove(find(EndpointList.begin(), EndpointList.end(), ep));
if (ep) {
if (RasServer::Instance()->IsPassThroughRegistrant())
RasServer::Instance()->RemoveAdditiveRegistration(ep->GetAliases());
ep->SetUsesH460P(false);
ep->RemoveNATSocket();
WriteLock lock(listLock);
InternalRemove(find(EndpointList.begin(), EndpointList.end(), ep));
}
}

void RegistrationTable::InternalRemove(iterator Iter)
Expand Down Expand Up @@ -2439,6 +2448,25 @@ void RegistrationTable::OnNATSocketClosed(CallSignalSocket * s)
}
}

void RegistrationTable::UnregisterAllEndpointsNotInCall()
{
WriteLock lock(listLock);

iterator Iter = EndpointList.begin();
while (Iter != EndpointList.end()) {
EndpointRec *ep = *Iter;
callptr call = CallTable::Instance()->FindCallRec(endptr(ep));
if (!call) {
ep->Unregister();
RasServer::Instance()->LogAcctEvent(GkAcctLogger::AcctUnregister, endptr(ep));
RemovedList.push_back(ep);
Iter = EndpointList.erase(Iter);
--regSize;
}
else ++Iter;
}
}

#ifdef HAS_H46017
void RegistrationTable::UnregisterAllH46017Endpoints()
{
Expand Down
1 change: 1 addition & 0 deletions RasTbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ class RegistrationTable : public Singleton<RegistrationTable> {
#ifdef HAS_H46017
void UnregisterAllH46017Endpoints();
#endif
void UnregisterAllEndpointsNotInCall();

void PrintAllRegistrations(USocket *client, bool verbose=FALSE);
void PrintAllCached(USocket *client, bool verbose=FALSE);
Expand Down
3 changes: 3 additions & 0 deletions SoftPBX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ void SoftPBX::MaintenanceMode(bool on, const PString & alternate)
} else {
Toolkit::Instance()->SetMaintenanceAlternate("");
}
if (on) {
RegistrationTable::Instance()->UnregisterAllEndpointsNotInCall();
}
GkStatus::Instance()->SignalStatus(PString("MaintenanceMode ") + (on ? "ON" : "OFF") + " " + alternate + "\r\n");
}

Expand Down

0 comments on commit 0af14c3

Please sign in to comment.