# Howto: Getting a CAPI ISDN modem working with Hylafax



## oobayly (Feb 9, 2010)

Afer the general headache of getting ISDN faxing to work with Hylafax on FreeBSD 7.2, I've written this simple howto should make life easier for anyone attempting to do what I have done. A decent amount of the information has been taken from shellbang.org, and in my case I was configuring an AVM B1 controller. However from the docs, this should work with other AVM controllers (C2, C4).
This should also work for Digi Datafire (formerly ITK IX1) controllers and legacy Diehl (now Eicon) controllers, however I can't vouch for this.

Thomas Wintergerst's publishes the source for CAPI4BSD (C4B) on his website. However it doesn't compile on FreeBSD 7.2.
Hellmuth Michaelis published a version of C4B patched for use on FreeBSD 7.2. Unfortunately it relied on his build environment, so it doesn't work out of the box. Luckily he provided a diff file. This can be used to patch the original C4B source. However there is another caveat: libc_r was deprecated as of 6.x, and removed in 7.0, so a modification had to be made to the diff. Hence we have to use the following diff: c4b-20100225-01.diff

Fetch the C4B source, and extract
`# fetch "http://www.nord-com.net/thomas.wintergerst/files_c4b/c4b-1.1.1.tar.gz"`
`# tar -xzf c4b-1.1.1.tar.gz`

Patch the C4B source:
`# patch --ignore-whitespace < c4b-20100225-01.diff`

Now, it should be possible to build & install C4B
`# cd c4b`
`# make obj && make depend && make && make install && make clean`

As per the README, add the following lines to /etc/rc.conf

```
capi_enable="YES"
avmaic_enable="YES"	# Only for AVM controllers
daic_enable="YES"	# Only for legacy Diehl controllers
ix1a_enable="YES"	# Only for ITK IX1 (Digi Datafire) controllers
```

Restart, and check dmesg for the controller
`# dmesg | grep -i capi`
`# capitest -lv`

To test, the controller send some noise over the line
`# capitest -o /etc/hosts -tv <number>`

A complete self test is done by using X.75 protocol for data transfer
`# capitest -s -tx <number>`

For more information about testing C4B, have a look at Shellbang.org
http://www.shellbang.org/freebsd/introducingc4b.html

Now that we know the controller is up and running, Hylafax needs to be installed. This should be as easy as installing it from the ports tree, or compiling it if you want to use different configuration
`# pkg_add -r hylafax`
`# cd /usr/ports/comms/hylafax && make config && make && make install && make clean`

Enable Hylafax on boot, by adding the following to /etc/rc.conf

```
hylafax_enable="YES"
```

I've finally managed to create a working port of CAPI4Hylafax, it also uses the current (v.01.03.00) of the source from available from the AVM FTP server. This version will also compile on FreeBSD amd64 (20050129 didn't).

To get CAPI4Hylafax v.01.03.00 installed, download the attached tarball, extract & build:
`# fetch -o capi4hylafax-01.03.00.tar.bz2 "http://forums.freebsd.org/attachment.php?attachmentid=993&stc=1&d=1284649628"`
`# tar -xjvf capi4hylafax-01.03.00.tar.bz2`
`# cd comms/capi4hylafax/ && make install && make clean`

I've left the previous build information here for reference.


Installing CAPI4Hylafax is a bit of a chore. There's no official port, and the port on Shellbang.org doesn't build properly. The reason appears to be that configure process doesn't appear to work, as well as some other basic issues. The work around is to execute the configure process oneself.

Fetch the port, and extract
`# fetch "http://www.shellbang.org/files/capi4hylafax-20050129.tar.gz"`
`# tar -xzf "capi4hylafax-20050129.tar.gz"`

Patch the Makefile
`# patch < capi4hylafax-20100209-01.diff`

Attempt to build. This will fail with an error like "Makefile: No such file or directory". Don't worry, as we'll do the configure ourselves.
`# cd comms/capi4hylafax/ && make`

Enter the work directory, and call the commands that should have been called after patching & before configuring. You'll get some warnings, but hopefully no errors.
`# cd work/capi4hylafax-20050129/`
`# aclocal && libtoolize --force --copy && autoreconf`

To configure, we also need to export some compiler flags before we call configure
`# export LDFLAGS=-L/usr/local/lib`
`# export CPPFLAGS=-I/usr/local/include`
`# ./configure`

Now that configure has succeeded, we can build the port
`# cd ../../ && make && make install && make clean`


You'll need to enable c2faxrecv in /etc/rc.conf so that Hylafax know the CAPI fax modem is available

```
capi4hylafax_c2faxrecv_enable="YES"
```


Before Hylafax has been configured, faxsetup needs to be run. Use your preferred settings, however when asked to configure a modem, select NO, as we'll create a configuration file for the cAPI modem
`# faxsetup`

