New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect translation of tel: uri to sip: uri in tel2sip() #1173
Comments
I expect that tel2uri() was implemented based on the needs of initial developer as documented at: It can be improved if one needs/wants more. Note also that specs are not implemented ad-litteram in a single function. The design of the application has been from the beginning to offer small tools (functions/statements) that can be blended in config script to get what you need. There are many functions and transformations that can help you replace/remove unwanted characters from user part of R-URI, such as subst_user(...), {re.subst} or {s...} transformations, etc. With all these I am pretty sure you can transfrorm tel to sip uri as per specs without using tel2sip() function. To be clear: I am not against enhancing tel2sip() to do more than it does now, but wanted to highlight that many spec requirements can be done with a combination of functions and expressions. I am not the author of tel2sip() and actually I haven't used it many times. I do URI normalization with script operations. |
@miconda, thanks very much! I will take a stab at an improvement and submit, starting with sorting the parameters according to the spec. This is good for me to understand the spec and kamailio code, and a small part of, over time, making kamailio better so that it can/will be used in more places. I do understand that there are trade-offs in enforcing esoteric details of the spec, and, in any case, it would be impossible (and not even desirable) to try to enforce everything. |
@miconda, I have written a routine that puts the parameters for the tel: uri into an array with key/value separated, then uses qsort to sort. With this, they can be put into the sip: uri in correct sorted order. The sort is very esoteric, specific to the requirements for sip: uri when converting from a tel: uri, so, I would suggest we add it to the existing conversion routine. Though, it would be very easy to make it a separate callable script called before the existing routine, to sort the tel: uri. Also, if inside the current routine, at the same time that we have the parameters split up, we can easily check if phone-context is present, and, if it is a domain, we can delete the phone-context parameter, and, move the domian to the standard place after the @ symbol. Please let me know how we can move forward. I can create a modified tel2sip() routine with the sorting of tel: parameters and a check to eliminate duplicate domains. Then, do testing here, and, finally send to you for your perusal before accepting. Thank you very much! |
Donald Carr writes:
@miconda, I have written a routine that puts the parameters for the
tel: uri into an array with key/value separated, then uses qsort to
sort. With this, they can be put into the sip: uri in correct sorted
order. The sort is very esoteric, specific to the requirements for
sip: uri when converting from a tel: uri ...
Could you give an example where sorting is needed and a pointer to
a relevant RFC?
…-- Juha
|
At the link below, you can go to 19.1.6. It is a very strange ordering giving priority to two parameters that should be first, if present. https://www.ietf.org/rfc/rfc3261.txt 19.1.6 Relating SIP URIs and tel URLs
|
@doncarr - it can be also a new function, like tel_to_sip_uri(), so if one wants to use the old/lightweight version can still do it. I guess the new function is not going to share too much code with the old onw. |
Actually, I intended to use most of the existing function, just inserting a sort, and, removal of duplicate domain. But, yes, it could be a new function, leaving the existing one exactly as-is. It would also be nice for the update to be active without having to edit the configuration file. I will leave it totally up to you on the best way to integrate. |
Donald Carr writes:
At the link below, you can go to 19.1.6. It is a very strange ordering
giving priority to two parameters that should be first, if present.
https://www.ietf.org/rfc/rfc3261.txt
19.1.6 Relating SIP URIs and tel URLs
. . . .
```
To mitigate this problem, elements constructing telephone-subscriber
fields to place in the userinfo part of a SIP or SIPS URI SHOULD fold
any case-insensitive portion of telephone-subscriber to lower case,
and order the telephone-subscriber parameters lexically by parameter
name, excepting isdn-subaddress and post-dial, which occur first and
in that order. (All components of a tel URL except for future-
extension parameters are defined to be compared case-insensitive.)
```
OK, telephone world is very weird.
…-- Juha
|
I have a fix just about ready for your review. As noted, there can be some weird things in the telephone world! There are a couple of not well defined issues. They more or less state that the objective of the sip: uri, is that two equivalent uris will always be the equivalent string, thus the need to sort the parameters and converting to lower case. That much is very clear. But, applying this same reasoning to the "phone-context" parameter, if it is a domain, then, it should be moved after the '@' symbol and not repeated as a "phone-context" parameter, as to have an equivalent string to one without the phone-context parameter. For example, the following two are obviously equivalent, but, are not the same string:
Also, they do not specifically state that visual separators should be removed from the "phone-context" parameter when it is a global phone number prefix, but, without removing them, we would again have the problem of equivalent sip uris not being equivalent strings. For example, the following two are obviously equivalent, but, not the same string:
If that all sounds good to you, I will submit a fix after more testing. I have not messed with checking for clearly bad use of visual separators, I just silently remove all visual separators wherever they appear, as was done with the existing code. Please let me know if you want any changes to the reasoning. You could also give me example tel: uris you would like me to test before submitting the fix. Thanks for everything! Don. |
Are you interested in the fix? I agree it is a bit esoteric, but, I think worth it to help reduce problems in the future. Especially removing the double domain name in the sip uri, and removing visual separators from the phone-context when it is a global number. Well, the parameters really should be sorted to meet the spec, but, not sure if any program would ever have a problem if they were not sorted. It is nice if equivalent uris look exactly the same. Please let me know, Don. |
@doncarr - yes, make a pull request, I suggested to be a new function so the lighweight version stays around and can be used by those that know it fits their needs. FYI: |
Donald Carr writes:
Are you interested in the fix? I agree it is a bit esoteric, but, I
think worth it to help reduce problems in the future. Especially
removing the double domain name in the sip uri, and removing visual
separators from the phone-context when it is a global number. Well,
the parameters really should be sorted to meet the spec, but, not sure
if any program would ever have a problem if they were not sorted. It
is nice if equivalent uris look exactly the same.
How about making a new function that "normalizes" tel uri (does sorting,
etc.)? That function would then be called before calling simple tel2sip
if all the fancy stuff is needed.
…-- Juha
|
On making a "normalizing" function. I could do that to remove the visual separators from the "phone-context" field when it is a phone number, and, also, pre-sort the parameters in the tel: uri, so that when the current (light weight) function pulls them, the parameters are already in the sorted order, and there are no visual separators in the "phone-context" field. A little more tricky, I could also delete the "phone-context" field from the tel: uri when it is a domain, assuming that the host name was already pulled out. But, if this was done before domain was extracted, it would cause an error (basically losing the domain). Currently, the domain in the "hostpart" variable is inserted after the "@" sign, and the contents in the "phone-context" field is inserted as is. Also, in this case, there can be no logic in deciding which domain to select (the one in the "hostpart", or the one in the "phone-context" It seems that the hostpart is currently pulled using cscf_get_realm_from_uri(), so, theoretically, the variable "hostpart" and the contents of "phone-context" should always be the same. Ok, in any case, I think it would be a little confusing to have a pre-filter that creates a special format of a tel: uri such that an existing translator will end up creating a standards compliant sip: uri. I think it would be best to give a simple/fast version and a standards compliant version. The existing function does try to do part of the standards in that it converts everything to lower case, and, removes visual separators from the phone number digits before the first semi-colon. |
I would also go straight for a function that give the final result. Having a two step approach is not useful and adds to complexity of the config. The existing function should be used by those that fit their need when they know what they expect. The new one, by those that want to ensure the result is standards compliant, even for unknown sources. |
@miconda, thanks, that is exactly what I have now, so, will submit it when I can. Below is the code that I wrote with a new function named "std_tel2sip()", as a preview I used most of the old procedure where possible, and tried to keep the same style. I have been given a task with a short deadline, so, will not be able to work on this anymore right now. I will get back to it as soon as possible. Don.
|
Any chance for a PR sometime soon, so this item can be closed here? |
Hey, very sorry, I got assigned another project and have not been able to
get back to this. Hopefully I will have some time soon. I think it will be
a good update that will avoid future problems. Don.
…On Sun, Sep 3, 2017 at 3:51 AM, Daniel-Constantin Mierla < ***@***.***> wrote:
Any chance for a PR sometime soon, so this item can be closed here?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1173 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEqRXOTUiZGD7LMkrcoZYG64ANE4xjEpks5semiLgaJpZM4OJzVh>
.
--
Don W. Carr
5137 Bartlett Dr
The Colony, TX 75056
Mobile: +1-719-424-8504
|
Hi, i've reviewed the code and made some minor improvements. I will commit a slightly modified version later this week. Thanks, |
Hey, thank you VERY much Carsten, that is really appreciated. Sorry that I
did not have time to take care of it. Don
…On Tue, Sep 12, 2017 at 9:27 AM, ng-voice GmbH ***@***.***> wrote:
Hi,
i've reviewed the code and made some minor improvements. I will commit a
slightly modified version later this week.
Thanks,
Carsten
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1173 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEqRXIC-OqO-MnNwXGfhGtLtYEkoLdAtks5shpDogaJpZM4OJzVh>
.
--
Don W. Carr
5137 Bartlett Dr
The Colony, TX 75056
Mobile: +1-719-424-8504
|
Hi Carsten, was this already commited? Somehow I did not found it, maybe I did not looked carefully enough. |
Hi guys, I am no longer at Verizon, but, can still help with this issue if
needed. Let me know. I do look forward to working on Kamailio again
sometime in the future. Don.
…On Sat, Mar 3, 2018 at 12:39 PM, henningw ***@***.***> wrote:
Hi Carsten, was this already commited? Somehow I did not found it, maybe I
did not looked carefully enough.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1173 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEqRXHk1tjs90G-PKaNpFE3N11Ewe9OKks5tauNrgaJpZM4OJzVh>
.
--
Don W. Carr
1021 Oakwood Circle
Keller, TX, 76248
Mobile: +1-719-424-8504
|
I did a quick search for some of the functions from the code block above, did not found them in git master. @ngvoice - did you managed to commit this already? |
I've reviewed the code and tested it intensively. I will make patch of it soon. Due to a busy schedule, this patch did not make it upstream yet.... |
Hey, thanks for taking care of this. Will be happy to have some of my code
finally submitted. I also sawed it out and tested it every which way but
loose. Don.
…On Fri, Nov 2, 2018 at 1:05 AM ng-voice GmbH ***@***.***> wrote:
I've reviewed the code and tested it intensively. I will make patch of it
soon. Due to a busy schedule, this patch did not make it upstream yet....
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1173 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEqRXOvO3lUDOh-N7uddVCrCzcJflVB9ks5uq-C3gaJpZM4OJzVh>
.
--
Don W. Carr
1021 Oakwood Circle
Keller, TX, 76248
Mobile: +1-719-424-8504
|
Close this one - please submit your code as a new pull request if you are still interested on working on this. |
Description
I received a wireshark trace from a team member showing that a tel: uri was translated to a sip: uri in a very strange (invalid) way:
INVITE tel:491234567891;phone-context=ims.mnc001.mcc001.3gppnetwork.org
Was translated to:
INVITE sip:491234567891;phone-context=ims.mnc001.mcc001.3gppnetwork.org@ims.mnc001.mcc001.3gppnetwork.org;user=phone
Troubleshooting
I first thought this was definitely an error, and only the phone number should be copied to the sip: uri. But, on further reading of the specification, (https://www.ietf.org/rfc/rfc3261.txt), I see that it is in fact legal to leave all parameters in. Though, when the phone-context parameter is simply a domain, it would at least seem the cleanest thing would be to remove it when the exact same domain is also inserted after the @ in the sip message.
So, looking to find where the message is translated, I saw in the scscf.cfg configuration file that there is a translation specified.
I found that "tel2sip" is mapped to the C function of the same name tel2sip()
In this function, the translation will do exactly what I found in the trace, in other words, it will leave in all parameters separated by semi-colon, inserted before the @ symbol.
But, reading the spec, I see that the spec is not being followed in any case. The spec states that all parameters included when translating, must be switched to alphabetic order, with the exception that
isdn-subaddress and post-dial, must occur first and in that order. There is no code in tel2sip() to perform that sorting.
Also, the parser removes '(', ')', '.', and '-' in the phone number, as specified, but, these same characters could be scattered anywhere in invalid places, and they are just silently removed, '+' can scattered anywhere and it is just left alone, Other characters can be scattered anywhere and they will just be left as-is, no error. So, I feel there should be some minimal checking of the phone number, trying to follow the spec (if we could just execute the BNF from the spec!).
Reproduction
This can be reproduced by sending a tel: uri with parameters inserted separated by semicolon.
Debugging Data
Log Messages
SIP Traffic
Possible Solutions
The solution would be to modify tel2sip(), adding the sorting of parameters, putting the two exceptions first if they exist, before inserting back into the string.
We should also throw errors on obvious bad formatting and ilegal characters, etc, in the input tel: uri
Should we remove the "phone-context" if it is a domain and also exactly the same as the domain inserted after the @?
Additional Information
kamailio -v
SIP spec:
https://www.ietf.org/rfc/rfc3261.txt
Wireshark output:
The text was updated successfully, but these errors were encountered: