Module: sip-router
Branch: master
Commit: 7bb5f98d7fd77ca6c21fb11e16d69116ef12cbb2
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7bb5f98…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Sat May 18 00:14:07 2013 +0100
modules/pv: added PVs to provide access to the user-agent string retrieved from usrloc
---
modules/pv/pv.c | 3 +++
modules/pv/pv_branch.c | 12 +++++++++++-
modules/pv/pv_core.c | 24 +++++++++++++++++++++---
modules/pv/pv_core.h | 3 +++
4 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/modules/pv/pv.c b/modules/pv/pv.c
index 2c4d544..44d35e0 100644
--- a/modules/pv/pv.c
+++ b/modules/pv/pv.c
@@ -416,6 +416,9 @@ static pv_export_t mod_pvs[] = {
{{"ruid", (sizeof("ruid")-1)}, /* */
PVT_OTHER, pv_get_ruid, 0,
0, 0, 0, 0},
+ {{"location_ua", (sizeof("location_ua")-1)}, /* */
+ PVT_OTHER, pv_get_location_ua, 0,
+ 0, 0, 0, 0},
{ {"shv", (sizeof("shv")-1)}, PVT_OTHER, pv_get_shvar,
pv_set_shvar, pv_parse_shvar_name, 0, 0, 0},
diff --git a/modules/pv/pv_branch.c b/modules/pv/pv_branch.c
index 791bb5a..0b5138a 100644
--- a/modules/pv/pv_branch.c
+++ b/modules/pv/pv_branch.c
@@ -41,6 +41,7 @@ int pv_get_branchx(struct sip_msg *msg, pv_param_t *param,
unsigned int fl = 0;
struct socket_info* fsocket = NULL;
str ruid;
+ str location_ua;
/* get the index */
if(pv_get_spec_index(msg, param, &idx, &idxf)!=0)
@@ -49,7 +50,7 @@ int pv_get_branchx(struct sip_msg *msg, pv_param_t *param,
return pv_get_null(msg, param, res);
}
- uri.s = get_branch(idx, &uri.len, &lq, &duri, &path, &fl,
&fsocket, &ruid, 0);
+ uri.s = get_branch(idx, &uri.len, &lq, &duri, &path, &fl,
&fsocket, &ruid, 0, &location_ua);
/* branch(count) doesn't need a valid branch, everything else does */
if(uri.s == 0 && ( param->pvn.u.isname.name.n != 5/* count*/ ))
@@ -84,6 +85,10 @@ int pv_get_branchx(struct sip_msg *msg, pv_param_t *param,
if(ruid.len==0)
return pv_get_null(msg, param, res);
return pv_get_strval(msg, param, res, &ruid);
+ case 8: /* location_ua */
+ if(location_ua.len==0)
+ return pv_get_null(msg, param, res);
+ return pv_get_strval(msg, param, res, &location_ua);
default:
/* 0 - uri */
return pv_get_strval(msg, param, res, &uri);
@@ -253,6 +258,9 @@ int pv_set_branchx(struct sip_msg* msg, pv_param_t *param,
case 7: /* ruid */
/* do nothing - cannot set the ruid */
break;
+ case 8: /* location_ua */
+ /* do nothing - cannot set the location_ua */
+ break;
default:
/* 0 - uri */
if(val==NULL || (val->flags&PV_VAL_NULL))
@@ -316,6 +324,8 @@ int pv_parse_branchx_name(pv_spec_p sp, str *in)
case 11:
if(strncmp(in->s, "send_socket", 11)==0)
sp->pvp.pvn.u.isname.name.n = 4;
+ else if(strncmp(in->s, "location_ua", 11)==0)
+ sp->pvp.pvn.u.isname.name.n = 8;
else goto error;
break;
case 5:
diff --git a/modules/pv/pv_core.c b/modules/pv/pv_core.c
index 3dda6a2..4225f21 100644
--- a/modules/pv/pv_core.c
+++ b/modules/pv/pv_core.c
@@ -1359,7 +1359,7 @@ int pv_get_branch(struct sip_msg *msg, pv_param_t *param,
return pv_get_null(msg, param, res);
- branch.s = get_branch(0, &branch.len, &q, 0, 0, 0, 0, 0, 0);
+ branch.s = get_branch(0, &branch.len, &q, 0, 0, 0, 0, 0, 0, 0);
if (!branch.s) {
return pv_get_null(msg, param, res);
}
@@ -1388,7 +1388,7 @@ int pv_get_branches(struct sip_msg *msg, pv_param_t *param,
cnt = s.len = 0;
- while ((uri.s = get_branch(cnt, &uri.len, &q, 0, 0, 0, 0, 0, 0)))
+ while ((uri.s = get_branch(cnt, &uri.len, &q, 0, 0, 0, 0, 0, 0, 0)))
{
cnt++;
s.len += uri.len;
@@ -1412,7 +1412,7 @@ int pv_get_branches(struct sip_msg *msg, pv_param_t *param,
i = 0;
p = pv_local_buf;
- while ((uri.s = get_branch(i, &uri.len, &q, 0, 0, 0, 0, 0, 0)))
+ while ((uri.s = get_branch(i, &uri.len, &q, 0, 0, 0, 0, 0, 0, 0)))
{
if (i)
{
@@ -1823,6 +1823,24 @@ int pv_get_ruid(struct sip_msg *msg, pv_param_t *param,
return pv_get_strval(msg, param, res, &msg->ruid);
}
+int pv_get_location_ua(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ if(msg==NULL)
+ return -1;
+
+ if(msg->first_line.type == SIP_REPLY)
+ return pv_get_null(msg, param, res);
+
+ if(msg->location_ua.len==0)
+ {
+ LM_DBG("no location_ua\n");
+ return pv_get_null(msg, param, res);
+ }
+
+ return pv_get_strval(msg, param, res, &msg->location_ua);
+}
+
int pv_get_tcpconn_id(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
diff --git a/modules/pv/pv_core.h b/modules/pv/pv_core.h
index 9b62d41..193185b 100644
--- a/modules/pv/pv_core.h
+++ b/modules/pv/pv_core.h
@@ -217,6 +217,9 @@ int pv_get_cnt(struct sip_msg *msg, pv_param_t *param,
int pv_get_ruid(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_location_ua(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_tcpconn_id(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);