From 24038ba5f9da1a618c452aba5bc12f2540bce5d0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 28 Dec 2007 22:53:04 +0000 Subject: [PATCH] add sip_refer_to var git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7008 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 26 +++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 131193f8bf..308869faf8 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -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 #include diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 39c875fd48..ed8f6bb055 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -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); }