[asterisk-commits] mjordan: branch 10 r346040 - /branches/10/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Nov 23 10:19:53 CST 2011
Author: mjordan
Date: Wed Nov 23 10:19:47 2011
New Revision: 346040
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=346040
Log:
Fixed SendMessage stripping extension from To: header in SIP MESSAGE
When using the MessageSend application to send a SIP MESSAGE to a non-peer,
chan_sip attempted to validate the hostname or IP Address. In the process,
it stripped off the extension and failed to add it back to the sip_pvt
structure before transmitting. This patch adds the full URI passed in
from the message core to the sip_pvt structure.
(closes issue ASTERISK-18903)
Reported by: Shaun Clark
Tested by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/1597/
Modified:
branches/10/channels/chan_sip.c
Modified: branches/10/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/channels/chan_sip.c?view=diff&rev=346040&r1=346039&r2=346040
==============================================================================
--- branches/10/channels/chan_sip.c (original)
+++ branches/10/channels/chan_sip.c Wed Nov 23 10:19:47 2011
@@ -24266,20 +24266,25 @@
{
struct sip_pvt *pvt;
int res;
- char *peer;
+ char *uri, *host;
struct sip_peer *peer_ptr;
if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_MESSAGE, NULL))) {
return -1;
}
- peer = ast_strdupa(to);
- if (strchr(peer, '@')) {
- strsep(&peer, "@");
- } else {
- strsep(&peer, ":");
- }
- if (ast_strlen_zero(peer)) {
+ uri = ast_strdupa(to);
+ if (!strncasecmp(uri, "sip:", 4)) {
+ uri += 4;
+ } else if (!strncasecmp(uri, "sips:", 5)) {
+ uri += 5;
+ }
+ host = ast_strdupa(uri);
+ if (strchr(host, '@')) {
+ strsep(&host, "@");
+ }
+
+ if (ast_strlen_zero(host)) {
ast_log(LOG_WARNING, "MESSAGE(to) is invalid for SIP - '%s'\n", to);
dialog_unlink_all(pvt);
dialog_unref(pvt, "MESSAGE(to) is invalid for SIP");
@@ -24315,12 +24320,16 @@
sip_pvt_lock(pvt);
- if (create_addr(pvt, peer, NULL, TRUE, NULL)) {
+ /* Look up the host to contact */
+ if (create_addr(pvt, host, NULL, TRUE, NULL)) {
sip_pvt_unlock(pvt);
dialog_unlink_all(pvt);
dialog_unref(pvt, "create_addr failed sending a MESSAGE");
return -1;
}
+
+ /* Set the tohost to the full URI provided */
+ ast_string_field_set(pvt, tohost, uri);
ast_sip_ouraddrfor(&pvt->sa, &pvt->ourip, pvt);
ast_set_flag(&pvt->flags[0], SIP_OUTGOING);
More information about the asterisk-commits
mailing list