[SR-Users] How to install the PHONENUM module?

Daniel-Constantin Mierla miconda at gmail.com
Mon Apr 20 15:25:47 CEST 2020


Try:


if($phn(src=>ccname) =~ "GB|FR") {


The =~ operator is for regex matching, left side is used as a string to
match against the right side value used as a regular expression.


Cheers,
Daniel


On 20.04.20 14:25, Edward Romanenco wrote:
> Last question, what's the easiest way to check if a country-name
> exists in a list of given countries?
>
> For example, if I want to have a certain logic for GB or FR, can I use
> something similar to the following?
>
> if($phn(src=>ccname) == GB|FR) {
> ...
> ...
> ...
> }
>
> Edward
> ------------------------------------------------------------------------
> *From:* Edward Romanenco <edward at telemessage.com>
> *Sent:* Monday, April 20, 2020 2:52 PM
> *To:* Kamailio (SER) - Users Mailing List
> <sr-users at lists.kamailio.org>; sr-users at lists.sip-router.org
> <sr-users at lists.sip-router.org>; miconda at gmail.com <miconda at gmail.com>
> *Subject:* Re: [SR-Users] How to install the PHONENUM module?
>  
> Never-mind, I knew I was missing something, CCNAME is what I was
> looking for.
>
> Edward
> ------------------------------------------------------------------------
> *From:* Edward Romanenco <edward at telemessage.com>
> *Sent:* Monday, April 20, 2020 2:31 PM
> *To:* Kamailio (SER) - Users Mailing List
> <sr-users at lists.kamailio.org>; sr-users at lists.sip-router.org
> <sr-users at lists.sip-router.org>; miconda at gmail.com <miconda at gmail.com>
> *Subject:* Re: [SR-Users] How to install the PHONENUM module?
>  
> The phonenum_match_cn(num, cnc, pvc) method doesn't help me much, as I
> want to be able to pull the country name instead of giving it on my own.
>
> Edward
> ------------------------------------------------------------------------
> *From:* Edward Romanenco <edward at telemessage.com>
> *Sent:* Monday, April 20, 2020 2:26 PM
> *To:* Kamailio (SER) - Users Mailing List
> <sr-users at lists.kamailio.org>; sr-users at lists.sip-router.org
> <sr-users at lists.sip-router.org>; miconda at gmail.com <miconda at gmail.com>
> *Subject:* Re: [SR-Users] How to install the PHONENUM module?
>  
> Thank you Daniel! I was able to install the library, finally. You are
> a lifesaver.
>
> My first and foremost motivation for using this module is to extract
> the country name from the number, the ndesc value of the phn variable
> gives me that... sometimes.
> For example +442033202609 returns London when queried using this
> module, while +972779211923 returns Israel.
>
> Is there any way to always show the country name? Maybe a key that I'm
> missing?
>
> Edward
> ------------------------------------------------------------------------
> *From:* Daniel-Constantin Mierla <miconda at gmail.com>
> *Sent:* Monday, April 20, 2020 1:34 PM
> *To:* Edward Romanenco <edward at telemessage.com>; Kamailio (SER) -
> Users Mailing List <sr-users at lists.kamailio.org>;
> sr-users at lists.sip-router.org <sr-users at lists.sip-router.org>
> *Subject:* Re: [SR-Users] How to install the PHONENUM module?
>  
>
> Use also "make install" inside kamailio source tree to deploy the
> module, rather than manual copy.
>
>
> Then, be sure that the location of libphonenumber library is in the
> path for linker and also run a 'ldconfig' to rebuild ld cache.
>
>
> Otherwise, it would be recommended to use the available packages, when
> available and they are ok to compile kamailio, in case you are not
> that familiar to tune the system options to make everything work when
> compiling sources.
>
>
> Cheers,
> Daniel
>
>
> On 20.04.20 12:22, Edward Romanenco wrote:
>> Awesome, trying Make Install on the libphonenumber source did help me
>> to complete the phonenum.so build, I've copied it into the
>> lib64/kamailio/modules and added it into my config file.
>>
>> But... the Kamailio service fails to start now. I'm getting the
>> following error logs:
>> Apr 20 13:00:35 kamaillioegress kamailio[920]: ERROR: <core>
>> [core/sr_module.c:582]: load_module(): could not open module
>> </usr/local/kamailio-5.1/lib64/kamailio/modules/phonenum.so>:
>> libphonenumber.so.8: cannot open shared object file:
>> Apr 20 13:00:35 kamaillioegress kamailio[920]: CRITICAL: <core>
>> [core/cfg.y:3488]: yyerror_at(): parse error in config file
>> /usr/local/kamailio-5.1/etc/kamailio/kamailio.cfg, line 241, column
>> 12-24: failed to load module
>>
>> Did anyone meet with this error before?
>> Should I even bother with building the libphonenumber sources, or
>> maybe switch to the 'libphonenumber7' package that seems to be
>> available for installation on my Ubuntu machine?
>>
>> Edward
>>
>> ------------------------------------------------------------------------
>> *From:* Daniel-Constantin Mierla <miconda at gmail.com>
>> <mailto:miconda at gmail.com>
>> *Sent:* Monday, April 20, 2020 12:19 PM
>> *To:* Edward Romanenco <edward at telemessage.com>
>> <mailto:edward at telemessage.com>; Kamailio (SER) - Users Mailing List
>> <sr-users at lists.kamailio.org> <mailto:sr-users at lists.kamailio.org>;
>> sr-users at lists.sip-router.org <mailto:sr-users at lists.sip-router.org>
>> <sr-users at lists.sip-router.org> <mailto:sr-users at lists.sip-router.org>
>> *Subject:* Re: [SR-Users] How to install the PHONENUM module?
>>  
>>
>>
>> On 20.04.20 08:47, Edward Romanenco wrote:
>>>
>>> Ubuntu 16.04, doesn't seem like it, any idea on how should I be
>>> verifying it?
>>>
>>
>> Did you wanted to say that "doesn't seem to have it"? Referring to
>> libphonenumber? Use "apt-cache search" to find out what packages are
>> available. Ubuntu 16.04 is quite old, so I am not sure what is
>> available there.
>>
>>>  
>>>
>>> As for the installation, I followed the process as it was written in
>>> their README page, what additional steps should I take to finalize
>>> the installation?
>>>
>>
>> I installed it from packages so far, but with the usual unix/linux
>> way there should be a "make install" for proper installation.
>>
>> Cheers,
>> Daniel
>>
>>
>>>  
>>>
>>> Edward
>>>
>>>  
>>>
>>> *מאת: *Daniel-Constantin Mierla <mailto:miconda at gmail.com>
>>> *נשלח: *יום שני 20 אפריל 2020 09:45
>>> *אל: *Kamailio (SER) - Users Mailing List
>>> <mailto:sr-users at lists.kamailio.org>; Edward Romanenco
>>> <mailto:edward at telemessage.com>; sr-users at lists.sip-router.org
>>> <mailto:sr-users at lists.sip-router.org>
>>> *נושא: *Re: [SR-Users] How to install the PHONENUM module?
>>>
>>>  
>>>
>>> Hello,
>>>
>>>  
>>>
>>> what operating system do you use? Isn't the libphonenumber packaged
>>> there? Should be easier if you install from packages.
>>>
>>>  
>>>
>>> Otherwise, have you installed the libphonenumber in the system? The
>>> commands shown suggest only compilation and testing in the source
>>> code library.
>>>
>>>  
>>>
>>> On the other hand, not that kamailio 5.1 is out of maintenance time
>>> frame, you better start with 5.3 at this moment.
>>>
>>>  
>>>
>>> Cheers,
>>> Daniel
>>>
>>>  
>>>
>>> On 19.04.20 17:46, Edward Romanenco wrote:
>>>
>>>     Hi, I'm trying to add the PHONENUM module into my Kamailio
>>>     installation. For this, I've cloned the main branch of
>>>     Libphonenumber
>>>     <https://github.com/google/libphonenumber/tree/master/cpp> and
>>>     followed the installation rules as they appear in the relevant
>>>     README file:
>>>
>>>     /Building and testing the library/
>>>
>>>     /--------------------------------/
>>>
>>>     /  $ cd libphonenumber/cpp/
>>>
>>>     /  $ mkdir build/
>>>
>>>     /  $ cd build/
>>>
>>>     /  $ cmake ../
>>>
>>>     /  $ make/
>>>
>>>     /  $ ./libphonenumber_test/
>>>
>>>      
>>>
>>>     It all went through and the library was created, but when I try
>>>     to make and install the module itself, I'm getting the following
>>>     error. Looks like the library wasn't included in the building
>>>     context, can you please lend me a hand and tell me how do I
>>>     include it?
>>>
>>>      
>>>
>>>     /root at kamaillioegress:/usr/local/src/kamailio-5.1/kamailio/src/modules/phonenum#
>>>     <mailto:root at kamaillioegress:/usr/local/src/kamailio-5.1/kamailio/src/modules/phonenum>
>>>     make/
>>>
>>>     /Compiling cphonenumber.cpp/
>>>
>>>     /g++ -fPIC -DPIC -g -funroll-loops -Wcast-align -m64
>>>     -minline-all-stringops -falign-loops -ftree-vectorize
>>>     -fno-strict-overflow -Wall -Wno-write-strings -Wno-deprecated
>>>     -Wno-unused-function -Wno-sign-compare -Wno-strict-aliasing
>>>     -fPIC -DPIC -g -funroll-loops -Wcast-align -m64
>>>     -minline-all-stringops -falign-loops -ftree-vectorize
>>>     -fno-strict-overflow -Wall  -DNAME='"kamailio"'
>>>     -DVERSION='"5.2.0-dev6"' -DARCH='"x86_64"' -DOS='linux_'
>>>     -DOS_QUOTED='"linux"' -DCOMPILER='"gcc 5.4.0"' -D__CPU_x86_64
>>>     -D__OS_linux -DVERSIONVAL=5002000
>>>     -DCFG_DIR='"/usr/local/kamailio-5.1/etc/kamailio/"'
>>>     -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MEM
>>>     -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE
>>>     -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER
>>>     -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE
>>>     -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS
>>>     -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS
>>>     -DWITH_AS_SUPPORT -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT
>>>     -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM
>>>     -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD
>>>     -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H
>>>     -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DHAVE_IP_MREQN
>>>     -DUSE_RAW_SOCKS -DHAVE_EPOLL -DHAVE_SIGIO_RT
>>>     -DSIGINFO64_WORKARROUND -DUSE_FUTEX -DHAVE_SELECT
>>>      -I/opt/local/include -DKAMAILIO_MOD_INTERFACE
>>>     -DMOD_NAME='"phonenum"' -c cphonenumber.cpp -o cphonenumber.o/
>>>
>>>     /cphonenumber.cpp:24:65: fatal error:
>>>     phonenumbers/geocoding/phonenumber_offline_geocoder.h: No such
>>>     file or directory/
>>>
>>>     /compilation terminated./
>>>
>>>     /Makefile:22: recipe for target 'cphonenumber.o' failed/
>>>
>>>     /make: *** [cphonenumber.o] Error 1/
>>>
>>>      
>>>
>>>     Edward
>>>
>>>
>>>
>>>     _______________________________________________
>>>
>>>     Kamailio (SER) - Users Mailing List
>>>
>>>     sr-users at lists.kamailio.org <mailto:sr-users at lists.kamailio.org>
>>>
>>>     https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>> -- 
>>> Daniel-Constantin Mierla -- www.asipto.com <http://www.asipto.com>
>>> www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
>>>
>>>  
>>>
>> -- 
>> Daniel-Constantin Mierla -- www.asipto.com <http://www.asipto.com>
>> www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
> -- 
> Daniel-Constantin Mierla -- www.asipto.com <http://www.asipto.com>
> www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20200420/0cd1ac7b/attachment.html>


More information about the sr-users mailing list