From 5572f25a0f73cb13eddd1851a1a145ea1f4aaf32 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 15 Aug 2008 19:30:34 +0000 Subject: [PATCH] fix MODENDP-121 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9305 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 8 ++++++++ src/mod/endpoints/mod_sofia/sofia_reg.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 6a395057f8..6b342d5aba 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -269,6 +269,7 @@ struct sofia_gateway { char *register_scheme; char *register_realm; char *register_username; + char *auth_username; char *register_password; char *register_from; char *register_contact; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index d328630963..161d1eb05e 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -775,6 +775,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) char *register_str = "true", *scheme = "Digest", *realm = NULL, *username = NULL, + *auth_username = NULL, *password = NULL, *caller_id_in_from = "false", *extension = NULL, @@ -807,6 +808,8 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) realm = val; } else if (!strcmp(var, "username")) { username = val; + } else if (!strcmp(var, "auth-username")) { + auth_username = val; } else if (!strcmp(var, "password")) { password = val; } else if (!strcmp(var, "caller-id-in-from")) { @@ -886,6 +889,10 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) from_domain = realm; } + if (switch_strlen_zero(auth_username)) { + auth_username = username; + } + if (!switch_strlen_zero(register_proxy)) { gateway->register_sticky_proxy = switch_core_strdup(gateway->pool, register_proxy); } @@ -899,6 +906,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) gateway->register_context = switch_core_strdup(gateway->pool, context); gateway->register_realm = switch_core_strdup(gateway->pool, realm); gateway->register_username = switch_core_strdup(gateway->pool, username); + gateway->auth_username = switch_core_strdup(gateway->pool, auth_username); gateway->register_password = switch_core_strdup(gateway->pool, password); if (switch_true(caller_id_in_from)) { switch_set_flag(gateway, REG_FLAG_CALLERID); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 37ba36a323..6dcb76c8d8 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -1094,7 +1094,7 @@ void sofia_reg_handle_sip_r_challenge(int status, goto cancel; } - switch_snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->register_username, gateway->register_password); + switch_snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->auth_username, gateway->register_password); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Authenticating '%s' with '%s'.\n", profile->username, authentication);