Installing Asterisk

Posted on 11 December 2006 in VoIP

Continuing down the VoIP-experimentation route, I've installed Asterisk on a spare Linux box. It seemed most sensible to do it from the CVS repository, so I tried:

jura:/home/root# cd /usr/src
jura:/usr/src# mkdir asterisk
jura:/usr/src# cd asterisk
jura:/usr/src/asterisk# export CVSROOT=:pserver:anoncvs@cvs.digium.com:/usr/cvsroot
jura:/usr/src/asterisk# cvs login

However:

jura:/usr/src/asterisk# cvs login
Logging in to :pserver:anoncvs@cvs.digium.com:2401/usr/cvsroot
CVS password:
Unknown host cvs.digium.com.
jura:/usr/src/asterisk# ping cvs.digium.com
ping: unknown host cvs.digium.com
jura:/usr/src/asterisk#

I guess they've moved over permanently to Subversion (which is a good thing, though it would be nice if it were more prominently documented). So:

jura:/usr/src/asterisk# svn checkout http://svn.digium.com/svn/asterisk/branches/1.2 asterisk-1.2
A  asterisk-1.2/build_tools

...

A  asterisk-1.2/formats/format_g726.c
A  asterisk-1.2/aescrypt.c
 U asterisk-1.2
Checked out revision 48358.
jura:/usr/src/asterisk# svn checkout http://svn.digium.com/svn/zaptel/branches/1.2 zaptel-1.2

...

A  zaptel-1.2/oct612x/Makefile
Checked out external at revision 12.

Checked out revision 1688.
jura:/usr/src/asterisk# svn checkout http://svn.digium.com/svn/libpri/branches/1.2 libpri-1.2

The rest of the build went reasonably easily once I started following the online instructions rather than the (admittedly literally months old) VoIP Hacks book, which omits certain bits of useful information (like the packages you need to have installed in order to make the compile work) and is clearly a bit out-of-date generally. For anyone else out there who googles for error messages to see if there's any easy fix, if you successfully compiled and installed libpri, but then found that building zaptel crapped out with vast numbers of error messages, the last ones looking like this:

/usr/include/linux/fs.h:383: error: storage size of `i_ctime' isn't known
/usr/include/linux/fs.h:515: error: storage size of `f_owner' isn't known
zaptel.h:1115: error: storage size of `confin' isn't known
zaptel.h:1116: error: storage size of `confout' isn't known
zaptel.c:6472: error: storage size of `zt_fops' isn't known
make: *** [zaptel.o] Error 1
jura:/usr/src/asterisk/zaptel-1.2#

...or, alternatively, when building asterisk, you got the following:

checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for tgetent in -lcurses... no
checking for tgetent in -lncurses... no
configure: error: termcap support not found
make: *** [editline/libedit.a] Error 1
jura:/usr/src/asterisk/asterisk-1.2#

...then you should go back and reread the list of packages you need installed before building. They are:

  • Linux 2.4 kernel sources or kernel 2.6 header files. (for libpri)
  • bison and bison-devel packages (This is used to build Asterisk)
  • ncurses and ncurses-devel packages (Used to build astman, etc.)
  • zlib and zlib-devel packages
  • openssl and openssl-devel packages

The relevant apt packages (for my Debian 2.4 test machine) were kernel-source-2.4.27, bison (bison-devel doesn't exist, which makes some kind of sense -- surely any use of a compiler compiler is development?), ncurses-dev and libncurses5-dev, zlib1g-dev, openssl, and libssl-dev.

Once these are installed, the build goes much more smoothly.

It's all installed happily on my machine, and if I didn't have work to do tomorrow I'd be posting again later this evening about how to set it up with the SPA-3102. I guess that will have to wait 'til later :-/

New project: VoIP

Posted on 5 December 2006 in VoIP

We need to sort out our phone system at Resolver, which has given me the excuse not only to wire up the office for gigabit ethernet (am I alone in thinking that self-adhesive trunking is an incredibly underrated invention?) but also to start playing with VoIP. I suspect that for the company I will wind up outsourcing everything, getting some kind of managed solution with an external POTS (normal phone) number that routes through to softphones on our desktop machines. I'll blog about anything interesting I find in that line.

With my home phone I can mess around a little more. In the excellent VoIP Hacks, I read about the Sipura SPA-3000, a clever device that connects to your phone socket and routes the signal onto your ethernet -- so that you can route incoming calls to a SIP (that is, VoIP) phone on your network, and -- if you are so inclined -- route your VoIP calls on the network out to the regular phone system. This is a great device because it allows you to start playing with VoIP at a minimal cost -- after all, if you want to do anything interesting, you'll need to mix your normal phone system in with your experiments, and phone cards for Asterisk servers can be costly and a pain to install.

Anyhow, after slightly more hunting around than you would hope, trying to find out where to get an SPA-3000 in the UK, I discovered that Sipura was acquired last year by Cisco -- their products are now sold under the Linksys brand (which, to be fair, is one I have a soft spot for). It's kind of odd that this fact isn't posted on the front page of the Sipura site, but there you are -- it looks like the site has been left unupdated for quite some time.

Once you know about the acquisition, it becomes easier to find the products, though it is still surprisingly difficult -- dabs.com, my favourite supplier, have nothing of interest, and none of the other companies I normally use stocked anything. However, BroadbandBuyer.co.uk have the SPA-3102, which is the successor to the SPA-3000. Mine arrived the other day.

The first step was to set up the device so that I was simply to be able to dial out and receive calls over my normal telephone line, with the phone and the line both connected to the device -- that is, to simply have it pass signals through in both directions. This should be trivial -- it's the default configuration, and should work even if the phone is switched off -- but, at least in the UK, it's not. The device comes with RJ-11 sockets (US telephone standard, a bit like the ethernet RJ-45 sockets but smaller) for both the FXO and the FXS ports, and an RJ-11 to RJ-11 cable. Like most modern phones sold in the UK, my normal telephone has an RJ-11 socket in the unit, into which is plugged an RJ-11 to BT socket cable (BT being the British standard, after British Telecom -- the plug looks a bit like a wide ethernet plug, with the "latch" to the side rather than on top). I initially tried connecting the phone to the unit by using the supplied RJ-11 cable, but got nothing. I then switched back to the old BT cable, but put an adaptor with a ring capacitor in between; this worked, and I got a (rather odd) dial tone from the device, and was able to use its voice prompts to find out what IP address it thought it had (192.168.0.1, no wonder my router was unhappy) and to change it to something sensible. So, lesson one -- if you want to plug a phone into the SPA-3102, you need to use the cable you would use to plug it into the wall, with a ring capacitor.

I then plugged the device into the telephone socket, using a different RJ-11 to BT cable. This did not work either; the dial tone on the phone did not change from the device's own tone to the BT one. A quick google, and I found this forum post; I needed a modem cable "with the wires swapped" rather than a straight-though cable. (My mental model for this is that it's kind of like an ethernet crossover cable.) A quick trip to Maplin, and voila -- the device worked in passthrough mode just fine, and I can start thinking about how to do something more useful with it!

Some pondering... initially I was thinking that it was because one has to mess around like this that VoIP has yet to hit prime time in this country... but then, I heard the laughter of thousands of aging british road warrior businessmen in my head, people who spent years on trips to the US, messing around with their modem cables -- back in the days when you could stay in a serious hotel that didn't have some kind of WiFi, or at least ethernet. "Of course you need a ring capacitor", they cry. "Isn't it obvious?"