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

Freeswitch SVN anthm at freeswitch.org
Thu Jul 17 09:36:02 EDT 2008


Author: anthm
Date: Thu Jul 17 09:36:02 2008
New Revision: 9068

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

Log:
wip

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	Thu Jul 17 09:36:02 2008
@@ -950,12 +950,34 @@
 	char *cur;
 	char authentication[256] = "";
 	int ss_state;
+	sofia_gateway_t *var_gateway = NULL;
+	const char *gw_name = NULL;
 
 	if (session) {
 		private_object_t *tech_pvt;
+		switch_channel_t *channel = switch_core_session_get_channel(session);
+
 		if ((tech_pvt = switch_core_session_get_private(session)) && switch_test_flag(tech_pvt, TFLAG_REFER)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "received reply from refer\n");
-			return;
+			goto end;
+		}
+
+		gw_name = switch_channel_get_variable(channel, "sip_use_gateway");
+	}
+
+	if (!gateway) {
+		if (gw_name) {
+			var_gateway = sofia_reg_find_gateway((char *)gw_name);
+		}
+
+#if __FINISHED__
+		if (!var_gateway) {
+			// look for it in the params of the contact or req uri etc.
+		}
+#endif
+
+		if (var_gateway) {
+			gateway = var_gateway;
 		}
 	}
 
@@ -966,7 +988,7 @@
 		authenticate = sip->sip_proxy_authenticate;
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Missing Authenticate Header!\n");
-		return;
+		goto end;
 	}
 	scheme = (char const *) authenticate->au_scheme;
 	if (authenticate->au_params) {
@@ -980,7 +1002,7 @@
 
 	if (!(scheme && realm)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No scheme and realm!\n");
-		return;
+		goto end;
 	}
 
 	if (!gateway) {
@@ -999,7 +1021,7 @@
 
 	nua_authenticate(nh, SIPTAG_EXPIRES_STR(gateway->expires_str), NUTAG_AUTH(authentication), TAG_END());
 
-	return;
+	goto end;
 
   cancel:
 
@@ -1009,6 +1031,16 @@
 		nua_cancel(nh, TAG_END());
 	}
 
+ end:
+
+	if (var_gateway) {
+		sofia_reg_release_gateway(var_gateway);
+	}
+
+	return;
+
+
+
 }
 
 auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization, sip_t const *sip, const char *regstr,



More information about the Freeswitch-svn mailing list