miércoles, 1 de diciembre de 2010

OpenVox G400P in Debian

Éste post está también disponible en español.
This post is also available in spanish.

I bought an OpenVox G400P GSM telephony card to set up a VoIP server running Debian. I clearly didn't do my research homework before starting, and it turned out that it was not easy to set up this card with Dahdi, wich I had to keep in order to be able to use another card I already had on that server.

Problems I found:
  • There was not official Dahdi support for this board until about  ~6 months ago.
  • When it finally appeared, it turned out that there were not just some patches to the original source code, but some scripts that supossed that my system was RPM based. Oh, and it also downloads, modifies, compiles and installs Dahdi and Asterisk, leaving no room for customization.
  • When I asked the support about this issue, they told me that if I gave them SSH access they would install it for me (!?). I took the time to explain them that asking their clients for SSH access to their servers was not a good idea. Sadly, it seems that they didn't took my advice

Dissasembling the script:

So my next move was to get and install either Elastix or Trixbox in a virtual machine, supossedly supported by the script they provide, get the modified source code, check it and compile it in my Debian box.  I got to download three different versions of those distros, and it seems I couldn't get the correct version the script needed. So the next step was obvious: print the script, analyze it and modify it to get the source code.

Of course, I used git to keep the changes :-)

Final source code:

Asterisk: http://dumbledore.com.ar/gitweb/?p=asterisk.git;a=summary (might be incomplete, I still have to check it).

In the Dahdi repo, the openvox-g400p branch has the chan-extra modifications, the oslec branch contains the support for OSLEC echo canceler. Finally master is a merge of both. I still didn't check if the G400P supports oslec, but I have it there because I use it with the other card I have in the server.

Recommendations for OpenVox:

While I find an excellent idea to have an "automagic" script for your clients, a user os another distributions or/and an advanced user will find a patch most suitable. The good thing about this is that git makes it's creation quite simple.

I suggest the following workflow:

1.- Uncompress Dahdi's source code, rename the new directory and create a git repo out of it.

$ tar -xf dahdi-x.y.z.tar.gz
$ mv dahdi-x.y.z dahdi
$ cd dahdi
$ git init
$ git add -A
$ git commit -m "Original Dahdi source code version x.y.z."

2.- Create an upstream branch to follow Dahdi's development.

$ git checkout -b upstream

3.- Tag Dahdi's release in the upstream branch.

$ git tag -a dahdi-x.y.z

4.- Go back to the master branch and develop the driver.

$ git checkout master
[... desarrollo...]

5.- Once finished a release, tag it.

$ git tag -a chan-extra-x.y.z

6.- Make a patch out of it (althought it would be better to just publish the git repo).

$ git diff upstream master > chan-extra-x.y.z.patch

Note: there are far more better ways to generate a proper patch using git... but I had no time to get into that yet :-/ Comments welcomed :-)

7.- Whenever we need to develop with a newer Dahdi's release, we just need to update the upstream branch and merge it back to master.

$ git checkout upstream
$ git rm '*'
$ git clean -xdff
$ tar zxfv ../../dahdi-x.y.z+1.tar.gz --strip=1
$ git add -A
$ git commit -m "Import upstream x.y.z+1 release."
$ git checkout master
$ git merge upstream

Then the user will just need to patch the original source code and compile. Of course, the same workflow can be used for making patches for Asterisk.

Comments on this workflow will be much appreciated :-)