[asterisk-bugs] [JIRA] (ASTERISK-28513) Should To: be rewritten when forwarding to a phone

Joshua C. Colp (JIRA) noreply at issues.asterisk.org
Tue Mar 16 04:11:15 CDT 2021


    [ https://issues.asterisk.org/jira/browse/ASTERISK-28513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=252353#comment-252353 ] 

Joshua C. Colp edited comment on ASTERISK-28513 at 3/16/21 4:10 AM:
--------------------------------------------------------------------

Hi,

how this issue going? can it be solved in the master branch?

I proposed another solution which does NOT affect existing configurations: https://issues.asterisk.org/jira/browse/ASTERISK-28928

and the patch is (based on asterisk 16):

<patch removed due to being inline and unlicensed>

and in extension.conf:
same => n,MessageSend(${CUT(MESSAGE(to),@,1)}@mydomain.com,${MESSAGE(from)})


was (Author: y):
Hi,

how this issue going? can it be solved in the master branch?

I proposed another solution which does NOT affect existing configurations: https://issues.asterisk.org/jira/browse/ASTERISK-28928

and the patch is (based on asterisk 16):

diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index 930cf84a53..2e7e443a65 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -236,6 +236,17 @@ static void update_to(pjsip_tx_data *tdata, char *to)
                        pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
                }
        }
+ /* assume it is 'sip:user[@domain]' format */
+ char *domain = strchr(to, '@');
+ pjsip_name_addr *name_addr;
+ pjsip_sip_uri *uri;
+ name_addr = (pjsip_name_addr *) PJSIP_MSG_TO_HDR(tdata->msg)->uri;
+ uri = pjsip_uri_get_uri(name_addr);
+ if(domain) {
+ pj_str_t pj_to;
+ pj_strset3(&pj_to, to, domain);
+ pj_strdup2(tdata->pool, &uri->host, domain + 1);
+ }
 }
and in extension.conf:
same => n,MessageSend(${CUT(MESSAGE(to),@,1)}@mydomain.com,${MESSAGE(from)})

> Should To: be rewritten when forwarding to a phone
> --------------------------------------------------
>
>                 Key: ASTERISK-28513
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-28513
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_pjsip_messaging
>    Affects Versions: 13.28.0
>            Reporter: Brian J. Murrell
>            Assignee: Unassigned
>              Labels: pjsip
>
> I have run into a problem with {{MESSAGE}} s and the [Linphone Android client|https://github.com/BelledonneCommunications/linphone-android].
> The [issue|https://github.com/BelledonneCommunications/linphone-android/issues/605] as described in their tracker is that when {{MESSAGE}} s come to the linphone client from the same sender, they can be "filed" into many different threads, rather than all in one chat/thread.  This is because linphone separates chats based on both the From: and To: headers.
> As I am sure you know, the {{To:}} header of a client can vary wildly based on the IP address it's connecting from.  This means that every time the IP address of the SIP client changes, a new chat for the same sender is created.
> But the problem is that Asterisk is setting the {{To:}} header of the {{MESSAGE}} to the {{user at ip_address}} of the remote SIP client and so this means that every time the IP address of the remote SIP client changes, a new To: header is created, and so is a new chat in the SIP client.
> Linphone defends this behaviour by insisting that the {{To:}} header value is a logical value of the recipient for a given domain and should always remain it's logical value no matter whether it's being forwarded on to a SIP client or not.
> So for example, if my Asterisk server is at pbx.example.com and somebody (my VOIP provider for example) send a {{MESSAGE}} to 555-555-1212 at ip-address-of-my-asterisk, when my Asterisk server receives that message and then wants to forward it on to a SIP client, the To: should be {{To:  _recipient_]@pbx.example.com}}, not {{To: _recipient_ at ip-address-of-SIP-client}}.
> They quote [RFC 3261 section 8.1.1.2|https://tools.ietf.org/html/rfc3261#section-8.1.1.2] further in defending this behaviour.  My reading of it doesn't leave me with much to argue against their defence.
> I don't see any way to make Asterisk (with PJSIP) to follow this behaviour.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list