[Opalvoip-svn] SF.net SVN: opalvoip:[23176] opal/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2009-07-29 07:36:41
|
Revision: 23176 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=23176&view=rev Author: rjongbloed Date: 2009-07-29 07:36:35 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Modified Paths: -------------- opal/trunk/include/sip/sippdu.h opal/trunk/src/sip/sipcon.cxx opal/trunk/src/sip/sippdu.cxx Property Changed: ---------------- opal/trunk/ Property changes on: opal/trunk ___________________________________________________________________ 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,22941 /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,23044,23140,23143 /opal/branches/v3_6:22169,22178,22184,22186,22197,22204,22216,22251,22253,22255,22258,22260,22291,22296,22300,22306,22308,22313,22319,22336,22353,22358,22436,22447,22449,22497,22511,22517,22519-22521,22527,22536,22538,22589,22596,22599,22617,22620,22622,22630,22640,22655,22675,22682,22726-22728,22730,22733,22738,22745-22746,22800,22820-22821,22842,22844-22845,22851,22853,22889,22896,22902,22904,22906,22924,22928,22946,22965,22967,22976,22978,22980,22982,22994,23028,23123,23125-23126,23128,23157,23165,23173 /opal/trunk:22308 /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,22941 /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,23044,23140,23143 /opal/branches/v3_6:22169,22178,22184,22186,22197,22204,22216,22251,22253,22255,22258,22260,22291,22296,22300,22306,22308,22313,22319,22336,22353,22358,22436,22447,22449,22497,22511,22517,22519-22521,22527,22536,22538,22589,22596,22599,22617,22620,22622,22630,22640,22655,22675,22682,22726-22728,22730,22733,22738,22745-22746,22800,22820-22821,22842,22844-22845,22851,22853,22889,22896,22902,22904,22906,22924,22928,22946,22965,22967,22976,22978,22980,22982,22994,23028,23123,23125-23126,23128,23157,23165,23173,23175 /opal/trunk:22308 /ptlib/trunk:20820 Modified: opal/trunk/include/sip/sippdu.h =================================================================== --- opal/trunk/include/sip/sippdu.h 2009-07-29 07:33:06 UTC (rev 23175) +++ opal/trunk/include/sip/sippdu.h 2009-07-29 07:36:35 UTC (rev 23176) @@ -343,7 +343,7 @@ PString GetEvent() const; void SetEvent(const PString & v); - PString GetSubscriptionState() const; + PCaselessString GetSubscriptionState() const; void SetSubscriptionState(const PString & v); PString GetUserAgent() const; Modified: opal/trunk/src/sip/sipcon.cxx =================================================================== --- opal/trunk/src/sip/sipcon.cxx 2009-07-29 07:33:06 UTC (rev 23175) +++ opal/trunk/src/sip/sipcon.cxx 2009-07-29 07:36:35 UTC (rev 23176) @@ -1950,40 +1950,54 @@ void SIPConnection::OnReceivedNOTIFY(SIP_PDU & request) { - PCaselessString event, state; - - if (referTransaction == NULL){ + const SIPMIMEInfo & mime = request.GetMIME(); + + SIPSubscribe::EventPackage package = mime.GetEvent(); + if (package != "refer") { PTRACE(2, "SIP\tNOTIFY in a connection only supported for REFER requests"); + request.SendResponse(*transport, SIP_PDU::Failure_BadEvent); return; } - - event = request.GetMIME().GetEvent(); - - // We could also compare the To and From tags - if (request.GetMIME().GetCallID() != referTransaction->GetMIME().GetCallID() - || event.Find("refer") == P_MAX_INDEX) { - request.SendResponse(*transport, SIP_PDU::Failure_BadEvent); + if (referTransaction == NULL) { + PTRACE(2, "SIP\tNOTIFY for REFER we never sent."); + request.SendResponse(*transport, SIP_PDU::Failure_TransactionDoesNotExist); return; } - state = request.GetMIME().GetSubscriptionState(); - + if (mime.GetContentType() != "message/sipfrag") { + PTRACE(2, "SIP\tNOTIFY for REFER has incorrect Content-Type"); + request.SendResponse(*transport, SIP_PDU::Failure_BadRequest); + return; + } + + PCaselessString body = request.GetEntityBody(); + unsigned code = body.Mid(body.Find(' ')).AsUnsigned(); + if (body.NumCompare("SIP/") != EqualTo || code < 100) { + PTRACE(2, "SIP\tNOTIFY for REFER has incorrect body"); + request.SendResponse(*transport, SIP_PDU::Failure_BadRequest); + return; + } + request.SendResponse(*transport, SIP_PDU::Successful_OK); - - // The REFER is over - if (state.Find("terminated") != P_MAX_INDEX) { - referTransaction->WaitForCompletion(); - referTransaction.SetNULL(); - // Release the connection - if (GetPhase() < ReleasingPhase) { - releaseMethod = ReleaseWithBYE; - Release(OpalConnection::EndedByCallForwarded); - } + if (mime.GetSubscriptionState().Find("terminated") == P_MAX_INDEX) + return; // The REFER is not over yet, ignore + + referTransaction->WaitForCompletion(); + referTransaction.SetNULL(); + + // The REFER is over, see if successful + if (code >= 300) { + PTRACE(2, "SIP\tNOTIFY indicated REFER did not proceed, taking call back"); + return; } - // The REFER is not over yet, ignore the state of the REFER for now + // Release the connection + if (GetPhase() < ReleasingPhase) { + releaseMethod = ReleaseWithBYE; + Release(OpalConnection::EndedByCallForwarded); + } } @@ -2025,7 +2039,7 @@ // send NOTIFY if transfer succeeded, but only if allowed by RFC4488 // Strictly speaking, we shouldn't send this until the the 200 OK, but..... if (!(request.GetMIME()("Refer-Sub") *= "false")) { - SIPReferNotify * notify = new SIPReferNotify(*this, *transport, SIP_PDU::Successful_Accepted); + SIPReferNotify * notify = new SIPReferNotify(*this, *transport, SIP_PDU::Successful_OK); notify->Start(); } } Modified: opal/trunk/src/sip/sippdu.cxx =================================================================== --- opal/trunk/src/sip/sippdu.cxx 2009-07-29 07:33:06 UTC (rev 23175) +++ opal/trunk/src/sip/sippdu.cxx 2009-07-29 07:36:35 UTC (rev 23176) @@ -1005,7 +1005,7 @@ } -PString SIPMIMEInfo::GetSubscriptionState() const +PCaselessString SIPMIMEInfo::GetSubscriptionState() const { return GetString("Subscription-State"); // no compact form } @@ -3289,14 +3289,12 @@ SIPReferNotify::SIPReferNotify(SIPConnection & connection, OpalTransport & transport, StatusCodes code) : SIPTransaction(connection, transport, Method_NOTIFY) { - PStringStream str; - mime.SetProductInfo(connection.GetEndPoint().GetUserAgent(), connection.GetProductInfo()); - mime.SetSubscriptionState("terminated;reason=noresource"); // Do not keep an internal state + mime.SetSubscriptionState(code < Successful_OK ? "active" : "terminated;reason=noresource"); mime.SetEvent("refer"); - mime.SetContentType("message/sipfrag;version=2.0"); + mime.SetContentType("message/sipfrag"); - + PStringStream str; str << "SIP/" << versionMajor << '.' << versionMinor << " " << code << " " << GetStatusCodeDescription(code); entityBody = str; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |