diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 2b2b3de45d..bf5d5d88ea 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1120,7 +1120,9 @@ typedef enum { typedef enum { CF_APP_TAGGED = (1 << 0), - CF_APP_T38 = (1 << 1) + CF_APP_T38 = (1 << 1), + CF_APP_T38_REQ = (1 << 2), + CF_APP_T38_FAIL = (1 << 3) } switch_channel_app_flag_t; diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 119294f4bd..e4457bd5b9 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -904,6 +904,7 @@ static t38_mode_t request_t38(pvt_t *pvt) switch_channel_set_private(channel, "t38_options", t38_options); pvt->t38_mode = T38_MODE_REQUESTED; + switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_REQ); /* This will send a request for t.38 mode */ msg.from = __FILE__; @@ -1173,7 +1174,10 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat switch (pvt->t38_mode) { case T38_MODE_REQUESTED: { - if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { + if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38_FAIL)) { + pvt->t38_mode = T38_MODE_REFUSED; + continue; + } else if (switch_channel_test_app_flag_key("T38", channel, CF_APP_T38)) { switch_core_session_message_t msg = { 0 }; pvt->t38_mode = T38_MODE_NEGOTIATED; spanfax_init(pvt, T38_MODE); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 69f7b24f30..86fa140046 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -524,6 +524,12 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { char *cid = generate_pai_str(tech_pvt); + if (sip_cause > 299) { + switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38); + switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ); + switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL); + } + 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()); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 12b0280974..c5efbf63bb 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4161,6 +4161,16 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status tech_pvt->last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data); } + + if (status > 299 && switch_channel_test_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ)) { + switch_channel_set_private(channel, "t38_options", NULL); + switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38); + switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ); + switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s T38 invite failed\n", switch_channel_get_name(tech_pvt->channel)); + } + + if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { if (channel && sip->sip_call_info) { char *p; @@ -4462,6 +4472,9 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status switch_channel_set_private(other_channel, "t38_options", NULL); sofia_clear_flag(tech_pvt, TFLAG_T38_PASSTHRU); sofia_clear_flag(other_tech_pvt, TFLAG_T38_PASSTHRU); + switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38); + switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ); + switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL); } else if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU) && has_t38 && sip->sip_payload && sip->sip_payload->pl_data) { switch_t38_options_t *t38_options = sofia_glue_extract_t38_options(session, sip->sip_payload->pl_data); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index b308b6038e..a0f71a9466 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -4391,6 +4391,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s switch_t38_options_t *t38_options = tech_process_udptl(tech_pvt, sdp, m); if (switch_true(switch_channel_get_variable(channel, "refuse_t38"))) { + switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38); match = 0; goto done; } else {