Hi @all,
I have following problem. I have registered all my phones on OpenSER with the full number. e.g. 43 11555 1007 When one employee from one site wants to call an employee from the same site I want them only to dial 1007 not The whole number. I have following perl script, but when I use the "canonical" function, it always adds "+" in front of the number.
I get following message: canonical number in 'sip:1777@server.com' is '+43115551007'
After the execution of the perl script I want to check, if the user with 43115551007: It looks like this:
if (uri=~"sip:[0-9]+@.*") { perl_exec("canonical"); if (does_uri_exist()) { route(2); } else { #route to LCR-Module route(3); }; }
But it does not run well.
The script looks like this: ------------------------------------------------- use OpenSER::Constants; use OpenSER::Utils::PhoneNumbers;
sub canonical { my $m = shift;
if ($m->getMethod() eq "INVITE") { my $p = new OpenSER::Utils::PhoneNumbers(publicAccessPrefix => "",
internationalPrefix => "",
longDistancePrefix => "", countryCode => "43", areaCode => "11555", pbxCode => "");
my $u = $m->getRURI();
if ($u =~ m/(.*)sip:([+0-9]+)@(.*)/) { my $c = $p->canonicalForm($2); OpenSER::log(L_INFO, "canonical number in '$u' is '$c'\n"); } else { OpenSER::log(L_INFO, "Not a POTS number.\n"); } } return 1; }
Can anyone provide me some help?
Thanks
martin
Hi,
On Mittwoch 26 September 2007, Martin.Gruber1@infineon.com wrote:
when I use the "canonical" function, it always adds "+" in front of the number.
the "canonical" form includes the "+" symbol to describe the international prefix. You may simply strip this symbol after calling the canonicalForm function with a perl regexp (or any other means, if you prefer) to be compliant with your setup: $c =~ s/+//;
Best, Bastian
Well, that is running, thanks.
But how can I access the new generated number. As you can see in my dialplan I call the script and then want To check the new number, if "does_uri_exist", but it always takes the 1007 without the new prefix, etc.
Thanks
Martin
-----Original Message----- From: users-bounces@openser.org [mailto:users-bounces@openser.org] On Behalf Of Bastian Friedrich Sent: Wednesday, September 26, 2007 11:27 AM To: users@openser.org Subject: Re: [OpenSER-Users] PERL-Script - dialnumbers
Hi,
On Mittwoch 26 September 2007, Martin.Gruber1@infineon.com wrote:
when I use the "canonical" function, it always adds "+" in front of the number.
the "canonical" form includes the "+" symbol to describe the international prefix. You may simply strip this symbol after calling the canonicalForm function with a perl regexp (or any other means, if you prefer) to be compliant with your setup: $c =~ s/+//;
Best, Bastian
-- Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany p: +49 (0) 761-45684-24 f: +49 (0) 761-45684-10 www.collax.com
Geschäftsführer: William K. Hite / Boris Nalbach AG München HRB 158898 . Ust.-IdNr: DE 814464942 \ Backups? We doan *NEED* no steenking baX%^~,VbKx NO CARRIER
_______________________________________________ Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Hi,
On Mittwoch 26 September 2007, Martin.Gruber1@infineon.com wrote:
Well, that is running, thanks.
Good.
But how can I access the new generated number.
If I got you right, you want the address returned by canonicalForm to be your new recipient URI (RURI). Thus, you could/should use the "rewrite_ruri()" function in your Perl script: $m->rewrite_ruri($c);
Bastian
Thanks for your answer again. I solved it just yesterday.
But I have another question: I have telephones registered on different sites (which means with different prefix) I want e.g. users from one site only to dial 1007 instead of 43 15555 1007. This is Now running, but how should I run it, that this is on every site so.
An if somebody dials 49 82345 1004 I do not want the perl script to add the prefix.... In the openser.cfg I have first to execute the script bevor I do routing!
Thanks for help!
Regards
martin
-----Original Message----- From: Bastian Friedrich [mailto:bastian.friedrich@collax.com] Sent: Thursday, September 27, 2007 1:01 PM To: users@openser.org Cc: Gruber Martin (IFKL IT OS NV) Subject: Re: [OpenSER-Users] PERL-Script - dialnumbers
Hi,
On Mittwoch 26 September 2007, Martin.Gruber1@infineon.com wrote:
Well, that is running, thanks.
Good.
But how can I access the new generated number.
If I got you right, you want the address returned by canonicalForm to be your new recipient URI (RURI). Thus, you could/should use the "rewrite_ruri()" function in your Perl script: $m->rewrite_ruri($c);
Bastian
-- Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany p: +49 (0) 761-45684-24 f: +49 (0) 761-45684-10 www.collax.com
Geschäftsführer: William K. Hite / Boris Nalbach AG München HRB 158898 . Ust.-IdNr: DE 814464942 \ A chicken is an egg's way of producing more eggs.