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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2017-06-27T15:54:55+02:00

pv: new variables - $Ru and $Rut

- $Ru - URI format for local socket where the SIP message was received,
  without trasport parameter for UDP
- $Rut - URI format for local socket where the SIP message was received,
  always with transport parameter

---

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

---

diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 483faa2d19..4e4eddfecf 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -375,6 +375,12 @@ static pv_export_t mod_pvs[] = {
        {{"Rp", (sizeof("Rp")-1)}, /* */
                PVT_OTHER, pv_get_rcvport, 0,
                0, 0, 0, 0},
+       {{"Ru", (sizeof("Ru")-1)}, /* */
+               PVT_OTHER, pv_get_rcvaddr_uri, 0,
+               0, 0, 0, 0},
+       {{"Rut", (sizeof("Rut")-1)}, /* */
+               PVT_OTHER, pv_get_rcvaddr_uri_full, 0,
+               0, 0, 0, 0},
        {{"RAi", (sizeof("RAi")-1)}, /* */
                PVT_OTHER, pv_get_rcv_advertised_ip, 0,
                0, 0, 0, 0},
@@ -408,12 +414,12 @@ static pv_export_t mod_pvs[] = {
        {{"su", (sizeof("su")-1)}, /* */
                PVT_OTHER, pv_get_srcaddr_uri, 0,
                0, 0, 0, 0},
-       {{"td", (sizeof("td")-1)}, /* */
-               PVT_OTHER, pv_get_to_attr, pv_set_to_domain,
-               0, 0, pv_init_iname, 3},
        {{"sut", (sizeof("sut")-1)}, /* */
                PVT_OTHER, pv_get_srcaddr_uri_full, 0,
                0, 0, 0, 0},
+       {{"td", (sizeof("td")-1)}, /* */
+               PVT_OTHER, pv_get_to_attr, pv_set_to_domain,
+               0, 0, pv_init_iname, 3},
        {{"to.domain", (sizeof("to.domain")-1)}, /* */
                PVT_OTHER, pv_get_to_attr, pv_set_to_domain,
                0, 0, pv_init_iname, 3},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index acd9105cb2..8e0074fca4 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -751,6 +751,44 @@ int pv_get_rcvport(struct sip_msg *msg, pv_param_t *param,
                        &msg->rcv.bind_address->port_no_str);
 }
 
+int pv_get_rcvaddr_uri_helper(struct sip_msg *msg, pv_param_t *param,
+               int tmode, pv_value_t *res)
+{
+       str uri;
+       str sr;
+
+       if(msg==NULL)
+               return -1;
+
+       if(get_rcv_socket_uri(msg, tmode, &uri)<0)
+               return pv_get_null(msg, param, res);
+
+       if (uri.len + 1 >= pv_get_buffer_size())
+       {
+               LM_ERR("local buffer size exceeded\n");
+               return pv_get_null(msg, param, res);
+       }
+
+       sr.s = pv_get_buffer();
+       strncpy(sr.s, uri.s, uri.len);
+       sr.len = uri.len;
+       sr.s[sr.len] = '\0';
+
+       return pv_get_strval(msg, param, res, &sr);
+}
+
+int pv_get_rcvaddr_uri(struct sip_msg *msg, pv_param_t *param,
+               pv_value_t *res)
+{
+       return pv_get_rcvaddr_uri_helper(msg, param, 0, res);
+}
+
+int pv_get_rcvaddr_uri_full(struct sip_msg *msg, pv_param_t *param,
+               pv_value_t *res)
+{
+       return pv_get_rcvaddr_uri_helper(msg, param, 1, res);
+}
+
 int pv_get_rcv_advertised_ip(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res)
 {
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 905fc89db5..81c86f02a8 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -145,6 +145,12 @@ int pv_get_rcvip(struct sip_msg *msg, pv_param_t *param,
 int pv_get_rcvport(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res);
 
+int pv_get_rcvaddr_uri(struct sip_msg *msg, pv_param_t *param,
+               pv_value_t *res);
+
+int pv_get_rcvaddr_uri_full(struct sip_msg *msg, pv_param_t *param,
+               pv_value_t *res);
+
 int pv_get_rcv_advertised_ip(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res);
 


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to