Module: sems
Branch: master
Commit: cc5676b8409b7322f1af272764a3cc4f0ccbdad9
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=cc5676b8409b7322f1af272764a3cc4f0ccbdad9

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Tue Feb  7 18:37:55 2012 +0100

sbc: b/f: don't use offer/answer on transparent B2BUA

---

 apps/sbc/SBC.cpp     |    4 +++
 core/AmSipDialog.cpp |   60 ++++++++++++++++++++++++++++++++++++++-----------
 core/AmSipDialog.h   |    2 +
 3 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/apps/sbc/SBC.cpp b/apps/sbc/SBC.cpp
index 5efe5a0..c154d72 100644
--- a/apps/sbc/SBC.cpp
+++ b/apps/sbc/SBC.cpp
@@ -903,6 +903,8 @@ void SBCDialog::onInvite(const AmSipRequest& req)
     }
   }
 
+  dlg.setOAEnabled(false);
+
 #undef REPLACE_VALS
 
   DBG("SBC: connecting to '%s'\n",ruri.c_str());
@@ -1530,6 +1532,8 @@ void SBCDialog::createCalleeSession()
   if(outbound_interface >= 0)
     callee_dlg.outbound_interface = outbound_interface;
 
+  callee_dlg.setOAEnabled(false);
+
   if(rtprelay_interface >= 0)
     callee_session->setRtpRelayInterface(rtprelay_interface);
 
diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp
index 1f47e53..2ef5b2c 100644
--- a/core/AmSipDialog.cpp
+++ b/core/AmSipDialog.cpp
@@ -61,6 +61,7 @@ const char* AmSipDialog::getStatusStr()
 
 AmSipDialog::AmSipDialog(AmSipDialogEventHandler* h)
   : status(Disconnected),oa(this),rel100(this,h),
+    offeranswer_enabled(true),
     early_session_started(false),session_started(false),
     cseq(10),r_cseq_i(false),hdl(h),
     pending_invites(0),cancel_pending(false),
@@ -124,16 +125,20 @@ void AmSipDialog::onRxRequest(const AmSipRequest& req)
     }
 
     if (req.method == SIP_METH_INVITE) {
-      if( pending_invites ||
+      bool pending = pending_invites;
+      if (offeranswer_enabled) {
          // not sure this is needed here: could be in AmOfferAnswer as well
-         ((oa.getState() != AmOfferAnswer::OA_None) && 
-          (oa.getState() != AmOfferAnswer::OA_Completed))) {
+       pending |= ((oa.getState() != AmOfferAnswer::OA_None) &&
+                   (oa.getState() != AmOfferAnswer::OA_Completed));
+      }
 
+      if (pending) {
        reply_error(req, 491, SIP_REPLY_PENDING,
                    SIP_HDR_COLSP(SIP_HDR_RETRY_AFTER) 
                    + int2str(get_random() % 10) + CRLF);
        return;
       }
+
       pending_invites++;
     }
     
@@ -189,8 +194,10 @@ void AmSipDialog::onRxRequest(const AmSipRequest& req)
 
   default: break;
   }
-  
-  oa.onRequestIn(req);
+
+  if (offeranswer_enabled) {
+    oa.onRequestIn(req);
+  }
 
   if(rel100.onRequestIn(req) && hdl)
     hdl->onSipRequest(req);
@@ -243,6 +250,12 @@ void AmSipDialog::setRel100State(Am100rel::State 
rel100_state) {
   rel100.setState(rel100_state);
 }
 
+void AmSipDialog::setOAEnabled(bool oa_enabled) {
+  DBG("%sabling offer_answer on SIP dialog '%s'\n",
+      oa_enabled?"en":"dis", local_tag.c_str());
+  offeranswer_enabled = oa_enabled;
+}
+
 /**
  * Update dialog status from UAC Request that we send (e.g. INVITE)
  * (called only from AmSessionContainer)
@@ -442,7 +455,9 @@ void AmSipDialog::onRxReply(const AmSipReply& reply)
     }
   }
 
-  oa.onReplyIn(reply);
+  if (offeranswer_enabled) {
+    oa.onReplyIn(reply);
+  }
 
   if(rel100.onReplyIn(reply) && hdl)
     hdl->onSipReply(reply, saved_status);
@@ -475,7 +490,9 @@ void AmSipDialog::uasTimeout(AmSipTimeoutEvent* to_ev)
   switch(to_ev->type){
   case AmSipTimeoutEvent::noACK:
     DBG("Timeout: missing ACK\n");
-    oa.onNoAck(to_ev->cseq);
+    if (offeranswer_enabled) {
+      oa.onNoAck(to_ev->cseq);
+    }
     if(hdl) hdl->onNoAck(to_ev->cseq);
     break;
 
@@ -724,7 +741,10 @@ int AmSipDialog::reply(const AmSipTransaction& t,
     reply.contact = getContactHdr();
   }
 
-  oa.onReplyOut(reply);
+  if (offeranswer_enabled) {
+    oa.onReplyOut(reply);
+  }
+
   rel100.onReplyOut(reply);
   hdl->onSendReply(reply,flags);
 
@@ -752,7 +772,11 @@ int AmSipDialog::reply(const AmSipTransaction& t,
     uas_trans.erase(reply.cseq);
   }
 
-  return oa.onReplySent(reply);
+  if (offeranswer_enabled) {
+    return oa.onReplySent(reply);
+  }
+
+  return ret;
 }
 
 
@@ -1065,7 +1089,7 @@ int AmSipDialog::sendRequest(const string& method,
   req.body = body;
   DBG("req.body = '%s'\n", req.body.c_str());
 
-  if(oa.onRequestOut(req))
+  if (offeranswer_enabled && oa.onRequestOut(req))
     return -1;
 
   rel100.onRequestOut(req);
@@ -1088,7 +1112,11 @@ int AmSipDialog::sendRequest(const string& method,
     uac_trans.erase(req_cseq);
   }
 
-  return oa.onRequestSent(req);
+  if (offeranswer_enabled) {
+    return oa.onRequestSent(req);
+  }
+
+  return 0;
 }
 
 int AmSipDialog::drop()
@@ -1144,8 +1172,8 @@ int AmSipDialog::send_200_ack(unsigned int inv_cseq,
 
   req.content_type = content_type;
   req.body = body;
-  
-  if(oa.onRequestOut(req))
+
+  if (offeranswer_enabled && oa.onRequestOut(req))
     return -1;
 
   if(hdl)
@@ -1156,7 +1184,11 @@ int AmSipDialog::send_200_ack(unsigned int inv_cseq,
     return -1;
 
   uac_trans.erase(inv_cseq);
-  return oa.onRequestSent(req);
+  if (offeranswer_enabled) {
+    return oa.onRequestSent(req);
+  }
+
+  return 0;
 }
 
 
diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h
index 42f8fd6..e78d0ff 100644
--- a/core/AmSipDialog.h
+++ b/core/AmSipDialog.h
@@ -124,6 +124,7 @@ private:
 
   // Current offer/answer transaction
   AmOfferAnswer oa;
+  bool offeranswer_enabled;
 
   // Reliable provisional reply support
   Am100rel rel100;
@@ -215,6 +216,7 @@ private:
 
   AmOfferAnswer::OAState getOAState();
   void setOAState(AmOfferAnswer::OAState n_st);
+  void setOAEnabled(bool oa_enabled);
 
   void setRel100State(Am100rel::State rel100_state);
 

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to