[sr-dev] git:master:e1df9208: pv: new variables - $RAu and $RAut
Daniel-Constantin Mierla
miconda at gmail.com
Tue Jun 27 16:19:50 CEST 2017
Module: kamailio
Branch: master
Commit: e1df92080a631b8c97c110d1e87f74fa1cd5ec9e
URL: https://github.com/kamailio/kamailio/commit/e1df92080a631b8c97c110d1e87f74fa1cd5ec9e
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-06-27T16:15:43+02:00
pv: new variables - $RAu and $RAut
- $RAu - URI format for local socket where the SIP message was received,
without trasport parameter for UDP, using the advertised address if available
- $RAut - URI format for local socket where the SIP message was received,
always with transport parameter, using the advertised address if available
---
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/e1df92080a631b8c97c110d1e87f74fa1cd5ec9e.diff
Patch: https://github.com/kamailio/kamailio/commit/e1df92080a631b8c97c110d1e87f74fa1cd5ec9e.patch
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 4e4eddfecf..c85d2015eb 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -387,6 +387,12 @@ static pv_export_t mod_pvs[] = {
{{"RAp", (sizeof("RAp")-1)}, /* */
PVT_OTHER, pv_get_rcv_advertised_port, 0,
0, 0, 0, 0},
+ {{"RAu", (sizeof("RAu")-1)}, /* */
+ PVT_OTHER, pv_get_rcvadv_uri, 0,
+ 0, 0, 0, 0},
+ {{"RAut", (sizeof("RAut")-1)}, /* */
+ PVT_OTHER, pv_get_rcvadv_uri_full, 0,
+ 0, 0, 0, 0},
{{"sf", (sizeof("sf")-1)}, /* */
PVT_OTHER, pv_get_sflags, pv_set_sflags,
0, 0, 0, 0},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index b49de912d7..34b03a411f 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -760,7 +760,7 @@ int pv_get_rcvaddr_uri_helper(struct sip_msg *msg, pv_param_t *param,
if(msg==NULL)
return -1;
- if(get_rcv_socket_uri(msg, tmode, &uri)<0)
+ if(get_rcv_socket_uri(msg, tmode, &uri, 0)<0)
return pv_get_null(msg, param, res);
if (uri.len + 1 >= pv_get_buffer_size())
@@ -820,6 +820,62 @@ int pv_get_rcv_advertised_port(struct sip_msg *msg, pv_param_t *param,
return pv_get_rcvport(msg, param, res);
}
+int pv_get_rcvadv_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, 1)<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_rcvadv_uri(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ if(msg==NULL)
+ return -1;
+
+ if(msg->rcv.bind_address!=NULL
+ && (msg->rcv.bind_address->useinfo.address_str.len > 0
+ || msg->rcv.bind_address->useinfo.port_no_str.len > 0)) {
+ return pv_get_rcvadv_uri_helper(msg, param, 0, res);
+ }
+
+ return pv_get_rcvaddr_uri_helper(msg, param, 0, res);
+}
+
+int pv_get_rcvadv_uri_full(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ if(msg==NULL)
+ return -1;
+
+ if(msg->rcv.bind_address!=NULL
+ && (msg->rcv.bind_address->useinfo.address_str.len > 0
+ || msg->rcv.bind_address->useinfo.port_no_str.len > 0)) {
+ return pv_get_rcvadv_uri_helper(msg, param, 1, res);
+ }
+
+ return pv_get_rcvaddr_uri_helper(msg, param, 1, res);
+}
+
/**
*
*/
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 81c86f02a8..ac36ef315a 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -157,6 +157,12 @@ int pv_get_rcv_advertised_ip(struct sip_msg *msg, pv_param_t *param,
int pv_get_rcv_advertised_port(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_rcvadv_uri(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
+int pv_get_rcvadv_uri_full(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_force_sock(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
More information about the sr-dev
mailing list