A few points, and reasons why the issue is both more simple and more complex than
indicated:
1. The definition of E.164 isn’t clear here. My assumption is that you mean a digit
string that starts with a plus character. There is no requirement in the E.164
specification that a leading plus character is represented. E.164
(
https://www.itu.int/rec/T-REC-E.164-201011-I/en) section 12 “International prefix”:
In accordance with [ITU-T E.123], the symbol
"+" is recommended to indicate that an international prefix is required.
This means that if you are indicating an international prefix is required, then use a “+”.
It doesn’t mandate that a plus be present. Moreover Annex B part 7 indicates that in
calling line information the leading plus should NOT be used (of course, it’s probably a
bad idea to reject calls where the From: URI user starts with a plus).
2. The term “11-digit US format” might be better defined as “North American Numbering
Plan” format (NANP). “1” is the country code (the first of the 11 digits) and covers more
than just the USA. It includes Canada, most of the Caribbean, etc. I’m not just being
“picky” here – some of the recommended modules in this thread (e.g. phonenumber) should
have a number beginning with 1617 showing not as US but as Guam. This may or may not be
what you want so it’s worth pointing out.
3. Performing the digit manipulation in Kamailio is simple, and there’s a few ways to
do it. `strip()`, prefix()`, and regex transformations will all work and are in the core.
But implied in your diagram is a single Kamailio proxy that connects to both users, who
presumably you do want to send/receive numbers with a leading plus, as well “Trunk”, which
might be multiple vendors some of whom might want a leading plus, and others who might
not. There are several modules (dispatcher, carrierroute, lcr…) that combine prefixing
stripping and appending to the destination. If you are already using one of these modules
to select your destination it’s probably best to use one of them.
From: Pavan Kumar via sr-users <sr-users(a)lists.kamailio.org>
Sent: Thursday, May 30, 2024 8:58 PM
To: Kamailio (SER) - Users Mailing List <sr-users(a)lists.kamailio.org>
Cc: Pavan Kumar <pavanputhra(a)gmail.com>
Subject: [SR-Users] Assistance Needed: Converting 11-Digit US Numbers to E.164 in
Kamailio
CAUTION: This email originated from outside the organization. Do not click links or open
attachments unless you recognize the sender and know the content is safe.
Hey everyone,
I have the following setup:
External User/Trunk <===> Kamailio <===> FreeSWITCH
I have configured FreeSWITCH and Kamailio to work only with phone numbers in E.164 format.
Recently, I needed to integrate a new SIP trunk that sends phone numbers in an 11-digit US
format.
My initial idea to solve this is to use Kamailio as a translator that converts 11-digit
numbers to E.164 when sending to FreeSWITCH, and back to 11-digit when sending to the
trunk.
Before writing the code, I want to know if there is already a solution to this problem in
one of the modules, so that I won't reinvent the wheel.
Thanks,
Pavan Kumar