]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3686
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 16 Nov 2011 15:57:15 +0000 (09:57 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 16 Nov 2011 15:57:21 +0000 (09:57 -0600)
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index 6aa1a2d99a324b0b94c24f587ce9456a7d66967e..fb98dab969f9f5785f03eda4a1ee78a2a3b8f50b 100644 (file)
@@ -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);
 
index 85d47882887cb26ae45c68a63c2ef84355f51f7f..aa6fdded3fa529b2e790949cf78545ac902cd30c 100644 (file)
@@ -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", "<sip:%s@%s:%s;lr>",
                                                                                           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);