[Kamailio-Users] avp

Alex Balashov abalashov at evaristesys.com
Mon Nov 9 14:41:16 CET 2009


Anders,

The strip() and prefix() core functions operate on the Request URI, 
which can be accessed via the pseudovariable $ru.  Its user part is 
$rU, the domain part is $rd, and the port is $rp.  To copy the user 
part of the Request URI into an AVP after manipulation, you can simply 
assign its current value:

    $avp(s:user_ip_tag) = $rU;

I'm guessing this (user part) is what you intended to do.

However, it is not necessary to import data into the Request URI for 
purposes of manipulation.  Kamailio has something called transformations:

    http://www.kamailio.org/dokuwiki/doku.php/transformations:1.5.x

For your purposes, you may think of these as something kind of like 
object-oriented string manipulation functions.  These can operate on 
any scalar string value, e.g.

   $(avp(s:user_ip_tag){s.len})
   $avp(s:user_ip_tag) = $(rU{s.substr,1,5});

In order to obtain the data you want you can simply use those.

Cheers,

-- Alex

Anders wrote:

> Hi all,
> 
> Here I am - back with more "Kamailio 101"-questions! ;-)
> 
> I need to strip the first character from the uri and write this to the
> 'acc' table. What I'm doing so far in kamailio.cfg is:
> 
> modparam("acc", "db_extra", "............., $avp(s:user_ip_tag)");
> 
> So I've added the avp-thing in that line. And independently I've
> created a new column in the 'acc' table called "user_ip_tag".
> 
> If the above is correct, my next step is to write something to this
> variable. In the routing, I have this:
> 
> 	if (uri=~"^sip:[1-9]00*")
> 		{
> 
> do_something_here_to_take_first_character_of_the_uri_and_put_to_avp...but_how?
> 			strip(1);
> 		}
> 
> What I want to do, is to take the 1-9 digit, if it starts with that
> and has to zeroes after, and put that to the avp - and the strip it
> off before I move on in the routing.
> 
> Yes, I have browsed the documentation, but I'm not sharp enough to
> understand it, it seems. (or alternatively, the documentation is not
> made for beginners).
> 
> Thanks!
> 
> _______________________________________________
> Kamailio (OpenSER) - Users mailing list
> Users at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users


-- 
Alex Balashov - Principal
Evariste Systems
Web     : http://www.evaristesys.com/
Tel     : (+1) (678) 954-0670
Direct  : (+1) (678) 954-0671



More information about the Users mailing list