Implementing routing and failure using perl

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Implementing routing and failure using perl

symack
Hello Everyone,

We use dr (ie, do_routing), and failure (ie, use_next_gw()) in our
opensips configuration. Now we are trying to migrate certain
functionality to our perl script where we do some processing on the
INVITEs.

My question is which predefined OpenSIPS perl functions do we have the
will allow us to implement the same routing and failover functionality
that we currently have using OpenSIPS script. More specifically, what
Perl functions do we have to implement relaying and failover. As
mentioned earlier, we do use DR so our dr_rules/gateways tables are
populated.

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Implementing routing and failure using perl

Ali Pey
Hello,

When you use perl, you would have to implement your own logic and you can't use the dynamic routing or load balancer module from inside your perl script. You must be thinking of something similar to ESL in freeswitch or AGI in asterisk and that's not here.

Regards,
Ali


On Tue, Dec 3, 2013 at 12:17 PM, Nick Cameo <[hidden email]> wrote:
Hello Everyone,

We use dr (ie, do_routing), and failure (ie, use_next_gw()) in our
opensips configuration. Now we are trying to migrate certain
functionality to our perl script where we do some processing on the
INVITEs.

My question is which predefined OpenSIPS perl functions do we have the
will allow us to implement the same routing and failover functionality
that we currently have using OpenSIPS script. More specifically, what
Perl functions do we have to implement relaying and failover. As
mentioned earlier, we do use DR so our dr_rules/gateways tables are
populated.

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Implementing routing and failure using perl

symack
Hello Ali,

Thank your for your response. Yes I was inquiring about a OpenSIPS
perl API (use OpenSIPS). The only thing is I cannot find any API
documentation in terms of what implementation is available. Only
complex examples that I am looking into right now. With that said,
what I am working on initially is not that complicated.

For every INVITE:

1) Extract the TO info (substring first 3/4 digits)
2) Query the databases for all prefixes that LIKE the substring of the
TO number order by price
3) do_routing (or whatever) for the first record in the result set.
Failing over to the next etc..

Kind Regards,

Nick from Toronto.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Implementing routing and failure using perl

Ali Pey
Hello Nick,

(Since you are from Toronto, I looked that up for you. I'm from Ottawa)

It's fairly simple. In your perl code, you do lookup $rU and then set some flag. Then back in your opensips route, you can examine this flag and route accordingly. I don't think you can return a result set to your opensips route.

sub check_number {
my $m = shift;
my $snumber = get_snumber( $m );
        my $called = $m->pseudoVar( '$rU' );

if ( $called ne '' ) {
my $p = select_row( 'select number from numbers where number=' . quote( $called ) . ' limit 1' );
if ( defined $p && $p->{ 'number' } ne '' ) {
$m->setFlag( 7 );
return 1;
}
}

$m->resetFlag( 7 );
return 1;
}


Regards,
Ali Pey


On Tue, Dec 3, 2013 at 12:45 PM, Nick Cameo <[hidden email]> wrote:
Hello Ali,

Thank your for your response. Yes I was inquiring about a OpenSIPS
perl API (use OpenSIPS). The only thing is I cannot find any API
documentation in terms of what implementation is available. Only
complex examples that I am looking into right now. With that said,
what I am working on initially is not that complicated.

For every INVITE:

1) Extract the TO info (substring first 3/4 digits)
2) Query the databases for all prefixes that LIKE the substring of the
TO number order by price
3) do_routing (or whatever) for the first record in the result set.
Failing over to the next etc..

Kind Regards,

Nick from Toronto.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Implementing routing and failure using perl

symack
Ali!!! Thank you, I will post the final script on here when it's done.
I have seen that there are a number of people looking to implement LCR
on here.

PS Technically speaking, I venture quite often between Montreal
(McGill student in CS) and Toronto.

Did you guys get dumped on the past few days?

Kind Regards,

Nick.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users