Archive for the ‘asterisk’ Category

ztloop with CAS support

Sunday, November 23rd, 2008

During some time I had the idea that it should be possible to test the user space software that deals with E1/T1 lines (Asterisk, FreeSwitch, OpenR2) without any hardware at all, that way I could work off-line in my laptop (when I am on-line I usually have access to some server with an E1 card on it). Yesterday I googled a bit about it and found the ztloop kernel module, developed by the company DruidSoftware. It’s a very simple module, based on the ztdummy module, but is not part of the zaptel package, so you have to download it, and patch the Makefile to compile it.

The module works by registering 4 zaptel spans. The first 2 are connected, by software, in loop. Which means anything you write to channel 1 (span 1) it will be available for reading in channel 32 (span 2). It does this by soft-wiring the tx and rx buffers of each span channel and registering a timer callback with the kernel, which will call it at a 1024Hz rate (just like ztdummy) and calling zt_transmit() and zt_receive() from within this callback (since there is no E1/T1 hardware interrupts, this timer is required).

The other 2 spans are for line tapping. All channels in span 3 tap span 1 and span 4 taps span 2. If you open a channel in span 3 you will be able to eavesdrop the data over the corresponding channel in span 1 (this tapping functionality can also be accomplished by zaptel pseudo devices, that is the way ztmonitor works).

The number of loop and tapping spans is configurable passing parameters to the kernel module.

Even though this module works fine for PRI lines, until today, it did not work for MFC/R2 lines, because it was lacking CAS support. After reading for some time Zaptel drivers code it started to make sense and I added a few lines of code required to loop R2 lines.

I basically added the span handler (a function pointer in the zt_span structure) to handle the transmission of CAS bits. This handler is called each time some process from user space calls ioclt(fd, ZT_SETTXBITS), most drivers would talk to the E1/T1 hardware to ask it to change the bits position, but, what I did is to call zt_rbsbits() function in the span that I know this span is looped to, that way the other span will “see” the bits and wake up any user space process that is waiting on bits changes.

It’s kind of cool that now I can test my Asterisk MFC/R2 development in my laptop w/o needing any hardware at all :-)

The source code for this modified ztloop kernel module can be found here: http://www.moythreads.com/ztloop.c. I will send the patch to the DruidSoftware guys to see if they include it in their next release.

Back from Astricon

Friday, October 17th, 2008

I got back from Astricon 3 weeks ago. It was good to meet some people I only had talk with on IRC or IM.

Here is my presentation: OpenR2 – MFC/R2 Free of headaches or your money back. My presentation explains how and why I started the OpenR2 project and how it can help to ease the MFC/R2 signaling support for Asterisk.

In other news tomorrow is my last day working for IBM. I started at IBM 2 years ago and I have learned how it is to work in such a big company, good things (salary, stability, no pressure), bad things (bureaucracy, slow development etc). Of course, being such a big company this may not be truth for all areas and will definitely vary among countries and development teams.

Having said that, it was quite difficult to me take the decision of leaving, but I was starting to enter in my comfort zone. It’s time to move, and more importantly, move to a job where I can learn new exciting technologies and I can work in telephony and open source communications that is what I like the most.

This Monday I will start working for Sangoma Technologies. It’s definitely not as big as IBM, but I think the company is at a sweet spot between a small and a big company. This also means soon I will be moving to Toronto. Let’s see how it goes …

Ah, btw, I also got married this week :)

I’ll be speaking in Phoenix at Astricon

Thursday, July 31st, 2008

So, not quite, Astricon will be in Glendale AZ, 9 miles northwest from Phoenix downtown. The conference will be from September 23 – 25 and I’ll be speaking about the support for MFC/R2 I am adding to Asterisk, hope to see you there!

MFC/R2 branches for Asterisk 1.2 and 1.4

Saturday, July 5th, 2008

I just created 2 branches for MFC/R2 support in chan_zap for Asterisk 1.2 and 1.4, this branches replaced the patches and .tar.gz I previously published, is much easier to keep them up-to-date this way. If you still need the patches you can easily get them using svn diff.

Let’s say you need a patch against Asterisk 1.4.21.1

svn diff  http://svn.digium.com/svn/asterisk/tags/1.4.21.1 \
http://svn.digium.com/svn/asterisk/team/moy/mfcr2-1.4 > asterisk-openr2-1.4.21.1.patch

That will create a patch to transform Asterisk 1.4.21.1 version into an OpenR2-enabled version. However this has other side-effect, changes that may have nothing to do with openr2 can be introduced. I therefore recommend using my branches directly.

OpenR2 back-ported to Asterisk 1.4 and 1.2

Thursday, June 19th, 2008

I just back-ported the support for MFC/R2 signaling using the OpenR2 library to Asterisk 1.4 and 1.2, go and get it while is still hot!

http://www.libopenr2.org/

I also updated the site to use TextMotion, a new web publishing software (aka CMS), works pretty well, kudos to the TextMotion devs.

MFC/R2 branch for Asterisk is available

Wednesday, April 30th, 2008

I just created a branch for Asterisk that has everything required to test the chan_zap MFC/R2 support. Now the installation steps are easier.

