[Kamailio-Users] rewriteuser with AVP
Samuel Muller
sml at 720.fr
Thu Nov 6 11:33:38 CET 2008
Ok,
you got the easiest way ... :)
thanks !
I used this one :
# callee is behind an ipbx (avp ipbx) ?
if (is_avp_set("$avp(s:callee_ipbx)"))
{
xlog("L_INFO", "-> user is behind an ipbx
($avp(s:callee_ipbx)), set flag ipbx and rewrite request-uri");
setflag(14); # flag IPBX
=> subst_user('/(.*)/$avp(s:callee_ipbx)/');
xlog("L_INFO", "-> verif: to-uri = $tu , request-uri =
$ru");
}
in the debug, result is the same :
Nov 6 11:32:32 ser0 kamailio[6616]: -> user is behind an ipbx (spa9000),
set flag ipbx and rewrite request-uri
Nov 6 11:32:32 ser0 kamailio[6616]: -> verif: to-uri =
sip:0123452001 at sip.720.fr <sip%3A0123452001 at sip.720.fr> , request-uri =
sip:spa9000 at sip.720.fr <sip%3Aspa9000 at sip.720.fr>
you remember to me that the pseudo-variable $rU is R/W too ...
many thanks !
.Sam.
On Wed, Nov 5, 2008 at 6:43 PM, Daniel-Constantin Mierla
<miconda at gmail.com>wrote:
> Hello,
>
> if you want to set the R-URI username with the value from the avp, then
> use:
>
> $rU = $avp(s:callee_ipbx);
>
> Cheers,
> Daniel
>
>
>
> On 11/05/08 14:16, Samuel Muller wrote:
>
>> Hello all,
>>
>> I've a little question :
>> I got a username in an AVP by avp_load_radius, and I would rewrite the uri
>> with it.
>>
>> The objectives is to replace the r-uri by an ipbx uri, then forward the
>> call to it by a new branch (to not loose the phone number requested).
>> in this case : 0123452000 is behind a spa9000. The user 0123452000 has an
>> AVP called "ipbx", that i'm using to do some groups and permissions (plus
>> the rewrite).
>>
>> actually, it does not work, i tried many ways :
>>
>> # load radius attributes of the callee
>> if (!avp_load_radius("callee"))
>> {
>> xlog("L_INFO","-> user unknown in radius usr db : $ru");
>> route(15); # route PSTN
>> }
>>
>> # verify the AVPs we got (caller and callee)
>> xlog("L_INFO", " -AVP------------------------------------- ");
>> avp_print();
>> xlog("L_INFO", " ----------------------------------------- ");
>>
>> # callee is behind an ipbx (avp ipbx) ?
>> if (is_avp_set("$avp(s:callee_ipbx)"))
>> {
>> xlog("L_INFO", "-> callee is behind an ipbx :
>> $avp(s:callee_ipbx)");
>> setflag(14); # flag IPBX
>> #subst_user('/$rU$/$avp(s:callee_ipbx)/');
>> #rewriteuri("sip:$avp(s:callee_ipbx)@$rd"**);
>> rewriteuser($avp(s:callee_ipbx));
>> }
>>
>> # callee in usrloc ?
>> if (lookup("location"))
>> {
>> append_hf("P-hint: usrloc applied\r\n");
>> xlog("L_INFO","-> registered user called : $tu");
>> route(7); # route FORWARD
>> }
>> else
>> {
>> xlog("L_INFO","-> 480: local user not found in usrloc :
>> $tu");
>> sl_send_reply("480","Temporarily Unavailable");
>> drop;
>> }
>>
>> and in the debugs log :
>>
>> Nov 5 13:04:51 ser0 kamailio[2930]:
>> -ROUTE--INBOUND--------------------------
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:avp_radius:load_avp_user: rc_auth
>> Success
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:avp_radius:load_avp_user: AVP
>> 'callee_asserted_id'/0='0123452000'/0 has been added
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:avp_radius:load_avp_user: AVP
>> 'callee_ipbx'/0='spa9000'/0 has been added
>> Nov 5 13:04:51 ser0 kamailio[2930]:
>> -AVP-------------------------------------
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> p=0x7fb3d7e5cfe8, flags=0x0003
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> ^I^I^Iname=<callee_ipbx>
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> ^I^I^Ival_str=<spa9000 / 7>
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> p=0x7fb3d7e5cf88, flags=0x0003
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> ^I^I^Iname=<callee_asserted_id>
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> ^I^I^Ival_str=<0123452000 / 10>
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> p=0x7fb3d7e5ced8, flags=0x0003
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> ^I^I^Iname=<caller_asserted_id>
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> ^I^I^Ival_str=<0123451011 / 10>
>> Nov 5 13:04:51 ser0 kamailio[2930]: INFO:avpops:ops_print_avp:
>> p=0x7fb3d7e5ce38, flags=0x0003
>> Nov 5 13:04:51 ser0 kamailio[2930]:
>> -----------------------------------------
>> Nov 5 13:04:51 ser0 kamailio[2930]: -> callee is behind an ipbx : spa9000
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:registrar:lookup: '$avp(
>> s at sip.720.fr <mailto:s at sip.720.fr>' Not found in usrloc
>> Nov 5 13:04:51 ser0 kamailio[2930]: -> 480: local user not found in
>> usrloc : sip:0123452000 at sip.720.fr <sip%3A0123452000 at sip.720.fr> <mailto:
>> sip%3A0123452000 at sip.720.fr <sip%253A0123452000 at sip.720.fr>>
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:core:parse_headers:
>> flags=ffffffffffffffff
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:core:check_via_address: params
>> 77.246.81.162 <http://77.246.81.162>, 192.168.0.134 <http://192.168.0.134>,
>> 0
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:core:destroy_avp_list: destroying
>> list 0x7fb3d7e5d040
>> Nov 5 13:04:51 ser0 kamailio[2930]: DBG:core:receive_msg: cleaning up
>>
>>
>> -> But, if I did it by :
>>
>> if (uri =~ "^sip:012345200{1}")
>> {
>> rewriteuri("sip:spa9000 at sip.720.fr<sip%3Aspa9000 at sip.720.fr><mailto:
>> sip%3Aspa9000 at sip.720.fr <sip%253Aspa9000 at sip.720.fr>>");
>> }
>> if (lookup("location"))
>> {
>> append_hf("P-hint: usrloc applied\r\n");
>> xlog("L_INFO","-> registered user called : $tu");
>> route(7); # route FORWARD
>> }
>>
>> it works great, and the call is ok (the ipbx forward correctly the request
>> the phone behind him).
>>
>>
>> Anyone has an idea ? thanks in advance !
>>
>>
>> --
>> Samuel MULLER
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.kamailio.org
>> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
>>
>>
>
> --
> Daniel-Constantin Mierla
> http://www.asipto.com
>
>
--
Samuel MULLER
Ingénieur Reseaux & Telecom
720 DEGRES
+33 (0)663 128 505
sml at 720.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/users/attachments/20081106/23abacb4/attachment.htm
More information about the Users
mailing list