Altering release cause

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(Created page with "Yate provides a default mapping from the call release cause of the call leg that initiated the release. You may want to alter the release cause or to enforce specific mapping...")
 
(Example)
Line 43: Line 43:
 
             }
 
             }
 
             break;
 
             break;
         case /^h323/:
+
         case /^h323\//:
 
             // Cause propagated to H.323
 
             // Cause propagated to H.323
 
             switch (msg.reason) {
 
             switch (msg.reason) {

Revision as of 17:37, 9 September 2013

Yate provides a default mapping from the call release cause of the call leg that initiated the release.

You may want to alter the release cause or to enforce specific mappings per protocol.

Concept

When a call leg is released a cause code is received over the protocol or is generated locally in case of an error.

The peer of the hung up call leg gets disconnected. At this stage it sends a chan.disconnected message that can be used to prevent the call release or to alter the propagated release cause.

Example

The following Javascript is an example of altering the release cause. The script can be placed in the share/scripts directory and be configured in javascript.conf

alter_cause=alter_release_cause.js

Content of a very simple script:

function onDisconnected(msg) {
    if (msg.reason == "congestion")
        msg.reason = "busy";
    return false;
}

Message.install(onDisconnected,"chan.disconnected",80);

A more complex script:

function onDisconnected(msg) {
    var newreason = false;
    switch (msg.id) {
        case /^sip\//:
            // Cause propagated to SIP
            switch (msg.lastpeerid) {
                case /^sip\//:
                    // SIP to SIP
                    switch (msg.reason) {
                        case "noroute":
                            newreason = "congestion";
                            break;
                        case "rejected":
                            newreason = "forbidden";
                            break;
                    }
                    break;
            }
            break;
        case /^h323\//:
            // Cause propagated to H.323
            switch (msg.reason) {
                case "congestion":
                    newreason = "busy";
                    break;
            }
            break;
    }
    if (newreason) {
        Engine.debug(Engine.DebugInfo,"Changing end reason '" + msg.reason + "' to '" + newreason + "'");
        msg.reason = newreason;
    }
    return false;
}

Message.install(onDisconnected,"chan.disconnected",80);
Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers