[Home]

Summary:ASTERISK-05860: [patch] Forced bypass switch in pbx.c - makes Realtime (or other switch) master
Reporter:Steven Sokol (ssokol)Labels:
Date Opened:2005-12-17 11:53:26.000-0600Date Closed:2008-03-10 16:58:40
Priority:MajorRegression?No
Status:Closed/CompleteComponents:PBX/NewFeature
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20080304__bug6019.diff.txt
( 1) bypass_hack.patch
Description:This hack allows you to set an alternate switch as the default switch for the system.  In my case, this allows me to place Realtime (ARA) as the master switch, bypassing the standard in-memory assembly of contexts and extensions.  This has a number of advantages over the standard method of using ARA (or any other switch).

The biggest advantage is that the system will search the alternate switch for a matching context (and thus you don't have to have a "proxy context" in extensions.conf which simply invokes the switch with the given context).

To make this work, simply patch pbx.c with the included patch, then go to the bottom of your extensions.conf file and create a context named "bypass_switch" and add a switch statement to include the new master switch:

[bypass_switch]
switch = Realtime/default@extensions

Restart your system.  The first time Asterisk calls pbx_find_extension it will look for your bypass_switch.  If found, the bypass switch will be mounted (cached) and used for all subsequent calls.


****** ADDITIONAL INFORMATION ******

This hack works in part by replacing the switch data value (default@extensions in the example above) with "[requested context]@extensions".  The switch then looks for the requested context.  This allows you to toss in extensions/contexts and new users/peers as you want.  You can change the context value and the device is immediately directed into the specified context.

The one exception to this is cached peers -- Asterisk requires a 'sip reload' or a 'reload' as this clears out the cache and forces Asterisk to reload the peer/user entry when a call is made.  

Possible Improvements:

1) Make this respond to some setting in the general section rather than a trigger context.
2) Set a flag so that checking for a bypass_switch context only occurs once.
3) Somehow make the system "fall back" to the default switch if the new master alt switch flakes out.

This is totally experimental, so please give it a try and let me know what you think.

Thanks

-S
Comments:By: Matt O'Gorman (mogorman) 2006-01-18 10:14:58.000-0600

Steven have you given any more thought or time to this?  I am sure many people appreciate the idea of plugging in a different switch directly in for dial plan, rather than the current default.

By: Steven Sokol (ssokol) 2006-01-18 14:25:07.000-0600

Actually, I am using this on my development system with good results (so far).  I use it in conjunction with ARA, the Postgresql ARA driver and my Realtime include hack (http://bugs.digium.com/view.php?id=6014) to make my switch "really realtime".

The downside to this hack is that it currently only works with ARA.  I replace the switch context value with the requested context name using the syntax which is required by ARA but unlikely to do the right thing for any other switch (i.e. IAX2, DUNDi, etc.)

What I really need to do is alter this patch so that it allows for some control over the data passed to the alt switch.  For example, change it to recognize %c as context, %e as extension, %i as CallerID, etc.  

This way an IAX2 switch would read as follows:

[bypass_switch]
switch => IAX2/username:[keyname]@dpserver.astricon.net/%c  

This way switches which don't need any changes (i.e. DUNDi and res_sqlite3) would not have any substitution to make -- the system would just pass the lookup function call on directly.

I also need to set it up so that it only checks for the bypass_switch once (the first time that pbx_find_extension is called.  Perhaps if somebody wants to mount an alternate switch at a later time they can execute a cli command (mount switch [blah]) to make that the main switch.

By: Adam Simpson (asimpson) 2006-07-15 10:53:21

When using the forced bypass switch patch (Bug ASTERISK-5956019) the dial plan seems to stop functioning as expected whereas whereas if you use a regular switch statement such as:

[mycontext]
switch => Realtime/mycontext@extensions

with the exact same dialplan, the dialplan works fine. In fact there are odd delays when using WaitExten and the 'i' invalid extension does not function at all.

My dialplan is very simple (which is in my mysql database):

[menu-1]
s,1,Background(mygreeting)
s,2,WaitExten
1,1,Playback(pls-hold-while-try)
1,2,Hangup
i,1,Playback(invalid)
i,2,Hangup

When using the bypass switch, if I press 5 on my phone the CLI reports that it tries to goto extension 5 with a priority of 1 rather than the invalid extension. If I press 1 asterisk waits like 4 seconds before going to extension 1.

If instead I just use a regular switch statement the menu-1 context rather than the bypass patch, everything works as expected without delays.

By: jmls (jmls) 2006-11-01 05:22:52.000-0600

it's been a long time since this was updated. Is it still relevant and a desired feature ?

By: Adam Simpson (asimpson) 2006-11-02 11:05:55.000-0600

I think that the functionality of being able to use contexts from the database without having to specify them in extensions.conf is a useful one.  If you are using asterisk to building dynamic menus or contexts, it is very difficult when you have to add switch statements to a extensions.conf file and then do a reload.  Perhaps a more elegant solution than a bypass hack would accomplish this.

By: jmls (jmls) 2007-09-12 16:32:18

this should probably be closed. Any objections ?

By: CLEMENT Frédéric (fclement) 2008-01-23 05:05:03.000-0600

It's a pity that this feature hasn't been integrated in the last version.
Imagine :
I have several companies and a context for each of theses.
Every time I add a company to my asterisk, I have to edit the extensions.conf file
to add a new context. That is not really the purpose of realtime.
I think this patch should be integrated in the official version.

By: Tilghman Lesher (tilghman) 2008-03-04 12:42:22.000-0600

We're looking at putting this in, so I've updated the patch to work with trunk.  Unfortunately, it's going to be difficult for me to test this, as I do not use switches on my setups.

Would someone like to test this patch, or alternately, give me some examples to try to test this?

By: Tilghman Lesher (tilghman) 2008-03-10 11:30:06

I need feedback on this issue or it will be closed.

By: Digium Subversion (svnbot) 2008-03-10 16:44:30

Repository: asterisk
Revision: 107231

_U  trunk/
U   trunk/include/asterisk/pbx.h
U   trunk/main/pbx.c
U   trunk/pbx/pbx_config.c

------------------------------------------------------------------------
r107231 | tilghman | 2008-03-10 16:44:29 -0500 (Mon, 10 Mar 2008) | 6 lines

(closes issue ASTERISK-5860)
Reported by: ssokol
Patches:
      20080304__bug6019.diff.txt uploaded by Corydon76 (license 14)
Tested by: putnopvut

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=107231

By: Digium Subversion (svnbot) 2008-03-10 16:58:40

Repository: asterisk
Revision: 107232

_U  branches/1.6.0/
U   branches/1.6.0/main/pbx.c

------------------------------------------------------------------------
r107232 | tilghman | 2008-03-10 16:58:39 -0500 (Mon, 10 Mar 2008) | 14 lines

Blocked revisions 107231 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
r107231 | tilghman | 2008-03-10 16:48:20 -0500 (Mon, 10 Mar 2008) | 6 lines

(closes issue ASTERISK-5860)
Reported by: ssokol
Patches:
      20080304__bug6019.diff.txt uploaded by Corydon76 (license 14)
Tested by: putnopvut

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=107232