diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index c52c798c..1e060a0d 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -105,6 +105,8 @@ AmSipDialog::provisional_100rel AmConfig::rel100 = REL100_SUPPORTED; vector AmConfig::CodecOrder; +bool AmConfig::WaitForByeTransaction = false; + Dtmf::InbandDetectorType AmConfig::DefaultDTMFDetector = Dtmf::SEMSInternal; bool AmConfig::IgnoreSIGCHLD = true; @@ -452,6 +454,10 @@ int AmConfig::readConfiguration() } } + if(cfg.hasParameter("wait_for_bye_transaction")){ + WaitForByeTransaction = (cfg.getParameter("wait_for_bye_transaction") == "yes"); + } + // single codec in 200 OK if(cfg.hasParameter("single_codec_in_ok")){ SingleCodecInOK = (cfg.getParameter("single_codec_in_ok") == "yes"); diff --git a/core/AmConfig.h b/core/AmConfig.h index 4e610dce..a8bf0f1e 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -143,6 +143,8 @@ struct AmConfig /** If 200 OK reply should be limited to preferred codec only */ static bool SingleCodecInOK; static vector CodecOrder; + + static bool WaitForByeTransaction; enum ApplicationSelector { App_RURIUSER, diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index 5bbb4e83..5a37e87d 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -363,6 +363,11 @@ void AmSipDialog::updateStatus(const AmSipReply& reply) // there is nothing we can do anymore... } } + + if((trans_method == "BYE") && (reply.code >= 200)){ + // final reply to BYE: Disconnecting -> Disconnected + status = Disconnected; + } break; case Pending: @@ -795,7 +800,10 @@ int AmSipDialog::bye(const string& hdrs, int flags) send_200_ack(it->second); } } - status = Disconnected; + if (AmConfig::WaitForByeTransaction) + status = Disconnecting; + else + status = Disconnected; return sendRequest("BYE", "", "", hdrs, flags); case Pending: diff --git a/core/etc/sems.conf.sample b/core/etc/sems.conf.sample index dd3042b7..e6e01e57 100644 --- a/core/etc/sems.conf.sample +++ b/core/etc/sems.conf.sample @@ -426,6 +426,16 @@ use_default_signature=yes # # dtmf_detector=spandsp +# optional parameter: wait_for_bye_transaction={yes|no} +# +# when SEMS stops a call sending BYE as UAC, this option sets whether +# SEMS waits for the BYE transaction to finish before forgetting the call. +# This may be necessary e.g. to authenticate the BYE request. +# +# default: no +# +# wait_for_bye_transaction=yes + # optional parameter: unhandled_reply_loglevel={error|warn|info|debug|no} # # the default application logic implemented in the applications is to stop