login | register
Sun 12 of Oct, 2008 [18:34 UTC]

voip-info.org

Discuss [17] History

Asterisk zaphfc

Created by: JustRumours,Last modification on Fri 07 of Dec, 2007 [09:24 UTC] by FrancoisMocq

ZAPHFC


Note: Using bristuff breaks PRI support, so you cant have both bri and pri in the same server.
However a user reports: "We are using Asterisk 1.0.7-BRIstuffed-0.2.0-RC8a with a Digium PRI card an a beroNet quadBRI
in one server and it's running perfecty for months. It depends only on the order the modules are loaded
(/sbin/modprobe zaptel, insmod qozap.ko, insmod wcte11xp.ko - in this order)."

If compared to a CAPI driven card a hfc-pci card provides your box with NT mode, zaptel timing and echo cancelation.

When multiple devices are connected to the ISDN connection, then all user device behave as slaves, where the network terminator (NT) behaves as master and synchronizes the communication on the S0 bus. The special behavior of the network terminator is called NT mode. User devices are normally not capable of running in NT mode. As a result, user devices can not communicate with each other even when they are connected via a crossed cable. Only some special ISDN cards (HFC chipset) are capable of running in NT mode, and can directly communicate with other ISDN user devices using a standard Ethernet cable (not crossover - TE and NT ports have the TX and RX pins switched already).


Recent versions:


Note Junghanns do NOT keep links on the front page up to date ... always check the downloads directory for the latest versions.

Caller-ID

(I believe that this is solved on bristuff 0.3.0-PRE1o. Can anybody please update the page? Tzafrir)

If you experience problems forwarding the incoming caller-id to internal phones, you probably forgot setting callerid=asreceived in your zapata.conf. Otherwise, add a SetCIDNum in your dialplan,i.e.
extensions.conf
exten => 444555544,1,SetCIDNum(0${PRI_NETWORK_CID})
exten => 444555544,2,Dial(SIP/123)

The above example, assigns the network provided callerid to the internal Caller ID field. A Zero is prefixed as it is nescessary for dialing out.

Meanwhile, there are one fork and one patch improving the driver in several ways:

  • The patch from Florian Zumbiehl:
    • Interrupt loss tolerant b channel handling (see below).
    • Support for the slave mode of the chip, enabling the cards to run completely in sync.
    • "Interrupt bundling" greatly reduces the driver's CPU usage with several cards in the system.
  • The fork from Daniele Orlandi:
    • not maintained anymore; instead see Asterisk vISDN
    • Interrupt loss tolerant b channel handling (see below).
    • Sniffing capability, so you can examine ISDN packets using a patched ethereal.

They have been created independently and both improve the b channel handling to be more tolerant to lost/delayed interrupts (which is a big problem with the original driver if you have more than one card, a card sharing interrupts, or any major concurrent load on the system). The other improvements are quite different, though, which is why they are both listed here for you to choose. They might be merged someday, but until then you will have to choose one of them.


For hfc install instructions see:




Setting up hfc cards for NT mode:

Q: Do I need to use a special kind of wire, is a NT1 (also called ntba or network termination device) needed for termination / powersupply between the card and a phone?

A: It depends. If the device(s) you want to connect have their own power supply, such as PBXes, you usually won't need an NT1 for power supply. Otherwise, use an hfc-s based card that does power the line (usually with an external power supply such as BNPW1). With an another card, just follow the documentation at http://isdn.jolly.de/ to wire up your card, your NT1 and your phone equipment. Of course, you always need termination - which can be done without the need for an NT1, though.

In order to connect a telephone directly to a card, you need to:
  • terminate the S0-bus by using resistors, no matter how short the cable is.
  • provide power feeding to the telephone, if it does not supply it's own power.
  • cross link the ports, because the card receives what the telephone sends and vice versa.
All this can be done easily by using an old NT1. Here is an easy way on doing it:
  • Take an ISDN cable and cut it in the middle. On each side of the cabe there is an RJ-45 plug. The middle pair (4 and 5) must be connected with the surrounding wire pair on the other side (3 and 6) and vice versa.
  • Add 2 100 ohm resistors to the wires. One to the first pair (connected to 4 and 5) and one to the second (connected to 3 and 6).
  • Use an old NT1 if you don't have an own power supply. U could even use a somehow broken NT1, as long as the power feeding function is still working.
NOTE: Ethernet cross link cables don't work, because they use different pairs than ISDN S0 does.

