Module: sip-router
Branch: pd/outbound
Commit: b53624e388c283ae1294bf595af123c3b77f6b93
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b53624e…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Thu Mar 14 23:55:14 2013 +0000
modules/pv: added new $ruid and $branch(ruid) PVs
---
modules/pv/pv.c | 3 +++
modules/pv/pv_branch.c | 12 +++++++++++-
modules/pv/pv_core.c | 15 +++++++++++++++
modules/pv/pv_core.h | 3 +++
4 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/modules/pv/pv.c b/modules/pv/pv.c
index 3d2f01c..4ea5cc6 100644
--- a/modules/pv/pv.c
+++ b/modules/pv/pv.c
@@ -410,6 +410,9 @@ static pv_export_t mod_pvs[] = {
{{"ua", (sizeof("ua")-1)}, /* */
PVT_OTHER, pv_get_useragent, 0,
0, 0, 0, 0},
+ {{"ruid", (sizeof("ruid")-1)}, /* */
+ PVT_OTHER, pv_get_ruid, 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 9ae5be3..b292e31 100644
--- a/modules/pv/pv_branch.c
+++ b/modules/pv/pv_branch.c
@@ -40,6 +40,7 @@ int pv_get_branchx(struct sip_msg *msg, pv_param_t *param,
str path;
unsigned int fl = 0;
struct socket_info* fsocket = NULL;
+ str ruid;
/* get the index */
if(pv_get_spec_index(msg, param, &idx, &idxf)!=0)
@@ -48,7 +49,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, 0);
+ uri.s = get_branch(idx, &uri.len, &lq, &duri, &path, &fl,
&fsocket, &ruid);
/* branch(count) doesn't need a valid branch, everything else does */
if(uri.s == 0 && ( param->pvn.u.isname.name.n != 5/* count*/ ))
@@ -79,6 +80,10 @@ int pv_get_branchx(struct sip_msg *msg, pv_param_t *param,
return pv_get_uintval(msg, param, res, nr_branches);
case 6: /* flags */
return pv_get_uintval(msg, param, res, fl);
+ case 7: /* ruid */
+ if(ruid.len==0)
+ return pv_get_null(msg, param, res);
+ return pv_get_strval(msg, param, res, &ruid);
default:
/* 0 - uri */
return pv_get_strval(msg, param, res, &uri);
@@ -245,6 +250,9 @@ int pv_set_branchx(struct sip_msg* msg, pv_param_t *param,
}
br->flags = val->ri;
break;
+ case 7: /* ruid */
+ /* do nothing - cannot set the ruid */
+ break;
default:
/* 0 - uri */
if(val==NULL || (val->flags&PV_VAL_NULL))
@@ -296,6 +304,8 @@ int pv_parse_branchx_name(pv_spec_p sp, str *in)
case 4:
if(strncmp(in->s, "path", 4)==0)
sp->pvp.pvn.u.isname.name.n = 2;
+ else if (strncmp(in->s, "ruid", 4)==0)
+ sp->pvp.pvn.u.isname.name.n = 7;
else goto error;
break;
case 1:
diff --git a/modules/pv/pv_core.c b/modules/pv/pv_core.c
index 99ae3d2..9c90902 100644
--- a/modules/pv/pv_core.c
+++ b/modules/pv/pv_core.c
@@ -1804,6 +1804,21 @@ int pv_get_cnt(struct sip_msg *msg, pv_param_t *param,
return pv_get_uintval(msg, param, res, n);
}
+int pv_get_ruid(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ if(msg==NULL)
+ return -1;
+
+ if(msg->ruid.len==0)
+ {
+ LM_DBG("no ruid\n");
+ return pv_get_null(msg, param, res);
+ }
+
+ return pv_get_strval(msg, param, res, &msg->ruid);
+}
+
/********* end PV get functions *********/
diff --git a/modules/pv/pv_core.h b/modules/pv/pv_core.h
index a8d36bb..a51349f 100644
--- a/modules/pv/pv_core.h
+++ b/modules/pv/pv_core.h
@@ -214,6 +214,9 @@ int pv_get_server_id(struct sip_msg *msg, pv_param_t *param,
int pv_get_cnt(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_ruid(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
/********* end PV get functions *********/
/********* start PV set functions *********/