[Freeswitch-svn] [commit] r7078 - in freeswitch/trunk: conf conf/dialplan src/include src/mod/applications/mod_dptools src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Thu Jan 3 18:42:15 EST 2008


Author: anthm
Date: Thu Jan  3 18:42:15 2008
New Revision: 7078

Modified:
   freeswitch/trunk/conf/dialplan/default.xml
   freeswitch/trunk/conf/vars.xml
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c

Log:
fix MODENDP-66

Modified: freeswitch/trunk/conf/dialplan/default.xml
==============================================================================
--- freeswitch/trunk/conf/dialplan/default.xml	(original)
+++ freeswitch/trunk/conf/dialplan/default.xml	Thu Jan  3 18:42:15 2008
@@ -2,6 +2,14 @@
 <!-- http://wiki.freeswitch.org/wiki/Dialplan_XML -->
 <include>
   <context name="default">
+
+    <extension name="unloop">
+      <condition field="${unroll_loops}" expression="^true$" continue="on-true"/>
+      <condition field="${sip_looped_call}" expression="^true$">
+	<action application="deflect" data="${destination_number}"/>
+      </condition>
+    </extension>
+
     <extension name="intercept">
       <condition field="destination_number" expression="^886$">
 	<action application="answer"/>
@@ -35,8 +43,10 @@
       <condition field="${numbering_plan}" expression="^$" break="never">
 	<action application="set_user" data="default@${domain}"/>
       </condition>
-      <condition>
+      <condition field="${call_debug}" expression="^true$" break="never">
 	<action application="info"/>
+      </condition>
+      <condition>
 	<action application="db" data="insert/spymap/${caller_id_number}/${uuid}"/>
 	<action application="db" data="insert/last_dial/${caller_id_number}/${destination_number}"/>
 	<action application="db" data="insert/last_dial/global/${uuid}"/>

Modified: freeswitch/trunk/conf/vars.xml
==============================================================================
--- freeswitch/trunk/conf/vars.xml	(original)
+++ freeswitch/trunk/conf/vars.xml	Thu Jan  3 18:42:15 2008
@@ -41,15 +41,14 @@
        Used by: sofia.conf.xml dingaling.conf.xml
   -->
   <X-PRE-PROCESS cmd="set" data="external_sip_ip=stun:stun.fwdnet.net"/>
-  <!-- server_name
-       A public ip address or DNS name that is used when advertising conference
-       presence or registering sip.
-       Used by: conference.conf.xml
+  <!-- unroll-loops
+       Used to turn on sip loopback unrolling.
   --> 
+  <X-PRE-PROCESS cmd="set" data="unroll_loops=true"/>
   <!-- outbound_caller_id and outbound_caller_name
        The caller ID telephone number we should use when calling out.
        Used by: conference.conf.xml
   -->
   <X-PRE-PROCESS cmd="set" data="outbound_caller_name=FreeSWITCH"/>
   <X-PRE-PROCESS cmd="set" data="outbound_caller_id=8777423583"/>
-
+  <X-PRE-PROCESS cmd="set" data="call_debug=false"/>

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Thu Jan  3 18:42:15 2008
@@ -431,6 +431,7 @@
 	SWITCH_MESSAGE_INDICATE_RESPOND    - indicate reject
 	SWITCH_MESSAGE_INDICATE_BROADCAST - indicate media broadcast
 	SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT - indicate media broadcast
+	SWITCH_MESSAGE_INDICATE_DEFLECT - indicate deflect
 </pre>
  */
 typedef enum {
@@ -449,7 +450,8 @@
 	SWITCH_MESSAGE_INDICATE_REDIRECT,
 	SWITCH_MESSAGE_INDICATE_RESPOND,
 	SWITCH_MESSAGE_INDICATE_BROADCAST,
-	SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT
+	SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT,
+	SWITCH_MESSAGE_INDICATE_DEFLECT
 } switch_core_session_message_types_t;
 
 

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Thu Jan  3 18:42:15 2008
@@ -428,6 +428,18 @@
 
 }
 
