From 7f8beb3748ed778f5a74819deda8522d0c73ca60 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 26 Jan 2008 03:56:40 +0000 Subject: [PATCH] fix all the bugs brought on by the guys who made me add t38 no-media passthru git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7366 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 20 ++++++++++++++------ src/mod/endpoints/mod_sofia/mod_sofia.h | 3 ++- src/mod/endpoints/mod_sofia/sofia.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index d603146d7e..81d5968015 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -333,7 +333,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) SIPTAG_REASON_STR("SIP;cause=200;text=\"Call completed elsewhere\"")), TAG_END()); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause); - nua_respond(tech_pvt->nh, sip_cause, NULL, TAG_END()); + nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause), TAG_END()); } } switch_set_flag(tech_pvt, TFLAG_BYE); @@ -984,9 +984,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi reason = msg->string_arg; } else { if (!switch_strlen_zero(msg->string_arg)){ - code = atoi(msg->string_arg); - if ((reason = strchr(msg->string_arg, ' '))) { - reason++; + if ((code = atoi(msg->string_arg))) { + if ((reason = strchr(msg->string_arg, ' '))) { + reason++; + } } } } @@ -999,7 +1000,14 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi code = 488; } - if (code == 407) { + if (!reason) { + reason = sip_status_phrase(code); + if (switch_strlen_zero(reason)) { + reason = "Because"; + } + } + + if (code == 407 && !msg->numeric_arg) { const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri"); const char *to_host = reason; @@ -1009,7 +1017,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri); sofia_reg_auth_challange(NULL, tech_pvt->profile, tech_pvt->nh, REG_INVITE, to_host, 0); switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE); - } else if (code == 484) { + } else if (code == 484 && msg->numeric_arg) { const char *to = switch_channel_get_variable(channel, "sip_to_uri"); const char *max_forwards = switch_channel_get_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index b2655568c9..35ab30b211 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -164,7 +164,8 @@ typedef enum { TFLAG_LATE_NEGOTIATION = (1 << 24), TFLAG_SDP = (1 << 25), TFLAG_VIDEO = (1 << 26), - TFLAG_TPORT_LOG = (1 << 27) + TFLAG_TPORT_LOG = (1 << 27), + TFLAG_SENT_UPDATE = (1 << 28) } TFLAGS; struct mod_sofia_globals { diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index bc13043fc3..d42d208cf2 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1308,12 +1308,17 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status switch_channel_t *channel = switch_core_session_get_channel(session); const char *uuid; switch_core_session_t *other_session; - + if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) { - if (status == 200 && !switch_channel_test_flag(channel, CF_ANSWERED) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA)) { + private_object_t *tech_pvt = switch_core_session_get_private(session); + switch_assert(tech_pvt != NULL); + + if (!switch_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) { return; } + switch_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE); + if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) { switch_core_session_message_t msg = { 0 }; @@ -1322,7 +1327,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status msg.message_id = SWITCH_MESSAGE_INDICATE_RESPOND; msg.from = __FILE__; msg.numeric_arg = status; - msg.string_arg = phrase; + msg.string_arg = switch_core_session_strdup(other_session, phrase); switch_core_session_receive_message(other_session, &msg); switch_core_session_rwunlock(other_session); }