Module: sems Branch: sayer/offer_answer Commit: b49107832e8e12bb3c0164f07c7ba19b25ae2943 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=b49107832e8e12bb3c0164f07c7ba19b25ae2943
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Tue Oct 19 21:40:07 2010 +0200 fix relaying requests in B2B --- core/AmB2BSession.cpp | 4 ++-- core/AmSipDialog.cpp | 49 ++++++++++++++++++++++++++++--------------------- core/AmSipDialog.h | 10 ++++++---- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/core/AmB2BSession.cpp b/core/AmB2BSession.cpp index f2dff24..513d02b 100644 --- a/core/AmB2BSession.cpp +++ b/core/AmB2BSession.cpp @@ -365,7 +365,7 @@ void AmB2BSession::relaySip(const AmSipRequest& req) { if (req.method != "ACK") { relayed_req[dlg.cseq] = AmSipTransaction(req.method,req.cseq,req.tt); - dlg.sendRequest(req.method,req.content_type, req.body, req.hdrs, SIP_FLAGS_VERBATIM); + dlg.sendRequest(req.method,req.content_type, req.body, req.hdrs, SIP_FLAGS_VERBATIM, false); // todo: relay error event back if sending fails if ((req.method == SIP_METH_INVITE || @@ -404,7 +404,7 @@ void AmB2BSession::relaySip(const AmSipRequest& orig, const AmSipReply& reply) { dlg.reply(orig,reply.code,reply.reason, reply.content_type, - reply.body,reply.hdrs,SIP_FLAGS_VERBATIM); + reply.body,reply.hdrs,SIP_FLAGS_VERBATIM,false); if ((orig.method == SIP_METH_INVITE || orig.method == SIP_METH_UPDATE) && diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index 93b5e6f..0f1d8c5 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -390,7 +390,7 @@ void AmSipDialog::initFromLocalRequest(const AmSipRequest& req) // UAC behavior for locally sent requests // (called from AmSipDialog::sendRequest()) -int AmSipDialog::onTxRequest(AmSipRequest& req) +int AmSipDialog::onTxRequest(AmSipRequest& req, bool do_offeranswer) { if((req.method == "INVITE") && (status == Disconnected)){ status = Trying; @@ -404,6 +404,9 @@ int AmSipDialog::onTxRequest(AmSipRequest& req) return -1; } + if (!do_offeranswer) + return 0; + if(req.content_type == "application/sdp") { if(onTxSdp(req.body)){ @@ -416,7 +419,7 @@ int AmSipDialog::onTxRequest(AmSipRequest& req) } // UAS behavior for locally sent replies -int AmSipDialog::onTxReply(AmSipReply& reply) +int AmSipDialog::onTxReply(AmSipReply& reply, bool do_offeranswer) { TransMap::iterator t_it = uas_trans.find(reply.cseq); if(t_it == uas_trans.end()){ @@ -468,29 +471,31 @@ int AmSipDialog::onTxReply(AmSipReply& reply) break; } - // update Offer/Answer state - // TODO: support multipart mime - if((reply.cseq_method == "INVITE") || (reply.cseq_method == "UPDATE")){ + if (do_offeranswer) { + // update Offer/Answer state + // TODO: support multipart mime + if ((reply.cseq_method == "INVITE") || (reply.cseq_method == "UPDATE")) { - if(triggerOfferAnswer(reply.content_type, reply.body)){ - DBG("triggerOfferAnswer() failed\n"); - return -1; + if (triggerOfferAnswer(reply.content_type, reply.body)) { + DBG("triggerOfferAnswer() failed\n"); + return -1; + } } - } - if(reply.content_type == "application/sdp") { + if (reply.content_type == "application/sdp") { - if(onTxSdp(reply.body)){ + if (onTxSdp(reply.body)) { - DBG("onTxSdp() failed (replying 500 internal error)\n"); - reply.code = 500; - reply.reason = "internal error"; - reply.body = ""; - reply.content_type = ""; + DBG("onTxSdp() failed (replying 500 internal error)\n"); + reply.code = 500; + reply.reason = "internal error"; + reply.body = ""; + reply.content_type = ""; + } } } - if((reply.code >= 200) && ((t.method != "INVITE") || (reply.cseq_method != "CANCEL"))){ + if ((reply.code >= 200) && ((t.method != "INVITE") || (reply.cseq_method != "CANCEL"))) { DBG("reply.cseq_method = %s; t.method = %s\n", reply.cseq_method.c_str(),t.method.c_str()); @@ -702,7 +707,8 @@ int AmSipDialog::reply(const AmSipRequest& req, const string& content_type, const string& body, const string& hdrs, - int flags) + int flags, + bool do_offeranswer) { string m_hdrs = hdrs; @@ -785,7 +791,7 @@ int AmSipDialog::reply(const AmSipRequest& req, reply.content_type = content_type; reply.body = body; - if(onTxReply(reply)){ + if(onTxReply(reply, do_offeranswer)){ DBG("onTxReply failed\n"); return -1; } @@ -998,7 +1004,8 @@ int AmSipDialog::sendRequest(const string& method, const string& content_type, const string& body, const string& hdrs, - int flags) + int flags, + bool do_offeranswer) { string msg,ser_cmd; string m_hdrs = hdrs; @@ -1058,7 +1065,7 @@ int AmSipDialog::sendRequest(const string& method, req.body = body; } - if(onTxRequest(req)) + if(onTxRequest(req, do_offeranswer)) return -1; if (SipCtrlInterface::send(req)) diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h index 33158ae..a7c240e 100644 --- a/core/AmSipDialog.h +++ b/core/AmSipDialog.h @@ -156,14 +156,16 @@ class AmSipDialog const string& content_type = "", const string& body = "", const string& hdrs = "", - int flags = 0); + int flags = 0, + bool do_offeranswer = true); /** @return 0 on success */ int sendRequest(const string& method, const string& content_type = "", const string& body = "", const string& hdrs = "", - int flags = 0); + int flags = 0, + bool do_offeranswer = true); /** @return 0 on success */ int send_200_ack(unsigned int inv_cseq, @@ -247,8 +249,8 @@ private: AmSipDialogEventHandler* hdl; - int onTxReply(AmSipReply& reply); - int onTxRequest(AmSipRequest& req); + int onTxReply(AmSipReply& reply, bool do_offeranswer); + int onTxRequest(AmSipRequest& req, bool do_offeranswer); int onRxSdp(const string& body, const char** err_txt); int onTxSdp(const string& body); _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
