diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index c766549391..e960207233 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1452,6 +1452,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session data = switch_core_session_strdup(nsession, outbound_profile->destination_number); profile_name = data; + nchannel = switch_core_session_get_channel(nsession); + if (!strncasecmp(profile_name, "gateway", 7)) { char *gw; sofia_gateway_t *gateway_ptr = NULL; @@ -1485,7 +1487,9 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } profile = gateway_ptr->profile; - + tech_pvt->gateway_name = switch_core_session_strdup(nsession, gateway_ptr->name); + switch_channel_set_variable(nchannel, "sip_gateway_name", gateway_ptr->name); + if (!switch_test_flag(gateway_ptr, REG_FLAG_CALLERID)) { tech_pvt->gateway_from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from); } @@ -1559,7 +1563,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session sofia_glue_attach_private(nsession, profile, tech_pvt, dest); - nchannel = switch_core_session_get_channel(nsession); + if (tech_pvt->local_url) { switch_channel_set_variable(nchannel, "sip_local_url", tech_pvt->local_url); } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index b3fb4261f7..a19cc47707 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -318,6 +318,7 @@ struct private_object { char *call_id; char *invite_contact; char *local_url; + char *gateway_name; unsigned long rm_rate; switch_payload_t pt; switch_mutex_t *flag_mutex; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index ee740e74f7..80a146dfd8 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -111,6 +111,9 @@ void sofia_event_callback(nua_event_t event, tech_pvt->call_id = switch_core_session_strdup(session, sip->sip_call_id->i_id); switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id); } + if (tech_pvt->gateway_name) { + gateway = sofia_reg_find_gateway(tech_pvt->gateway_name); + } } else { /* too late */ return;