From 1ab860da40ed42907b968b46dfcd00f68d0eb354 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 18 Apr 2007 20:21:53 +0000 Subject: [PATCH] merge patch from http://jira.freeswitch.org/browse/SFSIP-11 . Please note, when registering to a UA that requires the from header to match the auth username, you must now use the new setting force-fromuser. See sample configuration file for more details. Thanks Marcel. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4970 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- conf/sofia.conf.xml | 2 ++ src/mod/endpoints/mod_sofia/mod_sofia.c | 5 ++++- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 6 +++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/conf/sofia.conf.xml b/conf/sofia.conf.xml index e22c94b555..b21e8b0a67 100644 --- a/conf/sofia.conf.xml +++ b/conf/sofia.conf.xml @@ -10,6 +10,8 @@ + + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 09d64e787d..c4d3d98837 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -890,7 +890,9 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session } profile = gateway_ptr->profile; - tech_pvt->gateway_from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from); + if (gateway_ptr->force_fromuser) { + tech_pvt->gateway_from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from); + } if (!strchr(dest, '@')) { tech_pvt->dest = switch_core_session_sprintf(nsession, "sip:%s@%s", dest, gateway_ptr->register_proxy + 4); } else { @@ -1095,3 +1097,4 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void) * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: */ + diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 0c129d7144..cc308768ef 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -176,6 +176,7 @@ struct outbound_reg { char *register_realm; char *register_username; char *register_password; + switch_bool_t force_fromuser; char *register_from; char *register_contact; char *register_to; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 9e3dfe97d2..1993b17ef4 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -680,7 +680,7 @@ switch_status_t config_sofia(int reload) if ((gateway = switch_core_alloc(profile->pool, sizeof(*gateway)))) { char *register_str = "true", *scheme = "Digest", *realm = NULL, - *username = NULL, *password = NULL, *extension = NULL, *proxy = NULL, *context = "default", *expire_seconds = "3600"; + *username = NULL, *password = NULL, *force_fromuser = "false", *extension = NULL, *proxy = NULL, *context = "default", *expire_seconds = "3600"; gateway->pool = profile->pool; gateway->profile = profile; @@ -702,6 +702,8 @@ switch_status_t config_sofia(int reload) username = val; } else if (!strcmp(var, "password")) { password = val; + } else if (!strcmp(var, "force-fromuser")) { + force_fromuser = val; } else if (!strcmp(var, "extension")) { extension = val; } else if (!strcmp(var, "proxy")) { @@ -745,6 +747,7 @@ switch_status_t config_sofia(int reload) gateway->register_realm = switch_core_strdup(gateway->pool, realm); gateway->register_username = switch_core_strdup(gateway->pool, username); gateway->register_password = switch_core_strdup(gateway->pool, password); + gateway->force_fromuser = switch_true(force_fromuser); gateway->register_from = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, realm); gateway->register_contact = switch_core_sprintf(gateway->pool, "sip:%s@%s:%d", extension, profile->sipip, profile->sip_port); @@ -1765,3 +1768,4 @@ void sofia_handle_sip_i_options(int status, +