Author: anthm Date: Fri Dec 28 17:53:04 2007 New Revision: 7008 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Log: add sip_refer_to var Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Fri Dec 28 17:53:04 2007 @@ -72,6 +72,7 @@ #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> Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Dec 28 17:53:04 2007 @@ -1720,6 +1720,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); }