Asterisk How to connect with CAPI


Capi Support in Asterisk is provided through chan_capi, original written by Klaus Peter Junghanns, ongoing development and maintained by Cytronics & Melware. In order to use it you need a capi compliant ISDN card with Linux drivers. These include all the cards by AVM and several others such as the Eicon DIVA cards. Follow the step below to use capi with Asterisk:


  • Ensure you have CAPI support in your linux kernel.
  • 5/4/05 linux-2.6.11-rc5 breaks chan_capi 0.3.5, see comments for 2 different patches for linux kernels bigger than 2.6.11-rc5
  • please report if any of those patches break or not break chan_capi in kernels smaller than 2.6.11-rc5

For AVM cards type:

modprobe capi

If this works (you get no feedback) go on to step 2, if you get a message such as "modprobe: Can't locate module capi" then you need to recompile your kernel with capi as a module. In menuconfig select the following under

For Dialogic "Diva" boards (Dialogic was formerly known as Eicon)

Follow the instructions on this page: Eicon diva CAPI
This is much easier than doing the step below and means that after doing this you can go directly to step 3 .

Check if modules divadidd,divas,divacapi are loaded (part of vanilla kernel 2.6, tested with 2.6.10), type:


and you should see the modules. If ok, go on to step 2, otherwise include the required modules into the kernel:

Kernel configuration

Code maturity level options -->

[*] Prompt for development and/or incomplete code/drivers

then select the following in

ISDN Subsystem --> Active ISDN Cards -->:

<M> CAPI2.0 support
[*] Verbose reason code reporting (Kernel size +=7K)
[*] CAPI2.0 Middleware support (EXPERIMENTAL)
<M> CAPI2.0 /dev/capi support
[*] CAPI2.0 filesystem support
<M> CAPI2.0 capidrv interface support

Active cards (e.g. Dialogic "Diva Server") are directly supported,
ISDN Subsystem --> Active ISDN Cards -->Active Eicon DIVA Server cards-->:

[*] Support Eicon cards
<M> Support Eicon DIVA Server cards
[*] DIVA Server BRI/PCI support
<M> DIVA CAPI2.0 interface support
<M> DIVA User-IDI interface support
<M> DIVA Maint driver support

and recompile kernel (see here (debian) or here (all distros) for more information).

Step 2

  • You may need firmware in /usr/lib/isdn/ and a suitably configured /etc/capi.conf

(Please add extra pages with instructions for more cards)

Step 3

  • If not already done, download asterisk:

$ export CVSROOT=:pserver:anoncvs@cvs.digium.com:/usr/cvsroot
$ mkdir asterisk_src
$ cd asterisk_src
$ cvs login # password is anoncvs
$ cvs checkout asterisk
$ cd asterisk
$ # edit Makefile, i changed INSTALL_PREFIX to /home/risk/asterisk_bin (to keep an experiemental build separate from another * installation)
$ make
$ make install

Step 4

NOTE: If you are using chan_capi 0.3.5 with asterisk cvs-head (as of November 2004) you need to apply a small patch here for it to work. This patch also enables sending and receiving of faxes with active ISDN cards.

NOTE: If useing Asterisk cvs-head (as of April 2005) you will need the following patch to chan_capi 0.3.5 click here

NOTE: No patches are necessary when using latest package from ftp://ftp.chan-capi.org/chan-capi

  • I tried this on 2005-05-05, and the patch above did not apply cleanly. First of all you have to fix the long lines after cut'n'pasting the patch to a file. The patch program will give up with malformed patch errors on the lines where you have to remove a line break on the line before. Secondly, you have to steal include/asterisk/channel_pvt.h from 1.0.7 and copy it to /usr/include/asterisk/. After this is done, chan_capi 0.3.5 should compile. — RotHorseKid
  • Follow the chan_capi INSTALL file

NOTE: If your build of chan_capi fails because of a missing "capi20.h" just install the corresponding capi-devel (or sometimes isdn4linux-devel or isdn4k-utils-devel for Redhat 9, libcapi20-dev for Debian sarge, capi4k-utils for Slackware 10.2) package for your distribution.
NOTE2 (DK): If you have capi20.h, all include paths correctly entered in the Makefile and you still get a lot of no-sense messages while compiling from the first file (chan_capi.c) then do the following (it sounds crazy but it works!!!):
Change in the Makefile
DEBUG=-g #-pg

