Matt,<div>I'd recommend writing a custom module using libcurl.</div><div><br></div><div>One other thought, if you are flexible in your service offering you might be able to do something useful with db_http.</div><div>-Brett</div>
<div><br></div><div><br><br><div class="gmail_quote">On Thu, Nov 4, 2010 at 9:37 PM, Matt Smith <span dir="ltr"><<a href="mailto:msmith@bulkcnam.com">msmith@bulkcnam.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello List,<br>
<br>
I have a few carrier clients who are looking to use our CNAM (Caller<br>
ID Name) service, and seeking to do lookup directly on OpenSIPS,<br>
rather on the switch sitting behind the SIP router.<br>
<br>
We've provided our clients the following script snippets that uses the<br>
PERL module to perform the necessary HTTP lookup and set an AVP that<br>
will be used to change the Caller ID name with "uac_replace_from"<br>
function.<br>
<br>
Can anyone suggest a better of doing the lookup and changing the<br>
Caller ID Name? Is there a way to perform the HTTP lookup directly<br>
from the OpenSIPS script? Also, how can we set a timeout on Opensips<br>
to give up on the Perl script if no response is received after let's<br>
say 1000ms, and return to regular routing?<br>
<br>
Here's our OpenSIPS script snippet:<br>
<br>
modparam("perl", "modpath", "/usr/lib/opensips/perl/")<br>
modparam("perl", "filename", "/etc/opensips/<a href="http://bulkcnam.pl" target="_blank">bulkcnam.pl</a>")<br>
<br>
route {<br>
if (method == "INVITE") {<br>
route(6);<br>
return;<br>
}<br>
}<br>
<br>
route[6] {<br>
perl_exec("cnamgetname");<br>
uac_replace_from("$avp(i:201)","");<br>
avp_delete("*");<br>
// Continue Routing...<br>
}<br>
<br>
<a href="http://bulkcnam.pl" target="_blank">bulkcnam.pl</a> File:<br>
<br>
use OpenSIPS qw ( log );<br>
use OpenSIPS::Constants;<br>
use IO::Socket;<br>
use HTTP::Request;<br>
use LWP::UserAgent;<br>
<br>
sub cnamgetname {<br>
my $m = shift;<br>
$number = $m->getHeader(qw ( From));<br>
$number = test('sip:(.*?)\@', $number);<br>
my $server = "<a href="http://cnamserverIP/?id=BulkCNAM-ID-here&did=" target="_blank">http://cnamserverIP/?id=BulkCNAM-ID-here&did=</a>";<br>
$request = HTTP::Request->new( GET => $server.$number );<br>
$ua = LWP::UserAgent->new;<br>
$response = $ua->request($request);<br>
if ($response->is_success) {<br>
$name = $response->content;<br>
}<br>
OpenSIPS::AVP::add(201,$name);<br>
<br>
return 1;<br>
}<br>
<br>
sub test($$)<br>
{<br>
my $lookfor = shift;<br>
my $string = shift;<br>
if($string =~ m/$lookfor/)<br>
{ return $1 }<br>
}<br>
<br>
<br>
Thanks,<br>
<br>
Matt S.<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div><br></div>