Module: sems Branch: master Commit: fb22186abb12fc0953738426e3909b9a105ff19c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=fb22186abb12fc0953738426e3909b9a105ff19c
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Fri Jun 10 17:17:10 2011 +0200 b/f: reset offer/answer state before auth-resending request --- core/AmSipDialog.cpp | 29 +++++++++++++++++++++++++++-- core/AmSipDialog.h | 7 +++++++ core/plug-in/uac_auth/UACAuth.cpp | 7 ++++++- core/plug-in/uac_auth/UACAuth.h | 8 +++++--- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index e22a9f3..bdb2bdf 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -59,6 +59,20 @@ const char* AmSipDialog::getStatusStr() return dlgStatusStr(status); } +const char* __dlg_oa_status2str[AmSipDialog::__max_OA] = { + "None", + "OfferRecved", + "OfferSent", + "Completed" +}; + +const char* getOAStatusStr(AmSipDialog::OAState st) { + if((st < 0) || (st >= AmSipDialog::__max_OA)) + return "Invalid"; + else + return __dlg_oa_status2str[st]; +} + AmSipDialog::AmSipDialog(AmSipDialogEventHandler* h) : status(Disconnected),oa_state(OA_None), cseq(10),r_cseq_i(false),hdl(h), @@ -100,12 +114,22 @@ AmSipDialog::~AmSipDialog() } void AmSipDialog::setStatus(Status new_status) { - DBG("setting SIP dialog status: %s->%s\n", + DBG("setting SIP dialog status: %s->%s\n", getStatusStr(), dlgStatusStr(new_status)); status = new_status; } +AmSipDialog::OAState AmSipDialog::get_OA_state() { + return oa_state; +} + +void AmSipDialog::set_OA_state(OAState new_oa_state) { + DBG("setting SIP dialog O/A status: %s->%s\n", + getOAStatusStr(oa_state), getOAStatusStr(new_oa_state)); + oa_state = new_oa_state; +} + void AmSipDialog::onRxRequest(const AmSipRequest& req) { DBG("AmSipDialog::onRxRequest(req = %s)\n", req.method.c_str()); @@ -283,6 +307,7 @@ int AmSipDialog::onTxSdp(const string& body) case OA_OfferSent: // There is already a pending offer!!! + DBG("There is already a pending offer, onTxSdp fails\n"); return -1; default: @@ -1374,7 +1399,7 @@ int AmSipDialog::sendRequest(const string& method, req.content_type = content_type; req.body = body; - + DBG("req.body = '%s'\n", req.body.c_str()); OAState old_oa_state = oa_state; if(onTxRequest(req)) return -1; diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h index 7d7f132..8c5044c 100644 --- a/core/AmSipDialog.h +++ b/core/AmSipDialog.h @@ -208,6 +208,11 @@ private: void setStatus(Status new_status); + /** get offer/answer state */ + OAState get_OA_state(); + /** set offer/answer state (handle with caution!) */ + void set_OA_state(OAState new_oa_state); + string getContactHdr(); /** @@ -389,6 +394,8 @@ class AmSipDialogEventHandler const char* dlgStatusStr(AmSipDialog::Status st); +const char* getOAStatusStr(AmSipDialog::OAState st); + #endif diff --git a/core/plug-in/uac_auth/UACAuth.cpp b/core/plug-in/uac_auth/UACAuth.cpp index 64c1b2e..ae30e8b 100644 --- a/core/plug-in/uac_auth/UACAuth.cpp +++ b/core/plug-in/uac_auth/UACAuth.cpp @@ -183,6 +183,10 @@ bool UACAuth::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_st } } + + // reset OA state to what is was before sending the failed request + dlg->set_OA_state(ri->second.oa_state); + // resend request if (dlg->sendRequest(ri->second.method, ri->second.content_type, @@ -217,7 +221,8 @@ bool UACAuth::onSendRequest(const string& method, sent_requests[cseq] = SIPRequestInfo(method, content_type, body, - hdrs); + hdrs, + dlg->get_OA_state()); return false; } diff --git a/core/plug-in/uac_auth/UACAuth.h b/core/plug-in/uac_auth/UACAuth.h index 57d1880..cc52301 100644 --- a/core/plug-in/uac_auth/UACAuth.h +++ b/core/plug-in/uac_auth/UACAuth.h @@ -85,13 +85,15 @@ struct SIPRequestInfo { string content_type; string body; string hdrs; - + AmSipDialog::OAState oa_state; + SIPRequestInfo(const string& method, const string& content_type, const string& body, - const string& hdrs) + const string& hdrs, + AmSipDialog::OAState oa_state) : method(method), content_type(content_type), - body(body), hdrs(hdrs) { } + body(body), hdrs(hdrs), oa_state(oa_state) { } SIPRequestInfo() {} _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
