[OpenSIPS-Users] call forwarding with replace from uri

Bogdan-Andrei Iancu bogdan at opensips.org
Wed Feb 2 13:28:28 CET 2011


Hi Jesse,

Lost me a bit between those pieces of script.

Anyhow, as far I understood from your problem, you want to change the 
FROM URI in order to use the new value later in the script (in the auth 
part). Well, this does not work - in opensips, the changes you do over 
the message are not visible until the message is sent out. So you cannot 
use your own changes later in script.

To avoid this issue, you can use a variable to store the "correct" value 
of the FROM URI ($fu directly or the value from DB) - later in script, 
use for auth (or other purposes) this variable in order to deal with the 
FROM URI value (the right one).

Regards,
Bogdan

Jesse Cloutier wrote:
> Hi list,
>
> I having trouble with my script when trying to call forward by 
> reseting the $ru and doing a route(1)
>
> My problem seems to be coming from the fact that I am changing my $fu 
> with uac_replace_from. When I xlog the $fu right before the route() It 
> shows the correct value (the original $fu before it was changed by 
> uac_replace_from). But on the request to the forwarded number it tries 
> to authenticate the user using the new value (the value that 
> uac_replace_from put in)
>
> If I don't replace the $fu everything works fine.
>
> Thanks A lot for any help!!
>
> here is the relavant parts of my script:
>
> Replacing the uri in the original request:
>
>  if (is_avp_set("$avp(s:uri)")) {
>                         if (is_avp_set("$avp(s:fromname)")) {
>                                 xlog("L_INFO","Fromname set to 
> $avp(s:fromname) and URI set to $avp(s:uri)");
>                                 
> uac_replace_from("$avp(s:fromname)","$avp(s:uri)");
>                         } else {
>                                 uac_replace_from("","$avp(s:uri)");
>                                 xlog("L_INFO","Only Fromname Set");
>                         }
>                 }
>
>
> The fowrwarding:
>
>  if(avp_db_load("$ru","$avp(s:unavailcallfwd)")) {
>                                           #xlog("call forward is set 
> to: $avp(s:unavailcallfwd)");
>                                           
> avp_pushto("$ru","$avp(s:unavailcallfwd)");
>                                           xlog("call forward is set 
> to: $ru from $fu");
>
>                                           route(1);
>
>                                           exit;
> }
>
>
> And the proxy authorize
>
>
>         xlog("Checking if we should attempt authentication on $fu");
>         if (!(method=="REGISTER"))
>         {
>                 #Do not authenticate calls from the gateways
>                 xlog("Checking if its from a gateway");
>                 if(!is_from_gw()) # This check is from the drouting module
>                 {
>                         xlog("Checking if it is an IP Authed IP");
>                         if(!check_source_address("0", "$avp(i:9)")) 
> #This check looks in the address table
>                         {
>                                 xlog("Checking if it is a subscriber");
>
>                                 xlog("from is $fu");
>
>                                 if (!proxy_authorize("", "subscriber")) {
>                                         proxy_challenge("", "0");
>                                         xlog("Sent proxy challange to 
> $fu");
>                                         exit;
>                                 }
>                                 if (!db_check_from()) {
>                                         sl_send_reply("403","Forbidden 
> auth ID");
>                                         exit;
>                                 }
>
>                         }
>             }
>         }
>
>
> -- 
> Jesse Cloutier
> Network Administrator
> Cronomagic Canada
> 5143411579 x210
> jesse at cronomagic.com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   


-- 
Bogdan-Andrei Iancu
OpenSIPS Event - expo, conf, social, bootcamp
2 - 4 February 2011, ITExpo, Miami,  USA
OpenSIPS solutions and "know-how"




More information about the Users mailing list