[OpenSIPS-Users] opensips 2.1.2 not accepting transformation in if statement and t_relay()

Newlin, Ben Ben.Newlin at inin.com
Thu Apr 28 17:50:40 CEST 2016


Yes. I hadn’t thought about using shared variables. That would be a good way to go as well.

Ben Newlin

From: <users-bounces at lists.opensips.org<mailto:users-bounces at lists.opensips.org>> on behalf of Stefan Tobé <stefan.tobe at privatemobility.nl<mailto:stefan.tobe at privatemobility.nl>>
Reply-To: OpenSIPS users mailling list <users at lists.opensips.org<mailto:users at lists.opensips.org>>
Date: Thursday, April 28, 2016 at 11:33 AM
To: OpenSIPS users mailling list <users at lists.opensips.org<mailto:users at lists.opensips.org>>
Subject: Re: [OpenSIPS-Users] opensips 2.1.2 not accepting transformation in if statement and t_relay()

Thanks Ben,
so it is either

  1.  using shared variable ($shv(name)) which is globally available (and adaptable using MI...)     OR
  2.  re-initialize variable $var(xyz) every time in (main) route {} loop with these dashboard values?

Stefan


On Thu, Apr 28, 2016 at 3:10 PM, Newlin, Ben <Ben.Newlin at inin.com<mailto:Ben.Newlin at inin.com>> wrote:
Stefan,

$var type variable have process-level scope [1]. This means they are only valid in the same script process that initialized them. It is very likely in your case that the startup_route is running in a different child process than the message processing routes and that is causing the problem. You can add some xlog statements to check the values of the variables before using them. Xlog will print the process ID as part of the output as well so you can verify that. You can also try running OpenSIPS in foreground mode with the –F flag. This will cause it to run with only one process.

If you need multiple processes you cannot use $var for this. I would suggest looking into the local caching functionality instead [2].

[1] http://www.opensips.org/Documentation/Script-CoreVar-1-11
[2] http://www.opensips.org/Documentation/Script-CoreFunctions-1-11#toc3

Ben Newlin

From: <users-bounces at lists.opensips.org<mailto:users-bounces at lists.opensips.org>> on behalf of Stefan Tobé <stefan.tobe at gmail.com<mailto:stefan.tobe at gmail.com>>
Reply-To: OpenSIPS users mailling list <users at lists.opensips.org<mailto:users at lists.opensips.org>>
Date: Thursday, April 28, 2016 at 8:50 AM
To: "users at lists.opensips.org<mailto:users at lists.opensips.org>" <users at lists.opensips.org<mailto:users at lists.opensips.org>>
Subject: [OpenSIPS-Users] opensips 2.1.2 not accepting transformation in if statement and t_relay()

Hi there,
I am trying to sanitize the opensips script by using a script 'dashboard' in the beginning of the script (using  startup_route)

I face two problems here (opensips script errors)
problem 1: $var(uriqp) should be the uri-string in order to use that in t_relay() which is rejected
problem 2: completing IF statement where src_ip should be compared to transformed (to binary) ip address  and source port is both rejected

Can somebody explain

  1.  what the correct uri string for use in t_relay() would need to be ? (just entering t_relay("udp:10.130.2.4:5060<http://10.130.2.4:5060>") works fine)
  2.  what the correct way of transformation I need to use in order to have this IF statement accepted?

thanks

Stefan Tobé



####### Routing Logic ########
startup_route {
    ####### Local Parameters / Dashboard #########
        $var(qpip)=   "10.130.2.4";
        $var(qpprt)=  "5090";
#         $var(qpprt)=  5090;

    $var(uriqp)=  "udp:"+$var(qpip)+":"+$var(qpprt);


}


route{

if (src_ip == $(var(qpip){ip.pton}) && src_port == $var(qpprt)) {       (=> won't accept regardless whether $var(qpprt)=  "5090" or $var(qpprt)=  5090)
    # code here
    route(sbc);
}
else ....
}

route[qp] {

    if (!t_relay($var(uriqp)) {
        send_reply("500","Internal Error");
    }
    exit;
}

--
mvg
Stefan Tobé


_______________________________________________
Users mailing list
Users at lists.opensips.org<mailto:Users at lists.opensips.org>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




--
mvg
Stefan Tobé


Private Mobility Nederland B.V.
Bolderweg 2
1332 AT Almere
tel: 06 21 26 59 68
email: stefan.tobe at privatemobility.nl<mailto:stefan.tobe at privatemobility.nl>
internet: www.privatemobility.nl<http://www.privatemobility.nl>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20160428/be612a1b/attachment-0001.htm>


More information about the Users mailing list