From 501421f42c17a411bde0fb2401437fa2ba1f5c66 Mon Sep 17 00:00:00 2001 From: Stefan Mititelu Date: Tue, 2 Aug 2022 16:01:55 +0300 Subject: [PATCH] siptrace: Trace in-dialog ACK and dialog spirals Enable behavior via 2 new modparams. --- src/modules/siptrace/doc/siptrace_admin.xml | 37 +++++++++++++++++++++ src/modules/siptrace/siptrace.c | 24 +++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/modules/siptrace/doc/siptrace_admin.xml b/src/modules/siptrace/doc/siptrace_admin.xml index c160b97275e..7852647f37d 100644 --- a/src/modules/siptrace/doc/siptrace_admin.xml +++ b/src/modules/siptrace/doc/siptrace_admin.xml @@ -651,6 +651,43 @@ modparam("siptrace", "evcb_msg", "ksr_siptrace_msg") + +
+ <varname>trace_dialog_ack</varname> (str) + + Enable tracing of in-dialog ACK. + + + Default value is 0 (disabled). + + + Set <varname>trace_dialog_ack</varname> parameter + +... +modparam("siptrace", "trace_dialog_ack", 1) +... + + +
+ +
+ <varname>trace_dialog_spiral</varname> (str) + + Enable tracing of dialog spirals. + + + Default value is 0 (disabled). + + + Set <varname>trace_dialog_spiral</varname> parameter + +... +modparam("siptrace", "trace_dialog_spiral", 1) +... + + +
+
diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c index 9540e83d062..81913f064da 100644 --- a/src/modules/siptrace/siptrace.c +++ b/src/modules/siptrace/siptrace.c @@ -195,6 +195,10 @@ static str trace_local_ip = {NULL, 0}; static db1_con_t *db_con = NULL; /*!< database connection */ static db_func_t db_funcs; /*!< Database functions */ +int trace_dialog_ack = 0; +int trace_dialog_spiral = 0; +static int spiral_tracked; + int pv_parse_siptrace_name(pv_spec_t *sp, str *in); int pv_get_siptrace(sip_msg_t *msg, pv_param_t *param, pv_value_t *res); @@ -263,6 +267,8 @@ static param_export_t params[] = { {"trace_init_mode", PARAM_INT, &_siptrace_init_mode}, {"trace_mode", PARAM_INT, &_siptrace_mode}, {"evcb_msg", PARAM_STR, &_siptrace_evcb_msg}, + {"trace_dialog_ack", PARAM_INT, &trace_dialog_ack}, + {"trace_dialog_spiral", PARAM_INT, &trace_dialog_spiral}, {0, 0, 0} }; /* clang-format on */ @@ -1979,12 +1985,19 @@ static void trace_dialog(struct dlg_cell* dlg, int type, struct dlg_cb_params *p } /* request - params->req */ - if (params == NULL || params->req == NULL) { + if (params == NULL || (!trace_dialog_spiral && params->req == NULL)) { LM_ERR("Invalid args!\n"); return; } - if (!(params->req->msg_flags & FL_SIPTRACE)) { + if (trace_dialog_spiral && *params->param == NULL) { + LM_DBG("Spiraled dialog!\n"); + if (dlgb.register_dlgcb(dlg, DLGCB_SPIRALED, trace_dialog, &spiral_tracked, NULL) != 0) { + LM_ERR("could not register consider_exporting() for dialog event DLGCB_SPIRALED\n"); + } + } + + if (!trace_dialog_spiral && !(params->req->msg_flags & FL_SIPTRACE)) { LM_DBG("Trace is off for this request...\n"); return; } @@ -2007,6 +2020,13 @@ static void trace_dialog(struct dlg_cell* dlg, int type, struct dlg_cb_params *p return; } + /* this will trace in-dialog ACK */ + if(trace_dialog_ack && dlgb.register_dlgcb(dlg, DLGCB_CONFIRMED, + trace_dialog_transaction, xavp->val.v.vptr, 0) != 0) { + LM_ERR("Failed to register DLGCB_CONFIRMED callback!\n"); + return; + } + if(dlgb.register_dlgcb(dlg, DLGCB_TERMINATED, trace_dialog_transaction, xavp->val.v.vptr, trace_free_info) != 0) { LM_ERR("Failed to register DLGCB_TERMINATED callback!\n");