[Freeswitch-svn] [commit] r8186 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Wed Apr 23 18:23:23 EDT 2008


Author: anthm
Date: Wed Apr 23 18:23:23 2008
New Revision: 8186

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

Log:
update

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Wed Apr 23 18:23:23 2008
@@ -285,7 +285,7 @@
 			
 		if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
-			nua_bye(tech_pvt->nh, SIPTAG_REASON_STR(reason), TAG_END());
+			nua_bye(tech_pvt->nh, SIPTAG_RECORD_ROUTE_STR(tech_pvt->record_route), SIPTAG_REASON_STR(reason), TAG_END());
 		} else {
 			if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
@@ -386,7 +386,9 @@
 		}
 	}
 
+	printf("XXXXXXXXXXXXXXXXXXXXXXXXWTF [%s]\n", tech_pvt->record_route);
 	nua_respond(tech_pvt->nh, SIP_200_OK,
+				SIPTAG_RECORD_ROUTE_STR(tech_pvt->record_route),
 				NUTAG_AUTOANSWER(0),
 				NUTAG_SESSION_TIMER(session_timeout),
 				SIPTAG_CONTACT_STR(tech_pvt->reply_contact),

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	Wed Apr 23 18:23:23 2008
@@ -381,6 +381,7 @@
 	char *gateway_name;
 	char *local_crypto_key;
 	char *remote_crypto_key;
+	char *record_route;
 	int crypto_tag;
 	unsigned char local_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN];
 	unsigned char remote_raw_key[SWITCH_RTP_MAX_CRYPTO_LEN];
@@ -421,6 +422,8 @@
 	uint32_t video_count;
 	sofia_dtmf_t dtmf_type;
 	int q850_cause;
