Module: kamailio Branch: master Commit: 8375871957ce931b87cc03442915fa319b5b3ef6 URL: https://github.com/kamailio/kamailio/commit/8375871957ce931b87cc03442915fa31...
Author: iionita ionut-razvan.ionita@1and1.ro Committer: Henning Westerholt henningw@users.noreply.github.com Date: 2019-04-09T21:25:53+02:00
siptrace: add trace_flag after it was removed
As requested trace_flag is added back to siptrace module. Kamailio users requested ways to be able to stop tracing at any moment during the script.
---
Modified: src/modules/siptrace/siptrace.c
---
Diff: https://github.com/kamailio/kamailio/commit/8375871957ce931b87cc03442915fa31... Patch: https://github.com/kamailio/kamailio/commit/8375871957ce931b87cc03442915fa31...
---
diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c index 2f8f32a11f..9af3b522bf 100644 --- a/src/modules/siptrace/siptrace.c +++ b/src/modules/siptrace/siptrace.c @@ -132,6 +132,8 @@ static str siptrace_info_avp_str = str_init("$avp(__siptrace_info_avp__)"); #define NR_KEYS 12 #define SIP_TRACE_TABLE_VERSION 4
+int trace_flag = 0; + int trace_on = 0; int trace_sl_acks = 1;
@@ -213,6 +215,7 @@ static param_export_t params[] = { {"fromtag_column", PARAM_STR, &fromtag_column}, {"totag_column", PARAM_STR, &totag_column}, {"direction_column", PARAM_STR, &direction_column}, + {"trace_flag", INT_PARAM, &trace_flag}, {"trace_on", INT_PARAM, &trace_on}, {"traced_user_avp", PARAM_STR, &traced_user_avp_str}, {"trace_table_avp", PARAM_STR, &trace_table_avp_str}, @@ -274,6 +277,12 @@ static int mod_init(void) return -1; }
+ if(trace_flag < 0 || trace_flag > (int)MAX_FLAG) { + LM_ERR("invalid trace flag %d\n", trace_flag); + return -1; + } + trace_flag = 1 << trace_flag; + trace_to_database_flag = (int *)shm_malloc(sizeof(int)); if(trace_to_database_flag == NULL) { LM_ERR("no more shm memory left\n"); @@ -1122,7 +1131,8 @@ static int sip_trace(sip_msg_t *msg, dest_info_t *dst, }
#define trace_is_off(_msg) \ - (((_msg)->msg_flags & FL_SIPTRACE) == 0) + ((((_msg)->msg_flags & FL_SIPTRACE) == 0) \ + || ((_msg->flags & trace_flag) == 0))
static void trace_onreq_out(struct cell *t, int type, struct tmcb_params *ps) { @@ -1529,6 +1539,11 @@ static void trace_tm_neg_ack_in(struct cell *t, int type, struct tmcb_params *ps return; }
+ if(trace_is_off(ps->req)) { + LM_DBG("trace off...\n"); + return; + } + sip_trace(ps->req, info->uriState == STRACE_PARSED_URI ? &info->u.dest_info : NULL , NULL, NULL); }