Installing and configuring DAHDI

From SaruWiki
Jump to navigation Jump to search

Installation overview

When installing Asterisk, the installation can broadly follow these steps:

  1. install libpri library files
  2. physically install telephony hardware like one or more Digium telephony interface devices
  3. compile, install and configure DAHDI device drivers for this hardware
  4. compile and install Asterisk
  5. provide Asterisk with a default "sample" configuration

Of course, then the real fun starts - but let's leave that for another section of this wiki.

libpri configuration/installation

Asterisk needs the libpri package; a "primary rate ISDN specification library". This is primarily to handle digital telephony cards (T1/E1/ISDN-cards), but also for some other functions (although currently I don't know which ones :-). However, even if you don't need the files, they do you absolutely no harm, and waste only a handful of mebibytes of storage space. Thus we'd recommend installing it even if you don't have digital telephony cards (yet).

In Debian 5.0 "Lenny", the package is named libpri1.0 and it can be installed using apt-get. However, it's very easy to install the latest & greatest straight from the Digium website.

Obtaining and preparing libpri

To obtain libpri, simply download the latest version from the Digium website. You'll want to get both the actual software libpri-1.4-current.tar.gz and the accompanying readme README-1.4-current. Mind you, the website also provides these same files as fully-version-numbered files (something like libpri-1.4.11.5.tar.gz and README-1.4.11.5). However, a link to these files would get stale pretty fast. Mind you: if you need an older release, or if there are newer "major" releases, you could replace the 1.4 part of libpri-1.4-current.tar.gz for the designation of that release, e.g. libpri-1.2-current.tar.gz for the latest version of the older 1.2 release.

Thus we could get the software, and extract it in /usr/src using something akin to the following commands:

localhost:~# cd /usr/src
localhost:/usr/src# wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
--2010-06-20 20:32:41--  http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
Resolving downloads.asterisk.org... 76.164.171.233, 2001:470:e0d4::e9
Connecting to downloads.asterisk.org|76.164.171.233|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 225009 (220K) [application/x-gzip]
Saving to: `libpri-1.4-current.tar.gz'

100%[===================================================>] 225,009      250K/s   in 0.9s

2010-06-20 20:32:43 (250 KB/s) - `libpri-1.4-current.tar.gz' saved [225009/225009]
localhost:/usr/src# tar xzf libpri-1.4-current.tar.gz
localhost:/usr/src# cd libpri-1.4.11.2
localhost:/usr/src/libpri-1.4.11.2# _

Now we have the libpri software, but we need to compile it for our system.

Compiling and installing libpri

We're now assuming you have everything needed for compiling software for your Linux server, a.o.

  • Linux 2.6 kernel headers;
  • Development libraries and headers for ncurses, zlib and openssl, and for libnewt;
  • GCC and standard software build tools.

If all this is the case, the compilation will be as simple as running these commands:

localhost:/usr/src/libpri-1.4.11.2# make
gcc -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC   -O2 -MD -MT copy_string.o -MF .copy_string.o.d -MP -c -o copy_string.o copy_string.c
gcc -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC   -O2 -MD -MT pri.o -MF .pri.o.d -MP -c -o pri.o pri.c 
(lots more cryptic messages)
gcc -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g -fPIC   -O2 -MD -MT version.lo -MF .version.lo.d -MP -c -o version.lo version.c
gcc -shared -Wl,-hlibpri.so.1.4 -o libpri.so.1.4 copy_string.lo pri.lo q921.lo prisched.lo q931.lo pri_facility.lo asn1_primitive.lo rose.lo rose_address.lo rose_etsi_aoc.lo (etc etc...)
/sbin/ldconfig -n .
ln -sf libpri.so.1.4 libpri.so
localhost:/usr/src/libpri-1.4.11.2# make install
mkdir -p /usr/lib
mkdir -p /usr/include
install -m 644 libpri.h /usr/include
install -m 755 libpri.so.1.4 /usr/lib
#if [ -x /usr/sbin/sestatus ] && ( /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"); then /sbin/restorecon -v /usr/lib/libpri.so.1.4; fi
( cd /usr/lib ; ln -sf libpri.so.1.4 libpri.so)
install -m 644 libpri.a /usr/lib
if test $(id -u) = 0; then /sbin/ldconfig -n /usr/lib; fi
localhost:/usr/src/libpri-1.4.11.2# _

That's it, your server now has a means to understand the Primary Rate ISDN specification!

Files and updating

After installation, you'll find that /usr/lib contains 3 entries:

  1. the actual module libpri.so.1.4;
  2. a symlink to this module, called libpri.so
  3. static library file libpri.a

Furthermore, there's a single file in /usr/include:

  1. header file libpri.h

Updating is as simple as recompiling a new version, which will overwrite these files; if you don't need libpri any more, simply delete them.

For reference, the Debian libpri1.0 package contains
- module libpri.so.1.0
- a symlink to this module, called libpri.so.1
- libpri-bristuffed.so.1.0
- a symlink to this module, called libpri-bristuffed.so.1 The Debian package libpri1.0 (and by extension these files) can coexist with a vanilla libpri, as long as it's not an 1.0.x libpri.

DAHDI driver installation

The actual driver for your Digium hardware comes from the DAHDI part of Digium's download site. Supposing you've downloaded the file to /tmp, you could execute these commands:

cd /usr/src
tar zxvf /tmp/dahdi-linux-2.3.0.tar.gz
cd dahdi-linux-2.3.0
make
make install

DAHDI tools installation

The previous instructions gave you the DAHDI driver, but not the associated set of tools. Contrary to some documentation, you can download it separately from Digium. Supposing again you've downloaded the file to /tmp, you could execute these commands:

cd /usr/src
tar zxvf /tmp/dahdi-tools-2.3.0.tar.gz
cd dahdi-tools-2.3.0
./configure
make menuconfig
make
make install
make config

Note that the make menuconfig step is optional. With the DAHDI tools installed, we can generate a DAHDI default configuration:

dahdi_genconf modules

However, the driver is not started yet, so let's do that now:

/etc/init.d/dahdi start

Testing your DAHDI drivers

The success of the previous installation steps can be validated using one of the DAHDI tools (provided the "dahdi start" command has been issued):

localhost:~# dahdi_scan
[1]
active=yes
alarms=OK
description=Wildcard TDM410P Board 1
name=WCTDM/0
manufacturer=Digium
devicetype=Wildcard TDM410P (VPM100M)
location=PCI Bus 03 Slot 08
basechan=1
totchans=4
irq=22
type=analog
port=1,FXS
port=2,FXS
port=3,FXO
port=4,none
localhost:~# _

If you installed the dahdi-tools (highly recommended) then you can configure your hardware

Conversion from zaptel /etc/zaptel.conf Becomes /etc/dahdi/system.conf /etc/asterisk/zapata.conf Becomes /etc/asterisk/chan_dahdi.conf

Lets look at what we have

#dahdi_tool

This will give a overview of the hardware and if it is configured or not. It will all so show alarms on the hardware.

Now lets configure the card. First edit /etc/dadi/genconf_parameters. This file is used with dahdi_genconf and will produce /etc/dahdi-system.conf

  • lc_country nl

You can also set the echo cancelation here MG2 is default

#dahdi_genconf
#dahdi_cfg -vv

DAHDI Tools Version - 2.2.0
DAHDI Version: 2.2.0.1
Echo Canceller(s): MG2
Configuration
======================
Channel map:
 
Channel 01: FXO Kewlstart (Default) (Echo Canceler: mg2) (Slaves: 01)
Channel 02: FXO Kewlstart (Default) (Echo Canceler: mg2) (Slaves: 02)

2 channels to configure.

Setting echocan for channel 1 to mg2
Setting echocan for channel 2 to mg2

Check if the right module is loaded.

#cat /etc/dahdi/modules

You can configure the options of dahdi in /etc/asterisk/chan_dahdi.conf for example turn off the echo cancelation Also include this line #include dahdi-channels.conf in your chan_dahdi.conf (yes with the #) Otherwise you're asterisk will not see the channels.

You can also check the channels in asterisk

#asterisk -r
#server*CLI> dahdi show channels

Or set the verbose level on asterisk to see more output

#server*CLI> core set verbose 10

I had some trouble with the sounds. When asterisk plays hello-world.gsm it sounded stutterd. I did a

#dahdi_test

This gives a readout from the timinsettings in asterisk. Mine was -133% and it should give a reading close to 100%.I did a

#dahdi destroy channel 1
#dahdi destroy channel 2
#dahdi restart

Now i have 2 channels and no Pseudo channel (not shure were it's for) Dahdi_test gives me 99,6% and the spound is good