From 9c176dc203bf171fdc6ced883cd66c18f3a03182 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 21 Oct 2008 22:40:20 +0000 Subject: [PATCH] Add optional and tag to tag. current gateways are: now can also be: now can also be: any variables will be set on all outgoing channels using that gateway. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10103 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 10 ++++++++++ src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia_reg.c | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 46a1c3e90a..ff3ffe81cc 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2029,6 +2029,16 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } else { tech_pvt->invite_contact = switch_core_session_strdup(nsession, gateway_ptr->register_contact); } + + if (gateway_ptr->vars) { + switch_event_header_t *hp; + for(hp = gateway_ptr->vars->headers; hp; hp = hp->next) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s setting variable [%s]=[%s]\n", + switch_channel_get_name(nchannel), hp->name, hp->value); + switch_channel_set_variable(nchannel, hp->name, hp->value); + } + } + } else { if (!(dest = strchr(profile_name, '/'))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n"); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index edd38544fe..da2f44e8d0 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -297,6 +297,7 @@ struct sofia_gateway { reg_state_t state; switch_memory_pool_t *pool; int deleted; + switch_event_t *vars; struct sofia_gateway *next; }; diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 98acede608..ce339001fd 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -93,6 +93,9 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_from); switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_contact); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleted gateway %s\n", gateway_ptr->name); + if (gateway_ptr->vars) { + switch_event_destroy(&gateway_ptr->vars); + } } else { last = gateway_ptr; }