DEBUG=-g -pg

The only asterisk configuration files that appear to need changing to start using the CAPI device are "etc/asterisk/modules.conf" as detailed in the INSTALL file, a new "etc/asterisk/capi.conf" as created by "make config" (i didn't change this file to get it working) and "etc/asterisk/extensions.conf" where "TRUNK=CAPI" was inserted in the "globals" section (and other TRUNK assignments commented out)
(beware that the INSTALL file of the 0.3.1 is incomplete. In /etc/asterisk/modules.conf you have to put this two lines:

load => res_features.so
load => chan_capi.so

and in the [global] section:

since callgroup functionality has been introduced. If res_freatures.so is not loaded, asterisk will complain for a "undefined symbol: ast_get_group" when loading chan_capi!)
Note: With an older version of Asterisk, this module is called "res_parking.so".

Trying it out

  1. capiinit # (required if you are not loading capi at boot time)
  2. /home/risk/asterisk_bin/usr/sbin/asterisk -vvvgc
lots of verbose messages
Asterisk Ready.
  • CLI> capi info
Contr1: 2 B channels total, 2 B channels free.

then try ringing the isdn line the system is attached to and you should hear the asterisk congratulations message. Here some example dial statements for version 0.3.6:

s,1,Dial,CAPI/${MSN}:b${EXTEN}|30 always early B3
s,1,Dial,CAPI/${MSN}:${EXTEN}|30|r no early B3, fake ring indication

(Where you should replace ${MSN} with the MSN associated with the channel you want to dial out on, which should be listed on the msn= line in capi.conf.)

== NOTE==

The dial string has changed with the later version of chan_cap. Also the msn= param has been removed from capi.conf. Here is an excerpt from the version 0.6 README file:

"The Dial string

Example: Dial(CAPI/g<group>/<destination>[/<params>])
Or: Dial(CAPI/contr<controller>/<destination>[/<params>])
Or: Dial(CAPI/<interface-name>/<destination>[/<params>])

'group' can be a value, comma separated list of values or a range
using '-'. The according interface is found by searching a match with
the 'group' specified in the capi.conf for each interface.

'params' is an optional part to set special settings for this call.
The string consists of a list of characters with the following meaning:
'b' : early B3 always.
'B' : early B3 on successful calls only.
'o' : use overlap sending of number if number is longer than 2 digits
(This is useful, when further digits shall be send to complete the
destination address).

If the <interface-name> is used in dialstring, be sure the name (specified
in capi.conf) does not start with 'contr' or 'g'."

NOTE:Another thing to be careful of is dialing out while having a ringing (=non-answered) call. To signal incoming calls simultaneously on my mobile and my normal ISDN phone I let my asterisk box dial my mobile while a call is incoming. If the call is not answered on the mobile for some time, my asterisk answering machine comes to action. This worked perfectly without any special dial parameters until I upgraded to chan_capi-cm 0.6.1. From there on every call to my mobile was "hung up" (message in the log) after some seconds and without even ringing my mobile. In hours of work, I figured out, that the recent chan_capi (which is chan_cpi-cm) does not allow early B3 connects while the calling channel is not answered. If you want to dial out while a call is ringing, you have to explicitly set the "r"-option in the dial string, e.g.

Dial (CAPI/ISDN1/<destination numer>,30,r)

NOTE:On some ISDN lines if you use isdnmode=MSN, it is mandatory to also set immediate=yes. This applied to me after changing to the German Telko "Hansenet" aka "Alice". I had strange behaviour with immediate=no: Calls from other customers of my Telko where answered by asterisk, while those from mobiles and others Telkos where silently ignored (in the log you found Incoming call from xxx ... Hangup even if the MSN was defined in capi.conf). This cost me another couple of hours...

NOTE: If you have debian, the "/etc/init.d/asterisk start" script will not load asterisk (but no error message produced). This is because "asterisk" user must first be added to the "dialout" group, so it can access /dev/capi20)

See also

Created by: stan, Last modification: Fri 01 of Jun, 2012 (05:14 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+