You can either add the CAPI modem config using c2faxconfig, or do it manually. Personally, I looked at the automagically created config.faxCAPI, and used is as a base. Because the AVM B1 has two channels, I added a 2nd section so that it can send two concurrent faxes.

First, enter the Hylafax configuration directory
`# cd /var/spool/hylafax/etc/`

Make the following change to config. This will make Hylafax use the capi4hylafax sendfax command. Also, c2faxsend doesn't appear to support 2D TIFF compression, so
we have to tell Hylafax not to use it. This took some time to work out as all the files in the spool directory we valid, but the faxes were blank with only the tagline.

```
SendFaxCmd:	"/usr/local/bin/c2faxsend"
Use2D:		no
```

Finally, run faxmodem to create the FIFO symbolic links
`# faxmodem`


Providing that I've left nothing out, the final result is a basic working setup. If something isn't working or I've left out a step, please feel free to contact me.
I've left out receiving faxes and more advanced configuration as this has been documented far better than I ever could.


Thanks really has to go to Thomas Wintergerst for getting AVM active ISDN controllers working in FreeBSD, Hellmuth Michaelis for getting them to work in FreeBSD 7.2, and Jan Stocker for porting AVM's CAPI4Hylafax to FreeBSD.


----------



## stou (Feb 25, 2010)

Hi,

First thank you for this good tuto. But I have some trouble with this.. Can you help me? 

When I applie the patch c4b-20100209-01.diff (because I use FreeBSD 7.2). The are some errors like that : 

""""

```
Patching file c4b/kernel/i4b/i4bcapimgr/i4bcmgr_var.h using Plan A...
Hunk #1 failed at 45.
1 out of 1 hunks failed--saving rejects to c4b/kernel/i4b/i4bcapimgr/i4bcmgr_var.h.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -x '*.orig' -uprN2 c4b.orig/kernel/modules/Makefile c4b/kernel/modules/Makefile
|--- c4b.orig/kernel/modules/Makefile   2006-02-28 21:35:30.000000000 +0000
|+++ c4b/kernel/modules/Makefile        2007-12-01 22:08:39.000000000 +0000
--------------------------
Patching file c4b/kernel/modules/Makefile using Plan A...
Hunk #1 failed at 7.
1 out of 1 hunks failed--saving rejects to c4b/kernel/modules/Makefile.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -x '*.orig' -uprN2 c4b.orig/tools/capitest/capiutil.cc c4b/tools/capitest/capiutil.cc
|--- c4b.orig/tools/capitest/capiutil.cc        2006-02-28 21:35:39.000000000 +0000
|+++ c4b/tools/capitest/capiutil.cc     2007-12-01 23:16:35.000000000 +0000
--------------------------
Patching file c4b/tools/capitest/capiutil.cc using Plan A...
Hunk #1 failed at 430.
Hunk #2 failed at 472.
2 out of 2 hunks failed--saving rejects to c4b/tools/capitest/capiutil.cc.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -x '*.orig' -upN2 c4b.orig/tools/capitrace/Makefile c4b/tools/capitrace/Makefile
|--- c4b.orig/tools/capitrace/Makefile  2006-02-28 21:35:41.000000000 +0000
|+++ c4b/tools/capitrace/Makefile       2010-02-09 13:09:52.000000000 +0000
--------------------------
Patching file c4b/tools/capitrace/Makefile using Plan A...
Hunk #1 failed at 18.
1 out of 1 hunks failed--saving rejects to c4b/tools/capitrace/Makefile.rej
done
```

""""



Can you help me ?

I will do that because I'm on FreeBSD 7.2 and I have to use the Fritz card usb isdn.

Thank you for the help

Regards...


----------



## oobayly (Feb 25, 2010)

Hi stou

That's strange, I'm positive that I walked myself through the howto to make sure it all worked. Lo and behold, I got the same errors as yourself. It turns out that the c4b diff file was using windows line endings (not sure how that happened). Also the leading whitespace appears to be different.

I've uploaded a new diff (c4b-20100225-01.diff), and modified the howto to instruct you to use the --ignore-whitespace switch when using patch.

I've just run through the howto again, and everything seems to work properly. Thanks for bringing it to my attention.

As for using the FritzCard USB, I'm afraid I'm not convinced that c4b will do the job. The README says it only supports the AVM active ISDN boards (B1, C2, C4, T1). In fact it took some time to find a compatible ISDN controller for FreeBSD, and even longer for work to allow me to buy one! We've also got 2 FriztCard PCI adapters which I never got to work under FreeBSD.

Let me know if you have any issues.

Regards,
Johhn


----------



## Ben (Aug 14, 2011)

I followed your HowTo which worked so far, but now I want to compile CAPI4HylaFax on FreeBSD 7.4 but now it says that libcapi20 can not be found.

How can I solve this? Any hints?

Does it only work with 7.2?


----------

