[sr-dev] git:master:e28f4644: siptrace: trace incoming CANCEL into a dedicated callback
Federico Cabiddu
federico.cabiddu at gmail.com
Mon Apr 6 16:19:16 CEST 2020
Module: kamailio
Branch: master
Commit: e28f464457eea47cc606c73cbfe4b30fcc8b542a
URL: https://github.com/kamailio/kamailio/commit/e28f464457eea47cc606c73cbfe4b30fcc8b542a
Author: Federico Cabiddu <federico.cabiddu at gmail.com>
Committer: Federico Cabiddu <federico.cabiddu at gmail.com>
Date: 2020-04-03T11:59:50+02:00
siptrace: trace incoming CANCEL into a dedicated callback
---
Modified: src/modules/siptrace/siptrace.c
---
Diff: https://github.com/kamailio/kamailio/commit/e28f464457eea47cc606c73cbfe4b30fcc8b542a.diff
Patch: https://github.com/kamailio/kamailio/commit/e28f464457eea47cc606c73cbfe4b30fcc8b542a.patch
---
diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c
index b000d1ac8d..3c1ec436d7 100644
--- a/src/modules/siptrace/siptrace.c
+++ b/src/modules/siptrace/siptrace.c
@@ -64,8 +64,7 @@ MODULE_VERSION
#define SIPTRACE_ANYADDR_LEN (sizeof(SIPTRACE_ANYADDR) - 1)
#define trace_is_off(_msg) \
- ((((_msg)->msg_flags & FL_SIPTRACE) == 0) \
- || ((trace_flag != 0) && (_msg->flags & trace_flag) == 0))
+ (((_msg)->msg_flags & FL_SIPTRACE) == 0)
#define is_null_pv(_str) \
(!str_strcmp(&_str, pv_get_null_str()))
@@ -98,6 +97,7 @@ static int w_hlog2(struct sip_msg *, char *correlationid, char *message);
static int sip_trace_store_db(siptrace_data_t *sto);
static void trace_onreq_out(struct cell *t, int type, struct tmcb_params *ps);
+static void trace_cancel_in(struct cell *t, int type, struct tmcb_params *ps);
static void trace_onreply_in(struct cell *t, int type, struct tmcb_params *ps);
static void trace_onreply_out(struct cell *t, int type, struct tmcb_params *ps);
static void trace_tm_neg_ack_in(struct cell *t, int type, struct tmcb_params *ps);
@@ -1254,6 +1254,31 @@ static int w_sip_trace_mode(sip_msg_t *msg, char *pmode, char *p2)
return ki_sip_trace_mode(msg, &smode);
}
+static void trace_cancel_in(struct cell *t, int type, struct tmcb_params *ps)
+{
+ siptrace_info_t* info;
+ sip_msg_t *msg;
+
+ if(t == NULL || ps == NULL) {
+ LM_ERR("unexpected parameter values\n");
+ return;
+ }
+
+ if(ps->flags & TMCB_RETR_F) {
+ LM_DBG("retransmission - ignoring\n");
+ return;
+ }
+
+ info = (siptrace_info_t *)(*ps->param);
+ msg = ps->req;
+ if(tmb.register_tmcb(msg, 0, TMCB_RESPONSE_READY, trace_onreply_out, info, 0) <= 0) {
+ LM_ERR("can't register trace_onreply_out\n");
+ return;
+ }
+ msg->msg_flags |= FL_SIPTRACE;
+ sip_trace_helper(msg, NULL, NULL, NULL, NULL, 1);
+}
+
static void trace_onreq_out(struct cell *t, int type, struct tmcb_params *ps)
{
siptrace_data_t sto;
@@ -1296,19 +1321,9 @@ static void trace_onreq_out(struct cell *t, int type, struct tmcb_params *ps)
* and can register a callback for the reply */
memset(&sto, 0, sizeof(siptrace_data_t));
- if (unlikely(type == TMCB_E2ECANCEL_IN)) {
- msg->msg_flags |= FL_SIPTRACE;
-
- if(tmb.register_tmcb(msg, 0, TMCB_RESPONSE_READY, trace_onreply_out, info, 0)
- <= 0) {
- LM_ERR("can't register trace_onreply_out\n");
- return;
- }
- } else {
- if(traced_user_avp.n != 0)
- sto.avp = search_first_avp(traced_user_avp_type, traced_user_avp,
- &sto.avp_value, &sto.state);
- }
+ if(traced_user_avp.n != 0)
+ sto.avp = search_first_avp(traced_user_avp_type, traced_user_avp,
+ &sto.avp_value, &sto.state);
if((sto.avp == NULL) && trace_is_off(msg)) {
LM_DBG("trace off...\n");
@@ -1318,16 +1333,11 @@ static void trace_onreq_out(struct cell *t, int type, struct tmcb_params *ps)
if(sip_trace_prepare(msg) < 0)
return;
- if (unlikely(type == TMCB_E2ECANCEL_IN)) {
- sto.body.s = msg->buf;
- sto.body.len = msg->len;
+ if(ps->send_buf.len > 0) {
+ sto.body = ps->send_buf;
} else {
- if(ps->send_buf.len > 0) {
- sto.body = ps->send_buf;
- } else {
- sto.body.s = "No request buffer";
- sto.body.len = sizeof("No request buffer") - 1;
- }
+ sto.body.s = "No request buffer";
+ sto.body.len = sizeof("No request buffer") - 1;
}
sto.callid = msg->callid->body;
@@ -1866,7 +1876,7 @@ static void trace_transaction(sip_msg_t* msg, siptrace_info_t* info, int dlg_tra
return;
}
- if(tmb.register_tmcb(msg, 0, TMCB_E2ECANCEL_IN, trace_onreq_out, info, 0) <= 0) {
+ if(tmb.register_tmcb(msg, 0, TMCB_E2ECANCEL_IN, trace_cancel_in, info, 0) <= 0) {
LM_ERR("can't register trace_onreply_in\n");
return;
}
More information about the sr-dev
mailing list