Module: sems Branch: rco/offer_answer Commit: 8e7cef47730c07317cbf24374f093557c98046e1 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=8e7cef47730c07317cbf24374f093557c98046e1
Author: Raphael Coeffic <[email protected]> Committer: Raphael Coeffic <[email protected]> Date: Mon Jun 28 17:37:51 2010 +0200 support for delayed CANCEL Instead of sending the CANCEL request before the first reply is received from the UAS, we now wait for switching to another state as 'Trying' before sending anything. --- core/AmSipDialog.cpp | 45 ++++++++++++++++++++++++++++----------------- core/AmSipDialog.h | 6 ++++++ core/AmSipMsg.h | 1 + core/SipCtrlInterface.cpp | 2 ++ 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index 4685949..6ff9ff6 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -57,7 +57,8 @@ const char* AmSipDialog::getStatusStr() } AmSipDialog::AmSipDialog(AmSipDialogEventHandler* h) - : status(Disconnected),cseq(10),r_cseq_i(false),hdl(h),pending_invites(0), + : status(Disconnected),cseq(10),r_cseq_i(false),hdl(h), + pending_invites(0),cancel_pending(false), outbound_proxy(AmConfig::OutboundProxy), force_outbound_proxy(AmConfig::ForceOutboundProxy) { @@ -380,6 +381,14 @@ void AmSipDialog::onRxReply(const AmSipReply& reply) remote_tag = reply.to_tag; } } + else { // error reply + status = Disconnected; + } + + if(cancel_pending){ + cancel_pending = false; + bye(); + } break; case Early: @@ -396,16 +405,25 @@ void AmSipDialog::onRxReply(const AmSipReply& reply) route = reply.route; remote_uri = reply.contact; } + else { // error reply + status = Disconnected; + } break; case Cancelling: - if(reply.code >= 300){ - // CANCEL accepted - status = Disconnected; + if(reply.cseq_method == "INVITE"){ + if(reply.code >= 300){ + // CANCEL accepted + status = Disconnected; + } + else { + // CANCEL rejected + sendRequest("BYE"); + } } else { - // CANCEL rejected - sendRequest("BYE"); + // we don't care about + // the reply to the CANCEL itself... } break; @@ -415,23 +433,16 @@ void AmSipDialog::onRxReply(const AmSipReply& reply) } } - // TODO: remove the transaction only after the dedicated timer has hit - // this would help taking care of multiple 2xx replies. if(reply.code >= 200){ - // TODO: - // - place this somewhere else. - // (probably in AmSession...) if((reply.code < 300) && (t.method == "INVITE")) { - hdl->onInvite2xx(reply); } else { - uac_trans.erase(t_it); + uac_trans.erase(t_it); } } - if(hdl) - hdl->onSipReply(reply, old_dlg_status); + hdl->onSipReply(reply, old_dlg_status); } void AmSipDialog::uasTimeout(AmSipTimeoutEvent* to_ev) @@ -590,8 +601,8 @@ int AmSipDialog::bye(const string& hdrs) return sendRequest("BYE", "", "", hdrs); case Trying: - //TODO: wait for at least Proceeding - // or Early before CANCEL + cancel_pending=true; + return 0; case Proceeding: case Early: diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h index 1ea79b5..9f59261 100644 --- a/core/AmSipDialog.h +++ b/core/AmSipDialog.h @@ -193,8 +193,14 @@ private: TransMap uas_trans; TransMap uac_trans; + // Number of open UAS INVITE transactions unsigned int pending_invites; + // In case a CANCEL should have been sent + // while in 'Trying' state + bool cancel_pending; + + // Offer/answer OAState oa_state; AmSdp sdp_local; AmSdp sdp_remote; diff --git a/core/AmSipMsg.h b/core/AmSipMsg.h index d3e58d6..c90e1ef 100644 --- a/core/AmSipMsg.h +++ b/core/AmSipMsg.h @@ -19,6 +19,7 @@ class _AmSipMsgInDlg string callid; unsigned int cseq; + string cseq_method; string route; string contact; diff --git a/core/SipCtrlInterface.cpp b/core/SipCtrlInterface.cpp index 2caa550..f9cffdb 100644 --- a/core/SipCtrlInterface.cpp +++ b/core/SipCtrlInterface.cpp @@ -390,6 +390,7 @@ void SipCtrlInterface::handle_sip_request(const trans_ticket& tt, sip_msg* msg) req.from_tag = c2stlstr(((sip_from_to*)msg->from->p)->tag); req.to_tag = c2stlstr(((sip_from_to*)msg->to->p)->tag); req.cseq = get_cseq(msg)->num; + req.cseq_method = c2stlstr(get_cseq(msg)->method_str); req.body = c2stlstr(msg->body); req.tt = tt; @@ -439,6 +440,7 @@ void SipCtrlInterface::handle_sip_reply(sip_msg* msg) reply.body = msg->body.len ? c2stlstr(msg->body) : ""; reply.cseq = get_cseq(msg)->num; + reply.cseq_method = c2stlstr(get_cseq(msg)->method_str); reply.code = msg->u.reply->code; reply.reason = c2stlstr(msg->u.reply->reason); _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
