Discussion:
[SR-Users] mimic ds_select_dst with app_perl
Vik Killa
2014-09-15 17:17:18 UTC
Permalink
I like dispatcher but i need something more custom to my setup so I want to
attempt to emulate some basic behavior of dispatcher.

I have a simple perl script kamailio calls, it does a database query to get
an IP address and port similar to an item listed into the dispatcher list.

my question is how do I forward the SIP packet to the destination using the
database result query?

Here is what i have so far but it doesn't work because it's modifying the
request uri, where i just want to forward it to the FS server:

my $sth = $dbh->prepare("SELECT ip_address FROM host_machine WHERE
is_online = true ORDER BY random() LIMIT 1");
$sth->execute();
my $host_ip_address = $sth->fetchrow();
Kamailio::log(L_ERR, "Random server: " . $host_ip_address);
$m->rewrite_ruri('sip:' . $m->pseudoVar('$rU') . '@' . $host_ip_address .
':5060');
$sth->finish;


Thanks!
/V
Daniel-Constantin Mierla
2014-09-16 15:49:22 UTC
Permalink
Hello,

I don't know if perl embedded api has the option to set the dst_uri (the
equivalent of $du config variable).

If not, set the new uri in an avp and in kamailio.cfg, after executing
your perl script, do:

$du = $avp(urifromperl);

Cheers,
Daniel
Post by Vik Killa
I like dispatcher but i need something more custom to my setup so I
want to attempt to emulate some basic behavior of dispatcher.
I have a simple perl script kamailio calls, it does a database query
to get an IP address and port similar to an item listed into the
dispatcher list.
my question is how do I forward the SIP packet to the destination
using the database result query?
Here is what i have so far but it doesn't work because it's modifying
my $sth = $dbh->prepare("SELECT ip_address FROM host_machine WHERE
is_online = true ORDER BY random() LIMIT 1");
$sth->execute();
my $host_ip_address = $sth->fetchrow();
Kamailio::log(L_ERR, "Random server: " . $host_ip_address);
$host_ip_address . ':5060');
$sth->finish;
Thanks!
/V
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Loading...