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

Author: Victor Seva <[email protected]>
Committer: Victor Seva <[email protected]>
Date:   Thu Sep 19 13:27:21 2013 +0200

pv: get all values for second key for xavp

---

 modules/pv/pv_xavp.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/modules/pv/pv_xavp.c b/modules/pv/pv_xavp.c
index b434794..3ba737b 100644
--- a/modules/pv/pv_xavp.c
+++ b/modules/pv/pv_xavp.c
@@ -22,9 +22,13 @@
 
 #include "../../dprint.h"
 #include "../../xavp.h"
+#include "../../pvapi.h"
 
 #include "pv_xavp.h"
 
+#define PV_FIELD_DELIM ", "
+#define PV_FIELD_DELIM_LEN (sizeof(PV_FIELD_DELIM) - 1)
+
 int pv_xavp_get_value(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res, sr_xavp_t *avp)
 {
@@ -78,6 +82,8 @@ int pv_get_xavp(struct sip_msg *msg, pv_param_t *param,
        int idxf = 0;
        int idx = 0;
        int count;
+       char *p, *p_ini;
+       int p_size;
 
        if(param==NULL)
        {
@@ -127,6 +133,40 @@ int pv_get_xavp(struct sip_msg *msg, pv_param_t *param,
        avp = xavp_get_by_index(&xname->next->name, idx, &avp->val.v.xavp);
        if(avp==NULL)
                return pv_get_null(msg, param, res);
+       /* get all values of second key */
+       if(idxf==PV_IDX_ALL)
+       {
+               p_ini = pv_get_buffer();
+               p = p_ini;
+               p_size = pv_get_buffer_size();
+               do {
+                       if(p!=p_ini)
+                       {
+                               if(p-p_ini+PV_FIELD_DELIM_LEN+1>p_size)
+                               {
+                                       LM_ERR("local buffer length 
exceeded\n");
+                                       return pv_get_null(msg, param, res);
+                               }
+                               memcpy(p, PV_FIELD_DELIM, PV_FIELD_DELIM_LEN);
+                               p += PV_FIELD_DELIM_LEN;
+                       }
+                       if(pv_xavp_get_value(msg, param, res, avp)<0)
+                       {
+                               LM_ERR("can get value\n");
+                               return pv_get_null(msg, param, res);
+                       }
+                       if(p-p_ini+res->rs.len+1>p_size)
+                       {
+                               LM_ERR("local buffer length exceeded!\n");
+                               return pv_get_null(msg, param, res);
+                       }
+                       memcpy(p, res->rs.s, res->rs.len);
+                       p += res->rs.len;
+               } while ((avp=xavp_get_next(avp))!=0);
+               res->rs.s = p_ini;
+               res->rs.len = p - p_ini;
+               return 0;
+       }
        return pv_xavp_get_value(msg, param, res, avp);
 }
 


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to