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
On May 30, 2024, at 9:58 PM, Pavan Kumar via sr-users sr-users@lists.kamailio.org wrote:
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
You can check e164 with siputils is_e164 function (https://www.kamailio.org/docs/modules/stable/modules/siputils.html#siputils....) and then use uac_replace to adjust as needed.
I’m sure there are also other methods.
Regards,
Fred Posner p: +1 (352) 664-3733 https://fred.tel
Hi Kumar
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.
US numbers are fixed lenght 11 digits? What is the usual representation of a 'local' US number? Does it start with a 0?
I do this (to translate Swiss local numbers to e164):
$var(check_number) = "012 345 67 89" # local number example, use $rU or $fU or whatever you want to translate. route(TRANSLATE_TO_e164); $rU = $var(result);
route[TRANSLATE_TO_e164] { $var(result) = 'invalid'; $var(check_number) = $(var(check_number){s.rmws}); # Remove spaces if ($var(check_number) =~ "^+") { $var($result) = $var(check_number); # Already e164 } else if ($var(check_number) =~ "^00") { # international number in local notation replace 00 by + $var(result) = "+" + $(var(check_number){s.substr,2,0}); } else if ($var(check_number) =~ "^0") { # Swiss number in local notation replace 0 by +41 $var(result) = "+41" + $(var(check_number){s.substr,1,0}); } }
And of course I have a corresponding TRANSLATE_TO_LOCAL to display numbers to the customer in a format they are used to in Switzerland.
Hi Kumar,
Not sure whether this is of any help but you can check out https://kamailio.org/docs/modules/5.9.x/modules/phonenum.html module.
BR, Supreeth
On Fri, 31 May 2024 at 10:27, Benoît Panizzon via sr-users < sr-users@lists.kamailio.org> wrote:
Hi Kumar
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.
US numbers are fixed lenght 11 digits? What is the usual representation of a 'local' US number? Does it start with a 0?
I do this (to translate Swiss local numbers to e164):
$var(check_number) = "012 345 67 89" # local number example, use $rU or $fU or whatever you want to translate. route(TRANSLATE_TO_e164); $rU = $var(result);
route[TRANSLATE_TO_e164] { $var(result) = 'invalid'; $var(check_number) = $(var(check_number){s.rmws}); # Remove spaces if ($var(check_number) =~ "^+") { $var($result) = $var(check_number); # Already e164 } else if ($var(check_number) =~ "^00") { # international number in local notation replace 00 by + $var(result) = "+" + $(var(check_number){s.substr,2,0}); } else if ($var(check_number) =~ "^0") { # Swiss number in local notation replace 0 by +41 $var(result) = "+41" + $(var(check_number){s.substr,1,0}); } }
And of course I have a corresponding TRANSLATE_TO_LOCAL to display numbers to the customer in a format they are used to in Switzerland.
-- Mit freundlichen Grüssen
-Benoît Panizzon- @ HomeOffice und normal erreichbar
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
Answered in order of easiest answer to most complex:
Does it start with a 0?
No. I've never encountered any US number requiring a prefix of "0" nor a US number being written that way.
US numbers are fixed lenght 11 digits?
The USA is in the North American Numbering Plan (NANP). This includes USA, Canada, much of the Caribbean (Cuba, Jamaica, Barbados for example), some US territories in the Pacific (Guam, American Samoa). The NANP's "Country Code" is 1. In the USA and Canada (I think the entirety of the NANP) this is followed with a 3 digit area code (National Destination Number) followed by a 7 digit subscriber number.
What is the usual representation of a 'local' US number?
There is no consistent answer. Consider that the oldest phone network is in the USA, and the unplanned initial growth and many historic regional governing bodies it varies massively. It has also changed greatly over time. GENERALLY speaking people will use the 11 digit number or the 10 digit number (without the "1" country code), but there's not a lot of rhyme or reason as to which is preferred in one case vs another.
-----Original Message----- From: Benoît Panizzon via sr-users sr-users@lists.kamailio.org Sent: Friday, May 31, 2024 2:52 AM To: Pavan Kumar via sr-users sr-users@lists.kamailio.org Cc: Pavan Kumar pavanputhra@gmail.com; Benoît Panizzon benoit.panizzon@imp.ch Subject: [SR-Users] Re: 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.
Hi Kumar
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.
US numbers are fixed lenght 11 digits? What is the usual representation of a 'local' US number? Does it start with a 0?
I do this (to translate Swiss local numbers to e164):
$var(check_number) = "012 345 67 89" # local number example, use $rU or $fU or whatever you want to translate. route(TRANSLATE_TO_e164); $rU = $var(result);
route[TRANSLATE_TO_e164] { $var(result) = 'invalid'; $var(check_number) = $(var(check_number){s.rmws}); # Remove spaces if ($var(check_number) =~ "^+") { $var($result) = $var(check_number); # Already e164 } else if ($var(check_number) =~ "^00") { # international number in local notation replace 00 by + $var(result) = "+" + $(var(check_number){s.substr,2,0}); } else if ($var(check_number) =~ "^0") { # Swiss number in local notation replace 0 by +41 $var(result) = "+41" + $(var(check_number){s.substr,1,0}); } }
And of course I have a corresponding TRANSLATE_TO_LOCAL to display numbers to the customer in a format they are used to in Switzerland.
-- Mit freundlichen Grüssen
-Benoît Panizzon- @ HomeOffice und normal erreichbar -- I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch/ ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
On May 31, 2024, at 9:20 AM, Ben Kaufman via sr-users sr-users@lists.kamailio.org wrote:
Answered in order of easiest answer to most complex:
Does it start with a 0?
No. I've never encountered any US number requiring a prefix of "0" nor a US number being written that way.
US numbers are fixed lenght 11 digits?
The USA is in the North American Numbering Plan (NANP). This includes USA, Canada, much of the Caribbean (Cuba, Jamaica, Barbados for example), some US territories in the Pacific (Guam, American Samoa). The NANP's "Country Code" is 1. In the USA and Canada (I think the entirety of the NANP) this is followed with a 3 digit area code (National Destination Number) followed by a 7 digit subscriber number.
What is the usual representation of a 'local' US number?
There is no consistent answer. Consider that the oldest phone network is in the USA, and the unplanned initial growth and many historic regional governing bodies it varies massively. It has also changed greatly over time. GENERALLY speaking people will use the 11 digit number or the 10 digit number (without the "1" country code), but there's not a lot of rhyme or reason as to which is preferred in one case vs another.
It was mentioned previously, and requires libphonenumber, but the phonenum module is pretty decent for helping with NANP numbers and deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Regards,
Fred Posner p: +1 (352) 664-3733 https://fred.tel
the phonenum module is pretty decent for helping with NANP numbers and
deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Absolutely. And if his use case is to actually get the political country, it's a great choice. With that said, I'm guessing that in his case the vendor wants the + removed for all NANP numbers, so my point was to only use libphonenumber for this if was critical to differentiate the USA from the rest of the NANP.
-----Original Message----- From: Fred Posner fred@pgpx.io Sent: Friday, May 31, 2024 8:35 AM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: Pavan Kumar pavanputhra@gmail.com; Ben Kaufman bkaufman@bcmone.com Subject: Re: [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.
On May 31, 2024, at 9:20 AM, Ben Kaufman via sr-users sr-users@lists.kamailio.org wrote:
Answered in order of easiest answer to most complex:
Does it start with a 0?
No. I've never encountered any US number requiring a prefix of "0" nor a US number being written that way.
US numbers are fixed lenght 11 digits?
The USA is in the North American Numbering Plan (NANP). This includes USA, Canada, much of the Caribbean (Cuba, Jamaica, Barbados for example), some US territories in the Pacific (Guam, American Samoa). The NANP's "Country Code" is 1. In the USA and Canada (I think the entirety of the NANP) this is followed with a 3 digit area code (National Destination Number) followed by a 7 digit subscriber number.
What is the usual representation of a 'local' US number?
There is no consistent answer. Consider that the oldest phone network is in the USA, and the unplanned initial growth and many historic regional governing bodies it varies massively. It has also changed greatly over time. GENERALLY speaking people will use the 11 digit number or the 10 digit number (without the "1" country code), but there's not a lot of rhyme or reason as to which is preferred in one case vs another.
It was mentioned previously, and requires libphonenumber, but the phonenum module is pretty decent for helping with NANP numbers and deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Regards,
Fred Posner p: +1 (352) 664-3733 https://fred.tel/
Thank you, everyone, for your responses.
Benoît, thank you for providing the sample code. My concern is that the code may become complex as it needs to be both transaction and dialog aware. For example, it needs to be transaction-aware when sending a 100 or 200 response back and conversion from E.164 to 11 digits should happen. It needs to be dialog-aware when FreeSWITCH initiates a BYE request so that the conversion to 11 digits occurs. Additionally, we need to handle cases where FreeSWITCH (on behalf of the user) initiates a call by sending an INVITE. In these instances, I need to identify if the request is going to a trunk that doesn't accept the "+" prefix and strip it accordingly, potentially using a database to assist in this identification.
Ben, thank you for providing more information on the E.164 format and clarifying that the "+" prefix is not mandatory in some cases. Yes, when I referred to an 11-digit US number, I meant the NANP without the "+" prefix. Replacing "+1" with "1" is sufficient for my needs, and there is no need to identify the country.
Thanks & Regards, Pavan Kumar
On Fri, May 31, 2024 at 8:05 PM Ben Kaufman bkaufman@bcmone.com wrote:
the phonenum module is pretty decent for helping with NANP numbers and
deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Absolutely. And if his use case is to actually get the political country, it's a great choice. With that said, I'm guessing that in his case the vendor wants the + removed for all NANP numbers, so my point was to only use libphonenumber for this if was critical to differentiate the USA from the rest of the NANP.
-----Original Message----- From: Fred Posner fred@pgpx.io Sent: Friday, May 31, 2024 8:35 AM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: Pavan Kumar pavanputhra@gmail.com; Ben Kaufman bkaufman@bcmone.com Subject: Re: [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.
On May 31, 2024, at 9:20 AM, Ben Kaufman via sr-users <
sr-users@lists.kamailio.org> wrote:
Answered in order of easiest answer to most complex:
Does it start with a 0?
No. I've never encountered any US number requiring a prefix of "0" nor a US number being written that way.
US numbers are fixed lenght 11 digits?
The USA is in the North American Numbering Plan (NANP). This includes USA, Canada, much of the Caribbean (Cuba, Jamaica, Barbados for example), some US territories in the Pacific (Guam, American Samoa). The NANP's "Country Code" is 1. In the USA and Canada (I think the entirety of the NANP) this is followed with a 3 digit area
code (National Destination Number) followed by a 7 digit subscriber number.
What is the usual representation of a 'local' US number?
There is no consistent answer. Consider that the oldest phone network is in the USA, and the unplanned initial growth and many historic regional governing bodies it varies massively. It has also changed greatly over time. GENERALLY speaking people will use the 11 digit number or the 10 digit number (without the "1" country code), but
there's not a lot of rhyme or reason as to which is preferred in one case vs another.
It was mentioned previously, and requires libphonenumber, but the phonenum module is pretty decent for helping with NANP numbers and deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Regards,
Fred Posner p: +1 (352) 664-3733 https://fred.tel/
Hello guys,
My advice, always use e.164 with "+", your life will be easier if you normalise to something.
Regards,
David Villasmil email: david.villasmil.work@gmail.com phone: +34669448337
On Sat, Jun 1, 2024 at 6:10 AM Pavan Kumar via sr-users < sr-users@lists.kamailio.org> wrote:
Thank you, everyone, for your responses.
Benoît, thank you for providing the sample code. My concern is that the code may become complex as it needs to be both transaction and dialog aware. For example, it needs to be transaction-aware when sending a 100 or 200 response back and conversion from E.164 to 11 digits should happen. It needs to be dialog-aware when FreeSWITCH initiates a BYE request so that the conversion to 11 digits occurs. Additionally, we need to handle cases where FreeSWITCH (on behalf of the user) initiates a call by sending an INVITE. In these instances, I need to identify if the request is going to a trunk that doesn't accept the "+" prefix and strip it accordingly, potentially using a database to assist in this identification.
Ben, thank you for providing more information on the E.164 format and clarifying that the "+" prefix is not mandatory in some cases. Yes, when I referred to an 11-digit US number, I meant the NANP without the "+" prefix. Replacing "+1" with "1" is sufficient for my needs, and there is no need to identify the country.
Thanks & Regards, Pavan Kumar
On Fri, May 31, 2024 at 8:05 PM Ben Kaufman bkaufman@bcmone.com wrote:
the phonenum module is pretty decent for helping with NANP numbers and
deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Absolutely. And if his use case is to actually get the political country, it's a great choice. With that said, I'm guessing that in his case the vendor wants the + removed for all NANP numbers, so my point was to only use libphonenumber for this if was critical to differentiate the USA from the rest of the NANP.
-----Original Message----- From: Fred Posner fred@pgpx.io Sent: Friday, May 31, 2024 8:35 AM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: Pavan Kumar pavanputhra@gmail.com; Ben Kaufman <bkaufman@bcmone.com
Subject: Re: [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.
On May 31, 2024, at 9:20 AM, Ben Kaufman via sr-users <
sr-users@lists.kamailio.org> wrote:
Answered in order of easiest answer to most complex:
Does it start with a 0?
No. I've never encountered any US number requiring a prefix of "0" nor a US number being written that way.
US numbers are fixed lenght 11 digits?
The USA is in the North American Numbering Plan (NANP). This includes USA, Canada, much of the Caribbean (Cuba, Jamaica, Barbados for example), some US territories in the Pacific (Guam, American Samoa). The NANP's "Country Code" is 1. In the USA and Canada (I think the entirety of the NANP) this is followed with a 3 digit area
code (National Destination Number) followed by a 7 digit subscriber number.
What is the usual representation of a 'local' US number?
There is no consistent answer. Consider that the oldest phone network is in the USA, and the unplanned initial growth and many historic regional governing bodies it varies massively. It has also changed greatly over time. GENERALLY speaking people will use the 11 digit number or the 10 digit number (without the "1" country code),
but there's not a lot of rhyme or reason as to which is preferred in one case vs another.
It was mentioned previously, and requires libphonenumber, but the phonenum module is pretty decent for helping with NANP numbers and deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Regards,
Fred Posner p: +1 (352) 664-3733 https://fred.tel/
Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
…. Until you encounter something like STIR/SHAKEN (as implemented in the USA and Canada) which requires the e.164 globalized format which is without the leading “+”.
Sometimes it’s impossible to win.
Regards, Kaufman
From: David Villasmil david.villasmil.work@gmail.com Sent: Tuesday, June 4, 2024 6:53 AM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: Ben Kaufman bkaufman@bcmone.com; Fred Posner fred@pgpx.io; Pavan Kumar pavanputhra@gmail.com Subject: Re: [SR-Users] Re: 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.
Hello guys,
My advice, always use e.164 with "+", your life will be easier if you normalise to something.
Regards,
David Villasmil email: david.villasmil.work@gmail.commailto:david.villasmil.work@gmail.com phone: +34669448337
On Sat, Jun 1, 2024 at 6:10 AM Pavan Kumar via sr-users <sr-users@lists.kamailio.orgmailto:sr-users@lists.kamailio.org> wrote: Thank you, everyone, for your responses.
Benoît, thank you for providing the sample code. My concern is that the code may become complex as it needs to be both transaction and dialog aware. For example, it needs to be transaction-aware when sending a 100 or 200 response back and conversion from E.164 to 11 digits should happen. It needs to be dialog-aware when FreeSWITCH initiates a BYE request so that the conversion to 11 digits occurs. Additionally, we need to handle cases where FreeSWITCH (on behalf of the user) initiates a call by sending an INVITE. In these instances, I need to identify if the request is going to a trunk that doesn't accept the "+" prefix and strip it accordingly, potentially using a database to assist in this identification.
Ben, thank you for providing more information on the E.164 format and clarifying that the "+" prefix is not mandatory in some cases. Yes, when I referred to an 11-digit US number, I meant the NANP without the "+" prefix. Replacing "+1" with "1" is sufficient for my needs, and there is no need to identify the country.
Thanks & Regards, Pavan Kumar
On Fri, May 31, 2024 at 8:05 PM Ben Kaufman <bkaufman@bcmone.commailto:bkaufman@bcmone.com> wrote:
the phonenum module is pretty decent for helping with NANP numbers and
deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Absolutely. And if his use case is to actually get the political country, it's a great choice. With that said, I'm guessing that in his case the vendor wants the + removed for all NANP numbers, so my point was to only use libphonenumber for this if was critical to differentiate the USA from the rest of the NANP.
-----Original Message----- From: Fred Posner <fred@pgpx.iomailto:fred@pgpx.io> Sent: Friday, May 31, 2024 8:35 AM To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.orgmailto:sr-users@lists.kamailio.org> Cc: Pavan Kumar <pavanputhra@gmail.commailto:pavanputhra@gmail.com>; Ben Kaufman <bkaufman@bcmone.commailto:bkaufman@bcmone.com> Subject: Re: [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.
On May 31, 2024, at 9:20 AM, Ben Kaufman via sr-users <sr-users@lists.kamailio.orgmailto:sr-users@lists.kamailio.org> wrote:
Answered in order of easiest answer to most complex:
Does it start with a 0?
No. I've never encountered any US number requiring a prefix of "0" nor a US number being written that way.
US numbers are fixed lenght 11 digits?
The USA is in the North American Numbering Plan (NANP). This includes USA, Canada, much of the Caribbean (Cuba, Jamaica, Barbados for example), some US territories in the Pacific (Guam, American Samoa). The NANP's "Country Code" is 1. In the USA and Canada (I think the entirety of the NANP) this is followed with a 3 digit area code (National Destination Number) followed by a 7 digit subscriber number.
What is the usual representation of a 'local' US number?
There is no consistent answer. Consider that the oldest phone network is in the USA, and the unplanned initial growth and many historic regional governing bodies it varies massively. It has also changed greatly over time. GENERALLY speaking people will use the 11 digit number or the 10 digit number (without the "1" country code), but there's not a lot of rhyme or reason as to which is preferred in one case vs another.
It was mentioned previously, and requires libphonenumber, but the phonenum module is pretty decent for helping with NANP numbers and deciphering if one is let’s say US vs Canada vs Jamaica, etc.
Regards,
Fred Posner p: +1 (352) 664-3733 https://fred.tel/
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.orgmailto:sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
Ben Kaufman via sr-users sr-users@lists.kamailio.org writes:
US numbers are fixed lenght 11 digits?
The USA is in the North American Numbering Plan (NANP). This includes USA, Canada, much of the Caribbean (Cuba, Jamaica, Barbados for example), some US territories in the Pacific (Guam, American Samoa). The NANP's "Country Code" is 1. In the USA and Canada (I think the entirety of the NANP) this is followed with a 3 digit area code (National Destination Number) followed by a 7 digit subscriber number.
Agreed of course on NANP vs US.
I would say that "NANP numbers" are 10 digits, period. However E.164 representations of those are 11 as they include the 'country code'.
Beware that in the US you must use a 1 before long distance (and now most numbers), but this is a trunk access code and NOT a country code. It just happens to be the same digit.
This point is important as on local phone lines people do not input E.164 numbers directly.
They may enter 1+10digits as long distance. Sometimes 1+7, but that is rarer now than it used to be. (Part of that is with portability, it's now more of a flat 10-digit space; it used to be hierarchical.)
They may enter an international access code, 011 traditionally, + on cellular and then E.164 number.
SIP trunks can be set up multiple ways. Including wanting bare E.164 with no +, always country code followed by in-country number.
What is the usual representation of a 'local' US number?
There is no consistent answer. Consider that the oldest phone network is in the USA, and the unplanned initial growth and many historic regional governing bodies it varies massively. It has also changed greatly over time. GENERALLY speaking people will use the 11 digit number or the 10 digit number (without the "1" country code), but there's not a lot of rhyme or reason as to which is preferred in one case vs another.
I think the 10-digit representation is highly normal.
There is also the 7 digit number, and I think in many places if you are very local and the numbers are all in the area code where they belong then you can dial just 7, but this is only for old-school landlines. Because of overlay area codes and portability, a 7-digit representation is asking for trouble. So it is odd, and arguably not a good idea, to publish/distribute other than 10.
I am unaware of other than 10 or 7 as more than rarely for conventions.
I do see the local 10-digit number written as
+1 617 555 1212
which is not really a 'local' number but a global representation. The + is a clue that an E.164 number follows, and the 1 is a country code. To dial it, you realize that you are in the NANP, remove the +1 as telling you to dial international access code and country code, and then add back a DIFFERENT ONE to be the LD access code.
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@lists.kamailio.org Sent: Thursday, May 30, 2024 8:58 PM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: Pavan Kumar pavanputhra@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