]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
support final response in response header passing
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 28 Jun 2011 15:30:11 +0000 (10:30 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 28 Jun 2011 15:30:11 +0000 (10:30 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c

index 7d2164548fc0f291ae89d7507158c3858e099812..5d594094b9309654308343d1da63cf219a0709f7 100644 (file)
@@ -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);
                                }
                        }
                }
index 2a38fdc130813654920642758ba1f74c1d494cdd..e40b38cff93f4452eccd5423efe56ca92c696aba 100644 (file)
@@ -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)) {