Plug one end of your new cross link cable to your ISDN card that should run in NT-Mode, and one to your telephone. If your telephone set needs external power, connect an old NT1 to your ISDN card using the cross link cable, and your telephone with a NORMAL ISDN (or Ethernet/straightthrough wired) cable to your NT, using the second plug.

For a "cleaner" method please consult chapter 2.2 of this guide from http://isdn.jolly.de.

To load the card in NT1 mode you'll need to set the 'modes' option when loading the driver:

  insmod ./zaphfc.o modes=1

or if you have more cards (example: two) you can use
  
  insmod ./zaphfc.o modes=1  #(binary: 0 1)  card0: NT mode, card1: TE mode
or
  insmod ./zaphfc.o modes=2  #(binary: 1 0)  card0: TE mode, card1: NT mode
or
  insmod ./zaphfc.o modes=3  #(binary: 1 1)  card0: NT mode, card1: NT mode
and so on

Note that when using more than one card, the module will segfault when unloading:


 zaphfc: stop
 zaphfc: shutting down card at e0962000.
 unregistered from zaptel.
 zaphfc: freed one card.
 zaphfc: shutting down card at 00000000.
 Unable to handle kernel NULL pointer dereference at virtual address 0000006c
 printing eip:
 e095d086
 *pde = 00000000
 Oops: 0002
 CPU:    0
 EIP:    0010:<e095d086>    Tainted: P 
 EFLAGS: 00010082
 eax: 00000000   ebx: 00000282   ecx: dcc0a000   edx: dcc0bf7c
 esi: d5d5d5d5   edi: 00000000   ebp: bfffea58   esp: df4e5f64
 ds: 0018   es: 0018   ss: 0018
 Process rmmod.modutils (pid: 26999, stackpage=df4e5000)
 Stack: e095e660 00000000 d5d5d5d5 00000286 c15efa60 d5d5d5d5 d5d5d5d5e095e58a 
      d5d5d5d5 e095d000 fffffff0 c011caea e095d000 e095d000 fffffff0 da4b9000 
      c011be8f e095d000 00000000 00001000 df4e4000 00000001 0806fb00 c01090df 
 Call Trace:    <e095e660> <e095e58a> <c011caea> <c011be8f> <c01090df>

 Code: c6 40 6c 00 53 9d a1 30 ed 95 e0 89 44 24 04 8b 00 89 04 24 


... and you'll be stuck with a half removed module. The only cure I've found thus far is rebooting.

Use this patch to fix the problem (this problem is fixed in bristuff-0.2.0-RC5!):


+++ zaphfc.c 2005-01-04 18:02:17.344086630 +0100 @@ -78,7 +78,7 @@
    }
    
    spin_lock_irqsave(&hfctmp->lock,flags);
-
+ free_irq(hfc_dev_list->irq, hfc_dev_list);     printk(KERN_INFO "zaphfc: shutting down card at %p.\n",hfctmp->pci_io);
    hfctmp->regs.int_m2 = 0;
    hfc_outb(hfctmp, hfc_INT_M2, hfctmp->regs.int_m2);
@@ -105,7 +105,7 @@
kfree(hfctmp->ztdev);
printk(KERN_INFO "unregistered from zaptel.\n");
    }
- free_irq(hfc_dev_list->irq, hfc_dev_list);
+     spin_unlock_irqrestore(&hfctmp->lock,flags);
}


When configuring zaptel, you'll need to load the zaphfc driver before any wcfxs or wcfxo drivers, as the zaphfc channels are loaded as a span.

All in all, the driver is 'sort of' working, 'sometimes'. I have dialtone disappearing from the ISDN phones regularly, only a restart of asterisk brings it back. To be fair, the configuration of this setup has not had any real priority, and no real debugging has been done.

when picking up the handset on one of the phones, I allways get the following message in the console:

  Feb 17 21:02:07 WARNING147466: chan_zap.c:5954 zt_pri_error: PRI: XXX
  Missing mandatory IE 24/Channel Identification XXX

the configs



If you only have one hfc card it should be enough to change
  signalling = bri_cpe_ptmp
to
  signalling = bri_net_ptmp
in your /etc/asterisk/zapata.conf file

If you have two hfc cards you will have to do some more configuration.

add the following lines into /etc/zaptel.conf

span=1,1,3,ccs,ami 
bchan=1-2 
dchan=3
span=2,1,3,ccs,ami
bchan=4-5
dchan=6

Then execute
  ztcfg

You can double check by doing to get a verbose output:
  ztcfg -vv

The result should look somewhat like the following:

Zaptel Configuration
======================

