]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix MODENDP-66
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 3 Jan 2008 23:42:15 +0000 (23:42 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 3 Jan 2008 23:42:15 +0000 (23:42 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7078 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index a5ba393a526a05bf7313715191fb09244233a805..ca4769a86bb136bc8f099c8f7843d7b104683812 100644 (file)
@@ -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"/>
       <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}"/>
index c8b229f671f84aae123fa5ab13e615b1776f0ba6..54dd2bbcf069cf54e5ef068d5ff25f08f0f0dd16 100644 (file)
        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"/>
index 9278c95759186ce57fd0096a49bf8f20e4d785d9..c80271b84e8c26e513aacb339bd39ac3d4b17959 100644 (file)
@@ -431,6 +431,7 @@ typedef enum {
        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 @@ typedef enum {
        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;
 
 
index 030f0d289cca414bdb3a0f863a020b7c819fd2b9..8408a625ae883b3ffd3ba48b798d2a83014bd2e2 100644 (file)
@@ -428,6 +428,18 @@ SWITCH_STANDARD_APP(respond_function)
 
 }
 
+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_STANDARD_APP(audio_bridge_function)
                        }
 
                }
-
-               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_MODULE_LOAD_FUNCTION(mod_dptools_load)
        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);
index c562884e83e5f912ac11101e7f601b178fa7f7e4..eaf4a6e2e7c6317a7c780ba32824405e6498bfab 100644 (file)
@@ -914,6 +914,21 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                        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;
index f675ee6f86638f0ebc8a723a0f27bfb646679b2b..ebcdd1bc61e32e7ee5453734ab05195d43317b4f 100644 (file)
@@ -2241,7 +2241,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
        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 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
                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 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
                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;