[Freeswitch-svn] [commit] r10222 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN brian at freeswitch.org
Mon Nov 3 12:39:10 EST 2008


Author: brian
Date: Mon Nov  3 12:39:09 2008
New Revision: 10222

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c

Log:
cache auth_gateway_name in sofia for challenged bye

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Mon Nov  3 12:39:09 2008
@@ -109,7 +109,8 @@
 struct sofia_private {
 	char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
 	sofia_gateway_t *gateway;
-	char gateway_name[512];
+	char gateway_name[256];
+	char auth_gateway_name[256];
 	int destroy_nh;
 	int destroy_me;
 	int is_call;
@@ -586,8 +587,9 @@
 
 void sofia_reg_handle_sip_r_challenge(int status,
 									  char const *phrase,
-									  nua_t *nua, sofia_profile_t *profile, 
-									  nua_handle_t *nh, switch_core_session_t *session, sofia_gateway_t *gateway, sip_t const *sip, tagi_t tags[]);
+									  nua_t *nua, sofia_profile_t *profile,
+									  nua_handle_t *nh, sofia_private_t *sofia_private,
+									  switch_core_session_t *session, sofia_gateway_t *gateway, sip_t const *sip, tagi_t tags[]);
 void sofia_reg_handle_sip_r_register(int status,
 					char const *phrase,
 					nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Mon Nov  3 12:39:09 2008
@@ -182,6 +182,12 @@
 				tech_pvt = switch_core_session_get_private(session);
 				switch_assert(tech_pvt);
 				channel = switch_core_session_get_channel(tech_pvt->session);
+				if (status >= 180 && !*sofia_private->auth_gateway_name) {
+					const char *gwname = switch_channel_get_variable(channel, "sip_use_gateway");
+					if (!switch_strlen_zero(gwname)) {
+						switch_set_string(sofia_private->auth_gateway_name, gwname);
+					}
+				}
 				if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
 					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);
@@ -237,7 +243,7 @@
 	}
 
 	if (sip && (status == 401 || status == 407)) {
-		sofia_reg_handle_sip_r_challenge(status, phrase, nua, profile, nh, session, gateway, sip, tags);
+		sofia_reg_handle_sip_r_challenge(status, phrase, nua, profile, nh, sofia_private, session, gateway, sip, tags);
 		goto done;
 	}
 
@@ -3899,7 +3905,7 @@
 	memset(sofia_private, 0, sizeof(*sofia_private));
 	sofia_private->is_call++;
 	tech_pvt->sofia_private = sofia_private;
-
+	
 	if ((profile->pres_type)) {
 		sofia_presence_set_chat_hash(tech_pvt, sip);
 	}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	Mon Nov  3 12:39:09 2008
@@ -1097,7 +1097,7 @@
 
 void sofia_reg_handle_sip_r_challenge(int status,
 									  char const *phrase,
-									  nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
+									  nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private,
 									  switch_core_session_t *session, sofia_gateway_t *gateway, sip_t const *sip, tagi_t tags[])
 {
 	sip_www_authenticate_t const *authenticate = NULL;
@@ -1110,6 +1110,10 @@
 	sofia_gateway_t *var_gateway = NULL;
 	const char *gw_name = NULL;
 
+	if (sofia_private && *sofia_private->auth_gateway_name) {
+		gw_name = sofia_private->auth_gateway_name;
+	}
+
 	if (session) {
 		private_object_t *tech_pvt;
 		switch_channel_t *channel = switch_core_session_get_channel(session);



More information about the Freeswitch-svn mailing list