SPAN 1: CCS/ AMI Build-out: 399-533 feet (DSX-1)
SPAN 2: CCS/ AMI Build-out: 399-533 feet (DSX-1) 

Channel map:

Channel 01: Individual Clear channel (Default) (Slaves: 01)
Channel 02: Individual Clear channel (Default) (Slaves: 02)
Channel 03: D-channel (Default) (Slaves: 03)
Channel 04: Individual Clear channel (Default) (Slaves: 04)
Channel 05: Individual Clear channel (Default) (Slaves: 05)
Channel 06: D-channel (Default) (Slaves: 06)

6 channels configured.

In your /etc/asterisk/zapata.conf set

; Zapata telephony interface
;
; Configuration file
;
[channels]
;
;defaults
;language=de   ; you'll need to have German voiceprompts installed for this
switchtype = euroisdn
signalling = bri_net_ptmp   ; this is NT mode! Use bri_cpe_ptmp for standard TE mode
pridialplan=local
echocancel=yes
immediate=yes   ; is this correct, isn't this only for analog handsets?
setcallerid(""<${CALLERIDNUM}>)  ; is this correct, shouldn't it rather be "callerid=..."?
;callerid=asreceived
;usecallerid=yes
 context=from-bri
;context=default

 card 1 
group = 1,3
channel => 1-2

 card 2 
signalling = bri_cpe_ptmp 
group = 2,3
channel => 4-5

The meaning of the above keywords is very well explained in Asterisk config zapata.conf.

For the UK .. BT circuits on ISDN2E (probably all ISDN circuits) you MUST set:


pridialplan=unknown


Failing to set this will result in errors of "PRI: received SETUP message for a call that is not a new call " and messages related to "unable to transfer audio" .. examing PRI debug with 'intense' (pri intense debug span 1 on the CLI) will reveal an error related to "unallocated number" before the call is dropped. "unknown" works as a pridialplan setting "local" and others do not.

Note: Unlike in chan_capi you cannot set a filter in the .conf files to listen on specific MSNs and ignore calls to other MSNs on the same S0 bus. Instead you need to use contexts (like "from-bri" above).
Note: For CLIR (to hide your outgoing Caller ID Number) you'll need to use SetCallerPres in the dialplan.


Stability checks

  • I have now got this little ditty running to keep an eye on it:

 while true; do grep "(F" /proc/zaptel/2; sleep .1; done

Typical values are F4, F6 (DEACTIVATED) and of F7 (ACTIVATED)

  • On the CLI: pri show span 1
  • less /var/log/messages | grep zaphfc

zaphfc warnings in syslog and Frank Gockel's patch


If you find messages like these in your syslog:

Sep 9 23:37:41 nobaq kernel: zaphfc: bchan rx fifo not enough bytes to receive! (z1=6207, z2=6200, wanted 8 got 7), probably a buffer overrun.
Sep 9 23:37:41 nobaq kernel: zaphfc: bchan rx fifo not enough bytes to receive! (z1=6207, z2=6200, wanted 8 got 7), probably a buffer overrun.
Sep 9 23:43:14 nobaq kernel: zaphfc: bchan rx fifo not enough bytes to receive! (z1=7112, z2=7105, wanted 8 got 7), probably a buffer overrun.

maybe Frank Gockels patch is for you. You can find a detailed discussion here: http://www.ip-phone-forum.de/showthread.php?t=113781

Frank gockel programmed a patch for zaphfc which tries to recover lost interrupts. At the beginning, my syslog was full of these messages but after applying the patch, everything is OK. No such message for half a year and good sound quality.

You can find a description of the patch (in german) at http://home.arcor.de/frank.gockel/software/zaphfc/zaphfc.diff.txt.

Homepage of this wonderful patch: http://home.arcor.de/frank.gockel/software/zaphfc/


Problem with ZapHFC with ISDN BRI HFC cards and signalization (busy etc.)

  • edit /etc/asterisk/zapata.conf and insert the line for correct ISDN signalization:

priindication=outofband

Common compile error