+	char *remote_ip;
+	int remote_port;
 };
 
 struct callback_t {

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	Wed Apr 23 18:23:23 2008
@@ -2586,7 +2586,7 @@
 	uint32_t sess_max = switch_core_session_limit(0);
 	int is_auth = 0, calling_myself = 0;
 	su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
-	
+	int network_port = 0;
 
 	if (sess_count >= sess_max || !(profile->pflags & PFLAG_RUNNING)) {
 		nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
@@ -2601,6 +2601,7 @@
 
 	
 	get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
+	network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
 
 	if (profile->acl_count) {
 		uint32_t x = 0;
@@ -2649,6 +2650,17 @@
 	}
 	switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
 
+	tech_pvt->remote_ip = switch_core_session_strdup(session, network_ip);
+	tech_pvt->remote_port = network_port;
+
+	if (sip->sip_contact && sip->sip_contact->m_url) {
+		tech_pvt->record_route = switch_core_session_sprintf(session, "<sip:%s@%s:%d;lr>", 
+															 sip->sip_contact->m_url->url_user, 
+															 tech_pvt->remote_ip,
+															 tech_pvt->remote_port);
+	}
+
+
 	if (*key != '\0') {
 		tech_pvt->key = switch_core_session_strdup(session, key);
 	}

Modified: freeswitch/trunk/src/switch_console.c
==============================================================================
--- freeswitch/trunk/src/switch_console.c	(original)
+++ freeswitch/trunk/src/switch_console.c	Wed Apr 23 18:23:23 2008
@@ -584,8 +584,16 @@
 			switch_stream_handle_t mystream = { 0 };
 			SWITCH_STANDARD_STREAM(mystream);
 
-			if (!strcasecmp(argv[0], "add")) {
-				mystream.write_function(&mystream, "insert into complete values (");
+
+			if (!strcasecmp(argv[0], "stickyadd")) {
+				mystream.write_function(&mystream, "insert into complete values (1,");
+				for(x = 0; x < 10; x++) {
+					mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x+1]), x == 9 ? ")" : ", ");
+				}
+				switch_core_db_persistant_execute(db, mystream.data, 5);
+				status = SWITCH_STATUS_SUCCESS;
+			} else if (!strcasecmp(argv[0], "add")) {
+				mystream.write_function(&mystream, "insert into complete values (0,");
 				for(x = 0; x < 10; x++) {
 					mystream.write_function(&mystream, "'%s'%s", switch_str_nil(argv[x+1]), x == 9 ? ")" : ", ");
 				}
@@ -627,11 +635,19 @@
 			switch_core_db_t *db = switch_core_db_handle();
 			char *sql = NULL;
 
-			if (!strcasecmp(argv[0], "add") && argc == 3) {
+
+			if (!strcasecmp(argv[0], "stickyadd") && argc == 3) {
+				sql = switch_mprintf("delete from aliases where alias='%q'", argv[1]);
+				switch_core_db_persistant_execute(db, sql, 5);
+				switch_safe_free(sql);
+				sql = switch_mprintf("insert into aliases (sticky, alias, command) values (1, '%q','%q')", argv[1], argv[2]);
+				switch_core_db_persistant_execute(db, sql, 5);
+				status = SWITCH_STATUS_SUCCESS;
+			} else if (!strcasecmp(argv[0], "add") && argc == 3) {
 				sql = switch_mprintf("delete from aliases where alias='%q'", argv[1]);
 				switch_core_db_persistant_execute(db, sql, 5);
 				switch_safe_free(sql);
-				sql = switch_mprintf("insert into aliases (alias, command) values ('%q','%q')", argv[1], argv[2]);
+				sql = switch_mprintf("insert into aliases (sticky, alias, command) values (0, '%q','%q')", argv[1], argv[2]);
 				switch_core_db_persistant_execute(db, sql, 5);
 				status = SWITCH_STATUS_SUCCESS;
 			} else if (!strcasecmp(argv[0], "del") && argc == 2) {

Modified: freeswitch/trunk/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/trunk/src/switch_core_sqldb.c	(original)
+++ freeswitch/trunk/src/switch_core_sqldb.c	Wed Apr 23 18:23:23 2008
@@ -368,6 +368,7 @@
 	} else {
 		char create_complete_sql[] =
 			"CREATE TABLE complete (\n"
+			"   sticky  INTEGER,\n" 
 			"   a1  VARCHAR(255),\n" 
 			"   a2  VARCHAR(255),\n" 
 			"   a3  VARCHAR(255),\n" 
@@ -382,6 +383,7 @@
 
 		char create_alias_sql[] =
 			"CREATE TABLE aliases (\n"
+			"   sticky  INTEGER,\n" 
 			"   alias  VARCHAR(255),\n" 
 			"   command  VARCHAR(255)\n" 
 			");\n";
@@ -445,8 +447,10 @@
 		switch_core_db_exec(sql_manager.db, "PRAGMA cache_size=8000", NULL, NULL, NULL);
 		switch_core_db_exec(sql_manager.db, "PRAGMA temp_store=MEMORY;", NULL, NULL, NULL);
 
-		switch_core_db_test_reactive(sql_manager.db, "select a1 from complete", "DROP TABLE complete", create_complete_sql);
-		switch_core_db_test_reactive(sql_manager.db, "select alias from aliases", "DROP TABLE aliases", create_alias_sql);
+		switch_core_db_test_reactive(sql_manager.db, "select sticky from complete", "DROP TABLE complete", create_complete_sql);
+		switch_core_db_test_reactive(sql_manager.db, "select sticky from aliases", "DROP TABLE aliases", create_alias_sql);
+		switch_core_db_exec(sql_manager.db, "delete from complete where sticky=0", NULL, NULL, NULL);
+		switch_core_db_exec(sql_manager.db, "delete from aliases where sticky=0", NULL, NULL, NULL);
 		switch_core_db_exec(sql_manager.db, create_channels_sql, NULL, NULL, NULL);
 		switch_core_db_exec(sql_manager.db, create_calls_sql, NULL, NULL, NULL);
 		switch_core_db_exec(sql_manager.db, create_interfaces_sql, NULL, NULL, NULL);



More information about the Freeswitch-svn mailing list