1. Install zaptel from 1.4 branch http://svn.digium.com/svn/zaptel/branches/1.4

2. Install openr2 library from the trunk svn://libopenr2.org/openr2/trunk

3. Install Asterisk from the MFC/R2 branch: http://svn.digium.com/svn/asterisk/team/moy/mfcr2

Some people in brazil has now reported success with basic call setup. Configuration info is available at the bugtracker: http://bugs.digium.com/view.php?id=12509

The libopenr2.org site is up, but empty :-( , right now I just have the SVN server, but info will be added soon as well.

Asterisk with MFC/R2 in chan_zap

Friday, April 25th, 2008

I’ve been working lately in a library for the MFC/R2 telephony signalling. I named this library “OpenR2″. My goal is to include support for this signaling in the Asterisk project and eventually in FreeSwitch if possible. I just created a new issue in the bugtracker, that is the first patch I have to give MFC/R2 support in the Asterisk channel driver chan_zap. Hopefully this will eventually be the standard MFC/R2 implementation for Asterisk and finally it will “just work”.

If you are from the many people with R2 issues in Mexico or other country, you should consider to give this thing a try.

The code of the library is LGPL and is available temporarily to download from http://www.moythreads.com/openr2-april21.tar.gz.

I am in the process of getting an SVN account and will post later the link.

Patch for chan_zap: http://www.moythreads.com/chan_zap-mfr2.patch

All you have to do is download Asterisk from this branch: http://svn.digium.com/svn/asterisk/team/markster/mfr2

Then apply the patch. You will also need zaptel from this branch: http://svn.digium.com/svn/zaptel/branches/1.4

After applying the patch, please run ./bootstrap.sh in the Asterisk root directory. Then ./configure –prefix=/usr –with-openr2=/usr

Please report feedback in the bugtracker or contact me via e-mail or IM. My user at gmail it’s quite easy to remember: moises.silva

Zaptel Version

Thursday, April 3rd, 2008

Quick note to myself: to check the version of the loaded zaptel module just cat /sys/module/zaptel/version

Asterisk Asynchronous AGI

Monday, December 24th, 2007

I have been coding some new stuff for Asterisk lately, but the feature I like the most is Asynchronous AGI. I got the idea from MAGI, an old patch written by David Pollak that allowed AGI execution thru the manager interface. For those ignoring what AGI and AMI are, go read:

Asterisk Gateway Interface ( AGI )
Asterisk Manager API ( AMI )

So, my patch, allow users to execute AGI commands using “Action: AGI” and get the response reading “Event: AsyncAGI”. The manager header “CommandID” can be specified to match up the responses. Let’s see an example

In extensions.ael you would put something like this:

context sample-async-agi {
    test => {
        AGI(agi:async);
    };
};

That will put the channel to wait AGI commands. The channel will NOT do anything but wait for Hangup or any AGI command you ask it to execute. AGI commands can arrive from 2 sources. The most important and useful source of commands is the manager, but with my patch you can also execute AGI from the command line. Let’s see how it is done from the manager:

# telnet localhost 5038
Action: Login
Username: test
Secret: test

Action: AGI
Channel: SIP/33-blah
Command: EXEC Playback tt-monkeys
CommandID: MyCommandID

That would cause Asterisk to execute the “Playback” application on channel SIP/33-blah, which MUST be in AGI(agi:async) application. After executing the command you will be able to read an event with the AGI response url-encoded. If the channel is not in Async AGI, the command will not be executed and you will get an error response.

As I said, you can use the command line to execute Async AGI as well, just like this:

tcore*CLI> agi exec SIP/testing-09a5b960 “EXEC startmusiconhold”
tcore*CLI> agi exec SIP/testing-09a5b960 “EXEC stopmusiconhold”
tcore*CLI> agi exec SIP/testing-09a5b960 “EXEC Dial(Agent/23)”

That will start MOH, then stop it, and finally will dial to the Agent 23. This means you can implement a Queue without using native buggy Asterisk queues. You can receive calls and send them to Async AGI to put them on hold, then, when you detect availability of some of your Agents, Dial() to that agent.

If you want to learn more about this feature here is the mantis bug entry: http://bugs.digium.com/view.php?id=11282.

If you want the patch back-ported to 1.4, I have one here: http://www.moythreads.com/asterisk-1.4.15-async-agi.patch

In case you find this patch useful, please try it in trunk as well and provide feedback in mantis. Even when some people has found this patch useful, some of the top developers at asterisk-dev are hesitating in accepting it because similar results can be obtained thru the use of FastAGI, however, me and other people at asterisk-dev are trying to prove the patch also makes easier the implementation of some applications.

This is a hot discussion we got some weeks ago about it: http://lists.digium.com/pipermail/asterisk-dev/2007-December/031046.html

See you!

Asterisk, now with deadlock action!

Tuesday, November 20th, 2007

You gotta belive me, I love Asterisk, I have learned lots of stuff playing with it. However in the last days I have been trying FreeSwitch and reading its code. Yesterday I was hanging out at freeswitch-dev when Anthony posted a link, that I have to admit is so fucking funny!

http://www.sofaswitch.org/eg/pix/mfp_small.jpg

Enjoy,