diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 1e1f3dacbf..8389a495c3 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2319,7 +2319,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { sofia_glue_tech_patch_sdp(tech_pvt); - sofia_glue_tech_proxy_remote_addr(tech_pvt); + sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL); } if (sofia_use_soa(tech_pvt)) { nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index edd58babf1..b13d9ffd35 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -1037,7 +1037,7 @@ int sofia_glue_transport_has_tls(const sofia_transport_t tp); const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name); switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction); void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt); -switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt); +switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt, const char *sdp_str); void sofia_presence_event_thread_start(void); void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int reboot); void sofia_reg_check_call_id(sofia_profile_t *profile, const char *call_id); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 752754ccc3..a132539408 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4935,7 +4935,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status sip->sip_content_type && sip->sip_content_type->c_subtype && switch_stristr("sdp", sip->sip_content_type->c_subtype)) { tech_pvt->remote_sdp_str = switch_core_session_strdup(tech_pvt->session, sip->sip_payload->pl_data); r_sdp = tech_pvt->remote_sdp_str; - sofia_glue_tech_proxy_remote_addr(tech_pvt); + sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL); } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase); @@ -5780,6 +5780,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } + if (switch_channel_test_flag(channel, CF_PROXY_MODE)) { + sofia_glue_tech_proxy_remote_addr(tech_pvt, r_sdp); + } + msg = switch_core_session_alloc(other_session, sizeof(*msg)); msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT; msg->from = __FILE__; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index aa6fdded3f..52096dd02b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1374,7 +1374,7 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char } #define RA_PTR_LEN 512 -switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt) +switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt, const char *sdp_str) { const char *err; char rip[RA_PTR_LEN] = ""; @@ -1384,23 +1384,27 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt) int x; const char *val; - if (zstr(tech_pvt->remote_sdp_str)) { + if (zstr(sdp_str)) { + sdp_str = tech_pvt->remote_sdp_str; + } + + if (zstr(sdp_str)) { return SWITCH_STATUS_FALSE; } - if ((p = (char *) switch_stristr("c=IN IP4 ", tech_pvt->remote_sdp_str)) || (p = (char *) switch_stristr("c=IN IP6 ", tech_pvt->remote_sdp_str))) { + if ((p = (char *) switch_stristr("c=IN IP4 ", sdp_str)) || (p = (char *) switch_stristr("c=IN IP6 ", sdp_str))) { ip_ptr = p + 9; } - if ((p = (char *) switch_stristr("m=audio ", tech_pvt->remote_sdp_str))) { + if ((p = (char *) switch_stristr("m=audio ", sdp_str))) { port_ptr = p + 8; } - if ((p = (char *) switch_stristr("m=image ", tech_pvt->remote_sdp_str))) { + if ((p = (char *) switch_stristr("m=image ", sdp_str))) { port_ptr = p + 8; } - if ((p = (char *) switch_stristr("m=video ", tech_pvt->remote_sdp_str))) { + if ((p = (char *) switch_stristr("m=video ", sdp_str))) { vid_port_ptr = p + 8; } @@ -2399,7 +2403,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) { if (switch_rtp_ready(tech_pvt->rtp_session)) { - sofia_glue_tech_proxy_remote_addr(tech_pvt); + sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL); } sofia_glue_tech_patch_sdp(tech_pvt); } @@ -3167,7 +3171,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f } if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) { - if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt)) != SWITCH_STATUS_SUCCESS) { + if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL)) != SWITCH_STATUS_SUCCESS) { goto end; } @@ -3490,7 +3494,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f } if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) { - if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt)) != SWITCH_STATUS_SUCCESS) { + if ((status = sofia_glue_tech_proxy_remote_addr(tech_pvt, NULL)) != SWITCH_STATUS_SUCCESS) { goto end; }