From: Anthony Minessale Date: Tue, 28 Jun 2011 15:30:11 +0000 (-0500) Subject: support final response in response header passing X-Git-Tag: v1.2-rc1~108^2^2~119 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=acd0898e323f0a13a6a93c8f1d6d40000d8adce7;p=thirdparty%2Ffreeswitch.git support final response in response header passing --- diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 7d2164548f..5d594094b9 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -517,6 +517,8 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END()); } } else { + char *resp_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause); if (!tech_pvt->got_bye) { switch_channel_set_variable(channel, "sip_hangup_disposition", "send_refuse"); @@ -532,7 +534,12 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)), - TAG_IF(cid, SIPTAG_HEADER_STR(cid)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END()); + TAG_IF(cid, SIPTAG_HEADER_STR(cid)), + TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), + TAG_IF(!zstr(resp_headers), SIPTAG_HEADER_STR(resp_headers)), + TAG_END()); + + switch_safe_free(resp_headers); } } } diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 2a38fdc130..e40b38cff9 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4504,32 +4504,22 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status #endif - if ((status == 180 || status == 183 || status == 200)) { - const char *x_freeswitch_support, *vval; - - switch_channel_set_flag(channel, CF_MEDIA_ACK); - if ((x_freeswitch_support = sofia_glue_get_unknown_header(sip, "X-FS-Support"))) { - tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, x_freeswitch_support); - } + if ((status == 180 || status == 183 || status > 199)) { + const char *vval; - if (sip->sip_user_agent && sip->sip_user_agent->g_string) { - switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string); - } else if (sip->sip_server && sip->sip_server->g_string) { - switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string); - } - - if (status == 200) { + if (status > 199) { sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_RESPONSE_HEADER_PREFIX); } else { sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_PROGRESS_HEADER_PREFIX); } + if (!(vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) || switch_true(vval)) { switch_core_session_t *other_session; if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) { - if (status == 200) { + if (status > 199) { switch_ivr_transfer_variable(session, other_session, SOFIA_SIP_RESPONSE_HEADER_PREFIX_T); } else { switch_ivr_transfer_variable(session, other_session, SOFIA_SIP_PROGRESS_HEADER_PREFIX_T); @@ -4537,9 +4527,23 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status switch_core_session_rwunlock(other_session); } } - + } + + if ((status == 180 || status == 183 || status == 200)) { + const char *x_freeswitch_support; + switch_channel_set_flag(channel, CF_MEDIA_ACK); + + if ((x_freeswitch_support = sofia_glue_get_unknown_header(sip, "X-FS-Support"))) { + tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, x_freeswitch_support); + } + if (sip->sip_user_agent && sip->sip_user_agent->g_string) { + switch_channel_set_variable(channel, "sip_user_agent", sip->sip_user_agent->g_string); + } else if (sip->sip_server && sip->sip_server->g_string) { + switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string); + } + sofia_update_callee_id(session, profile, sip, SWITCH_FALSE); if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTOFIX_TIMING)) {