If you have something like this :
/usr/src/bristuff-0.2.0-RC8o/zaphfc/zaphfc.c:396: error: structure has no member named `bytes2transmit'
/usr/src/bristuff-0.2.0-RC8o/zaphfc/zaphfc.c:419: error: structure has no member named `bytes2transmit'
/usr/src/bristuff-0.2.0-RC8o/zaphfc/zaphfc.c:436: error: structure has no member named `eoftx'

It's because zaptel was not patched correctly. Maybe you don't have patch (debian : apt-get install patch).
You can try this :
cd bristuff-0.3.0-PRE-1p/zaptel-1.2.5
patch -p1 < ../patches/zaptel.patch

Finding cards - where and what to buy

You're looking for a 'Cologne HFC' card. The Cologne chips are used by different manufacturers at the low end of the market. That's fine as you're going to throw the cheap Windows drivers and software away anyay! In the UK, there are very few cards for sale due to the RoHS legislation - some manufacturers just stopped making the cards rather than spend money making them compliant. Have a look on eBay though as there are still some old, non-RoHS cards out there, as well as new ones!

See also


Other ISDN BRI channels in Asterisk:

Go back to Asterisk zaptelBRI


Comments

Comments Filter
222

333zaphfc in a Xen3 DomU...?!

by wubbla, Wednesday 02 of April, 2008 [17:23:01 UTC]
Hi!
Anyone has got an idea how to get a HFC-s card running under a Xen3 DomU?
When loading the kernel module zaphfc, dmesg shows me the following:

PCI: Enabling device 0000:00:01.0 (0000 -> 0003)
zaphfc: CCD/Billion/Asuscom 2BD0 configured at mem 0xee1d8400 fifo 0xe5738000(0x4ed9d000) IRQ 17 HZ 250
zaphfc: Card 0 configured for TE mode
zaphfc: Card 0 configured for master mode
zaphfc: hfc busy.
....

Another interesting thing is this:

chef:~# cat /proc/interrupts
          CPU0
16: 2 Phys-irq zaphfc
17: 2 Phys-irq zaphfc
....

Please let me know, if you've got any idea how to get this thing right...
Thanks in advance!

222

333Re: PRI: received SETUP message for a call that is not a new call - PLEASE HELP!

by rszemeti, Monday 07 of May, 2007 [10:49:13 UTC]
try changing the setting of 'pridialplan' in zapata.conf

it is probably:

 pridialplan = local

try :
 
 pridialplan = unknown

222

333HFC BRI and TDM400P on the same machine

by UlbabraB, Thursday 09 of November, 2006 [21:41:58 UTC]
We are using Asterisk 1.2.13-BRIstuffed-0.3.0-PRE-1v with an HFC card and a TDM400P with two FXO modules (slots 3 and 4).
Load zaphfc before wctdm module and put in zaptel.conf:

...
span=1,1,3,ccs,ami
bchan=1,2
dchan=3

fxsks=6-7

and run ztcfg as usual. From zapata.conf:

...
signalling=fxs_ks
channel => 6-7
...
signalling=bri_cpe_ptmp
channel => 1-2
222

333PRI: received SETUP message for a call that is not a new call - PLEASE HELP!

by kurgan, Monday 16 of October, 2006 [09:20:51 UTC]
I have about 10 asterisk boxes with an HFC card that connects to an ISDN phone line (in Italy, we use EuroISDN and normally the lines are configured as P2MP). Quite every box sometimes ignores a call (the caller hears ringing) with the following error: "PRI: received SETUP message for a call that is not a new call". I have no clues on what to check, I have googled a lot and I have found that I am not the only one, but that no one has found a solution yet. It seems that this issue disappears when the ISDN channels are configured as P2P instead of P2MP.

Can anyone provide some suggestions about this issue?

Also, is there a way to disable call waiting?
222

333BRI and PRI in one server?

by haary, Thursday 01 of December, 2005 [16:11:08 UTC]
Since when breaks bristuff PRI support? We are using Asterisk 1.0.7-BRIstuffed-0.2.0-RC8a with a Digium PRI card an a beroNet quadBRI
in one server and it's running perfecty for months. It depends only on the order the modules are loaded (/sbin/modprobe zaptel, insmod qozap.ko, insmod wcte11xp.ko - in this order).

Has this behaviour changed somehow? Would be a pity and would prevent us from upgrading our server.


222

3331.2beta1

by flobi, Tuesday 11 of October, 2005 [16:29:50 UTC]
This does not seem to install correctly with 1.2beta1.
222

333system crash

by g.grandis, Thursday 06 of October, 2005 [08:12:54 UTC]
Hi!

I'm using bristuff-0.2.0-RC7k with 2 hfc single bri pci card. I load the zapata module but whrn i try to load the zaphfc module by this command ("insmod /usr/src/bristuff-0.2.0-RC7k/zaphfc/./zaphfc.o") my system crash and frooze, i have to reboot it.

This is my interrupts:

          CPU0
 0:     232589          XT-PIC  timer
 1:        267          XT-PIC  keyboard
 2:          0          XT-PIC  cascade
 8:          1          XT-PIC  rtc
 9:          0          XT-PIC  usb-uhci
11:          0          XT-PIC  VIA8233, usb-uhci, usb-uhci
12:       6229          XT-PIC  eth0, ehci_hcd, PS/2 Mouse
14:       2267          XT-PIC  ide0
NMI: 0
ERR: 0

ah this is my /proc/pci

 Bus  0, device  19, function  0:
   Network controller: Cologne Chip Designs GmbH ISDN network controller HFC-PCI (rev 2).
     IRQ 12.
     Master Capable.  Latency=16.  Max Lat=16.
     I/O at 0xdc00 0xdc07.
     Non-prefetchable 32 bit memory at 0xde003000 0xde0030ff.
 Bus  0, device  20, function  0:
   Network controller: Cologne Chip Designs GmbH ISDN network controller HFC-PCI (#2) (rev 2).
     IRQ 9.
     Master Capable.  Latency=16.  Max Lat=16.
     I/O at 0xe000 0xe007.
     Non-prefetchable 32 bit memory at 0xde004000 0xde0040ff.
 Bus  1, device   0, function  0:

Thanks

Giordano
222

333system crash

by g.grandis, Thursday 06 of October, 2005 [08:12:31 UTC]
Hi!

I'm using bristuff-0.2.0-RC7k with 2 hfc single bri pci card. I load the zapata module but whrn i try to load the zaphfc module by this command ("insmod /usr/src/bristuff-0.2.0-RC7k/zaphfc/./zaphfc.o") my system crash and frooze, i have to reboot it.

This is my interrupts:

          CPU0
 0:     232589          XT-PIC  timer
 1:        267          XT-PIC  keyboard
 2:          0          XT-PIC  cascade
 8:          1          XT-PIC  rtc
 9:          0          XT-PIC  usb-uhci
11:          0          XT-PIC  VIA8233, usb-uhci, usb-uhci
12:       6229          XT-PIC  eth0, ehci_hcd, PS/2 Mouse
14:       2267          XT-PIC  ide0
NMI: 0
ERR: 0

ah this is my /proc/pci

 Bus  0, device  19, function  0:
   Network controller: Cologne Chip Designs GmbH ISDN network controller HFC-PCI (rev 2).
     IRQ 12.
     Master Capable.  Latency=16.  Max Lat=16.
     I/O at 0xdc00 0xdc07.
     Non-prefetchable 32 bit memory at 0xde003000 0xde0030ff.
 Bus  0, device  20, function  0:
   Network controller: Cologne Chip Designs GmbH ISDN network controller HFC-PCI (#2) (rev 2).
     IRQ 9.
     Master Capable.  Latency=16.  Max Lat=16.
     I/O at 0xe000 0xe007.
     Non-prefetchable 32 bit memory at 0xde004000 0xde0040ff.
 Bus  1, device   0, function  0:

Thanks

Giordano
222

333ZapHFC NT mode success

by wpeople, Tuesday 30 of August, 2005 [10:53:07 UTC]
Hi!

First of all I have to say thanks to Andras of Opennetworks.hu, for configuring ZapHFC to NT mode. For all of you who want to make BRI for your existing ISDN PBX, here is a great manual how to make ISDN cross cable:
http://www.pro-linux.de/work/asterisk/asterisk-1.html
sadly it won't worked for me because of ISDN termination, so I patched my card like this: http://shadow.ms.hu/~wpeople/bipac-100ohm.jpg this helped, and now working fine even in NT or TE mode :-) thanks again!
222

333bristuff-0.2.0-RC7f/RC7j

by Blackvel, Saturday 05 of March, 2005 [23:35:10 UTC]
Hi all,

just want to warn you about RC7f.
I had upgraded from RC2b and the voice quality was really bad.
Also I had noticed a lot of buffer problems for zaphfc in dmesg.
RC7j works great.

If you have an ISDN/analog pbx with an analog telephone (like Euracom 182), please make sure, you really change for /etc/asterisk/zapata.conf the following:

overlapdial=yes
immediate=no

I had used DISA before, which accepted the complete extension number, so I had not to wait for the dailtone (I changed app_disa.c timeout from 10/20 seconds to 1/2 seconds).
But that only worked for RC2.
Instead of
isdn-incoming
exten => s/,1,DISA,no-password|ctx_myContext

you should now use in your extensions.conf:
exten => _X./90,1,Goto(ctx_myContext,${EXTEN},1)