Module: kamailio
Branch: master
Commit: 501421f42c17a411bde0fb2401437fa2ba1f5c66
URL:
https://github.com/kamailio/kamailio/commit/501421f42c17a411bde0fb2401437fa…
Author: Stefan Mititelu <stefan-cristian.mititelu(a)1and1.ro>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2022-08-08T15:16:34+02:00
siptrace: Trace in-dialog ACK and dialog spirals
Enable behavior via 2 new modparams.
---
Modified: src/modules/siptrace/doc/siptrace_admin.xml
Modified: src/modules/siptrace/siptrace.c
---
Diff:
https://github.com/kamailio/kamailio/commit/501421f42c17a411bde0fb2401437fa…
Patch:
https://github.com/kamailio/kamailio/commit/501421f42c17a411bde0fb2401437fa…
---
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")
</programlisting>
</example>
</section>
+
+ <section id="siptrace.p.trace_dialog_ack">
+ <title><varname>trace_dialog_ack</varname>
(str)</title>
+ <para>
+ Enable tracing of in-dialog ACK.
+ </para>
+ <para>
+ Default value is 0 (disabled).
+ </para>
+ <example>
+ <title>Set <varname>trace_dialog_ack</varname>
parameter</title>
+<programlisting format="linespecific">
+...
+modparam("siptrace", "trace_dialog_ack", 1)
+...
+</programlisting>
+ </example>
+ </section>
+
+ <section id="siptrace.p.trace_dialog_spiral">
+ <title><varname>trace_dialog_spiral</varname>
(str)</title>
+ <para>
+ Enable tracing of dialog spirals.
+ </para>
+ <para>
+ Default value is 0 (disabled).
+ </para>
+ <example>
+ <title>Set <varname>trace_dialog_spiral</varname>
parameter</title>
+<programlisting format="linespecific">
+...
+modparam("siptrace", "trace_dialog_spiral", 1)
+...
+</programlisting>
+ </example>
+ </section>
+
</section>
<section>
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");