[Opalvoip-svn] SF.net SVN: opalvoip:[34677] opal/branches/v3_16
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-03-12 16:30:55
|
Revision: 34677 http://sourceforge.net/p/opalvoip/code/34677 Author: rjongbloed Date: 2016-03-12 16:30:53 +0000 (Sat, 12 Mar 2016) Log Message: ----------- Changed SIP authentication so that if INVITE to domain which was not registered, but we are asked for authentication, we use the credentials of the first registration current. While not guaranteed to work, it will under some odd circumstances (e.g. redirect which uses different address for same registrar/proxy) and will not cause any damage if it subsequently doesn't work. Modified Paths: -------------- opal/branches/v3_16/include/sip/handlers.h opal/branches/v3_16/src/sip/handlers.cxx opal/branches/v3_16/src/sip/sipep.cxx Modified: opal/branches/v3_16/include/sip/handlers.h =================================================================== --- opal/branches/v3_16/include/sip/handlers.h 2016-03-11 10:57:02 UTC (rev 34676) +++ opal/branches/v3_16/include/sip/handlers.h 2016-03-12 16:30:53 UTC (rev 34677) @@ -360,12 +360,6 @@ bool DeleteObjectsToBeRemoved() { return m_handlersList.DeleteObjectsToBeRemoved(); } - /** Get the first handler in the list. Further enumeration may be done by - the ++operator on the safe pointer. - */ - PSafePtr<SIPHandler> GetFirstHandler(PSafetyMode mode = PSafeReference) const - { return PSafePtr<SIPHandler>(m_handlersList, mode); } - /** * Return the number of registered accounts */ @@ -376,6 +370,17 @@ */ PStringList GetAddresses(bool includeOffline, SIP_PDU::Methods meth, const PString & eventPackage = PString::Empty()) const; + /** Get the first handler in the list. Further enumeration may be done by + the ++operator on the safe pointer. + */ + PSafePtr<SIPHandler> GetFirstHandler(PSafetyMode mode = PSafeReference) const + { return PSafePtr<SIPHandler>(m_handlersList, mode); } + + /** Get the first handler in the list for the specified method. Further enumeration may be done by + the ++operator on the safe pointer. + */ + PSafePtr<SIPHandler> FindFirstHandler(SIP_PDU::Methods meth, PSafetyMode mode = PSafeReference) const; + /** * Find the SIPHandler object with the specified callID */ Modified: opal/branches/v3_16/src/sip/handlers.cxx =================================================================== --- opal/branches/v3_16/src/sip/handlers.cxx 2016-03-11 10:57:02 UTC (rev 34676) +++ opal/branches/v3_16/src/sip/handlers.cxx 2016-03-12 16:30:53 UTC (rev 34677) @@ -2506,6 +2506,16 @@ } +PSafePtr<SIPHandler> SIPHandlersList::FindFirstHandler(SIP_PDU::Methods meth, PSafetyMode mode) const +{ + PSafePtr<SIPHandler> handler(m_handlersList, PSafeReference); + while (handler != NULL && handler->GetMethod() != meth) + ++handler; + handler.SetSafetyMode(mode); + return handler; +} + + PSafePtr<SIPHandler> SIPHandlersList::FindSIPHandlerByCallID(const PString & callID, PSafetyMode mode) { return PSafePtrCast<SIPHandlerBase, SIPHandler>(m_handlersList.FindWithLock(callID, mode)); Modified: opal/branches/v3_16/src/sip/sipep.cxx =================================================================== --- opal/branches/v3_16/src/sip/sipep.cxx 2016-03-11 10:57:02 UTC (rev 34676) +++ opal/branches/v3_16/src/sip/sipep.cxx 2016-03-12 16:30:53 UTC (rev 34677) @@ -2063,8 +2063,11 @@ if (m_registeredUserMode) return false; - if ((handler = activeSIPHandlers.FindSIPHandlerByAuthRealm(realm, PSafeReadOnly)) == NULL) - return false; + if ((handler = activeSIPHandlers.FindSIPHandlerByAuthRealm(realm, PSafeReadOnly)) == NULL) { + if ((handler = activeSIPHandlers.FindFirstHandler(SIP_PDU::Method_REGISTER, PSafeReadOnly)) == NULL) + return false; + PTRACE(4, "Using first registrar " << handler->GetAddressOfRecord() << " for authentication"); + } } // really just after password, but username MAY change too. @@ -2153,9 +2156,7 @@ } else if (domain.IsEmpty() || OpalIsE164(domain)) { // No context, just get first registration - handler = activeSIPHandlers.GetFirstHandler(); - while (handler != NULL && handler->GetMethod() != SIP_PDU::Method_REGISTER) - ++handler; + handler = activeSIPHandlers.FindFirstHandler(SIP_PDU::Method_REGISTER); if (handler != NULL) { PTRACE(4, "Using first registrar " << handler->GetAddressOfRecord() << " for tel URI"); if (connection != NULL) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |