]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add sip_refer_to var
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 28 Dec 2007 22:53:04 +0000 (22:53 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 28 Dec 2007 22:53:04 +0000 (22:53 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7008 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index 131193f8bfc3f50db54480995bbc3f19ea0814c1..308869faf8da632dc5b17ae7897d80404c762c7f 100644 (file)
@@ -72,6 +72,7 @@ typedef struct private_object private_object_t;
 #define SOFIA_SIP_HEADER_PREFIX_T "~sip_h_"
 #define SOFIA_DEFAULT_PORT "5060"
 #define SOFIA_DEFAULT_TLS_PORT "5061"
+#define SOFIA_REFER_TO_VARIABLE "sip_refer_to"
 
 #include <sofia-sip/nua.h>
 #include <sofia-sip/sip_status.h>
index 39c875fd482ebc1e708f36584b1fcc2b2de2799a..ed8f6bb05536ca8e39f906c482c199a26bbf631c 100644 (file)
@@ -1720,6 +1720,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
        switch_channel_t *channel_a = NULL, *channel_b = NULL;
        su_home_t *home = NULL;
        char *full_ref_by = NULL;
+       char *full_ref_to = NULL;
 
        tech_pvt = switch_core_session_get_private(session);
        channel_a = switch_core_session_get_channel(session);
@@ -1739,14 +1740,16 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
        from = sip->sip_from;
        to = sip->sip_to;
        
+       home = su_home_new(sizeof(*home));
+       switch_assert(home != NULL);
 
-       if (sip->sip_referred_by) {
-               home = su_home_new(sizeof(*home));
-               switch_assert(home != NULL);
+       if (sip->sip_referred_by) {             
                full_ref_by = sip_header_as_string(home, (void *) sip->sip_referred_by);
        }
 
        if ((refer_to = sip->sip_refer_to)) {
+               full_ref_to = sip_header_as_string(home, (void *) sip->sip_refer_to);
+
                if (profile->pflags & PFLAG_FULL_ID) {
                        exten = switch_mprintf("%s@%s", (char *) refer_to->r_url->url_user, (char *) refer_to->r_url->url_host);
                } else {
@@ -1774,11 +1777,6 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                        goto done;
                                }
 
-                               if (!home) {
-                                       home = su_home_new(sizeof(*home));
-                                       switch_assert(home != NULL);
-                               }
-
                                if ((replaces = sip_replaces_make(home, rep))
                                        && (bnh = nua_handle_by_replaces(nua, replaces))) {
                                        sofia_private_t *b_private = NULL;
@@ -1845,6 +1843,10 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                                                switch_channel_set_variable(t_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
                                                                        }
 
+                                                                       if (!switch_strlen_zero(full_ref_to)) {
+                                                                               switch_channel_set_variable(t_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
+                                                                       }
+                                                                       
                                                                        switch_ivr_session_transfer(t_session, ext, NULL, NULL);
                                                                        nua_notify(tech_pvt->nh,
                                                                                                NUTAG_NEWSUB(1),
@@ -1898,7 +1900,9 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                        if (!switch_strlen_zero(full_ref_by)) {
                                                                switch_channel_set_variable(channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
                                                        }
-
+                                                       if (!switch_strlen_zero(full_ref_to)) {
+                                                               switch_channel_set_variable(channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
+                                                       }
                                                        if (switch_ivr_originate(a_session,
                                                                                                         &tsession, &cause, exten, timeout, &noop_state_handler, NULL, NULL, NULL, SOF_NONE) 
                                                                != SWITCH_STATUS_SUCCESS) {
@@ -1954,7 +1958,9 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                if (!switch_strlen_zero(full_ref_by)) {
                                        switch_channel_set_variable(b_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
                                }
-                               
+                               if (!switch_strlen_zero(full_ref_to)) {
+                                       switch_channel_set_variable(b_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
+                               }
                                switch_ivr_session_transfer(b_session, exten, NULL, NULL);
                                switch_core_session_rwunlock(b_session);
                        }