From 6136965cd5f0769430906a9a668f1f3387c9d35b Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 14 Jul 2009 19:49:34 +0000 Subject: [PATCH] MODSOFIA-17 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14251 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia.c | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index b4628e1b76..7a272d4d51 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4856,13 +4856,16 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } if (url) { - if (strchr(url, '>')) { - tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url, - sofia_glue_transport2str(transport)); - } else { - tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", url, - sofia_glue_transport2str(transport)); - } + const char *brackets = NULL; + const char *proto = NULL; + + brackets = strchr(url, '>'); + proto = switch_stristr("transport=", url); + tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s%s%s%s%s", + brackets ? "" : "<", url, + proto ? "" : ";transport=", + proto ? "" : sofia_glue_transport2str(transport), + brackets ? "" : ">"); } else { switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); } @@ -4876,13 +4879,16 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } if (url) { - if (strchr(url, '>')) { - tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url, - sofia_glue_transport2str(transport)); - } else { - tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", url, - sofia_glue_transport2str(transport)); - } + const char *brackets = NULL; + const char *proto = NULL; + + brackets = strchr(url, '>'); + proto = switch_stristr("transport=", url); + tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s%s%s%s%s", + brackets ? "" : "<", url, + proto ? "" : ";transport=", + proto ? "" : sofia_glue_transport2str(transport), + brackets ? "" : ">"); } else { switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); }