Summary: | ASTERISK-18992: Asterisk From and To fields setup for SIP out of dialog MESSAGE method | ||||||
Reporter: | Yuri (ys) | Labels: | |||||
Date Opened: | 2011-12-08 06:41:54.000-0600 | Date Closed: | 2012-01-25 11:19:01.000-0600 | ||||
Priority: | Major | Regression? | |||||
Status: | Closed/Complete | Components: | Channels/chan_sip/General Channels/chan_sip/Messaging | ||||
Versions: | SVN 10.0.0-rc2 | Frequency of Occurrence | Constant | ||||
Related Issues: |
| ||||||
Environment: | Linux and FreeBSD machne asterisk-10.0.0-rc2 and asterisk trunk ( revision 347528) | Attachments: | ( 0) 347939.diff | ||||
Description: | This issue are related with ASTERISK-18903, ASTERISK-18916, ASTERISK-18917 I,m dance some days with sip IM message service in asterisk and found the following bugs: If I set MESSAGE_DATA(to) and/or MESSAGE_DATA(from) variable in dialplan, for example: exten => 100,1,set(MESSAGE_DATA(to)=sip:100) exten => 100,n,set(MESSAGE_DATA(from)=${MESSAGE(from)}) exten => 100,n,MessageSend(MESSAGE_DATA(to), ${MESSAGE_DATA(from)}) Asterisk send MESSAGE to destination w/two From: and To: headers! MESSAGE sip:100@192.168.1.119:46944;rinstance=2c4db922ff368387;transport=UDP SIP/2.0 Via: SIP/2.0/UDP 192.168.1.1:15072;branch=z9hG4bK533df9e5;rport Max-Forwards: 70 From: " sip:100@192.168.1.1:15072;transport=UDP" <sip:asterisk@192.168.1.1:15072>;tag=as42cac1e2 To: <sip:100@192.168.1.119:46944;rinstance=2c4db922ff368387;transport=UDP> Contact: <sip:asterisk@192.168.1.1:15072> Call-ID: 1c6ae69362a502b264f246b8732a180f@192.168.1.1:0 CSeq: 102 MESSAGE User-Agent: Asterisk PBX SVN-trunk-r347008 To: sip:100 From: sip:100@192.168.1.1:15072;transport=UDP Content-Type: text/plain;charset=UTF-8 Content-Length: 4 test --- SIP/2.0 400 Bad Request(Multiple values in single-value header To,Multiple values in single-value header From) Via: SIP/2.0/UDP 192.168.1.1:15072;branch=z9hG4bK533df9e5;rport=15072 To: <sip:100@192.168.1.119:46944;rinstance=2c4db922ff368387;transport=UDP>;tag=dc6c4220 From: " sip:100@192.168.1.1:15072;transport=UDP" <sip:asterisk@192.168.1.1:15072>;tag=as42cac1e2 Call-ID: 1c6ae69362a502b264f246b8732a180f@192.168.1.1:0 CSeq: 102 MESSAGE Content-Length: 0 The first (valid ?) "To" and "From" SIP header created by sip_msg_send()function and placed into "struct sip_pvt". Inside transmit_message_with_msg(pvt, msg) function, call to initreqprep(); added valid "From" and "To" SIP header into sip request The second (invalid?)"From"/"To" header added later in transmit_message_with_msg() inside interrator by add_header() As a solution, we can disable adding standard SIP headers that we get from asterisk message engine (main/message.c). | ||||||
Comments: | By: Yuri (ys) 2011-12-10 04:54:37.584-0600 I'm attach file, where I make the following: 1. For out of dialog MESSAGE I remove check for content-type, that allow the indication transmisssion between the peer, for example: MESSAGE sip:100@192.168.1.1:15072;transport=UDP SIP/2.0 Via: SIP/2.0/UDP 192.168.1.119:20434;branch=z9hG4bK-d8754z-c6c10996151f0619-1---d8754z- Max-Forwards: 70 To: <sip:200@192.168.1.1:15072;transport=UDP> From: "100"<sip:100@192.168.1.1:15072;transport=UDP>;tag=f771a43c Call-ID: YmI5N2Y1NDkzMDc5NTI3MDc2MzQ0MGQzYjc2MmIxMTM. CSeq: 11 MESSAGE Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE Content-Type: application/im-iscomposing+xml User-Agent: Zoiper Communicator 2.05.11136 rev.11135 Allow-Events: presence, kpml Content-Length: 323 <?xml version="1.0" encoding="UTF-8"?> <isComposing xmlns="urn:ietf:params:xml:ns:im-iscomposing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:im-composing iscomposing.xsd"> <state>active</state> <refresh>120</refresh> </isComposing> This work as expected. 2. Content-type may changed by dialplan funtion MESSAGE_DATA(), defaults is "text/plain;charset=UTF-8" 3. I add check for prevent re-add the SIP header "From" and "To" into SIP message. 4. Decrement "Max-Forwards" headers for forwarded messages. 5. "From" field passed to ast_message w/o ast_str_buffer() call. 6. Message send engine pass msg->from to sip level message transmitter, if this argument not set in dialplan function. Affected files: main/message.c channels/chan_sip.c By: Yuri (ys) 2011-12-14 12:54:50.252-0600 Also found: create_addr(), that called from sip_msg_send(), overwrite fromuser in SIP dialog, what set in this function before, if fromuser= set in sip.conf. This leads to the field "From" in outgoing OOD MESSAGE becoming invalid... By: Richard Mudgett (rmudgett) 2012-01-20 16:03:00.603-0600 Posted a patch on reviewboard https://reviewboard.asterisk.org/r/1683/ * I removed the new feature to allow other incoming Content-Types. That can only be put on trunk. Also that feature needs to be configurable and should specify what other Content-Type values are allowed rather than allowing anything. * Reading header items out of the incoming message (Content-Type and From) is not a good idea. The incoming message may have come from a different technology. Remember, the messaging system also supports XMPP (Jabber). |