From 5dfc7cf8038274ff08eebe01299d70770668985a Mon Sep 17 00:00:00 2001 From: Stan Gor Date: Tue, 19 Aug 2014 11:54:09 -0700 Subject: [PATCH] Add sofia gateway parameter "destination-prefix" FS-5497 add sofia gateway parameter destination-prefix in case you need to send Invites to your provider with prefix only to this gateway --- src/mod/endpoints/mod_sofia/mod_sofia.c | 4 ++-- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 8b3f075612..2e422669f0 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -4986,9 +4986,9 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } if (!strchr(dest, '@')) { - tech_pvt->dest = switch_core_session_sprintf(nsession, "sip:%s@%s", dest, sofia_glue_strip_proto(gateway_ptr->register_proxy)); + tech_pvt->dest = switch_core_session_sprintf(nsession, "sip:%s%s@%s", gateway_ptr->destination_prefix, dest, sofia_glue_strip_proto(gateway_ptr->register_proxy)); } else { - tech_pvt->dest = switch_core_session_sprintf(nsession, "sip:%s", dest); + tech_pvt->dest = switch_core_session_sprintf(nsession, "sip:%s%s", gateway_ptr->destination_prefix, dest); } if ((host = switch_core_session_strdup(nsession, tech_pvt->dest))) { diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index b66008695e..f8c9173de9 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -511,6 +511,7 @@ struct sofia_gateway { char *register_context; char *expires_str; char *register_url; + char *destination_prefix; char *from_domain; sofia_transport_t register_transport; uint32_t freq; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 4102dbecc0..696b7584f3 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3006,6 +3006,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) gateway->ob_calls = 0; gateway->ib_failed_calls = 0; gateway->ob_failed_calls = 0; + gateway->destination_prefix = ""; if ((x_params = switch_xml_child(gateway_tag, "variables"))) { param = switch_xml_child(x_params, "variable"); @@ -3107,6 +3108,10 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) outbound_proxy = val; } else if (!strcmp(var, "distinct-to")) { distinct_to = switch_true(val); + } else if (!strcmp(var, "destination-prefix")) { + if (!zstr(val)) { + gateway->destination_prefix = switch_core_strdup(gateway->pool, val); + } } else if (!strcmp(var, "rfc-5626")) { rfc_5626 = switch_true(val); } else if (!strcmp(var, "reg-id")) { -- 2.47.2