From 051300e04bb6bc24796c03f0b80fda87ab07627f Mon Sep 17 00:00:00 2001 From: Julien Chavanton Date: Tue, 28 Jul 2020 23:22:42 +0000 Subject: [PATCH] acc: add to-tag for locally generated replies --- src/modules/acc/acc.c | 7 +++++++ src/modules/acc/acc_api.h | 1 + src/modules/acc/acc_logic.c | 14 +++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/modules/acc/acc.c b/src/modules/acc/acc.c index 91a12f6cdb4..500629cf73a 100644 --- a/src/modules/acc/acc.c +++ b/src/modules/acc/acc.c @@ -123,6 +123,13 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals) t_vals[2] = TYPE_NULL; } + LM_DBG("default - totag[%.*s]\n", c_vals[2].len, c_vals[2].s); + if (c_vals[2].len == 0 && acc_env.to_tag.s && acc_env.to_tag.len > 0) { + LM_DBG("extra [%p] totag[%.*s]\n", acc_env.to_tag.s, acc_env.to_tag.len, acc_env.to_tag.s); + c_vals[2].len = acc_env.to_tag.len; + c_vals[2].s = acc_env.to_tag.s; + } + /* Callid */ if (req->callid && req->callid->body.len) { c_vals[3] = req->callid->body; diff --git a/src/modules/acc/acc_api.h b/src/modules/acc/acc_api.h index 93f8acc1001..0a6df2e32ce 100644 --- a/src/modules/acc/acc_api.h +++ b/src/modules/acc/acc_api.h @@ -54,6 +54,7 @@ typedef struct acc_enviroment { str code_s; str reason; struct hdr_field *to; + str to_tag; /*!< locally generated to-tag */ str text; time_t ts; struct timeval tv; diff --git a/src/modules/acc/acc_logic.c b/src/modules/acc/acc_logic.c index 41636705d80..818c7aa1017 100644 --- a/src/modules/acc/acc_logic.c +++ b/src/modules/acc/acc_logic.c @@ -79,8 +79,7 @@ struct acc_enviroment acc_env; static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps ); -static inline struct hdr_field* get_rpl_to( struct cell *t, - struct sip_msg *reply) +static inline struct hdr_field* get_rpl_to( struct cell *t, struct sip_msg *reply) { if (reply==FAKED_REPLY || !reply || !reply->to) return t->uas.request->to; @@ -88,13 +87,17 @@ static inline struct hdr_field* get_rpl_to( struct cell *t, return reply->to; } +void env_set_totag(struct cell *t, struct sip_msg *reply) +{ + if (reply==FAKED_REPLY || !reply || !reply->to) + tmb.t_get_reply_totag(t->uas.request, &acc_env.to_tag); +} static inline void env_set_to(struct hdr_field *to) { acc_env.to = to; } - static inline void env_set_text(char *p, int len) { acc_env.text.s = p; @@ -493,7 +496,9 @@ static inline void on_missed(struct cell *t, struct sip_msg *req, /* set env variables */ env_set_to( get_rpl_to(t,reply) ); - env_set_code_status( code, reply); + env_set_code_status(code, reply); + /* for missed calls, we make sure to include the totag if it is locally generated */ + env_set_totag(t, reply); /* we report on missed calls when the first * forwarding attempt fails; we do not wish to @@ -512,7 +517,6 @@ static inline void on_missed(struct cell *t, struct sip_msg *req, acc_db_request( req ); flags_to_reset |= 1 << db_missed_flag; } - /* run extra acc engines */ acc_run_engines(req, 1, &flags_to_reset);