]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_loopback] add refer mock to null endpoint
authorSeven Du <seven@signalwire.com>
Fri, 6 Dec 2019 08:41:03 +0000 (16:41 +0800)
committerAndrey Volk <andywolk@gmail.com>
Mon, 30 Dec 2019 23:07:49 +0000 (03:07 +0400)
src/mod/endpoints/mod_loopback/mod_loopback.c

index 6e1d629abf14e4a457b97766d846bfb710dd9e16..6d77eb946b9f0a88038591e6b07e5bca76d3b959 100644 (file)
@@ -1551,6 +1551,29 @@ static switch_status_t null_channel_receive_message(switch_core_session_t *sessi
        case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
                switch_core_timer_sync(&tech_pvt->timer);
                break;
+       case SWITCH_MESSAGE_INDICATE_DEFLECT:
+               if (msg->string_array_arg[0]) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "string_array_arg[0]: %s\n", (char *)msg->string_array_arg[0]);
+               } else {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "string_arg: %s\n", (char *)msg->string_arg);
+                       if (msg->string_arg) {
+                               if (!strncmp(msg->string_arg, "sip:refer-200", 13)) {
+                                       switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_BLIND_TRANSFER);
+                                       switch_channel_set_variable(channel, "sip_refer_status_code", "202");
+                                       switch_channel_set_variable(channel, "sip_refer_reply", "SIP/2.0 200 OK\r\n");
+                               } else if (!strncmp(msg->string_arg, "sip:refer-202", 13)) {
+                                       switch_channel_set_variable(channel, "sip_refer_status_code", "202");
+                                       // no notify received
+                                       switch_yield(5000000);
+                                       switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                               } else if (!strncmp(msg->string_arg, "sip:refer-403", 13)) {
+                                       switch_channel_set_variable(channel, "sip_refer_status_code", "202");
+                                       switch_channel_set_variable(channel, "sip_refer_reply", "SIP/2.0 403 Forbidden\r\n");
+                                       switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_BLIND_TRANSFER);
+                               }
+                       }
+               }
+               break;
        default:
                break;
        }