[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Apr 13 09:57:59 CDT 2011


branch "master" has been updated
       via  95c838e77ca99e63a13721981e2aa07867c4bea1 (commit)
      from  d7418a0d23a8a23431e859442c782501abfc0553 (commit)

Summary of changes:
 src/PJSipSessionModule.cpp             |   28 ++++++++++++++++++++++++----
 src/PJSipSessionModule.h               |    1 +
 src/PJSipSessionModuleConstruction.cpp |    2 +-
 3 files changed, 26 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit 95c838e77ca99e63a13721981e2aa07867c4bea1
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Apr 13 12:00:45 2011 -0300

    Verify we can handle incoming INVITEs and if we can not then respond accordingly.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index c770f45..165f35b 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -441,16 +441,36 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
 
     //XXX Put caller identification code in here!
 
-    //XXX According to pjsip docs, we should call
-    //pjsip_inv_verify_request to be sure we can
-    //handle the request. For now, just plunge forward.
+    pjsip_tx_data *tdata = NULL;
+    unsigned options = PJSIP_INV_SUPPORT_100REL;
+
+    // Verify we can handle this invite request and respond accordingly if we can not
+    if (pjsip_inv_verify_request(rdata, &options, NULL, NULL, mEndpoint, &tdata) != PJ_SUCCESS)
+    {
+	if (tdata)
+	{
+	    pjsip_endpt_send_response2(mEndpoint, rdata, tdata, NULL, NULL);
+	}
+	else
+	{
+	    pjsip_endpt_respond_stateless(mEndpoint, rdata, 500, NULL, NULL, NULL);
+	}
+	return;
+    }
 
     pjsip_dialog *dlg, *replaced_dlg;
-    pjsip_tx_data *tdata;
 
     // If this is an attended transfer and something is amuck... respond accordingly
     if (pjsip_replaces_verify_request(rdata, &replaced_dlg, PJ_FALSE, &tdata) != PJ_SUCCESS)
     {
+	if (tdata)
+	{
+	    pjsip_endpt_send_response2(mEndpoint, rdata, tdata, NULL, NULL);
+	}
+	else
+	{
+	    pjsip_endpt_respond_stateless(mEndpoint, rdata, 500, NULL, NULL, NULL);
+	}
         return;
     }
 
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index a1fdde3..e22c31d 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -95,6 +95,7 @@ private:
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
     AsteriskSCF::SmartProxy::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> mStateReplicator;
     AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
+    pjsip_endpoint *mEndpoint;
 };
 
 }; //end namespace SipSessionManager
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index c1da3a7..9f7d71e 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -99,7 +99,7 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     const AsteriskSCF::System::Component::V1::ReplicaPtr& replica)
     : mName(moduleName), mEndpointFactory(endpointFactoryPtr),
       mSessionRouter(sessionRouter), mServiceLocator(serviceLocator),
-      mStateReplicator(stateReplicator), mReplica(replica)
+      mStateReplicator(stateReplicator), mReplica(replica), mEndpoint(endpt)
 {
     sessionModule = this;
     mModule.name = pj_str(moduleName);

-----------------------------------------------------------------------


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list