diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 6aa1a2d99a..fb98dab969 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -183,6 +183,12 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip, } } + if (sip->sip_contact) { + char *c = sip_header_as_string(nh->nh_home, (void *) sip->sip_contact); + switch_channel_set_variable(channel, "sip_invite_contact", c); + su_free(nh->nh_home, c); + } + if (sip->sip_record_route) { sip_record_route_t *rrp; switch_stream_handle_t stream = { 0 }; @@ -192,13 +198,13 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip, for(rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) { char *rr = sip_header_as_string(nh->nh_home, (void *) rrp); - + stream.write_function(&stream, x == 0 ? "%s" : ",%s", rr); su_free(nh->nh_home, rr); x++; } - + switch_channel_set_variable(channel, "sip_invite_record_route", (char *)stream.data); free(stream.data); } @@ -235,6 +241,7 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip, su_free(nh->nh_home, full); } } + if (sip->sip_to) { char *p = strip_quotes(sip->sip_to->a_display); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 85d4788288..aa6fdded3f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1954,12 +1954,19 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) char *record_route = NULL; if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { + const char *recover_contact = switch_channel_get_variable(tech_pvt->channel, "sip_recover_contact"); + if (!zstr(invite_record_route)) { record_route = switch_core_session_sprintf(session, "Record-Route: %s", invite_record_route); } + + if (recover_contact) { + char *tmp = switch_core_session_strdup(session, recover_contact); + tech_pvt->redirected = sofia_glue_get_url_from_contact(tmp, 0); + } } - - + + rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER); switch_assert(tech_pvt != NULL); @@ -5384,6 +5391,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName switch_channel_t *channel; private_object_t *tech_pvt = NULL; const char *tmp; + const char *rr; xml = switch_xml_parse_str_dynamic(argv[3], SWITCH_TRUE); @@ -5424,18 +5432,17 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName } } + rr = switch_channel_get_variable(channel, "sip_invite_record_route"); + if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_req_uri")); switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, "sip_full_from")); switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, "sip_full_to")); } else { - const char *rr; - + tech_pvt->redirected = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_contact_uri")); - if ((rr = switch_channel_get_variable(channel, "sip_invite_record_route"))) { - switch_channel_set_variable(channel, "sip_invite_route_uri", rr); - } else { + if (zstr(rr)) { switch_channel_set_variable_printf(channel, "sip_invite_route_uri", "", switch_channel_get_variable(channel, "sip_from_user"), switch_channel_get_variable(channel, "sip_network_ip"), switch_channel_get_variable(channel, "sip_network_port") @@ -5453,6 +5460,10 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName } } + if (rr) { + switch_channel_set_variable(channel, "sip_invite_route_uri", rr); + } + tech_pvt->dest_to = tech_pvt->dest; sofia_glue_attach_private(session, h->profile, tech_pvt, NULL);