+SWITCH_STANDARD_APP(deflect_function)
+{
+	switch_core_session_message_t msg = { 0 };
+
+	/* Tell the channel to respond the call */
+	msg.from = __FILE__;
+	msg.string_arg = data;
+	msg.message_id = SWITCH_MESSAGE_INDICATE_DEFLECT;
+	switch_core_session_receive_message(session, &msg);
+
+}
+
 
 SWITCH_STANDARD_APP(set_function)
 {
@@ -1398,8 +1410,9 @@
 			}
 
 		}
-
-		switch_channel_hangup(caller_channel, cause);
+		if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && switch_channel_get_state(caller_channel) != CS_RING) {
+			switch_channel_hangup(caller_channel, cause);
+		}
 		return;
 	} else {
 		if (no_media_bridge) {
@@ -1632,6 +1645,7 @@
 	SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "reject", "Send session reject (depricated)", "Send a respond message to a session.", respond_function, "<respond_data>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "queue_dtmf", "Queue dtmf to be sent", "Queue dtmf to be sent from a session", queue_dtmf_function, "<dtmf_data>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "sched_hangup", SCHED_HANGUP_DESCR, SCHED_HANGUP_DESCR, sched_hangup_function, "[+]<time> [<cause>]", SAF_SUPPORT_NOMEDIA);

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	Thu Jan  3 18:42:15 2008
@@ -914,6 +914,21 @@
 			nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END());
 		}
 		break;
+
+	case SWITCH_MESSAGE_INDICATE_DEFLECT:
+		{
+			char ref_to[128] = "";
+
+			if (!strstr(msg->string_arg, "sip:")) {
+				switch_snprintf(ref_to, sizeof(ref_to), "sip:%s@%s", msg->string_arg, tech_pvt->profile->sipip);
+			} else {
+				switch_set_string(ref_to, msg->string_arg);
+			}
+
+			nua_refer(tech_pvt->nh, SIPTAG_REFER_TO_STR(ref_to), SIPTAG_REFERRED_BY_STR(tech_pvt->contact_url), TAG_END());
+		}
+		break;
+
 	case SWITCH_MESSAGE_INDICATE_RESPOND:
 		if (msg->numeric_arg || msg->string_arg) {
 			int code = msg->numeric_arg;

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	Thu Jan  3 18:42:15 2008
@@ -2241,7 +2241,7 @@
 	switch_event_t *v_event = NULL;
 	uint32_t sess_count = switch_core_session_count();
 	uint32_t sess_max = switch_core_session_limit(0);
-	int is_auth = 0;
+	int is_auth = 0, calling_myself = 0;
 	su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
 	
 	if (sess_count >= sess_max) {
@@ -2261,12 +2261,19 @@
 		return;
 	}
 	
+
+	get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
+
 	if ((profile->pflags & PFLAG_AUTH_CALLS) || sip->sip_proxy_authorization || sip->sip_authorization) {
-		if (sofia_reg_handle_register(nua, profile, nh, sip, REG_INVITE, key, sizeof(key), &v_event)) {
-			if (v_event) {
-				switch_event_destroy(&v_event);
+		if (strcmp(network_ip, profile->sipip)) {
+			if (sofia_reg_handle_register(nua, profile, nh, sip, REG_INVITE, key, sizeof(key), &v_event)) {
+				if (v_event) {
+					switch_event_destroy(&v_event);
+				}
+				return;
 			}
-			return;
+		} else {
+			calling_myself++;
 		}
 		is_auth++;
 	}
@@ -2288,13 +2295,16 @@
 		tech_pvt->key = switch_core_session_strdup(session, key);
 	}
 
-	get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
-
 	channel = switch_core_session_get_channel(session);
+
 	if (is_auth) {
 		switch_channel_set_variable(channel, "sip_authorized", "true");
 	}
 
+	if (calling_myself) {
+		switch_channel_set_variable(channel, "sip_looped_call", "true");
+	}
+
 	if (v_event) {
 		switch_event_header_t *hp;
 		



More information about the Freeswitch-svn mailing list