OpenR2 Library
(main page: http://www.libopenr2.org/ )
(online repo: http://code.google.com/p/openr2/ )
OpenR2 installation is pretty straight forward, however there are some pre-requisites you should fulfil.
Along with the library, branches and patches for Asterisk and FreeSWITCH are provided with MFC/R2 support using chan_zap, chan_dahdi and OpenZAP.
Install instructions for Aserisk/Dahdi
Step 1 - Download and install dependencies
Starting with Asterisk 1.6.2 official support for MFC-R2 is through the use of the chan_dahdi module, and therefore the library requires DAHDI (not Asterisk) in order to compile.
If you need to instructions on how to install Dahdi please see Downloading and installing Dahdi
WARNING* : You may run into troubles if you have more than one DAHDI package installed because OpenR2 will compile using the first that it finds. Try to purge multiple versions beforehand. |
Step 2 - Download Wanpipe Driver
The latest version of the driver can be found on our Linux driver download page
Step 3 - Install Wanpipe Driver for Asterisk
For instructions on how to install the Sangoma Wanpipe driver for use with Dahdi and Asterisk please see Installing Wanpipe for Asterisk/Dahdi
Step 4 - Download and install OpenR2 library
Download OpenR2 from google code web page @
http://code.google.com/p/openr2/downloads/list either manually or using the following commands:
wget http://openr2.googlecode.com/files/openr2-1.3.2.tar.gz tar -xzf openr2-1.3.2.tar.gz cd openr2-1.3.2.tar.gz |
Run the 'configure' script and then compile and install the library.
./configure --prefix=/usr make make install |
NOTES* :
|
Final steps...
Now that the library is installed you can proceed to install Asterisk. However, you can also test your R2 lines without Asterisk being involved.
For instructions on how to conduct these tests please see the section OpenR2 Test to test without Asterisk. If you are not interested in testing without Asterisk, you can proceed to the next section.
Step 5 - Install Asterisk
Install Asterisk by running the following commands from the the Asterisk source directory.
./configure |
... |
make make install make samples (in case of very first install) |
Now Asterisk should be installed and ready for configuration.
Asterisk and OpenR2
Asterisk does not understand R2 signaling by itself, it requires the help of the OpenR2 library to do it.
You also need to make Asterisk aware of the presence of the OpenR2 library so the proper code inside Asterisk can be compiled to make use of OpenR2.
There are currently 2 ways to get an R2-enabled Asterisk version:
You can either download an Asterisk 1.6.2 that's already have OpenR2 support (we recommend this option).
You can download a normal Asterisk .tar.gz from 1.2, 1.4, 1.6.0, 1.6.1 and then download the deprecated OpenR2-Asterisk patches and apply them yourself (we don't recommend and don't support it).
Be aware, however, that if you download a normal Asterisk .tar.gz and then try to apply the deprecated OpenR2-Asterisk patch, the patch may fail to apply if the Asterisk .tar.gz is too old or too new.
Given the Asterisk development cycles, Asterisk 1.2 and Asterisk 1.4 will never include MFC/R2 support in official releases because those 2 versions are already frozen for features.
This means Digium will NOT accept big feature changes like MFC/R2 support. However, Asterisk 1.6.2 has native support for MFC/R2 support using OpenR2 library.
Starting with Asterisk 1.6.2, it is required to run the configure script to install Asterisk. This configure script will take care of detecting the libraries you have installed on your system including OpenR2.
If OpenR2 is found, Asterisk will be installed with chan_dahdi.so enabled for MFC/R2 signaling.
If you don't have OpenR2 installed chan_dahdi.so may still be compiled (if DAHDI is present) but without MFC/R2 support.
In order to verify if chan_dahdi.so is properly compiled and linked with OpenR2, you can execute the following command from within the asterisk source directory:
ldd channels/chan_dahdi.so | grep openr2 |
libopenr2.so.1 => /usr/lib/libopenr2.so.1 (0x0000000000589000) |
*NOTE: The load address (0x0000000000589000) and library version (.1) can be different. |
OpenR2 Test Application
The OpenR2 library provides you with a small test program called “r2test” (unless you specified the option --without-r2test).
It is a small application that uses a configuration file to “listen” for calls into the DAHDI devices you specify and answer calls and either put them in an echo-like
application or plays a file (in alaw format). The r2test program can be used to wait for calls or configured to make calls.
In order to use r2test you need first to create a configuration file.
A sample configuration file is included in OpenR2 in the openr2<version>/doc/r2test.conf, the format for the file is:
# this is a comment parameter1=value parameter2=value channel=start-end |
When r2test finds a “channel” parameter, it will create a new block of DAHDI channels starting
with “start” and ending with “end” and configure them with any preceding parameters.
You should make sure “start” and “end” are valid DAHDI devices.
For example, this is a minimal r2test.conf configuration file:
variant=mx caller=no maxani=10 maxdnis=4 channel=1-15 |
An r2test.conf file with such contents would open DAHDI channels from 1 to 15, and configure them with caller=no, maxani=10 and maxdnis=4.
If you get “No such file or directory” errors, it might be because you have not loaded the DAHDI drivers.
When DAHDI drivers are loaded, they create devices in /dev/dahdi or /dev/zap, in the previous configuration example devices /dev/ dahdi/1 to /dev/dahdi/15 are required.
The “variant” parameter determines which R2 variant will be used.
You can list the supported variants with the command:
r2test -l |
Variant Code Country AR Argentina BR Brazil CN China CZ Czech Republic CO Colombia EC Ecuador ID Indonesia ITU International Telecommunication Union MX Mexico PH Philippines VE Venezuela |
The “caller” parameter determines whether that group of channels will make calls or wait for calls.
“caller=yes” means the channels will make calls, in that case the “dnid” parameter must be specified.
Parameters “maxani” and “maxdnis” just determine what is the maximum number of digits that will be received for ANI and DNIS.
The “channel” parameter *must* be in the format “x-y” to specify the range of channels for which the previous configuration parameters will be applied to.
(just like chan_dahdi.conf) If you just need 1 channel you must specify it like “channel=1-1”
r2test -c r2test.conf |
found category = NATIONAL_SUBSCRIBER |
The default behavior after completing a call is to put the audio in an echo-like application where everything said is repeated immediately.
However, you can also specify the options:
playaudio=yes
audiofile=doc/intro-openr2-es.alaw
Assuming you are running r2test from the same folder where you have the sources.
OpenR2 provides 3 sample audio files in ALAW format, intro-openr2-xx.alaw in es (spanish), br (Portuguese) and en (english).
The ALAW format is the only one openr2 understands.
Debugging options are useful when you are trying to get help in mailing lists or IRC.
Debugging output may not mean anything to you but will greatly help to anyone who understands the R2 signaling protocol!
The option “loglevel” is quite powerful for filtering messages. The following logging values are available:
Levels 'error', 'warning', 'notice' and 'debug' are self-descriptive, will log any critical messages, warning messages, notice messages and general debug messages.
Level 'cas' is for logging CAS tx and rx signals.
Level 'mf' is for logging the multi frequency tones tx and rx.
Level 'all' is a special value that enables all the debugging messages.
Level 'nothing' is another special value to not log anything.
When requesting support make sure that your debugging level is set to 'all'.
You can mix up values like this: “loglevel=warning,error,notice”.
There is another interesting option for debugging that is independent of the loglevel option, this
is “callfiles”. This option accepts “yes” or “no”. If you chose “yes” a special “.call” file will be
dropped after each call in the directory where you run r2test. These “.call” files contain valuable
debugging information.
The previously described options are the most important ones, but, not the only ones. You can find
more extensive (and probably more accurate) documentation about all the options in the sample
r2test.conf file provided with openr2 in the doc/ folder.
There is just one final option for r2test, that is “-v” to display the openr2 version installed.
r2test -v |
Variant Code Country AR Argentina BR Brazil CN China CZ Czech Republic CO Colombia EC Ecuador ID Indonesia ITU International Telecommunication Union MX Mexico PH Philippines VE Venezuela |
For more information about r2test you can also try “man r2test” to see the help.
Freeswitch/FreeTDM Install instructions
Detailed installation instructions for use with Freeswitch/FreeTDM can be found here: http://wiki.freeswitch.org/wiki/FreeTDM_OpenR2