Hello,

On 29/10/15 09:40, Jonathan Hunter wrote:
Sorry Daniel, missed off list!

Hi Daniel,

Great thanks for that response, I have been working with AVPs and Im almost there.

I will certainly check out the jansson module, is that new to 4.3 as Im currently on 4.2?

iirc, is in 4.3, but probably works to just take the module and run it through 4.2 instance.


In terms of AVPs, if you have an array structure in place, I appreciate it pushes entries up the stack, but can you set a specific index value to an AVP?

You will need to do copy operations using different names if you use AVPs. If you use XAVPs, then you can set a value using index directly.


As I basically want to move the first entry in the Array and move it to  the end, ie I have;

$(avp(Pgrp1)[0]);
$(avp(Pgrp1)[1]);
$(avp(Pgrp1)[2]);

Can I swap [0] with [2] without setting  entries to null and rebuilding the avp from scratch?
Not with avp, but with xavp -- you can just add x in front of those avps in your config file.

Cheers,
Daniel

Thanks

Jon


To: sr-users@lists.sip-router.org
From: miconda@gmail.com
Date: Wed, 28 Oct 2015 15:39:15 +0100
Subject: Re: [SR-Users] Multi-Array with AVPs

Hello,

when adding an xavp structure, use:

$xavp(a=>b) = "...";

Now, adding another fieldx to the structure:

$xavp(a[0]=>c) = "...";
$xavp(a[0]=>d) = "...";

Pushing another new structure means starting from beginning:

$xavp(a=>b) = "...";

The previous structure will be available at index 1:

$xavp(a[1]=>b) = "...";

As alternative, maybe it is easier to return (or pack) all those attributes in a json document and then use jansson module to navigate through it via json-path mechanism.

Cheers,
Daniel

On 24/10/15 21:38, Jonathan Hunter wrote:
Hi Alex and guys,

Are there any further examples of XAVPs used in this manner?

So associate a number of variables by another variable?

I am trying with a number of scenarios but the penny is  yet to drop!

Sorry!

Jon


 
From: hunterj91@hotmail.com
To: sr-users@lists.sip-router.org
Date: Fri, 23 Oct 2015 17:13:47 +0000
Subject: [SR-Users] Multi-Array with AVPs

Alex,

Thanks for the fast response!

I dont like hard mode, my lifes tough enough :)

Will try the XAVPs.

Thanks

Jon

> To: sr-users@lists.sip-router.org
> From: abalashov@evaristesys.com
> Date: Fri, 23 Oct 2015 13:07:27 -0400
> Subject: Re: [SR-Users] Multi-Array with AVPs
>
> Jon,
>
> For complex, nonscalar structures where members can be other AVP
> nonscalars, you might wish to consider XAVPs instead:
>
> http://www.kamailio.org/wiki/cookbooks/4.3.x/pseudovariables#xavp_id_-_xavps
>
> Otherwise, you're playing life on hard mode. ;-)
>
> -- Alex
>
> On 10/23/2015 01:00 PM, Jonathan Hunter wrote:
>
> > Hi Guys,
> >
> > Hope all are well?
> >
> > sorry to post but Im just trying to get something working where Im
> > trying to convert a php function script into the kamailio.cfg.
> >
> > Im getting there but wonder how I can group results of sets of avps with
> > another avp.
> >
> > Say I have these variables;
> >
> > $(avp(NTgrp)) =
> > 'SB100_000361@1.2.3.4|SB100_000213@1.2.3.5|SB100_000225@1.2.3.6|SB100_000361@1.2.3.7|SB100_000213@1.2.3.8';
> > $(avp(Prio)) = '1|1|1|2|2';
> > $(avp(Wgt)) = '10000|10000|80000|30000|70000';
> > $(avp(CInc)) = '0|0|1|0|1';
> > $(avp(WTot))= '100000|100000|100000|100000|100000';
> > I then run a while script to split up their variables via the delimiter
> > | in user;
> >
> > $var(j)=0;
> > while($var(j)<$var(count)) {
> > $(avp(NTgrpP))=$(avp(NTgrp){s.select,$var(j),|});
> > $(avp(PrioP))=$(avp(Prio){s.select,$var(j),|});
> > $(avp(WgtP))=$(avp(Wgt){s.select,$var(j),|});
> > $(avp(CIncP))=$(avp(CInc){s.select,$var(j),|});
> > $(avp(WTotP))=$(avp(WTot){s.select,$var(j),|});
> > xlog("L_INFO"," Now Each time we have $(avp(NTgrpP)) $(avp(PrioP))
> > $(avp(WgtP)) $(avp(CIncP)) $(avp(WTotP))\n");
> > $var(j)=$var(j)+1;
> > }
> >
> > This then results in;
> > INFO: <script>: Now Each time we have SB100_000223@1.2.3.4 1 10000 0 100000
> > INFO: <script>: Now Each time we have SB100_000225@1.2.3.5 1 10000 0 100000
> > INFO: <script>: Now Each time we have SB100_000386@1.2.3.6 1 80000 0 100000
> > INFO: <script>: Now Each time we have SB100_000213@1.2.3.7 2 30000 0 100000
> > INFO: <script>: Now Each time we have SB100_000361@1.2.3.8 2 70000 0 100000
> >
> > Now what Id like to do is group them via priorities so I can do some
> > further functional checks on them when in same priority group, as you
> > can see there are 3 results at priority 1 and 2 at priority 2.
> >
> > Is there away I can create something of a multi-array using the AVP
> > $(avp(PrioP)) I just created so I can group by priority?
> >
> > As in php I would do something like;
> >
> > $multi_arr[$prio_arr[$p]][] = array(
> > "ntgrp" => $ntgrp_arr[$p],
> > "prio" => $prio_arr[$p],
> > "wght" => $wght_arr[$p],
> > "cinc" => $cinc_arr[$p],
> > "wtot" => $wtot_arr[$p],
> > );
> > }
> >
> > Any help would be great.
> >
> > Many thanks
> >
> > Jon
> >
> >
> >
> > _______________________________________________
> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> > sr-users@lists.sip-router.org
> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
> >
>
>
> --
> Alex Balashov | Principal | Evariste Systems LLC
> 303 Perimeter Center North, Suite 300
> Atlanta, GA 30346
> United States
>
> Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct)
> Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users@lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com
Kamailio Advanced Training, Nov 30-Dec 2, Berlin - http://asipto.com/kat

_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com
Kamailio Advanced Training, Nov 30-Dec 2, Berlin - http://asipto.com/kat