[asterisk-dev] [Code Review] SendMessage strips extension from To: Header in SIP MESSAGE

mjordan reviewboard at asterisk.org
Fri Dec 2 15:40:56 CST 2011

This is an automatically generated e-mail. To reply, visit:

(Updated Dec. 2, 2011, 3:40 p.m.)

Review request for Asterisk Developers.


Yup, this wasn't the right way to do this.

As it turned out, setting tohost to have the peername only "worked" because initreqprep used the fullcontact field to set the SIP header, which had already been populated to the full contact URI for the peer.  So that was mostly just getting lucky, but was certainly incorrect.

However, once the :port issue was identified by David, parsing the To URI in sip_msg_send just got uglier.  The correct approach, in my opinion, is to use what we already wrote via the parse_uri function to get the username / hostname out of the URI field (which is what its there for).  If a username is returned, we set the correct field in the sip_pvt structure (username), which resolves the original issue correctly.

Tested with:
sip:user (where user is a peer)
sip:user at hostname
sip:user at hostname:port

All worked correctly.

As this was previously committed, the new diff is against the patch that was previously written.


When using the MessageSend application to send a SIP MESSAGE to a non-peer, chan_sip attempts to validate the hostname / IP Address.  In the process, it strips off the destination, and fails to add it back to the sip_pvt structure before transmission.  This patch attempts to handle valid URIs passed to chan_sip from the message core that contain either a peer to send to or a URI.  Acceptable forms from MessageSend take one of the following two forms:

sip:destination at hostname
sip:destination at ip_address

Note that more complex URIs (such as "User" <sip: blah at blah>) won't be accepted by the message core, as the message technology will assume that the user name is part of the message technology type.  That limitation is outside the scope of this issue.

This addresses bug ASTERISK-18903.

Diffs (updated)

  /branches/10/channels/chan_sip.c 346804 

Diff: https://reviewboard.asterisk.org/r/1597/diff


Tested with:

sip:destination at hostname
sip:destination at ip_address

All three were accepted by the MessageSend application and properly forwarded to their destinations / peers.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20111202/219f0f85/attachment.htm>

More information about the asterisk-dev mailing list