From 576c0c98fb0b93ed987737794acff15fad4a6172 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 11 Mar 2008 18:19:17 +0000 Subject: [PATCH] add sip_invite_params var git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7859 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.h | 2 +- src/mod/endpoints/mod_sofia/sofia_glue.c | 40 ++++++++++++++++++------ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 15a94b1248..4e8bdeb32e 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -529,7 +529,7 @@ char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup); void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip); void sofia_glue_sql_close(sofia_profile_t *profile); int sofia_glue_init_sql(sofia_profile_t *profile); -char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only); +char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only, const char *params); switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile, switch_bool_t master, switch_mutex_t *mutex, diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index ce8d227cec..575ba24aff 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -670,7 +670,7 @@ int sofia_glue_transport_has_tls(const sofia_transport_t tp) } } -char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only) +char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only, const char *params) { char *stripped = switch_core_session_strdup(session, uri); char *new_uri = NULL; @@ -681,16 +681,37 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char if (switch_stristr("port=", stripped)) { new_uri = switch_core_session_sprintf(session, "%s%s%s", uri_only ? "" : "<", stripped, uri_only ? "" : ">"); } else { + if (strchr(stripped, ';')) { - new_uri = switch_core_session_sprintf(session, "%s%s&transport=%s%s", uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), uri_only ? "" : ">"); + if (params) { + new_uri = switch_core_session_sprintf(session, "%s%s&transport=%s&%s%s", + uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), params, uri_only ? "" : ">"); + } else { + new_uri = switch_core_session_sprintf(session, "%s%s&transport=%s%s", + uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), uri_only ? "" : ">"); + } } else { - new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s%s", uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), uri_only ? "" : ">"); + if (params) { + new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s&%s%s", + uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), params, uri_only ? "" : ">"); + } else { + new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s%s", + uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), uri_only ? "" : ">"); + } } } } else { - new_uri = stripped; + if (params) { + if (strchr(stripped, ';')) { + new_uri = switch_core_session_sprintf(session, "%s&%s", stripped, params); + } else { + new_uri = switch_core_session_sprintf(session, "%s;%s", stripped, params); + } + } else { + new_uri = stripped; + } } - + return new_uri; } @@ -963,10 +984,11 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) } } - url_str = sofia_overcome_sip_uri_weakness(session, url, tech_pvt->transport, SWITCH_TRUE); - invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, tech_pvt->transport, SWITCH_FALSE); - from_str = sofia_overcome_sip_uri_weakness(session, use_from_str, 0, SWITCH_FALSE); - to_str = sofia_overcome_sip_uri_weakness(session, tech_pvt->dest_to, 0, SWITCH_FALSE); + url_str = sofia_overcome_sip_uri_weakness(session, url, tech_pvt->transport, SWITCH_TRUE, + switch_channel_get_variable(tech_pvt->channel, "sip_invite_params")); + invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, tech_pvt->transport, SWITCH_FALSE, NULL); + from_str = sofia_overcome_sip_uri_weakness(session, use_from_str, 0, SWITCH_FALSE, NULL); + to_str = sofia_overcome_sip_uri_weakness(session, tech_pvt->dest_to, 0, SWITCH_FALSE, NULL); /* Does the "genius" who wanted SIP to be "text-based" so it was "easier to read" even use it now,