Module: kamailio
Branch: master
Commit: 57ec3497c5a584850bd2883d6a6e8fd0535e11d7
URL: 
https://github.com/kamailio/kamailio/commit/57ec3497c5a584850bd2883d6a6e8fd0535e11d7

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-05-15T12:10:30+02:00

pv: added $tts variable

- return to-tag state: 0 - if not set; 1 - if set

---

Modified: src/modules/pv/pv.c
Modified: src/modules/pv/pv_core.c
Modified: src/modules/pv/pv_core.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/57ec3497c5a584850bd2883d6a6e8fd0535e11d7.diff
Patch: 
https://github.com/kamailio/kamailio/commit/57ec3497c5a584850bd2883d6a6e8fd0535e11d7.patch

---

diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 81781303049..89f5d5c2a14 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -398,6 +398,8 @@ static pv_export_t mod_pvs[] = {
                        pv_init_iname, 5},
        {{"tt", (sizeof("tt") - 1)}, /* */
                        PVT_OTHER, pv_get_to_attr, 0, 0, 0, pv_init_iname, 4},
+       {{"tts", (sizeof("tts") - 1)}, /* */
+                       PVT_OTHER, pv_get_totagstate, 0, 0, 0, 0, 0},
        {{"tu", (sizeof("tu") - 1)}, /* */
                        PVT_TO, pv_get_to_attr, pv_set_to_uri, 0, 0, 
pv_init_iname, 1},
        {{"to", (sizeof("to") - 1)}, /* */
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 56d96b20d75..a1064738bba 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -509,6 +509,27 @@ int pv_get_to_attr(struct sip_msg *msg, pv_param_t *param, 
pv_value_t *res)
        return pv_get_xto_attr(msg, param, res, get_to(msg), 0);
 }
 
+int pv_get_totagstate(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
+{
+       if(msg == NULL)
+               return pv_get_uintval(msg, param, res, 0);
+
+       if(msg->to == NULL && parse_headers(msg, HDR_TO_F, 0) == -1) {
+               LM_ERR("cannot parse To header\n");
+               return pv_get_uintval(msg, param, res, 0);
+       }
+       if(msg->to == NULL || get_to(msg) == NULL) {
+               LM_DBG("no To header\n");
+               return pv_get_uintval(msg, param, res, 0);
+       }
+
+       if(get_to(msg)->tag_value.s != NULL && get_to(msg)->tag_value.len > 0) {
+               return pv_get_uintval(msg, param, res, 1);
+       }
+
+       return pv_get_uintval(msg, param, res, 0);
+}
+
 int pv_get_from_attr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
 {
        if(msg == NULL)
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 16b14bf31cd..1341c9ba0f0 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -77,6 +77,8 @@ int pv_get_xto_attr(struct sip_msg *msg, pv_param_t *param, 
pv_value_t *res,
 
 int pv_get_to_attr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
 
+int pv_get_totagstate(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
+
 int pv_get_from_attr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
 
 int pv_get_cseq(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to