[Opalvoip-svn] SF.net SVN: opalvoip:[23309] opal/branches/csoutheren/LalandeBranch1
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2009-08-31 06:53:14
|
Revision: 23309 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=23309&view=rev Author: rjongbloed Date: 2009-08-31 06:53:02 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Fixed problem with REGISTER IntervalTooBrief response handling not using correct interface for new transaction. Make sure the multiple interface forked transactions for all REGISTER/SUBSCRIBE/etc is collapsed when any response is received. Cleaned up the handling of non-connection related SIP responses, don't break them out in the endpoint, do so in the handler where it is more useful. (Backport from Sirius) Modified Paths: -------------- opal/branches/csoutheren/LalandeBranch1/include/sip/handlers.h opal/branches/csoutheren/LalandeBranch1/include/sip/sipep.h opal/branches/csoutheren/LalandeBranch1/src/sip/handlers.cxx opal/branches/csoutheren/LalandeBranch1/src/sip/sipep.cxx Property Changed: ---------------- opal/branches/csoutheren/LalandeBranch1/ Property changes on: opal/branches/csoutheren/LalandeBranch1 ___________________________________________________________________ Modified: svn:mergeinfo - /opal/branches/autoconf:20594-21001 /opal/branches/rjongbloed/BarnardPlus:20584,20656,20749,20751,20756,20762,20786,20789,20814,20820,20829,20831,20841,20843,20923,20927,20938,22016-22017,22518,22582 /opal/branches/v3_2:21143,21220,21227,21253,21455 /opal/branches/v3_4:21060,21062,21088,21092,21111,21113,21115,21119,21143,21148,21151-21152,21155,21158,21184,21188,21253,21265-21266,21283-21284,21298,21300,21303,21307,21309,21311,21327,21331,21333,21359,21367,21369,21488,21556,21564-21565,21568,21570,21620,21625,21631,21748,21751,21756,21759,21761,21767,21770,22246 /opal/branches/v3_6:23294 /opal/trunk:12524-20593,22117-22118,22128,22138,22140,22142,22146,22152,22157-22158,22161,22218-22219,22222-22223,22227,22262,22264,22278,22329,22341,22349,22360,22362-22363,22365,22385,22397,22399,22415,22420,22422,22425,22427,22466-22467,22469,22471,22492,22541-22543,22546,22554,22615,22618,22667,22795,23132,23135,23253,23275,23281 /ptlib/branches/v2_4:22246 /ptlib/trunk:20820 + /opal/branches/autoconf:20594-21001 /opal/branches/rjongbloed/BarnardPlus:20584,20656,20749,20751,20756,20762,20786,20789,20814,20820,20829,20831,20841,20843,20923,20927,20938,22016-22017,22518,22582 /opal/branches/v3_2:21143,21220,21227,21253,21455 /opal/branches/v3_4:21060,21062,21088,21092,21111,21113,21115,21119,21143,21148,21151-21152,21155,21158,21184,21188,21253,21265-21266,21283-21284,21298,21300,21303,21307,21309,21311,21327,21331,21333,21359,21367,21369,21488,21556,21564-21565,21568,21570,21620,21625,21631,21748,21751,21756,21759,21761,21767,21770,22246 /opal/branches/v3_6:23284,23294 /opal/trunk:22117-22118,22128,22138,22140,22142,22146,22152,22157-22158,22161,22218-22219,22222-22223,22227,22262,22264,22278,22329,22341,22349,22360,22362-22363,22365,22385,22397,22399,22415,22420,22422,22425,22427,22466-22467,22469,22471,22492,22541-22543,22546,22554,22615,22618,22667,22795,23132,23135,23246,23253,23275,23281 /ptlib/branches/v2_4:22246 /ptlib/trunk:20820 Modified: opal/branches/csoutheren/LalandeBranch1/include/sip/handlers.h =================================================================== --- opal/branches/csoutheren/LalandeBranch1/include/sip/handlers.h 2009-08-31 06:42:06 UTC (rev 23308) +++ opal/branches/csoutheren/LalandeBranch1/include/sip/handlers.h 2009-08-31 06:53:02 UTC (rev 23309) @@ -116,6 +116,8 @@ virtual SIPSubscribe::EventPackage GetEventPackage() const { return PString::Empty(); } + virtual void OnReceivedResponse(SIPTransaction & transaction, SIP_PDU & response); + virtual void OnReceivedIntervalTooBrief(SIPTransaction & transaction, SIP_PDU & response); virtual void OnReceivedAuthenticationRequired(SIPTransaction & transaction, SIP_PDU & response); virtual void OnReceivedOK(SIPTransaction & transaction, SIP_PDU & response); virtual void OnTransactionFailed(SIPTransaction & transaction); @@ -136,7 +138,6 @@ const SIPURL & GetRemoteAddress() const { return m_remoteAddress; } protected: - void CollapseFork(SIPTransaction & transaction); PDECLARE_NOTIFIER(PTimer, SIPHandler, OnExpireTimeout); static PBoolean WriteSIPHandler(OpalTransport & transport, void * info); bool WriteSIPHandler(OpalTransport & transport); Modified: opal/branches/csoutheren/LalandeBranch1/include/sip/sipep.h =================================================================== --- opal/branches/csoutheren/LalandeBranch1/include/sip/sipep.h 2009-08-31 06:42:06 UTC (rev 23308) +++ opal/branches/csoutheren/LalandeBranch1/include/sip/sipep.h 2009-08-31 06:53:02 UTC (rev 23309) @@ -283,28 +283,6 @@ SIP_PDU * pdu ); - /**Handle an incoming IntervalTooBrief response PDU - */ - virtual void OnReceivedIntervalTooBrief( - SIPTransaction & transaction, - SIP_PDU & response) - ; - - /**Handle an incoming Proxy Authentication Required response PDU - */ - virtual void OnReceivedAuthenticationRequired( - SIPTransaction & transaction, - SIP_PDU & response - ); - - /**Handle an incoming OK response PDU. - This actually gets any PDU of the class 2xx not just 200. - */ - virtual void OnReceivedOK( - SIPTransaction & transaction, - SIP_PDU & response - ); - /**Handle an incoming NOTIFY PDU. */ virtual PBoolean OnReceivedNOTIFY( @@ -940,6 +918,10 @@ #endif bool m_disableTrying; + + P_REMOVE_VIRTUAL_VOID(OnReceivedIntervalTooBrief(SIPTransaction &, SIP_PDU &)); + P_REMOVE_VIRTUAL_VOID(OnReceivedAuthenticationRequired(SIPTransaction &, SIP_PDU &)); + P_REMOVE_VIRTUAL_VOID(OnReceivedOK(SIPTransaction &, SIP_PDU &)); }; Modified: opal/branches/csoutheren/LalandeBranch1/src/sip/handlers.cxx =================================================================== --- opal/branches/csoutheren/LalandeBranch1/src/sip/handlers.cxx 2009-08-31 06:42:06 UTC (rev 23308) +++ opal/branches/csoutheren/LalandeBranch1/src/sip/handlers.cxx 2009-08-31 06:53:02 UTC (rev 23309) @@ -330,8 +330,66 @@ } -void SIPHandler::OnReceivedAuthenticationRequired(SIPTransaction & transaction, SIP_PDU & response) +void SIPHandler::OnReceivedResponse(SIPTransaction & transaction, SIP_PDU & response) { + // Received a response, so collapse the foking on multiple interfaces. + + transactions.Remove(&transaction); // Take this transaction out of list + + // And kill all the rest + PSafePtr<SIPTransaction> transToGo; + while ((transToGo = transactions.GetAt(0)) != NULL) { + transactions.Remove(transToGo); + transToGo->Abort(); + } + + // Finally end connect mode on the transport + m_transport->SetInterface(transaction.GetInterface()); + + switch (response.GetStatusCode()) { + case SIP_PDU::Failure_UnAuthorised : + case SIP_PDU::Failure_ProxyAuthenticationRequired : + OnReceivedAuthenticationRequired(transaction, response); + break; + + case SIP_PDU::Failure_IntervalTooBrief : + OnReceivedIntervalTooBrief(transaction, response); + break; + + case SIP_PDU::Failure_RequestTimeout : + OnTransactionFailed(transaction); + break; + + default : + switch (response.GetStatusCode()/100) { + case 1 : + // Do nothing on 1xx + break; + + case 2 : + OnReceivedOK(transaction, response); + break; + + default : + OnFailed(response); + } + } +} + + +void SIPHandler::OnReceivedIntervalTooBrief(SIPTransaction & transaction, SIP_PDU & response) +{ + SetExpire(response.GetMIME().GetMinExpires()); + + // Restart the transaction with new authentication handler + State oldState = state; + state = Unavailable; + SendRequest(oldState); +} + + +void SIPHandler::OnReceivedAuthenticationRequired(SIPTransaction & /*transaction*/, SIP_PDU & response) +{ bool isProxy = response.GetStatusCode() == SIP_PDU::Failure_ProxyAuthenticationRequired; #if PTRACING @@ -395,9 +453,6 @@ m_username = username; m_password = password; - // And end connect mode on the transport - CollapseFork(transaction); - // Restart the transaction with new authentication handler SendRequest(GetState()); } @@ -427,28 +482,9 @@ // reset the number of unsuccesful authentication attempts authenticationAttempts = 0; - - CollapseFork(transaction); } -void SIPHandler::CollapseFork(SIPTransaction & transaction) -{ - // Take this transaction out - transactions.Remove(&transaction); - - // And kill all the rest - PSafePtr<SIPTransaction> transToGo; - while ((transToGo = transactions.GetAt(0)) != NULL) { - transactions.Remove(transToGo); - transToGo->Abort(); - } - - // Finally end connect mode on the transport - m_transport->SetInterface(transaction.GetInterface()); -} - - void SIPHandler::OnTransactionFailed(SIPTransaction & transaction) { if (transactions.Remove(&transaction)) { Modified: opal/branches/csoutheren/LalandeBranch1/src/sip/sipep.cxx =================================================================== --- opal/branches/csoutheren/LalandeBranch1/src/sip/sipep.cxx 2009-08-31 06:42:06 UTC (rev 23308) +++ opal/branches/csoutheren/LalandeBranch1/src/sip/sipep.cxx 2009-08-31 06:53:02 UTC (rev 23309) @@ -700,50 +700,12 @@ void SIPEndPoint::OnReceivedResponse(SIPTransaction & transaction, SIP_PDU & response) { - PSafePtr<SIPHandler> handler = NULL; - - if (transaction.GetMethod() == SIP_PDU::Method_REGISTER - || transaction.GetMethod() == SIP_PDU::Method_SUBSCRIBE - || transaction.GetMethod() == SIP_PDU::Method_PUBLISH - || transaction.GetMethod() == SIP_PDU::Method_MESSAGE) { - // Have a response to various non-INVITE messages - handler = activeSIPHandlers.FindSIPHandlerByCallID(transaction.GetMIME().GetCallID(), PSafeReadWrite); - if (handler == NULL) - return; + PSafePtr<SIPHandler> handler = activeSIPHandlers.FindSIPHandlerByCallID(response.GetMIME().GetCallID(), PSafeReadWrite); + if (handler != NULL) + handler->OnReceivedResponse(transaction, response); + else { + PTRACE(2, "SIP\tResponse received for unknown handler ID: " << response.GetMIME().GetCallID()); } - - switch (response.GetStatusCode()) { - case SIP_PDU::Failure_IntervalTooBrief : - OnReceivedIntervalTooBrief(transaction, response); - break; - - case SIP_PDU::Failure_UnAuthorised : - case SIP_PDU::Failure_ProxyAuthenticationRequired : - OnReceivedAuthenticationRequired(transaction, response); - break; - - case SIP_PDU::Failure_RequestTimeout : - if (handler != NULL) - handler->OnTransactionFailed(transaction); - break; - - default : - switch (response.GetStatusCode()/100) { - case 1 : - // Do nothing on 1xx - break; - - case 2 : - OnReceivedOK(transaction, response); - break; - - default : - // Failure for a SUBSCRIBE/REGISTER/PUBLISH/MESSAGE - if (handler != NULL) - handler->OnFailed(response); - break; - } - } } @@ -875,48 +837,7 @@ return PTrue; } -void SIPEndPoint::OnReceivedIntervalTooBrief(SIPTransaction & transaction, SIP_PDU & response) -{ - const SIPMIMEInfo & responseMIME = response.GetMIME(); - PSafePtr<SIPHandler> handler = activeSIPHandlers.FindSIPHandlerByCallID(responseMIME.GetCallID(), PSafeReadOnly); - if (handler == NULL) - return; - SIPTransaction *newTransaction = handler->CreateTransaction(transaction.GetTransport()); - if (newTransaction) { - handler->SetExpire(responseMIME.GetMinExpires()); - newTransaction->GetMIME().SetExpires(responseMIME.GetMinExpires()); - newTransaction->GetMIME().SetCallID(handler->GetCallID()); - if (newTransaction->Start()) - return; - } - - PTRACE(1, "SIP\t Could not restart REGISTER after IntervalTooBrief error!"); - handler->OnFailed(SIP_PDU::Failure_IntervalTooBrief); - return; -} - -void SIPEndPoint::OnReceivedAuthenticationRequired(SIPTransaction & transaction, SIP_PDU & response) -{ - // Try to find authentication information for the given call ID - PSafePtr<SIPHandler> handler = activeSIPHandlers.FindSIPHandlerByCallID(response.GetMIME().GetCallID(), PSafeReadOnly); - if (handler == NULL) - return; - - handler->OnReceivedAuthenticationRequired(transaction, response); -} - - -void SIPEndPoint::OnReceivedOK(SIPTransaction & transaction, SIP_PDU & response) -{ - PSafePtr<SIPHandler> handler = activeSIPHandlers.FindSIPHandlerByCallID(response.GetMIME().GetCallID(), PSafeReadOnly); - if (handler == NULL) - return; - - handler->OnReceivedOK(transaction, response); -} - - void SIPEndPoint::OnTransactionFailed(SIPTransaction & transaction) { PSafePtr<SIPHandler> handler = activeSIPHandlers.FindSIPHandlerByCallID(transaction.GetMIME().GetCallID(), PSafeReadOnly); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |