Installing and configuring DAHDI

From SaruWiki
Revision as of 21:02, 20 June 2010 by Saruman! (talk | contribs) (updated libpri section)
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; 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 packages 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 Asterisk website.

Obtaining and preparing libpri

To obtain libpri, simply download the latest version from the Asterisk website. At the time of writing, the most recent version of libpri could be found at the Asterisk download site; 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.2.tar.gz and README-1.4.11.2). 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 installation

DAHDI tools installation

Testing your DAHDI drivers