From c9ecbe97af96e20312f1f2daa0afe3b5121cb0c0 Mon Sep 17 00:00:00 2001 From: jaybeepee Date: Mon, 29 Feb 2016 14:13:03 +0200 Subject: [PATCH] modules/ims_dialog: add default reason headers for mi-terminated dlgs --- modules/ims_dialog/dlg_req_within.c | 7 ++++--- modules/ims_dialog/ims_dialog.c | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/ims_dialog/dlg_req_within.c b/modules/ims_dialog/dlg_req_within.c index 2de823ddd8a..e8b3ffd1b45 100644 --- a/modules/ims_dialog/dlg_req_within.c +++ b/modules/ims_dialog/dlg_req_within.c @@ -403,13 +403,14 @@ struct mi_root * mi_terminate_dlg(struct mi_root *cmd_tree, void *param) { struct mi_node* node; struct dlg_cell * dlg = NULL; - str mi_extra_hdrs = {NULL, 0}; + str mi_extra_hdrs = {"Reason: mi_terminated\r\n", 23}; int status, msg_len; char *msg; str callid = {NULL, 0}; str ftag = {NULL, 0}; str ttag = {NULL, 0}; + str reason = {"mi_terminated", 13}; if (d_table == NULL) goto end; @@ -448,9 +449,9 @@ struct mi_root * mi_terminate_dlg(struct mi_root *cmd_tree, void *param) { dlg = get_dlg(&callid, &ftag, &ttag, &dir); //increments ref count! if (dlg) { - LM_DBG("Found dialog to terminate and it is in state [%i]\n", dlg->state); + LM_DBG("Found dialog to terminate and it is in state [%i] [%.*s]\n", dlg->state, mi_extra_hdrs.len, mi_extra_hdrs.s); - if (dlg_terminate(dlg, 0, NULL/*reson*/, /* all sides of a dialog*/ 2, &mi_extra_hdrs) < 0) { + if (dlg_terminate(dlg, 0, &reason/*reson*/, /* all sides of a dialog*/ 2, &mi_extra_hdrs) < 0) { status = 500; msg = MI_DLG_OPERATION_ERR; msg_len = MI_DLG_OPERATION_ERR_LEN; diff --git a/modules/ims_dialog/ims_dialog.c b/modules/ims_dialog/ims_dialog.c index 6d4732a237a..94c84e6b291 100644 --- a/modules/ims_dialog/ims_dialog.c +++ b/modules/ims_dialog/ims_dialog.c @@ -929,7 +929,9 @@ static const char *rpc_end_dlg_entry_id_doc[2] = { static void rpc_end_dlg_entry_id(rpc_t *rpc, void *c) { unsigned int h_entry, h_id; struct dlg_cell * dlg = NULL; - str rpc_extra_hdrs = {NULL,0}; + str rpc_extra_hdrs = {0,0}; + str dfl_rpc_extra_hdrs = {"Reason: mi_terminated\r\n",23}; + str reason = {"mi_terminated", 12}; int n; n = rpc->scan(c, "dd", &h_entry, &h_id); @@ -940,7 +942,7 @@ static void rpc_end_dlg_entry_id(rpc_t *rpc, void *c) { } if(rpc->scan(c, "*S", &rpc_extra_hdrs)<1) { - rpc_extra_hdrs.s = NULL; + rpc_extra_hdrs = dfl_rpc_extra_hdrs; rpc_extra_hdrs.len = 0; } @@ -951,8 +953,8 @@ static void rpc_end_dlg_entry_id(rpc_t *rpc, void *c) { } unref_dlg(dlg, 1); - - dlg_terminate(dlg, NULL, NULL/*reason*/, 2, NULL); + LM_DBG("Setting reason to [%.*s] and extra headers to [%.*s]\n", reason.len, reason.s, rpc_extra_hdrs.len, rpc_extra_hdrs.s); + dlg_terminate(dlg, NULL, &reason/*reason*/, 2, &rpc_extra_hdrs); }