[SR-Dev] git:master: pv: assignment to an avp with index '*'

Daniel-Constantin Mierla miconda at gmail.com
Fri May 15 09:29:21 CEST 2009


Module: sip-router
Branch: master
Commit: 2ce347b890d6bb9291e774c30a34e43818476876
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2ce347b890d6bb9291e774c30a34e43818476876

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri May 15 10:25:58 2009 +0300

pv: assignment to an avp with index '*'

- $(avp(name)[*]) = val; - overwrites all avps with same name
- equivalent of $avp(name) := val; in K

---

 modules_k/pv/pv_core.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules_k/pv/pv_core.c b/modules_k/pv/pv_core.c
index 0203920..2d9c914 100644
--- a/modules_k/pv/pv_core.c
+++ b/modules_k/pv/pv_core.c
@@ -1514,6 +1514,8 @@ int pv_set_avp(struct sip_msg* msg, pv_param_t *param,
 	int_str avp_val;
 	int flags;
 	unsigned short name_type;
+	int idxf;
+	int idx;
 	
 	if(param==NULL)
 	{
@@ -1521,20 +1523,28 @@ int pv_set_avp(struct sip_msg* msg, pv_param_t *param,
 		return -1;
 	}
 
+	/* get the name */
 	if(pv_get_avp_name(msg, param, &avp_name, &name_type)!=0)
 	{
 		LM_ALERT("BUG in getting dst AVP name\n");
 		goto error;
 	}
+	/* get the index */
+	if(pv_get_spec_index(msg, param, &idx, &idxf)!=0)
+	{
+		LM_ERR("invalid index\n");
+		return -1;
+	}
+
 	if(val == NULL)
 	{
-		if(op == ASSIGN_T)
+		if(idxf == PV_IDX_ALL)
 			destroy_avps(name_type, avp_name, 1);
 		else
 			destroy_avps(name_type, avp_name, 0);
 		return 0;
 	}
-	if(op == ASSIGN_T)
+	if(idxf == PV_IDX_ALL)
 		destroy_avps(name_type, avp_name, 1);
 	flags = name_type;
 	if(val->flags&PV_TYPE_INT)




More information about the sr-dev mailing list