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

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-05-16T21:24:24+02:00

pv: added $ctu - return contact header uri

---

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/e738bd08b14bfc765a8317267d738a8b1b574c64.diff
Patch: 
https://github.com/kamailio/kamailio/commit/e738bd08b14bfc765a8317267d738a8b1b574c64.patch

---

diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 5e9da2703e0..3226c773a2e 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -163,6 +163,8 @@ static pv_export_t mod_pvs[] = {
                        PVT_OTHER, pv_get_cseq_body, 0, 0, 0, 0, 0},
        {{"ct", (sizeof("ct") - 1)}, /* */
                        PVT_OTHER, pv_get_contact, 0, 0, 0, 0, 0},
+       {{"ctu", (sizeof("ctu") - 1)}, /* */
+                       PVT_OTHER, pv_get_contact_uri, 0, 0, 0, 0, 0},
        {{"cT", (sizeof("cT") - 1)}, /* */
                        PVT_OTHER, pv_get_content_type, 0, 0, 0, 0, 0},
        {{"dd", (sizeof("dd") - 1)}, /* */
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index b10b7513a6f..8eed3c2e019 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -381,6 +381,29 @@ int pv_get_contact(struct sip_msg *msg, pv_param_t *param, 
pv_value_t *res)
        return pv_get_strval(msg, param, res, &msg->contact->body);
 }
 
+int pv_get_contact_uri(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
+{
+       contact_body_t *cb = NULL;
+
+       if(msg == NULL)
+               return -1;
+
+       if(msg->contact == NULL && parse_headers(msg, HDR_CONTACT_F, 0) == -1) {
+               LM_DBG("no contact header\n");
+               return pv_get_null(msg, param, res);
+       }
+       if(parse_contact_headers(msg) < 0) {
+               return pv_get_null(msg, param, res);
+       }
+
+       cb = (contact_body_t *)msg->contact->parsed;
+       if(cb->star == 1 || cb->contacts == NULL) {
+               return pv_get_null(msg, param, res);
+       }
+
+       return pv_get_strval(msg, param, res, &cb->contacts->uri);
+}
+
 int pv_get_xto_attr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res,
                struct to_body *xto, int type)
 {
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index caaa12e54d1..7d4681dab96 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -65,6 +65,8 @@ int pv_get_errinfo_attr(
 
 int pv_get_contact(struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
 
+int pv_get_contact_uri(struct sip_msg *msg, pv_param_t *param, pv_value_t 
*res);
+
 int pv_get_xto_attr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res,
                struct to_body *xto, int type);
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to