Hi all,
I'd like to know if SER offers a way to register many phone numbers with just one REGISTER request. For example I've an IP gateway connected to the PBX and to the PSTN (for backup):
Phones-----> PBX--------> IP GW --------> PSTN Backup | | IP Backbone ------> SER
This PBX has a lot of phone numbers associated and a main phone number (receptionist for example). I would like to make this phone numbers registered on the proxy when the IP GW is running fine. But if the PBX has 100 numbers, the IP GW has to send 100 register requests to SER, moreover I'd like to register every 5-6 minutes so that the IP GW can use PSTN backup in case of failover of the WAN link. The problem is that I'm not sure that the IP GW will scale very well for a huge quantity of phone numbers (some customers have 700 phones numbers), and all these requests will consume bandwidth.
For the moment I've done a Perl Script running each time an IP GW register one number (the receptionist number for example) using the exec_dset function (exec_dset("/root/sip_registration.pl $SIP_HF_TO $SIP_SRCIP");).
This perl script looks into a database all the numbers related to the "receptionist" number and sends as many register information to the SER FIFO.
But I'm not very satisfied because I've to create (not yet implemented) as many temporary FIFO receipt as I receive "receptionist" register to maintain the relationship between a register request and the FIFO output (SER FIFO receipt). Moreover it's not easy to be sure that all the information passed to the FIFO have been correctly used (I'm for sure not a good programmer).
So I would like to know if there is a way in SER to do this (perhaps AVP ???) so I don't have to program a crappy perl script (see below for a first release of this perl script, if somebody know how I can create a temporary unix fifo in perl without using the system command: mkifo).
Thanks,
Rodrigue,
Here's my script:
#!/usr/bin/perl -w \
use DBI; use strict; use Fcntl;
#Database arguments
my $db = 'DBI:mysql:telephone:localhost'; my $username = 'root'; my $passwd = 'mo1000$$'; my $table = 'association';
#Error Log
my $error_log = "/var/log/sip_registration.log";
#SER FIFO arguments
my $fifo_method = "ul_add"; my $fifo_receipt = "ser_receipt_fifo"; my $fifo_table = "location"; my $fifo_expiration_timer = 60; my $fifo_qvalue = 0; my $fifo_replicate = 0; my $fifo_flags = 0;
#Get the uri and ip to register
my $uri = $ARGV[0]; my $ip = $ARGV[1];
#Get the phone number from the uri
my ($phone_number)= $uri =~ /sip:(.*)@/;
#Retrieve from database the numbers associated to the uri
my $dbh = DBI->connect($db, $username, $passwd); my $sql = qq{ SELECT associated FROM $table where initnumber='$phone_number' }; my $sth = $dbh->prepare($sql); $sth->execute;
#Bulk registration using FIFO
open(my $wr,">", "/tmp/ser_fifo");
select((select($wr), $|=1)[0]);
sysopen(my $read, "/tmp/$fifo_receipt", O_RDONLY | O_NONBLOCK); my $i=1;
my $associated_phone; $sth->bind_col(1,$associated_phone); while($sth->fetch()) { if ($associated_phone != $phone_number) { print $wr ":$fifo_method:$fifo_receipt\n$fifo_table\n$associated_phone\nsip:$associate d_phone@$ip\n$fifo_expiration_timer\ n$fifo_qvalue\n$fifo_replicate\n$fifo_flags\n" or die; my @read_fifo; while(<$read>){ $read_fifo[0]=$_; #print "$i $read_fifo[0]";
} $i++; } } #print "ASSOCIATED PHONE : $associated_phone"; # Wait till the loop see the last associated phone, the receipt FIFO has to #be completely synchronised between Input (SER FIFO) and Ouput (Temporary #receipt FIFO) , not sure that SER works in this way.
while(<$read> !~ /sip:$associated_phone@$ip/){ #DO NOTHING
} close($read); close($wr);
$sth->finish(); $dbh->disconnect();
#Return uri to STDOUT to be compliant with SER exec_dset function
print "$uri";